/* =====================================================================
   Medieval Pixel Idle Game – global stylesheet  (Sub-task 2)
   Parchment / stone / gold medieval theme with pixel-style UI.
   ===================================================================== */

/* ---- Reset & box model ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Rarity colour variables ------------------------------------------ */
:root {
    --rarity-common:    #9a9a9a;
    --rarity-uncommon:  #48b84e;
    --rarity-rare:      #4888e0;
    --rarity-epic:      #9840d0;
    --rarity-legendary: #e08820;

    --col-gold:         #f0d040;
    --col-gold-dark:    #a88020;
    --col-parchment:    #f0daa0;
    --col-parchment-dk: #c8a060;
    --col-stone:        #7a7060;
    --col-stone-dk:     #403830;
    --col-wood:         #6b4423;
    --col-wood-dk:      #3b2212;
    --col-ink:          #1a1208;

    --border-radius:    0;        /* pixel-sharp corners everywhere */
    --pixel-font:       "Courier New", "Lucida Console", "Consolas", monospace;
}

/* ---- Base ------------------------------------------------------------- */
html, body {
    width: 100%; height: 100%;
    background: var(--col-ink);
    overflow: hidden;
    font-family: var(--pixel-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--col-parchment);
    user-select: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ---- Canvas wrapper --------------------------------------------------- */
#game-canvas-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

/* Subtle cinematic 16-bit canvas render pass vignette */
#game-canvas-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 52%, rgba(12,8,6,0.32) 80%, rgba(8,4,2,0.68) 100%);
    z-index: 5;
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ---- UI root ---------------------------------------------------------- */
#ui-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

#ui-root .screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

#ui-root .screen.active { display: flex; }

/* ---- Loading screen --------------------------------------------------- */
#loading-screen {
    background: var(--col-ink);
    z-index: 100;
    font-size: 1.4em;
    letter-spacing: 0.2em;
    color: var(--col-gold);
    text-transform: uppercase;
}

#loading-screen::after {
    content: '...';
    animation: ellipsis 1.2s steps(3, end) infinite;
}

@keyframes ellipsis {
    0%   { content: '.'; }
    33%  { content: '..'; }
    66%  { content: '...'; }
    100% { content: '.'; }
}

/* ---- FPS counter ------------------------------------------------------ */
#fps-counter {
    position: fixed;
    top: 4px; right: 8px;
    font-size: 11px;
    font-family: var(--pixel-font);
    color: #88ff88;
    pointer-events: none;
    z-index: 200;
    display: none;
}

/* ---- Parchment panel -------------------------------------------------- */
.panel {
    background: var(--col-parchment);
    color: var(--col-ink);
    border: 3px solid var(--col-wood-dk);
    outline: 2px solid var(--col-gold-dark);
    padding: 16px 20px;
    position: relative;
    font-family: var(--pixel-font);
}

/* Ornamental corner notches (pseudo-element technique) */
.panel::before,
.panel::after {
    content: '';
    position: absolute;
    width: 8px; height: 8px;
    background: var(--col-wood-dk);
}
.panel::before { top: -1px; left: -1px; }
.panel::after  { bottom: -1px; right: -1px; }

/* Dark stone variant */
.panel-stone {
    background: var(--col-stone-dk);
    color: var(--col-parchment);
    border-color: var(--col-stone);
    outline-color: var(--col-stone);
}

/* Gold-accented variant */
.panel-gold {
    background: #2a1e0a;
    border: 3px solid var(--col-gold-dark);
    outline: 2px solid var(--col-gold);
    color: var(--col-gold);
}

/* ---- Section headings ------------------------------------------------- */
.panel-title {
    font-size: 1.1em;
    font-weight: bold;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--col-wood-dk);
    border-bottom: 2px solid var(--col-wood-dk);
    padding-bottom: 4px;
    margin-bottom: 12px;
}

.panel-stone .panel-title,
.panel-gold  .panel-title {
    color: var(--col-gold);
    border-color: var(--col-gold-dark);
}

/* ---- Pixel-style buttons ---------------------------------------------- */
.btn {
    display: inline-block;
    padding: 6px 14px;
    font-family: var(--pixel-font);
    font-size: 0.85em;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
    outline: none;
    position: relative;
    user-select: none;
    transition: none;   /* no smooth transitions – snap pixel feel */

    /* Default: parchment / wood */
    background: var(--col-parchment-dk);
    color: var(--col-ink);

    /* Hard pixel shadow to simulate 3-D press */
    box-shadow:
        2px 2px 0 var(--col-wood-dk),
        4px 4px 0 var(--col-ink);
}

.btn:hover {
    background: var(--col-parchment);
    color: var(--col-wood-dk);
    box-shadow:
        2px 2px 0 var(--col-wood-dk),
        4px 4px 0 var(--col-ink);
}

.btn:active,
.btn.pressed {
    /* Shift inward to simulate press-down */
    transform: translate(2px, 2px);
    box-shadow:
        0px 0px 0 var(--col-wood-dk),
        2px 2px 0 var(--col-ink);
}

.btn:disabled,
.btn.disabled {
    background: var(--col-stone);
    color: var(--col-stone-dk);
    cursor: default;
    box-shadow: 2px 2px 0 #222;
}

/* Gold / primary action button */
.btn-gold {
    background: var(--col-gold-dark);
    color: var(--col-ink);
    box-shadow:
        2px 2px 0 #604010,
        4px 4px 0 var(--col-ink);
}
.btn-gold:hover {
    background: var(--col-gold);
}

/* Danger button (red) */
.btn-danger {
    background: #6a1010;
    color: var(--col-parchment);
    box-shadow:
        2px 2px 0 #300,
        4px 4px 0 var(--col-ink);
}
.btn-danger:hover {
    background: #c42020;
}

/* Small button */
.btn-sm {
    padding: 3px 8px;
    font-size: 0.75em;
}

/* Icon button (square, no text) */
.btn-icon {
    padding: 4px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---- Rarity borders / glows ------------------------------------------- */
.rarity-common    { border-color: var(--rarity-common); }
.rarity-uncommon  { border-color: var(--rarity-uncommon); }
.rarity-rare      { border-color: var(--rarity-rare); }
.rarity-epic      { border-color: var(--rarity-epic); }
.rarity-legendary { border-color: var(--rarity-legendary); }

.rarity-text-common    { color: var(--rarity-common); }
.rarity-text-uncommon  { color: var(--rarity-uncommon); }
.rarity-text-rare      { color: var(--rarity-rare); }
.rarity-text-epic      { color: var(--rarity-epic); }
.rarity-text-legendary { color: var(--rarity-legendary); }

/* ---- Pixel progress bars ---------------------------------------------- */
.bar-wrap {
    width: 100%;
    height: 10px;
    background: var(--col-ink);
    border: 1px solid var(--col-stone);
    position: relative;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.15s steps(10, end);  /* discrete / chunky fill */
}

.bar-hp     { background: #c42020; }
.bar-mana   { background: #2060c0; }
.bar-xp     { background: #8030b0; }
.bar-stamina { background: #3a9020; }
.bar-boss   { background: #e06020; }

/* ---- Screen transitions ----------------------------------------------- */
/* Fade overlay – JS adds/removes .fade-in / .fade-out on #ui-root */
#screen-fade {
    position: fixed;
    inset: 0;
    background: var(--col-ink);
    pointer-events: none;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.2s steps(5, end);
}
#screen-fade.fade-in  { opacity: 1; }
#screen-fade.fade-out { opacity: 0; }

/* ---- Menu screen ------------------------------------------------------- */
#menu-screen {
    background: rgba(0, 0, 0, 0.72);
}

.menu-title {
    font-family: var(--pixel-font);
    font-size: 2.2em;
    letter-spacing: 0.3em;
    color: var(--col-gold);
    text-transform: uppercase;
    text-shadow:
        2px 2px 0 var(--col-ink),
        4px 4px 0 #604010;
    margin-bottom: 24px;
}

.menu-subtitle {
    font-size: 0.8em;
    color: var(--col-parchment-dk);
    letter-spacing: 0.1em;
    margin-bottom: 20px;
}

.menu-button-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* ---- HUD screen ------------------------------------------------------- */
#play-screen {
    background: transparent;
    pointer-events: none;
}

.hud-bars {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 180px;
    pointer-events: none;
}

.hud-bar-label {
    font-size: 0.7em;
    color: var(--col-parchment-dk);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.hud-skills {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 6px;
    pointer-events: none;
}

.hud-skill-slot {
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.6);
    border: 2px solid var(--col-stone);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65em;
    color: var(--col-parchment-dk);
    position: relative;
}

.hud-skill-slot .cooldown-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}

/* ---- Level-up screen -------------------------------------------------- */
#levelup-screen, #merchant-screen {
    background: rgba(0, 0, 0, 0.78);
}

/* Modal screens must sit above the in-game HUD (z-index 100) */
#levelup-screen, #merchant-screen, #pause-screen, #results-screen {
    z-index: 120;
}

.levelup-title {
    font-size: 1.6em;
    color: var(--col-gold);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 20px;
    animation: pulse-gold 0.6s steps(3, end) infinite;
}

@keyframes pulse-gold {
    0%   { color: var(--col-gold); }
    50%  { color: var(--col-gold-dark); }
    100% { color: var(--col-gold); }
}

.levelup-cards {
    display: flex;
    gap: 16px;
}

.levelup-card {
    width: 120px;
    min-height: 140px;
    padding: 12px;
    background: var(--col-parchment);
    color: var(--col-ink);
    border: 3px solid var(--col-wood-dk);
    outline: 2px solid var(--col-gold-dark);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
    font-family: var(--pixel-font);
    text-align: center;
    transition: none;
}

.levelup-card:hover {
    background: var(--col-gold);
    border-color: var(--col-gold-dark);
}

.levelup-card-icon {
    width: 32px; height: 32px;
    image-rendering: pixelated;
}

/* ---- Results screen --------------------------------------------------- */
#results-screen {
    background: rgba(0, 0, 0, 0.85);
}

/* ---- Pause screen ----------------------------------------------------- */
#pause-screen {
    background: rgba(10, 8, 4, 0.80);
}

/* ---- Icon gallery (showcase overlay) ---------------------------------- */
#icon-gallery {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 150;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-width: 320px;
    background: rgba(0,0,0,0.7);
    border: 2px solid var(--col-gold-dark);
    padding: 6px;
    pointer-events: none;
}

#icon-gallery img,
#icon-gallery canvas {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
    border: 1px solid var(--col-stone-dk);
}

/* ---- Sprite showcase panel -------------------------------------------- */
#showcase-panel {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 140;
    font-family: var(--pixel-font);
    font-size: 0.75em;
    color: var(--col-parchment-dk);
    letter-spacing: 0.08em;
    text-align: center;
    pointer-events: none;
    background: rgba(0,0,0,0.5);
    padding: 6px 12px;
    border: 1px solid var(--col-stone);
}

/* ---- Hotkey hint bar -------------------------------------------------- */
#hotkey-bar {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 140;
    font-family: var(--pixel-font);
    font-size: 0.7em;
    color: var(--col-parchment-dk);
    letter-spacing: 0.08em;
    text-align: center;
    pointer-events: none;
}

.hotkey-key {
    display: inline-block;
    background: var(--col-stone-dk);
    color: var(--col-gold);
    border: 1px solid var(--col-stone);
    padding: 1px 5px;
    margin: 0 2px;
    font-size: 0.9em;
}

/* ---- Scrollable list -------------------------------------------------- */
.scroll-list {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--col-stone) var(--col-ink);
}

.scroll-list::-webkit-scrollbar {
    width: 6px;
}
.scroll-list::-webkit-scrollbar-track {
    background: var(--col-ink);
}
.scroll-list::-webkit-scrollbar-thumb {
    background: var(--col-stone);
}

/* ---- Tooltip ---------------------------------------------------------- */
.tooltip {
    position: absolute;
    z-index: 500;
    background: var(--col-ink);
    border: 2px solid var(--col-gold-dark);
    padding: 8px 12px;
    font-size: 0.78em;
    color: var(--col-parchment);
    max-width: 200px;
    pointer-events: none;
    display: none;
}

/* ---- Toast notifications ---------------------------------------------- */
.toast {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 400;
    background: var(--col-stone-dk);
    border: 2px solid var(--col-gold-dark);
    color: var(--col-gold);
    padding: 8px 16px;
    font-size: 0.8em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 1;
    transition: opacity 0.3s steps(3, end);
}
.toast.hidden { opacity: 0; }

/* ---- Screen divs medieval title styling ------------------------------- */
#menu-screen    h1 { font-family: var(--pixel-font); }
#select-screen  h1,
#loadout-screen h1,
#pause-screen   h1,
#results-screen h1 {
    font-family: var(--pixel-font);
    font-size: 1.4em;
    color: var(--col-gold);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* ---- Divider ---------------------------------------------------------- */
hr.medieval-hr {
    border: none;
    border-top: 2px solid var(--col-gold-dark);
    margin: 10px 0;
    position: relative;
}

hr.medieval-hr::before {
    content: '✦';
    position: absolute;
    left: 50%;
    top: -8px;
    transform: translateX(-50%);
    background: var(--col-ink);
    padding: 0 6px;
    color: var(--col-gold-dark);
    font-size: 10px;
}

/* ---- Inline pixel canvas images -------------------------------------- */
canvas.pixel-img,
img.pixel-img {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* =====================================================================
   Sub-task 7 Game Feel / UI Juice animations
   ===================================================================== */

/* Shake on insufficient funds / invalid action */
.shake-error {
    animation: shake-error-anim 0.35s steps(2, start) !important;
}

@keyframes shake-error-anim {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-6px, 0); }
    40%  { transform: translate(6px, 0); }
    60%  { transform: translate(-4px, 0); }
    80%  { transform: translate(4px, 0); }
    100% { transform: translate(0, 0); }
}

/* Purchase / Unlock gold shine */
.shine-fx {
    position: relative;
    overflow: hidden;
}

.shine-fx::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,240,160,0.6) 50%, rgba(255,255,255,0) 100%);
    animation: shine-sweep 0.45s ease-out forwards;
    pointer-events: none;
}

@keyframes shine-sweep {
    0%   { left: -100%; }
    100% { left: 200%; }
}

/* Card flip / slide entry */
.levelup-card {
    animation: card-entry 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) backwards;
}

.levelup-card:nth-child(1) { animation-delay: 0.05s; }
.levelup-card:nth-child(2) { animation-delay: 0.12s; }
.levelup-card:nth-child(3) { animation-delay: 0.19s; }

@keyframes card-entry {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1.0);
    }
}


/* =====================================================================
   Sub-task 10 – Menus, meta-progression & retention screens
   ===================================================================== */
#ui-root #menu-screen, #ui-root .meta-screen, #ui-root #exit-screen { z-index: 130; }
#ui-root .meta-screen { justify-content: flex-start; align-items: stretch; overflow: hidden;
    background: radial-gradient(ellipse at 50% 0%, #2b1d10 0%, #150e08 70%); }
.dim { color: var(--col-parchment-dk); opacity: 0.85; font-size: 0.85em; }
kbd { background: var(--col-ink); border: 1px solid var(--col-stone); padding: 1px 6px; color: var(--col-gold); font-family: var(--pixel-font); }
.meta-icon { vertical-align: middle; image-rendering: pixelated; }
.spr-preview { image-rendering: pixelated; display: block; margin: 0 auto; }
.badge { background: #c42020; color: #fff; padding: 0 5px; margin-left: 4px; font-size: 0.8em; }

/* header + wallet */
.meta-head { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: rgba(0,0,0,0.55); border-bottom: 3px solid var(--col-gold-dark); flex: 0 0 auto; }
.meta-head h1 { flex: 1; font-size: 1.3em; letter-spacing: 0.2em; text-transform: uppercase; color: var(--col-gold); text-shadow: 2px 2px 0 var(--col-ink); }
.meta-wallet { display: flex; gap: 14px; align-items: center; }
.meta-wallet .w-item { background: var(--col-ink); border: 1px solid var(--col-stone); padding: 2px 10px; color: var(--col-gold); font-size: 0.9em; }
.meta-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.meta-body::-webkit-scrollbar { width: 10px; } .meta-body::-webkit-scrollbar-thumb { background: var(--col-gold-dark); }
.meta-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.meta-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.meta-table th { text-align: left; color: var(--col-gold); border-bottom: 2px solid var(--col-gold-dark); padding: 4px 8px; }
.meta-table td { padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.panel-stone .panel-title { margin-bottom: 8px; }

/* toasts + modals (always on top, independent of #ui-root) */
#toast-root { position: fixed; top: 14px; right: 14px; z-index: 600; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: 300px; }
.meta-toast { display: flex; gap: 10px; align-items: center; background: var(--col-stone-dk); border: 2px solid var(--col-gold-dark); padding: 8px 12px; color: var(--col-parchment);
    font-size: 0.8em; box-shadow: 3px 3px 0 var(--col-ink); animation: toast-in 0.25s steps(4, end); transition: opacity 0.4s steps(4, end); }
.meta-toast.gold { border-color: var(--col-gold); }
.meta-toast.out { opacity: 0; }
.mt-title { color: var(--col-gold); font-weight: bold; text-transform: uppercase; letter-spacing: 0.1em; }
@keyframes toast-in { from { transform: translateX(120%); } to { transform: translateX(0); } }
#modal-root { position: fixed; inset: 0; z-index: 650; pointer-events: none; }
.meta-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; pointer-events: all; }
.meta-modal { min-width: 340px; max-width: 520px; text-align: center; box-shadow: 0 10px 40px #000; }
.mm-title { color: var(--col-gold); letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 10px; }
.mm-body { margin-bottom: 14px; line-height: 1.6; }
.mm-buttons { display: flex; gap: 12px; justify-content: center; }
.offline-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 1.3em; color: var(--col-gold); }

/* ---- main menu backdrop ---- */
#ui-root #menu-screen { overflow: hidden; background: linear-gradient(#070b1a 0%, #1a1530 45%, #3a2418 100%); justify-content: center; }
.menu-backdrop { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.menu-sky { position: absolute; inset: 0; }
.menu-star { position: absolute; width: 2px; height: 2px; background: #fff; animation: twinkle 3s steps(3, end) infinite; }
@keyframes twinkle { 0%,100% { opacity: 0.2; } 50% { opacity: 1; } }
.menu-moon { position: absolute; top: 8%; right: 14%; width: 56px; height: 56px; background: #f4ecc8; box-shadow: 0 0 40px 10px rgba(244,236,200,0.35); }
.menu-castle { position: absolute; bottom: 0; left: 0; width: 100%; height: 55%; }
.menu-windows { animation: win-flicker 2.4s steps(6, end) infinite; }
@keyframes win-flicker { 0%,100% { opacity: 1; } 30% { opacity: 0.55; } 60% { opacity: 0.9; } 80% { opacity: 0.7; } }
.menu-torch { position: absolute; bottom: 8%; width: 14px; height: 120px; }
.menu-torch.left { left: 6%; } .menu-torch.right { right: 6%; }
.menu-torch .stick { position: absolute; bottom: 0; left: 4px; width: 6px; height: 80px; background: var(--col-wood-dk); }
.menu-torch .flame { position: absolute; bottom: 78px; left: 0; width: 14px; height: 22px; background: #ffb030; transform-origin: 50% 100%; animation: flame 0.35s steps(3, end) infinite alternate; }
.menu-torch .flame.f2 { left: 3px; width: 8px; height: 14px; background: #fff0a0; animation-duration: 0.28s; }
.menu-torch .glow { position: absolute; bottom: 60px; left: -40px; width: 94px; height: 94px; border-radius: 50%; background: radial-gradient(circle, rgba(255,170,60,0.4), rgba(255,170,60,0) 70%); animation: glow-flicker 0.6s steps(4, end) infinite alternate; }
@keyframes flame { from { transform: scaleY(0.8) scaleX(1.05); } to { transform: scaleY(1.15) scaleX(0.85); } }
@keyframes glow-flicker { from { opacity: 0.6; transform: scale(0.92); } to { opacity: 1; transform: scale(1.06); } }
.menu-embers { position: absolute; inset: 0; }
.ember { position: absolute; bottom: -6px; background: #ff9a30; box-shadow: 0 0 6px 1px rgba(255,140,40,0.8); animation: ember-rise linear infinite; opacity: 0; }
@keyframes ember-rise { 0% { transform: translate(0,0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(var(--drift, 10px), -85vh); opacity: 0; } }
.menu-top { position: absolute; top: 10px; right: 16px; z-index: 2; }
.menu-content { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; width: 100%; }
.menu-main { display: flex; gap: 48px; align-items: center; justify-content: center; }
.menu-hero { text-align: center; display: flex; flex-direction: column; align-items: center; }
.menu-hero .spr-preview { filter-drop: none; animation: hero-bob 1.6s steps(4, end) infinite; }
@keyframes hero-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.menu-plinth { width: 120px; height: 14px; background: var(--col-stone-dk); border-top: 3px solid var(--col-stone); margin-top: -6px; }
.menu-hero-name { color: var(--col-gold); font-weight: bold; letter-spacing: 0.15em; margin-top: 8px; }
.menu-hero-title { font-size: 0.8em; color: var(--col-parchment-dk); }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: 300px; }
.menu-big { padding: 10px 14px; font-size: 1em; text-align: center; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-grid .btn { text-align: center; }
.menu-account { position: relative; z-index: 2; margin-top: 22px; width: 420px; display: flex; align-items: center; gap: 10px; font-size: 0.8em; color: var(--col-parchment); }
.menu-account .bar-wrap { flex: 1; height: 12px; }
#ui-root #exit-screen { justify-content: center; align-items: center; background: #0d0905; }
.exit-panel { text-align: center; max-width: 520px; }
.exit-panel p { margin: 8px 0; }

/* ---- instructions ---- */
.ins-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; }
.ins-body > .ins-card:first-child { grid-column: 1 / span 2; }
.ins-list { padding-left: 18px; line-height: 1.7; font-size: 0.9em; }
.ins-dl dt { color: var(--col-gold); margin-top: 6px; } .ins-dl dd { font-size: 0.85em; margin-left: 24px; }

/* ---- character select ---- */
.cs-body { flex-direction: row; gap: 16px; }
.cs-cards { display: flex; flex-direction: column; gap: 8px; width: 170px; flex: 0 0 auto; }
.cs-card { background: var(--col-stone-dk); border: 3px solid var(--col-stone); padding: 6px; text-align: center; cursor: pointer; position: relative; }
.cs-card:hover { border-color: var(--col-gold-dark); }
.cs-card.viewing { border-color: var(--col-gold); } .cs-card.selected { outline: 2px solid var(--col-uncommon, #48b84e); }
.cs-card.locked .spr-preview { filter: grayscale(1) brightness(0.45); }
.cs-name { font-size: 0.8em; font-weight: bold; } .cs-tag { font-size: 0.7em; color: var(--col-parchment-dk); } .cs-tag.ok { color: #6fdc6f; } .cs-tag.lock { color: var(--col-gold); }
.cs-detail { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; }
.cs-top { display: flex; gap: 18px; align-items: center; }
.cs-preview { flex: 0 0 150px; text-align: center; background: rgba(0,0,0,0.35); padding: 6px; border: 1px solid var(--col-stone); }
.cs-hero-name { color: var(--col-gold); } .cs-hero-title { color: var(--col-parchment-dk); font-size: 0.85em; } .cs-desc { font-size: 0.85em; margin: 6px 0; }
.cs-mastery { font-size: 0.8em; }
.cs-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.cs-bar-row { display: flex; align-items: center; gap: 8px; font-size: 0.8em; } .cs-bar-label { width: 62px; } .cs-bar-val { width: 36px; text-align: right; }
.cs-skills { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cs-skill { display: flex; gap: 8px; background: rgba(0,0,0,0.3); padding: 6px; border: 1px solid var(--col-stone); font-size: 0.78em; }
.cs-skill.passive { border-color: var(--col-gold-dark); } .cs-skill-name { color: var(--col-gold); font-weight: bold; } .cs-lv { color: #6fdc6f; } .cs-skill-meta { color: var(--col-parchment-dk); }
.cs-tints { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 0.8em; }
.cs-actions { display: flex; gap: 14px; justify-content: center; margin-top: 4px; }

/* ---- stage select ---- */
.ss-map { text-align: center; } .ss-map h2 { letter-spacing: 0.2em; text-transform: uppercase; }
.ss-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ss-card { cursor: pointer; display: flex; flex-direction: column; gap: 4px; font-size: 0.82em; }
.ss-card h3 { font-size: 1em; color: var(--col-gold); }
.ss-card.selected { border-color: var(--col-gold); outline-color: var(--col-gold); }
.ss-card.locked { opacity: 0.6; filter: grayscale(0.7); }
.ss-row { display: flex; justify-content: space-between; } .ss-row b { color: var(--col-gold); }
.ss-tag { align-self: flex-start; padding: 1px 8px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.1em; background: #3a8a3a; color: #fff; }
.ss-tag.diff-medium { background: #b8860b; } .ss-tag.diff-hard { background: #c4501a; } .ss-tag.diff-nightmare { background: #7a1a8a; }
.ss-mod { padding: 4px; background: rgba(0,0,0,0.3); min-height: 3.2em; color: var(--col-parchment-dk); } .ss-mod.has { color: #ff9a6a; }
.ss-clear { display: flex; justify-content: space-between; align-items: center; }
.star { color: #444; font-size: 1.3em; } .star.on { color: var(--col-gold); }
.ss-lock { color: #d08080; }

/* ---- loadout ---- */
.lo-summary { display: flex; align-items: center; gap: 16px; }
.lo-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lo-pet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
.lo-pet, .lo-item, .lo-rune { cursor: pointer; background: rgba(0,0,0,0.3); border: 2px solid var(--col-stone); padding: 4px; text-align: center; font-size: 0.75em; }
.lo-pet:hover, .lo-item:hover, .lo-rune:hover, .lo-slot:hover { border-color: var(--col-gold-dark); }
.lo-pet.equipped, .lo-slot.active { border-color: var(--col-gold); }
.lo-pet-ico { font-size: 2em; height: 48px; line-height: 48px; }
.lo-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.lo-slot { position: relative; height: 62px; border: 2px solid var(--col-stone); background: rgba(0,0,0,0.4); text-align: center; cursor: pointer; padding-top: 6px; }
.lo-slot-key { position: absolute; top: 1px; left: 3px; font-size: 0.65em; color: var(--col-gold); } .lo-slot-qty { font-size: 0.7em; } .lo-slot-empty { margin-top: 12px; font-size: 0.7em; color: var(--col-stone); }
.lo-item-list, .lo-rune-list { display: flex; flex-direction: column; gap: 3px; max-height: 190px; overflow-y: auto; }
.lo-item, .lo-rune { display: flex; align-items: center; gap: 6px; text-align: left; } .lo-item span, .lo-rune span { flex: 1; } 
.lo-rune-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 8px; }
.lo-rune-slot { min-height: 60px; border: 2px dashed var(--col-stone); text-align: center; font-size: 0.65em; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lo-rune-slot.filled { border-style: solid; border-color: var(--col-gold-dark); cursor: pointer; } .lo-rune-slot.locked { opacity: 0.55; }
.lo-start { padding: 12px 40px; font-size: 1.1em; }

/* ---- shop / upgrades / runes / achievements ---- */
.shop-card { display: flex; flex-direction: column; gap: 6px; font-size: 0.82em; }
.shop-head { display: flex; gap: 10px; align-items: center; } .shop-name { color: var(--col-gold); font-weight: bold; } .shop-desc { flex: 1; font-size: 0.9em; }
.pet-card.owned { border-color: var(--col-gold-dark); }
.up-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.up-row, .quest-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 0.82em; }
.up-main { flex: 1; display: flex; flex-direction: column; gap: 3px; } .up-name { color: var(--col-gold); font-weight: bold; } .up-tier { color: #6fdc6f; font-size: 0.85em; }
.up-after { color: #6fdc6f; } .up-btns, .rune-btns { display: flex; flex-direction: column; gap: 4px; } .rune-btns { flex-direction: row; }
.up-miles { display: flex; flex-direction: column; font-size: 0.85em; color: var(--col-stone); } .mile.reached { color: #6fdc6f; }
.up-locked { display: flex; gap: 10px; align-items: center; }
.rune-slots { display: flex; gap: 10px; align-items: center; }
.rs { width: 34px; height: 34px; border: 2px solid var(--col-gold-dark); display: inline-flex; align-items: center; justify-content: center; flex-direction: column; font-size: 0.55em; }
.rs.locked { opacity: 0.5; border-style: dashed; } .rs i { font-style: normal; }
.rune-card.equipped { border-color: var(--col-gold); }
.ach-card.claimed { opacity: 0.55; } .ach-card.done:not(.claimed) { border-color: var(--col-gold); }
.ach-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 0.85em; }
.quest-row.done:not(.claimed) { background: rgba(240,208,64,0.08); }

/* ---- ascension / settings ---- */
.asc-panel p { margin: 6px 0; } .asc-resets, .asc-keeps { margin: 6px 0; font-size: 0.85em; } .asc-locked { margin-top: 10px; color: #d08080; }
.set-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 0.85em; } .set-row label { flex: 0 0 210px; } .set-row input[type=range] { flex: 1; accent-color: var(--col-gold); }
.set-val { width: 46px; text-align: right; color: var(--col-gold); } .set-seg { display: flex; gap: 4px; }
.keys-table td:nth-child(odd) { color: var(--col-parchment-dk); width: 18%; } .key-btn { min-width: 76px; } .key-btn.capturing { background: var(--col-gold); }
.set-save-btns { display: flex; gap: 8px; margin-bottom: 8px; }
#save-string { width: 100%; background: var(--col-ink); color: var(--col-parchment); border: 1px solid var(--col-stone); font-family: var(--pixel-font); font-size: 0.75em; padding: 4px; user-select: text; resize: vertical; }
.menu-buttons .disabled { opacity: 0.55; }

/* layout fix: children of the scrolling meta body keep their natural height */
.meta-body > * { flex-shrink: 0; }
.cs-body > .cs-detail { flex: 1 1 0; min-width: 0; align-self: flex-start; }
.cs-body > .cs-cards { align-self: flex-start; }
