:root {

    /* palette for menu, text and tooltip */
    --dark-bg: #13130e;
    --bg: #272721; /* background base */
    --bg2: #56564a; /* background base 2*/
    --bg3: #6d6d5d;   /* one step lighter than bg2 */
    --hover: #84846f;   /* lighter still, for hover states */
    --accent: #d0d0b5; /* accent color for text and buttons*/
    --muted: #90907e; /* muted text color for less important text*/
    --golden: #ffd700;

    /* parchment family, shared by generators & powers */
    --parchment-light: #e8d29c;
    --parchment: #d4b87a;
    --parchment-dark: #a07c3a;
    --parchment-text: #1a3a7a;
    --parchment-text-light: #2d5996;
    --magic-glow: #7c3aed;
    --disable-parchment: #3c3a33;
    --disable-parchment-text: #7a7669;
    --disable-parchment-border: #56534a;
}

* {
    box-sizing: border-box
}

body {
    font-family: Inter, system-ui, Segoe UI, Roboto, Arial;
    line-height: 1.4;
    margin: 0;
    color: var(--accent);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    cursor: default;
}

.app {
    display: flex;
    flex: 1;
    flex-direction: row;
    width: 100%;
}


aside.menu {
    width: 220px;
    background: var(--bg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}


.game-name {
    font-weight: 700;
    font-size: 22px;
    color: var(--accent);
    margin-bottom: 6px;
}


.tabs {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--muted);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--muted);
    font-weight: 600;
    text-align: left
}

.tab-btn:hover {
    background-color: var(--bg2);
    border-color: var(--accent);
    color: var(--accent);
}

.tab-btn.active {
    background: var(--dark-bg);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
}

main {
    flex: 1;
    overflow: hidden;
    position: relative;
    /*background-image: url(https://cdn.mos.cms.futurecdn.net/kvRimKWowJ84VfeBBj6r9j-878-80.jpg.webp);*/
    /*background-size: 100% 100%;*/
    /*background-position: center;*/
    background: var(--bg);
}

section {
    position: absolute;
    top: 0;
    left: 0;
    height: 100vh;
    width: 25%;
    background-color: color(from var(--bg2) srgb r g b / 0.7);
    box-shadow: 2px 0 0 var(--accent);
    backdrop-filter: blur(10px);
    padding: 20px;
    z-index: 1;
    transform: translateX(-110%);
    transition: transform .3s ease-in-out;
}

section.open {
    transform: translateX(0);
}

.text-muted {
    color: var(--muted);
    font-size: 13px
}

/* Les boutons générateurs et power (share same desing) */

/* Générateurs - barre latérale droite */
aside.generators {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 3;
}

/* Power button : First the containers */

.powers-bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    justify-content: center;
    z-index: 2;
    width: fit-content;
    padding: 10px 10px 10px;
}

.power-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* Now the buttons */

/* First what is common */

.parchment,
button.generator {
    position: relative;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid var(--parchment-dark);
    background: linear-gradient(180deg, var(--parchment-light) 0%, var(--parchment) 65%);
    color: var(--parchment-text);
    font-weight: bold;
}

.parchment:hover,
button.generator:hover:not(:disabled) {
    background: var(--parchment-light);
    color: var(--parchment-text-light);
}

.parchment:disabled,
button.generator:disabled {
    background: var(--disable-parchment);
    border-color: var(--disable-parchment-border);
    color: var(--disable-parchment-text);
    text-shadow: none;
    cursor: not-allowed;
    box-shadow: none;
}

.parchment:disabled:hover,
button.generator:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Specific to the generator button */
button.generator {
    display: block;
    width: 180px;
    padding: 10px 16px;
    text-align: center;
    text-shadow: none;
    box-shadow: 0 0 6px rgba(160, 124, 58, 0.35);
}

button.generator.generator-hidden {
    display: none;
}

/* Power button : Second the button */

.parchment {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 70px;
    padding: 10px 6px 8px;
}

@keyframes parchmentPulse {
    0%, 100% { box-shadow: 0 0 8px 2px rgba(124, 58, 237, 0.5); }
    50%      { box-shadow: 0 0 20px 7px rgba(124, 58, 237, 0.9); }
}

.parchment.power-active {
    border-color: var(--magic-glow);
    animation: parchmentPulse 1.5s ease-in-out infinite;
}

/* Power button : Lastly inside the button */

.parchment-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.parchment-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.parchment-cost {
    font-size: 10px;
    font-weight: 700;
    color: var(--parchment-text);
    letter-spacing: 0.02em;
}

.parchment:disabled .parchment-icon img {
    filter: saturate(0.5);
}

.parchment:disabled .parchment-cost {
    color: var(--disable-parchment-text);
}
/* Power timer */

.power-timer {
    position: relative;
    width: 70px;
    height: 15px;
    border: 2px solid silver;
    border-radius: 3px;
    overflow: hidden;
    visibility: hidden;
}

.power-timer.active {
    visibility: visible;
}

.power-timer-fill {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 100%;
    background: #7c3aed;
    transform-origin: left;
    transition: width 0.9s linear;
}

.power-timer-label {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 8px;
    font-weight: 700;
    color: white;
    line-height: 10px;
    z-index: 1;
}

/* Spell-cast particles */
.cast-particle {
    position: fixed;
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff7cc 0%, var(--golden) 60%, transparent 100%);
    box-shadow: 0 0 6px 1px rgba(255, 215, 0, 0.8);
    pointer-events: none;
    z-index: 99999;
    animation: castParticleFly 0.7s ease-out forwards;
}

@keyframes castParticleFly {
    0%   { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0.3); }
}

/* Gold Label */

#goldLabel {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    position: absolute;
    bottom: 24px;
    left: 36px;
    font-size: 16px;
    color: var(--golden);
    background: transparent;
    border: 2px solid var(--golden);
    border-radius: 24px;
    padding: 6px 16px;
    z-index: 5;
}

/* in-game Tooltip */

.game-tooltip {
    position: absolute;
    padding: 8px 12px;
    background-color: var(--dark-bg);
    border: 1px solid var(--muted);
    border-radius: 8px;
    font-size: 12px;
    display: none;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    line-height: 1.5;
}

.game-tooltip .tooltip-title {
    font-weight: 700;
    color: var(--golden);
    font-size: 13px;
    margin-bottom: 2px;
}

.game-tooltip .tooltip-line {
    color: var(--muted);
}



/* Effet de clic */

/* Coin popping out of the click point, then falling back and fading */
.click-coin {
    position: fixed;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    pointer-events: none;
    z-index: 99999;
    animation: clickCoin 1s ease-out forwards;
}

/*@keyframes clickCoin {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.4) rotate(0deg); }
    12%  { opacity: 1; transform: translate(calc(var(--drift) * 0.15), calc(var(--rise) * 0.44)) scale(1) rotate(40deg); }
    40%  { opacity: 1; transform: translate(calc(var(--drift) * 0.5), var(--rise)) scale(1) rotate(160deg); }
    100% { opacity: 0; transform: translate(var(--drift), calc(var(--rise) * 0.52)) scale(1) rotate(320deg); }
}*/

@keyframes clickCoin {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.4) rotate3d(0.6, 1, 0.2, 0deg); }
   12%  { opacity: 1; transform: translate(calc(var(--drift) * 0.15), calc(var(--rise) * 0.44)) scale(1) rotate3d(0.6, 1, 0.2, 170deg); }
    40%  { opacity: 1; transform: translate(calc(var(--drift) * 0.5), var(--rise)) scale(1) rotate3d(0.6, 1, 0.2, 320deg); }
   100% { opacity: 0; transform: translate(var(--drift), calc(var(--rise) * 0.52)) scale(1.2) rotate3d(0.6, 1, 0.2, 420deg); }
}

/* Floating "+1" gold text */
.click-float-text {
    position: fixed;
    margin: -10px 0 0 -10px;
    color: var(--golden);
    font-weight: 800;
    font-size: 15px;
    text-shadow: 0 0 6px rgba(0,0,0,0.9), 0 0 2px #fff7cc;
    pointer-events: none;
    z-index: 99999;
    animation: clickFloatText 0.7s ease-out forwards;
}

@keyframes clickFloatText {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.5); }
    15%  { opacity: 1; transform: translate(0, -4px) scale(1); }
    100% { opacity: 0; transform: translate(var(--drift), -60px) scale(1); }
}

/* Boutons de sauvegarde */

#saveButtons {
    display: flex;
    gap: 10px; /* 👈 this creates spacing */
}

.save-buttons {
    background-color: var(--bg);
    border: 2px solid var(--muted);
    color: red;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.save-buttons:hover {
    background-color: var(--dark-bg);
    border-color: var(--accent);
}

.save-buttons:active {
    border-color: #fff;
}

/* Orbe magique */
.orb {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--golden);
    overflow: hidden;
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgb(11 18 32 / 40%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

/* Interieur de l'orbe qui se rempli */

#fullOrb {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0;
    background : linear-gradient(to top, #60a5fa, #1e3a8a);
    transition: height 0.2s ease-in-out;
}

/* Magic Label */

#magicLabel {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--golden);
    text-shadow: 0 0 6px rgba(96, 165, 250, 0.25);
    z-index: 5;
}

/* Magic Rate */

#magicRateLabel {
    position: relative;
    z-index: 5;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
}


/* Shop pannel : toogle  */


.shop-section {
    margin-top: 12px;
}

.shop-section-toggle-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: color(from var(--bg) srgb r g b / 0.8);
    border: 1px solid color(from var(--accent) srgb r g b /0.8);
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

.shop-section-toggle-btn:hover {
    background: color(from var(--bg2) srgb r g b / 0.8);}

.shop-section-body {
    max-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 0 4px;
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
    flex-wrap: wrap;
}

.shop-section-body.open {
    max-height: 600px;
    padding: 10px 4px 4px;
}

/* Button unlock generators */

.shop-card-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    border: 2px solid #2563eb;
    background: var(--dark-bg);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(96, 165, 250, 0.4);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    position: relative;
}

.shop-card-btn:hover {
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.6);
    transform: translateY(-2px);
}

.shop-card-btn-hidden {
    display: none;
}

.shop-card-btn img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    pointer-events: none;
}

.shop-card-btn:active {
    transform: translateY(1px);
    box-shadow: 0 0 4px rgba(96, 165, 250, 0.3);
}

.shop-card-btn:disabled {
    border-color: var(--muted);
    filter: grayscale(120%);
    cursor: not-allowed;
    box-shadow: none;
}

.shop-card-btn:disabled:hover {
    box-shadow: none;
    transform: none;
}

.shop-card-btn.bought {
    border-color: #16a34a;
    filter: grayscale(0%);
    cursor: default;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
}

.shop-card-btn.bought:hover {
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
    transform: none;
}

.shop-card-btn.bought::after {
    content: '✔';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 4px;
    color: #8af3af;
    font-size: 14px;
}

/* Tier badge on upgrade buttons */

.tier-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 9px;
    font-weight: 700;
    color: #93c5fd;
    line-height: 1;
    pointer-events: none;
}

.tier-badge.tier-2 { color: #c4b5fd; }
.tier-badge.tier-3 { color: #fde68a; }


/* Stats panel */

.stats-section {
    margin-top: 16px;
}

.stats-section-title {
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    padding-bottom: 6px;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stats-grid-header {
    display: grid;
    grid-template-columns: 1fr 0.7fr 0.9fr 0.7fr;
    padding: 0 10px;
    margin-bottom: 2px;
}

.stats-grid-header .stats-row-value {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: color(from var(--bg) srgb r g b / 0.7);
    border: 1px solid var(--muted);
    border-radius: 8px;
    padding: 8px 10px;
}

#stats-categories .stats-row {
    display: grid;
    grid-template-columns: 1fr 0.7fr 0.9fr 0.7fr;
    margin-bottom: 4px;
}

.stats-row-hidden {
    display: none;
}

.stats-row-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--accent);
}

.stats-row-value {
    font-weight: 700;
    font-size: 13px;
    color: var(--accent);
    text-align: right;
}


/* */

.buy-amount-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    background: var(--dark-bg);
    border: 1px solid var(--muted);
    border-radius: 8px;
    padding: 3px;
}

.settings-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
}

.settings-btn:hover {
    color: var(--accent);
    background: var(--bg2);
}

.settings-btn.active {
    background: var(--dark-bg);
    color: var(--accent);
}