/* TDidle — tdidle.com. Aged oak, forged brass, rune-gold. Mobile-first.
   Knobs: --ui-scale (0.8..1.3), --panel-alpha (Settings > Interface).
   One panel height for every tab: GAME/SKILLS/SETTINGS must FIT it, only
   upgrades/shop/achievements scroll.
   Top bands must never overlap: HUD > #wave-countdown > #toasts > #levelup.
   Every selector is declared ONCE. All media queries are at the end of the
   file, in cascade order: 761+ / 760 / touch / no-hover / 520 / short / RM. */
/* THE TYPEFACE — regenerate with `python make_font.py`, never by hand.
   A high-contrast bold serif traced onto a 13-cell em, so every stem lands on a
   whole pixel and the serifs survive as single-pixel spurs. That contrast is
   the whole point: v0.58 traced Georgia, a low-contrast screen serif, and the
   result read soft and modern. Any glyph it does not carry (emoji, box drawing)
   falls through to the serif behind it in --font — deliberate, do not "fix" it.
   4 KB. The version is in the FILENAME because /assets is cached for a week. */
@font-face{
  font-family:'TDPixel';
  src:url('../assets/fonts/tdpixel-2.woff2') format('woff2');
  font-weight:normal;font-style:normal;font-display:swap;
}

:root{
  --ui-scale: 1;
  --radius: 3px;          /* rugged, not bubbly — corners are chamfers, not pills */
  --panel-alpha: 1;

  /* ONE plaque size for every sprite button in the game.
     2.15 is the CANVAS aspect that normalize_buttons.py writes, and it is not
     a free number: the painted signs are 2.2-2.5:1, so a wider canvas fits
     them all by HEIGHT and leaves the widths ragged — which is exactly what
     "the buttons are still different sizes" meant for three releases. At 2.15
     every plaque's ink is 96% of the canvas WIDTH, so a column of buttons
     measures identically. Change this and re-run normalize_buttons.py, or the
     art and the box stop agreeing.
     Change --plaque-h and every plaque in the game scales together.
     NEVER size a .sprite-btn locally. If a screen ever genuinely needs a
     different size, redeclare BOTH variables there: the var(--plaque-h) inside
     --plaque-w resolves where --plaque-w is declared, which is here, so
     overriding the height alone only stretches the box. Nothing does this
     today, and that is the point — one size, everywhere. */
  --plaque-h: 46px;
  --plaque-w: calc(var(--plaque-h) * 2.15);

  /* wood / brown */
  --wood-0:#120c07;
  --wood-1:#1e150d;
  --wood-2:#2b1f13;
  --wood-3:#3a2a19;
  --wood-4:#4d3823;

  /* brass / gold */
  --brass:#8a6a35;
  --brass-lit:#b98f45;
  --gold:#ffd970;
  --gold-2:#c9a227;
  --gold-dim:#8f7328;

  /* semantic text colors */
  --text:#ecdcc0;
  --dim:#9d8b70;
  --t-name:#ffe9a8;
  --t-type:#7fd4ff;
  --t-num:#ffb347;
  --t-var:#c9a0ff;
  --t-str:#a3e07a;
  --t-key:#ff9f6b;

  --danger:#e5533d;
  --ok:#7ec850;
  --crystal:#c44bff;
  --arc:#4adfff;

  --font:'TDPixel',Georgia,'Times New Roman',serif;
  --shadow:0 6px 22px rgba(0,0,0,.65);
}

*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
/* App-shell feel: nothing selectable, no iOS long-press callouts. */
html,body{width:100%;height:100%;overflow:hidden;background:var(--wood-0);color:var(--text);
  font-family:var(--font);font-size:calc(15px * var(--ui-scale));
  -webkit-text-size-adjust:100%;overscroll-behavior:none;touch-action:manipulation;
  user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;
  /* a pixel face must not be faux-bolded or hinted into mush */
  font-synthesis:none;-webkit-font-smoothing:antialiased}

/* ONE scrollbar look everywhere something scrolls — brass rail on dark oak,
   square like the rest of the chrome. Firefox gets the two-colour form. */
*{scrollbar-width:thin;scrollbar-color:var(--brass) rgba(0,0,0,.35)}
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-track{background:rgba(0,0,0,.35);border-radius:0}
::-webkit-scrollbar-thumb{background:linear-gradient(180deg,var(--brass-lit),var(--brass));
  border:1px solid var(--wood-0);border-radius:0}
::-webkit-scrollbar-thumb:hover{background:linear-gradient(180deg,var(--gold-2),var(--brass-lit))}
::-webkit-scrollbar-corner{background:transparent}
input,textarea,[contenteditable="true"]{user-select:text;-webkit-user-select:text}
button{font-family:var(--font);cursor:pointer;color:inherit}
img{-webkit-user-drag:none;user-select:none;-webkit-touch-callout:none}
/* clicks land on the button, never its artwork */
button img,a img{pointer-events:none}
.hidden{display:none!important}
::selection{background:var(--gold-2);color:#000}
/* no 300ms tap delay, no accidental double-tap zoom */
button,.tab-btn,.sprite-btn{touch-action:manipulation;-webkit-tap-highlight-color:transparent}

/* reusable wood surface */
.wood{
  background:
    linear-gradient(180deg,rgba(255,255,255,.05),transparent 40%),
    repeating-linear-gradient(96deg,rgba(0,0,0,.10) 0 2px,transparent 2px 7px),
    linear-gradient(170deg,var(--wood-3),var(--wood-1));
  border:1px solid var(--brass);
  box-shadow:inset 0 1px 0 rgba(255,220,160,.10),inset 0 -2px 6px rgba(0,0,0,.5),var(--shadow);
}

/* The canvas is revealed only once the world EXISTS (.on) and is WANTED
   (body.scene-live). */
#scene{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none;
  opacity:0;transition:opacity .9s ease;pointer-events:none}
body.scene-live #scene.on{opacity:1;pointer-events:auto}

/* Pure-CSS backdrop behind the title screen. Once the live world shows it is
   redundant: the delayed `visibility` stops the compositor blending a
   full-screen layer every frame after the fade completes. */
#static-bg{position:fixed;inset:0;z-index:-1;transition:opacity .6s ease, visibility 0s;
  background:
    radial-gradient(ellipse 60% 45% at 50% 34%, rgba(201,162,39,.13) 0%, rgba(201,162,39,0) 70%),
    radial-gradient(ellipse 90% 70% at 50% 50%, #17100a 0%, #0d0906 55%, #060403 100%)}
body.scene-live #static-bg{opacity:0;visibility:hidden;transition:opacity .6s ease, visibility 0s .6s}

/* ===== AUTH ===== */
#auth{position:fixed;inset:0;z-index:100;display:none;align-items:center;justify-content:center;
  flex-direction:column;gap:10px;padding:18px;
  background:
    radial-gradient(ellipse 60% 45% at 50% 28%, rgba(201,162,39,.12) 0%, rgba(201,162,39,0) 70%),
    radial-gradient(ellipse 90% 70% at 50% 50%, #17100a 0%, #0d0906 55%, #060403 100%)}
#auth.open{display:flex}
/* Opaque, no backdrop-filter: the card sits over the landing menu (z95) and the
   live 3D demo, and blurring a full-screen live canvas costs a frame's work for
   an effect nothing can see through. */
#auth.modal-mode{background:#060305}

/* height:auto is LOAD-BEARING: index.html carries width="480" height="315" so
   the box is reserved before decode; setting only `width` renders it stretched. */
#auth-logo{width:min(180px,42vw);height:auto;filter:drop-shadow(0 3px 10px rgba(0,0,0,.75));
  transition:filter .3s;cursor:default}
#auth-logo:hover{filter:drop-shadow(0 3px 10px rgba(0,0,0,.75)) brightness(1.04)}
#auth.modal-mode #auth-logo{width:min(120px,32vw);margin-bottom:2px}

.auth-box{position:relative;display:flex;flex-direction:column;gap:10px;
  width:min(300px,88vw);padding:10px;border-radius:var(--radius);
  background:none;border:none;box-shadow:none}

#auth-close{
  display:none;position:fixed;top:calc(12px + env(safe-area-inset-top,0px));right:14px;
  width:34px;height:34px;border-radius:8px;
  background:var(--wood-2);border:1px solid var(--brass);
  color:var(--dim);font-size:1rem;line-height:1;z-index:2;
}
#auth-close:hover{color:var(--danger);border-color:var(--danger)}
#auth.modal-mode #auth-close{display:flex;align-items:center;justify-content:center}

/* Reserve the slot Google's rendered button lands in, so the card does not
   grow and reflow ~200ms after it opens. */
#g-btn-host{display:flex;align-items:center;justify-content:center;min-height:44px}
.g-btn{display:flex;align-items:center;justify-content:center;gap:9px;width:100%;padding:10px;
  border-radius:6px;border:1px solid var(--brass);background:linear-gradient(180deg,#fff,#e8e6e1);
  color:#2b1f13;font-weight:bold;font-size:.85rem;transition:.13s}
.g-btn:hover{filter:brightness(1.03);transform:translateY(-1px)}
.g-btn svg{width:17px;height:17px}
/* `hidden` is a UA-stylesheet rule on the ATTRIBUTE, so .g-btn{display:flex}
   beats it. This puts the attribute back in charge. */
.g-btn[hidden]{display:none}

/* collapses when empty so the card carries no permanent gap */
#auth-err{color:var(--danger);font-size:.82rem;text-align:center;line-height:1.35}
#auth-err:empty{display:none}

.auth-guest{display:flex;align-items:center;justify-content:center;margin-top:2px}
.auth-guest span{color:var(--dim);font-size:.72rem;font-style:italic}
/* the login card's PLAY plaque is the standard plaque, like every other one */
.auth-guest{--plaque-h:40px}

/* Privacy/Terms stay visible on the sign-in surface, including modal mode. */
.auth-legal{margin-top:4px;text-align:center;font-size:.7rem;color:var(--dim)}
.auth-legal a{color:var(--dim);text-decoration:underline}
.auth-legal a:hover{color:var(--gold)}

/* gold click sparkle on the title screens */
.gold-spark{position:fixed;width:6px;height:6px;margin:-3px 0 0 -3px;border-radius:50%;
  background:radial-gradient(circle,#fff6cf 0%,#ffd970 45%,rgba(255,200,60,0) 72%);
  pointer-events:none;z-index:120;
  box-shadow:0 0 6px 1px rgba(255,217,112,.8);
  animation:goldSpark .6s ease-out forwards}
@keyframes goldSpark{
  0%{transform:translate(0,0) scale(1);opacity:1}
  100%{transform:translate(var(--dx),var(--dy)) scale(.2);opacity:0}
}
.ov-logo.pulse,#auth-logo.pulse{animation:logoPulse .5s ease}
@keyframes logoPulse{
  35%{filter:drop-shadow(0 6px 22px rgba(201,162,39,.4)) drop-shadow(0 0 9px rgba(255,224,130,.4)) brightness(1.05)}
}

/* ===== TOP HUD — one movable pod ===== */
/* Wraps rather than scrolls: an overflow-x scroller under touch-action:none
   can never be panned, so a clipped control is unreachable. */
/* Part of the dock's flex column, not a floating pod: it cannot be dragged out
   of the viewport, so a resize or a browser zoom just reflows it. It WRAPS
   rather than scrolls — an overflow-x scroller under touch-action:none can
   never be panned, and a clipped control would be unreachable. */
/* The status row of the one console — no frame of its own, the dock is the
   frame. `.wood` is stripped off it in CSS rather than in the HTML so the
   markup stays readable. */
#hud{
  display:flex;flex-wrap:wrap;align-items:center;justify-content:center;
  gap:3px 5px;padding:3px 6px;margin:0;
  width:100%;box-sizing:border-box;user-select:none;
  background:none!important;border:none!important;box-shadow:none!important;border-radius:0;
}
#hud-logo{display:block;height:20px;cursor:pointer;filter:drop-shadow(0 2px 5px #000)}
#hud-logo:hover{filter:drop-shadow(0 2px 7px rgba(255,217,112,.6))}
/* square brass tokens, not bubbles */
.hud-pill{display:flex;align-items:center;gap:4px;padding:2px 6px;font-size:.6rem;font-weight:bold;
  background:rgba(10,6,3,.6);border:1px solid var(--brass);border-radius:var(--radius);
  white-space:nowrap;cursor:default}
.hud-pill:hover{border-color:var(--brass-lit)}
.hud-pill .ico{font-size:.7rem;line-height:1}
#hud-gold{color:var(--gold)}
#hud-crystals{color:var(--crystal)}
#hud-round{color:var(--t-type)}
#hud-name{color:var(--t-name);font-size:.6rem;font-style:italic;font-weight:normal;max-width:115px;
  min-width:0;flex-shrink:1;overflow:hidden;text-overflow:ellipsis}
/* the bars never shrink — a 2px HP bar reads as no HP bar */
/* Keep HP unmissable: it is the one number that ends the run. Taller than the
   pills, hard-edged, with the reading printed inside it. */
#hud-hp{position:relative;flex:0 0 auto;width:clamp(84px,19vw,168px);height:15px;background:#0a0603;
  border:1px solid var(--brass);border-radius:var(--radius);overflow:hidden;cursor:default;
  box-shadow:inset 0 2px 5px rgba(0,0,0,.8)}
#hud-hp-fill{position:absolute;inset:0;width:100%;transition:width .25s}
#hud-hp-text{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  font-size:.55rem;font-weight:bold;color:#fff;text-shadow:0 1px 2px #000,0 0 4px #000}
#hud-shield{position:relative;flex:0 0 auto;width:clamp(90px,20vw,190px);height:7px;margin-top:2px;
  background:#050a12;border:1px solid #2a4a6a;border-radius:var(--radius);overflow:hidden}
#hud-shield-fill{position:absolute;inset:0;width:100%;transition:width .25s;
  background:linear-gradient(90deg,#2a6ab0,#7fd4ff);
  box-shadow:0 0 8px rgba(127,212,255,.5) inset}

/* HUD mini-controls (1x/2x, XP, skip) are sprite plaques — no wood chrome. */
#speed-ctl{display:flex;gap:5px;margin-left:4px}
/* min-height is a real tap target, not the old 19px sliver */
#speed-ctl button{display:flex;align-items:center;justify-content:center;
  min-height:calc(30px * var(--ui-scale));padding:0 5px;border-radius:6px;
  background:none;border:none;box-shadow:none;color:var(--gold);letter-spacing:.03em;cursor:pointer}
#speed-ctl button:hover{filter:brightness(1.18)}
#speed-ctl button img{height:calc(26px * var(--ui-scale));display:block;
  filter:drop-shadow(0 2px 4px rgba(0,0,0,.6))}
#btn-skip img{height:calc(27px * var(--ui-scale));filter:drop-shadow(0 2px 5px rgba(0,0,0,.6))}
#btn-speed.active img{filter:drop-shadow(0 0 7px rgba(255,217,59,.9))}
#btn-xp:not(.on){opacity:.6;filter:grayscale(.5)}
#btn-xp:not(.on) img{filter:grayscale(1) brightness(.55)}
#btn-xp.on:hover{filter:brightness(1.1)}

/* ===== WAVE BANNER / COUNTDOWN / TOASTS / LEVEL-UP ===== */
/* Fixed top bands, stacked so they can never meet. Change one offset, check
   the other two (and the touch overrides at the end of the file). */
#wave-announce{position:fixed;top:19%;left:50%;transform:translateX(-50%);z-index:15;text-align:center;
  pointer-events:none;opacity:0;width:90vw}
#wave-announce.show{animation:waveIn 3s ease forwards}
@keyframes waveIn{0%{opacity:0;transform:translateX(-50%) translateY(16px) scale(.92)}
  12%{opacity:1;transform:translateX(-50%) translateY(0) scale(1)}78%{opacity:1}
  100%{opacity:0;transform:translateX(-50%) translateY(-12px)}}
.wave-round{font-size:.72rem;letter-spacing:6px;font-weight:bold;text-transform:uppercase;
  background:linear-gradient(180deg,#fff3c4,var(--gold) 45%,#b8862b);
  -webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;
  filter:drop-shadow(0 2px 4px #000) drop-shadow(0 0 10px rgba(255,200,90,.6));
  padding-bottom:2px}
.wave-round::before,.wave-round::after{content:"";display:inline-block;width:26px;height:1px;
  vertical-align:middle;margin:0 10px;
  background:linear-gradient(90deg,transparent,var(--gold-2),transparent)}
.wave-name{font-size:1.45rem;font-weight:bold;letter-spacing:2px;text-transform:uppercase;
  text-shadow:0 3px 14px #000, 0 0 10px currentColor, 0 0 30px currentColor, 0 0 60px currentColor;
  margin:5px 0;animation:waveNameGlow 2.4s ease-in-out infinite}
@keyframes waveNameGlow{
  0%,100%{filter:drop-shadow(0 0 6px currentColor)}
  50%{filter:drop-shadow(0 0 18px currentColor)}}
.wave-desc{font-size:.76rem;letter-spacing:.5px;color:var(--t-str);font-style:italic;
  text-shadow:0 2px 6px #000,0 0 12px rgba(0,0,0,.8);max-width:520px;margin:2px auto 0}
.boss-tag{font-size:1rem;letter-spacing:7px;font-weight:bold;text-transform:uppercase;
  color:#ff5a3d;text-shadow:0 2px 8px #000,0 0 14px #ff5a3d,0 0 34px #ff2a14;
  animation:bossTag .7s ease-in-out infinite}
@keyframes bossTag{50%{opacity:.55;transform:scale(1.04)}}

#wave-countdown{position:fixed;top:calc(58px + env(safe-area-inset-top));left:50%;
  transform:translateX(-50%);z-index:15;
  padding:5px 15px;font-size:.78rem;color:var(--gold);border-radius:99px;display:none;
  user-select:none;cursor:pointer}
#wave-countdown:hover{filter:brightness(1.2)}

#toasts{position:fixed;top:calc(94px + env(safe-area-inset-top));bottom:auto;left:50%;
  transform:translateX(-50%);z-index:40;
  display:flex;flex-direction:column;align-items:center;gap:5px;pointer-events:none;
  width:92vw;max-width:440px}
.toast{padding:5px 12px;font-size:.8rem;font-weight:bold;text-align:center;white-space:nowrap;
  max-width:100%;overflow:hidden;text-overflow:ellipsis;
  color:var(--text);text-shadow:0 2px 6px #000,0 0 12px #000;
  background:none;border:none;
  opacity:0;transform:translateY(10px) scale(.95);transition:all .3s}
.toast.show{opacity:1;transform:translateY(0) scale(1)}
/* Hard cap the visible stack at the 2 newest so the band cannot grow into
   #levelup, whatever the JS queue length is. */
#toasts .toast:nth-last-child(n+3){display:none}

#levelup{position:fixed;left:50%;top:calc(156px + env(safe-area-inset-top));
  transform:translate(-50%,0);z-index:45;pointer-events:none;
  display:none;flex-direction:column;align-items:center;gap:4px}
#levelup.show{display:flex;animation:luInTop 2.2s ease forwards}
@keyframes luInTop{0%{opacity:0;transform:translate(-50%,-8px) scale(.6)}
  16%{opacity:1;transform:translate(-50%,0) scale(1.08)}
  26%{transform:translate(-50%,0) scale(1)}
  80%{opacity:1}100%{opacity:0;transform:translate(-50%,-10px) scale(1)}}
#levelup .lu-ico{width:82px;height:82px;object-fit:contain;
  filter:drop-shadow(0 0 18px currentColor) drop-shadow(0 4px 10px #000);animation:luSpin 2.2s ease-out}
@keyframes luSpin{0%{transform:rotate(-25deg) scale(.5)}30%{transform:rotate(0) scale(1)}}
#levelup .lu-t{font-size:.8rem;letter-spacing:6px;color:var(--gold);text-shadow:0 2px 6px #000}
#levelup .lu-n{font-size:1.7rem;letter-spacing:1px;font-weight:bold;
  text-shadow:0 3px 10px #000,0 0 24px currentColor}
#levelup .lu-s{font-size:.78rem;color:var(--t-num);text-shadow:0 2px 5px #000}
#levelup .lu-ring{position:absolute;width:150px;height:150px;border:3px solid currentColor;
  border-radius:50%;top:24px;opacity:.7;animation:luRing 1.1s ease-out forwards}
@keyframes luRing{to{transform:scale(2.4);opacity:0}}

/* ===== BOTTOM DOCK — status strip + tab bar + panel =====
   One bottom-pinned column. Nothing inside is draggable or hand-resizable, so
   there is no stored pixel geometry for a resize or a ctrl+/- zoom to invalidate.
   Height is capped against --vh (the real viewport height, kept current by
   UI.relayout) so the dock can never grow taller than the screen. */
/* ONE BOX. The status strip, the tab plaques and the panel are a single framed
   console, not three floating slabs — Mikey's rule is that the game has one
   menu and it is impossible to lose. Nothing here is draggable or resizable,
   so there is no stored geometry for a resize or a ctrl+/- zoom to invalidate. */
#dock{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(6px + env(safe-area-inset-bottom));
  z-index:30;display:flex;flex-direction:column;align-items:stretch;
  width:min(620px, calc(100vw - 12px));
  max-height:calc(var(--vh, 1vh) * 88);
  padding:0;gap:0;overflow:hidden;   /* children run edge to edge inside the frame */
  background:
    linear-gradient(180deg,rgba(255,255,255,.045),transparent 38%),
    repeating-linear-gradient(96deg,rgba(0,0,0,.10) 0 2px,transparent 2px 7px),
    linear-gradient(170deg,var(--wood-3),var(--wood-1));
  border:1px solid var(--brass);
  box-shadow:inset 0 1px 0 rgba(255,220,160,.10),inset 0 -2px 6px rgba(0,0,0,.5),var(--shadow);
  border-radius:var(--radius)}
#dock > *{pointer-events:auto}

/* The strip is chrome-free: the tab plaques ARE the bar. Five tabs, sized big
   and set close together. A hairline rule separates them from the status row —
   the frame around all three is the dock itself. */
#tabbar{display:flex;justify-content:center;gap:2px;padding:2px 3px;height:auto;
  background:rgba(0,0,0,.22);border:none;border-top:1px solid rgba(138,106,53,.5);
  border-radius:0;box-shadow:none;overflow:visible}
.tab-btn{flex:1;min-width:0;padding:2px 0 1px;font-size:.48rem;letter-spacing:.35px;color:#c9b48e;
  border-radius:6px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;
  background:linear-gradient(180deg,var(--wood-3),var(--wood-2));
  border:1px solid var(--wood-4);
  cursor:pointer;transition:all .12s;overflow:hidden}
.tab-btn img{height:calc(17px * var(--ui-scale));max-width:100%;width:auto;object-fit:contain;
  transition:transform .12s}
.tab-btn:hover{color:var(--text);border-color:var(--brass-lit)}
.tab-btn:hover img{transform:translateY(-2px) scale(1.08)}
.tab-btn.active{color:#241503;border-color:#ffe9a8;
  background:linear-gradient(180deg,var(--gold),#c9992a);
  box-shadow:0 0 12px rgba(255,217,112,.4),inset 0 1px 0 rgba(255,240,200,.5);
  font-weight:800}
.tab-btn.active img{filter:drop-shadow(0 1px 1px rgba(0,0,0,.4))}
/* Icon tabs: equal flex boxes, art scaled to FIT, glow allowed to breathe past
   the button edge. Must stay after the .tab-btn rules above — it wins on order. */
.tab-btn.tab-icon{
  flex:1 1 0;min-width:0;height:calc(62px * var(--ui-scale));
  background:none;border:none;box-shadow:none;padding:1px;
  display:flex;align-items:center;justify-content:center;overflow:visible;
}
.tab-btn.tab-icon img{
  width:100%;height:100%;max-height:calc(48px * var(--ui-scale));object-fit:contain;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.5));transition:transform .1s, filter .1s;
}
.tab-btn.tab-icon:hover img{transform:translateY(-1px) scale(1.08);
  filter:drop-shadow(0 2px 5px rgba(0,0,0,.6)) brightness(1.15)}
.tab-btn.tab-icon.active img{transform:scale(1.12);
  filter:drop-shadow(0 0 8px rgba(255,217,112,.6)) brightness(1.2)}

/* ONE height for every tab, sized so the SKILLS grid (4 rows) fits exactly.
   Taller tabs scroll inside #panel-content; the tab bar never jumps. */
#panel{
  position:relative;z-index:25;
  height:min(34vh, 196px);
  max-height:min(34vh, 196px);
  display:none;flex-direction:column;
  overflow:hidden;
}
#panel.open{display:flex}
/* Inset well inside the dock frame, not a second floating card.
   --panel-alpha fades the surface see-through while text stays solid. */
/* NO FRAME OF ITS OWN. The dock is the frame; the panel is the bottom room
   inside it, separated by the same hairline that separates the tab strip from
   the status row. A border here is what made the console read as two stacked
   boxes instead of one (Mikey, three times running). */
#panel.wood{
  margin:0;border:none;border-radius:0;
  border-top:1px solid rgba(138,106,53,.5);
  background:linear-gradient(180deg, rgba(9,6,4,var(--panel-alpha)), rgba(5,3,2,var(--panel-alpha)));
  box-shadow:inset 0 3px 9px rgba(0,0,0,.6);
}

/* Title bar hidden — the tab itself toggles the panel. Kept in the DOM so the
   JS that writes #panel-title / binds #panel-close never hits null. */
#panel-bar{display:none;align-items:center;gap:4px;padding:4px 5px 4px 9px;flex-shrink:0;
  background:linear-gradient(180deg,var(--wood-4),var(--wood-2));
  border-bottom:1px solid var(--brass);cursor:default;user-select:none}
#panel-title{flex:1;font-size:.78rem;letter-spacing:2px;color:var(--gold);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#panel-title .sub{font-size:.68rem;letter-spacing:0;color:var(--dim);font-style:italic}
.bar-btn{width:24px;height:24px;font-size:.75rem;line-height:1;border-radius:5px;flex-shrink:0;
  background:var(--wood-2);border:1px solid var(--brass);color:var(--dim);
  display:flex;align-items:center;justify-content:center;transition:.12s}
.bar-btn:hover{color:var(--gold);border-color:var(--gold-2);background:var(--wood-4)}
.bar-btn.close:hover{color:var(--danger);border-color:var(--danger)}

#panel-content{flex:1;overflow-y:auto;overflow-x:hidden;padding:9px;overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch}
#panel-content::-webkit-scrollbar{width:7px}
#panel-content::-webkit-scrollbar-track{background:var(--wood-0)}
#panel-content::-webkit-scrollbar-thumb{background:var(--brass);border-radius:4px}
/* SKILLS and SETTINGS are authored to fit; the GAME tab keeps the inherited
   `auto` because its idle block can genuinely exceed the panel. */
#panel-content:has(.skill-grid){overflow-y:hidden}
#panel-content:has(.set-cats){overflow-y:hidden}

/* ===== FILTER BAR ===== */
.filter-bar{display:flex;flex-wrap:wrap;align-items:center;gap:3px;margin-bottom:8px}
/* pushes a group to the far end of the strip */
.filter-tail{display:flex;gap:3px;margin-left:auto}
/* UPGRADES: one line you swipe, never a second row and never a fold-out */
.filter-strip{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;padding-bottom:2px;
  scrollbar-width:none;-webkit-overflow-scrolling:touch}
.filter-strip::-webkit-scrollbar{display:none}
.filter-strip > *{flex:0 0 auto}
.filter-strip .search-inp{min-width:96px}
.filter-btn{min-width:30px;height:30px;padding:0 7px;font-size:.65rem;letter-spacing:1px;color:var(--dim);
  background:var(--wood-2);border:1px solid var(--brass);border-radius:5px;
  display:flex;align-items:center;justify-content:center;transition:.12s;flex-shrink:0}
.filter-btn img{width:19px;height:19px;object-fit:contain}
.filter-btn:hover{border-color:var(--brass-lit);background:var(--wood-4)}
.filter-btn.active{border-color:var(--gold);color:var(--gold);background:#5b421f;
  box-shadow:0 0 8px rgba(255,217,112,.25)}
/* sprite plaques: the plaque IS the button, unpicked ones dim back */
.filter-btn.sprite{padding:0;height:34px;min-width:0;background:none;border:none;box-shadow:none}
.filter-btn.sprite img{height:100%;width:auto;display:block;
  filter:grayscale(.5) brightness(.68);transition:filter .12s}
.filter-btn.sprite:hover img{filter:grayscale(.15) brightness(.95)}
.filter-btn.sprite.active img{filter:drop-shadow(0 0 6px rgba(255,217,112,.55)) brightness(1.06)}
/* flex-basis 0 gives every plaque an identical share of the row */
.filter-sprites{gap:5px;align-items:center;flex-wrap:nowrap}
.filter-sprites .filter-btn{flex:1 1 0;min-width:0;height:30px;padding:0 2px;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis}
.filter-sprites .filter-btn.sprite img{width:100%;height:100%;object-fit:contain}
.search-inp{flex:1;min-width:90px;height:30px;padding:0 9px;font-size:.75rem;font-family:var(--font);
  background:#0a0603;border:1px solid var(--brass);border-radius:5px;color:var(--text);outline:none}
.search-inp:focus{border-color:var(--gold-2)}

/* ===== UPGRADES — square icon-first cards; the whole card is the buy button ===== */
.spell-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(58px,1fr));gap:4px}
.spell-card{--el:#4adfff;--elglow:#7fd4ff;position:relative;aspect-ratio:1/1;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:1px;padding:3px 2px;text-align:center;border-radius:6px;cursor:pointer;user-select:none;
  background:linear-gradient(160deg,var(--wood-2),var(--wood-1));
  border:1px solid var(--brass);border-left:2px solid var(--el);
  transition:.11s;overflow:hidden}
.spell-card.owned{background:linear-gradient(160deg,#3a2a19,var(--wood-1))}
.spell-card:hover{border-color:var(--el);transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(0,0,0,.5),0 0 10px color-mix(in srgb,var(--el) 30%,transparent)}
.spell-card.afford{border-color:var(--gold-2)}
.spell-card.afford:hover{background:linear-gradient(180deg,#5b421f,var(--wood-2));
  box-shadow:0 0 10px rgba(255,217,112,.25)}
.spell-card:active{transform:translateY(1px)}
.sc-icon{width:17px;height:17px;object-fit:contain;flex-shrink:0;filter:drop-shadow(0 2px 4px #000)}
.spell-card .sc-icon{width:78%;height:auto;max-height:68%;flex:1;object-fit:contain;margin:0 auto}
.sc-name{font-size:.48rem;font-weight:bold;color:var(--elglow);max-width:100%;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.15}
.spell-card .sc-name{font-size:.52rem;line-height:1.25}
.sc-lv{position:absolute;top:2px;right:2px;font-size:.48rem;font-weight:bold;color:var(--t-num);
  background:rgba(0,0,0,.45);padding:0 3px;border-radius:99px;border:1px solid var(--gold-dim);
  flex-shrink:0}
.sc-cost{width:100%;text-align:center;font-size:.6rem;font-weight:bold;color:var(--gold);
  margin-top:auto;padding-top:2px;border-top:1px solid rgba(138,106,53,.35)}
.sc-cost.no{color:var(--dim)}
.sc-cost.max{color:var(--crystal);letter-spacing:1px}

/* ===== SKILLS — 4x4 grid, icon · name · level, thin XP bar on the floor ===== */
.skill-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}
.skill-card{--el:#4adfff;position:relative;display:flex;align-items:center;gap:6px;
  padding:6px 8px 10px;min-height:38px;min-width:0;text-align:left;border-radius:6px;cursor:pointer;
  background:linear-gradient(170deg,var(--wood-2),var(--wood-1));
  border:1px solid var(--brass);border-top:2px solid var(--el);transition:.12s}
.skill-card:hover{transform:translateY(-1px);border-color:var(--el);background:var(--wood-4);
  box-shadow:0 0 10px rgba(255,255,255,.06)}
.skill-card img{width:22px;height:22px;object-fit:contain;flex-shrink:0;filter:drop-shadow(0 2px 5px #000)}
.sk-mid{flex:1;min-width:0}
.skill-card .sk-mid{overflow:hidden}
.sk-name{font-size:.62rem;font-weight:bold;margin:0;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sk-lv{font-size:.74rem;font-weight:bold;margin:0;color:var(--t-num);
  background:rgba(0,0,0,.4);border-radius:4px;padding:1px 6px}
.sk-bar{height:5px;background:#0a0603;border-radius:99px;overflow:hidden;border:1px solid rgba(0,0,0,.7)}
.skill-card .sk-bar{position:absolute;left:4px;right:4px;bottom:3px;height:3px;margin:0}
.sk-fill{height:100%;border-radius:99px;transition:width .3s;box-shadow:0 0 6px currentColor}

/* skill -> spell detail view */
.sk-detail-head{display:flex;align-items:center;gap:9px;padding:8px;border-radius:6px;margin-bottom:8px;
  background:linear-gradient(90deg,color-mix(in srgb,var(--el) 18%,transparent),var(--wood-1))}
.sk-detail-head img{width:42px;height:42px;filter:drop-shadow(0 3px 7px #000)}
.sk-dh-body{flex:1;min-width:0}
.sk-dh-name{font-size:1rem;font-weight:bold}
.sk-dh-sub{font-size:.7rem;color:var(--t-str);font-style:italic}
.sk-dh-stats{font-size:.72rem;color:var(--dim);margin-top:2px}
.sk-dh-stats b{color:var(--t-num)}
.sb-toggle{width:100%;text-align:left;padding:7px 9px;border-radius:6px;
  font-family:var(--font);font-size:.72rem;letter-spacing:1px;font-weight:800;color:var(--gold);
  background:linear-gradient(180deg,var(--wood-3),var(--wood-2));border:1px solid var(--brass)}
.sb-toggle .cv{float:right;color:var(--dim)}
.sb-toggle:hover{border-color:var(--gold-2)}

/* ===== ACHIEVEMENTS — dense chips ===== */
.ach-list{display:grid;grid-template-columns:repeat(5,1fr);gap:3px}
.ach-row{display:flex;align-items:center;gap:4px;padding:3px 5px;border-radius:5px;cursor:default;
  background:var(--wood-1);border:1px solid var(--brass);opacity:.55;transition:.12s;min-width:0}
.ach-row:hover{opacity:1;border-color:var(--brass-lit);transform:translateY(-1px)}
.ach-row.got{opacity:1;border-color:var(--gold-2);
  background:linear-gradient(90deg,rgba(255,217,112,.10),var(--wood-1) 60%)}
.ach-badge{font-size:.74rem;flex-shrink:0}
.ach-name{flex:1;min-width:0;font-size:.62rem;font-weight:bold;color:var(--text);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ach-row.got .ach-name{color:var(--gold)}
.ach-reward{font-size:.58rem;font-weight:bold;color:var(--crystal);flex-shrink:0}
.ach-row.got .ach-reward{color:var(--ok)}
/* tall enough for the unlocked count to ride its right end */
.ach-prog{position:relative;height:14px;border-radius:99px;background:#0a0603;border:1px solid var(--brass);
  overflow:hidden;margin-bottom:8px}
.ach-prog > div{height:100%;background:linear-gradient(90deg,var(--gold-2),var(--gold));transition:width .4s}
.ach-count{position:absolute;right:7px;top:50%;transform:translateY(-50%);
  font-size:.58rem;font-weight:bold;letter-spacing:1px;color:var(--gold);
  text-shadow:0 1px 2px rgba(0,0,0,.9);pointer-events:none}

/* ===== SHOP — one card style for every category ===== */
.shop-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:4px}
.shop-card{position:relative;padding:5px 4px;border-radius:6px;text-align:center;
  background:linear-gradient(165deg,var(--wood-2),var(--wood-1));border:1px solid var(--brass);transition:.12s}
.shop-card:hover{transform:translateY(-2px);border-color:var(--brass-lit)}
.shop-card.owned{border-color:var(--arc)}
.shop-card.equipped{border-color:var(--gold);box-shadow:0 0 12px rgba(255,217,112,.2)}
.sw{width:24px;height:24px;margin:0 auto 4px;border-radius:50%;border:2px solid rgba(255,255,255,.15);
  box-shadow:inset 0 2px 6px rgba(0,0,0,.6),0 2px 7px rgba(0,0,0,.5)}
/* transform, not filter: hue-rotate repaints the swatch every frame */
.sw.rainbow{background:conic-gradient(#ff4d3b,#ffd93b,#5fd44a,#4adfff,#c44bff,#ff4d3b);
  animation:swspin 4s linear infinite}
@keyframes swspin{to{transform:rotate(360deg)}}
.shop-name{font-size:.64rem;font-weight:bold;color:var(--t-name);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* Price plates: a struck metal tag, not a web button. The top highlight and
   bottom shadow are what sell "stamped", and the colour says which currency. */
.shop-btn{width:100%;margin-top:4px;padding:3px 4px;font-size:.6rem;font-weight:bold;letter-spacing:.5px;
  border-radius:var(--radius);border:1px solid var(--brass);color:var(--text);transition:.11s;
  background:linear-gradient(180deg,var(--wood-3),var(--wood-1));
  box-shadow:inset 0 1px 0 rgba(255,225,170,.14),inset 0 -2px 4px rgba(0,0,0,.45);
  text-shadow:0 1px 2px rgba(0,0,0,.8)}
.shop-btn:active{transform:translateY(1px);box-shadow:inset 0 2px 5px rgba(0,0,0,.6)}
.shop-btn.buy{border-color:var(--crystal);color:#e9b6ff;
  background:linear-gradient(180deg,#3a1a4d,#1b0d25)}
.shop-btn.buy:hover{color:#fff;border-color:#e9b6ff;
  background:linear-gradient(180deg,#7a2fb0,#43176a);
  box-shadow:inset 0 1px 0 rgba(255,225,255,.25),0 0 11px rgba(196,75,255,.45)}
.shop-btn.gold{border-color:var(--gold-2);color:var(--gold);
  background:linear-gradient(180deg,#4a3413,#241803)}
.shop-btn.gold:hover{color:#fff6d0;border-color:var(--gold);
  background:linear-gradient(180deg,#8a6420,#4a3413);
  box-shadow:inset 0 1px 0 rgba(255,240,190,.3),0 0 11px rgba(255,217,112,.4)}
.shop-btn.poor{color:var(--dim);opacity:.5;cursor:not-allowed;
  background:linear-gradient(180deg,var(--wood-2),var(--wood-1));box-shadow:none}
.shop-btn.poor:hover{box-shadow:none;background:linear-gradient(180deg,var(--wood-2),var(--wood-1))}
.shop-btn.own{border-color:var(--arc);color:var(--arc);
  background:linear-gradient(180deg,#0e2c36,#06161c)}
.shop-btn.own:hover{color:#001b22;background:linear-gradient(180deg,#7fe9ff,#2aa8c8);
  box-shadow:0 0 11px rgba(74,223,255,.45)}
.shop-btn.eq{border-color:var(--gold);color:#fff3c4;cursor:default;
  background:linear-gradient(180deg,#7a5a1e,#4a3413);
  box-shadow:inset 0 1px 0 rgba(255,240,190,.35),0 0 9px rgba(255,217,112,.25)}
.shop-btn.eq:active{transform:none}
.shop-btn.sprite{background:none;border:none;box-shadow:none;padding:0;display:flex;justify-content:center}
.shop-btn.sprite img{height:22px;width:auto;display:block}
.shop-btn.own.sprite:hover{background:none;box-shadow:none}
.shop-btn.own.sprite:hover img{filter:brightness(1.15) drop-shadow(0 0 5px rgba(74,223,255,.5))}

/* shop 3D preview: canvas + details side by side, never clipped */
.pv-pop{
  position:fixed; z-index:400; display:flex; gap:10px; align-items:stretch;
  width:372px; padding:8px; border-radius:12px; pointer-events:none;
  background:linear-gradient(160deg, rgba(40,44,66,.97), rgba(10,11,18,.98));
  border:1.5px solid var(--brass); box-shadow:0 14px 40px rgba(0,0,0,.75);
}
.pv-pop canvas{
  width:180px; height:180px; flex:0 0 180px; border-radius:9px;
  background:radial-gradient(circle at 50% 40%, rgba(30,34,56,.9), rgba(6,7,12,.95));
  border:1px solid var(--wood-4);
}
.pv-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:5px;padding:4px 2px}
.pv-name{font-weight:800;font-size:.95rem;color:var(--t-name)}
.pv-cat{font-size:.62rem;letter-spacing:.12em;color:var(--dim);text-transform:uppercase}
.pv-desc{font-size:.74rem;line-height:1.45;color:var(--t-str);font-style:italic}
.pv-cost{margin-top:auto;font-size:.8rem;font-weight:700}

/* ===== MENU BOXES — shared by SETTINGS (incl. Profile) and the GAME tab ===== */
.menu-wrap{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:7px}
.menu-box{padding:9px;border-radius:6px;
  background:linear-gradient(170deg,var(--wood-2),var(--wood-1));border:1px solid var(--brass)}
.menu-btn-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px}
.menu-note{font-size:.73rem;color:var(--dim);line-height:1.55}
.menu-note b{color:var(--t-name)}
.menu-note kbd{background:var(--wood-3);border:1px solid var(--brass);border-bottom-width:2px;
  border-radius:3px;padding:0 4px;font-family:monospace;font-size:.7rem;color:var(--gold)}
.menu-note-acc{text-align:center}
/* rows are text + control and nothing more, so SETTINGS always fits its panel */
.setting-row{display:flex;justify-content:space-between;align-items:center;gap:6px;padding:2px 0;
  font-size:.68rem;border-bottom:1px solid rgba(138,106,53,.18);cursor:pointer}
.setting-row:last-child{border-bottom:none}
.setting-row input[type=checkbox]{width:16px;height:16px;accent-color:var(--gold-2);cursor:pointer;flex-shrink:0}
.setting-row input[type=range]{width:100px;accent-color:var(--gold-2)}
.setting-row select{background:#0a0603;color:var(--text);border:1px solid var(--brass);border-radius:4px;
  padding:3px 6px;font-family:var(--font);font-size:.72rem}
.menu-txt-btn{padding:7px 14px;font-size:.68rem;letter-spacing:2px;border-radius:5px;
  color:var(--gold);background:linear-gradient(170deg,var(--wood-3),var(--wood-1));
  border:1px solid var(--brass)}
.menu-txt-btn:hover{border-color:var(--gold-2);background:var(--wood-4)}
.menu-txt-btn.active{border-color:var(--gold);background:#5b421f}
.menu-txt-btn.sprite{background:none;border:none;box-shadow:none;padding:0;height:34px}
.menu-txt-btn.sprite img{height:100%;width:auto;display:block}
.menu-txt-btn.sprite:hover{filter:brightness(1.12)}
.menu-txt-btn.sprite.menu-del{height:24px;opacity:.85}
.menu-txt-btn.sprite.menu-del img{filter:drop-shadow(0 0 4px rgba(224,47,75,.45))}
.menu-txt-btn.sprite.menu-del:hover{opacity:1;filter:none}
.about-legal{display:flex;gap:10px;justify-content:center;margin-top:10px}
.about-legal .menu-txt-btn.sprite{height:38px}
.dev-btn{padding:5px 9px;font-size:.66rem;letter-spacing:1px;border-radius:5px;
  background:linear-gradient(170deg,var(--wood-3),var(--wood-1));color:var(--gold);
  border:1px solid var(--brass)}
.dev-btn:hover{background:var(--wood-4);color:var(--gold);border-color:var(--gold-2)}

/* SETTINGS: 7 category plaques in a tight 4-wide grid */
.set-cats{display:grid;grid-template-columns:repeat(4,1fr);gap:3px;margin-bottom:6px}
.set-cats .filter-btn{width:100%;height:30px;font-size:.62rem}
.set-cats .filter-btn.sprite img{width:100%;height:100%;object-fit:contain;margin:0 auto}
/* squeeze the SETTINGS tab so it fits the panel without scrolling */
#panel-content:has(.set-cats) .menu-box{padding:3px 8px}
#panel-content:has(.set-cats) .setting-row{padding:1px 0}
#panel-content:has(.set-cats) .menu-note{font-size:.64rem;line-height:1.5}

/* ===== CHOOSE-MODE SCREEN — the one step between the menu and playing =====
   Five plaques in one column, all the standard size, and NOTHING scrolls: the
   whole point of the screen is that you can see every option at once. If a
   viewport is too short for five rows the media queries shrink --plaque-h. */
/* gap:0 — this screen sets the spacing BETWEEN its three groups itself, so the
   five plaques can sit tight without the box's uniform gap prising them apart */
#overlay.modes .ov-box{gap:0}
#overlay.modes .ov-title{margin-bottom:10px}
/* RESUME: FULL SIZE, like every other plaque in the game (Mikey, v0.62) — it
   was briefly shrunk to read as secondary, and matching sizes matters more.
   No --plaque-h override here; that is the whole point. Air underneath keeps
   it from reading as a sixth mode. */
.mode-resume{margin-bottom:16px}
/* the five, as one block */
.mode-list{display:flex;flex-direction:column;align-items:center;gap:4px}
.mode-row{display:flex;flex-direction:column;align-items:center}
.ov-foot{flex:0 0 auto;display:flex;justify-content:center;gap:12px;margin-top:4px}
/* BACK, pushed clear of the block so it is never mis-tapped */
#overlay.modes .ov-foot{margin-top:22px}

/* ENDLESS arena picker — real snapshot thumbnails, four across */
.arena-pick{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;
  width:min(430px,92vw);max-height:52vh;overflow-y:auto;padding:2px}
.arena-cell{display:flex;flex-direction:column;gap:3px;padding:3px;cursor:pointer;
  background:linear-gradient(170deg,var(--wood-2),var(--wood-1));
  border:1px solid var(--brass);border-radius:var(--radius);transition:.12s}
.arena-cell:hover{border-color:var(--brass-lit);transform:translateY(-2px)}
.arena-cell.active{border-color:var(--gold);box-shadow:0 0 11px rgba(255,217,112,.3)}
.arena-cell .arena-thumb{width:100%;height:52px;margin:0;border-radius:2px;border:1px solid var(--wood-4);
  background:#100a08}
.arena-nm{font-size:.54rem;letter-spacing:.4px;color:var(--t-name);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media (max-width:520px){ .arena-pick{grid-template-columns:repeat(3,1fr)} }
.idle-live{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:4px;margin-top:6px}
.idle-stat{display:flex;flex-direction:column;gap:2px;padding:5px 8px;border-radius:8px;
  background:rgba(0,0,0,.28);border:1px solid var(--wood-4)}
.idle-stat span{font-size:calc(.62rem * var(--ui-scale));color:var(--dim);letter-spacing:.08em}
.idle-stat b{font-size:calc(.85rem * var(--ui-scale))}
.idle-row{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:7px}
.idle-row .idle-h{font-size:.62rem;letter-spacing:2px;color:var(--gold);flex:0 0 auto;min-width:52px}
.idle-row .filter-btn{height:26px;min-width:26px}
.idle-row input{width:4.2em;padding:.2em}

/* ===== HIGH SCORES ===== */
.hs-table{display:flex;flex-direction:column;gap:1px}
.hs-row{display:grid;grid-template-columns:22px 1fr 46px 54px;gap:4px;font-size:.7rem;padding:3px 5px;border-radius:3px}
.hs-row:nth-child(even){background:rgba(138,106,53,.10)}
.hs-head{color:var(--gold);letter-spacing:1px;font-size:.64rem}
.hs-row i{color:var(--dim);font-size:.62rem}
/* No inner scroller: #panel-content (tab) and .hs-modal-body (modal) already
   scroll, and a nested one gives the board two scrollbars and breaks the
   sticky "you" row. */
.hs-wrap{max-height:none;overflow:visible}
.hs-you{background:linear-gradient(90deg,rgba(255,217,112,.22),rgba(255,217,112,.08));
  border:1px solid var(--gold-2);border-radius:4px;color:var(--gold);font-weight:bold;
  position:sticky;top:0;z-index:1}
.hs-you-inline{color:var(--gold)}
.hs-modal-body{max-height:56vh;overflow:auto;text-align:left;margin-top:6px}
.hs-login.sprite-btn{margin:8px auto 0}
.hs-skills{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;margin-top:7px}
.hs-sk{display:flex;flex-direction:column;align-items:center;gap:1px;padding:4px 2px;
  background:rgba(0,0,0,.3);border-radius:7px}
.hs-sk img{width:18px;height:18px;object-fit:contain}
.hs-sk b{font-size:.78rem;color:var(--t-num);line-height:1.1}
.hs-sk span{font-size:.52rem;color:var(--dim)}
.hs-sk i{font-size:.54rem;font-style:normal;color:var(--gold)}

/* Hover detail card — the game's ONLY explanatory surface. Label left, value
   right, a short italic note at the bottom. Same shape everywhere so a player
   learns to read one thing, not nine. */
.hv{min-width:172px}
.hv-head{font-size:.72rem;letter-spacing:2px;text-transform:uppercase;color:var(--gold);
  margin-bottom:4px;padding-bottom:3px;border-bottom:1px solid rgba(138,106,53,.45)}
.hv-row{display:flex;justify-content:space-between;align-items:baseline;gap:12px;
  font-size:.68rem;line-height:1.6}
.hv-row span{color:var(--dim)}
.hv-row b{color:var(--text);white-space:nowrap}
.hv-sep{height:1px;margin:4px 0;background:linear-gradient(90deg,transparent,rgba(138,106,53,.6),transparent)}
.hv-note{margin-top:5px;padding-top:4px;border-top:1px solid rgba(138,106,53,.28);
  font-size:.64rem;line-height:1.5;color:var(--t-str);font-style:italic}
/* clearing / holding, said with a dot instead of a word */
.idle-dot{display:inline-block;width:5px;height:5px;margin-left:4px;vertical-align:middle;
  border-radius:50%;box-shadow:0 0 5px currentColor}

/* ===== TOOLTIP ===== */
.tooltip{position:fixed;z-index:70;width:270px;max-width:90vw;padding:9px 11px;pointer-events:none;
  border-radius:6px;font-size:.74rem;
  background:linear-gradient(180deg,rgba(43,31,19,.98),rgba(10,6,3,.99));
  border:1px solid var(--brass);box-shadow:0 12px 34px rgba(0,0,0,.85),0 0 0 1px #000;
  animation:tipIn .11s ease}
@keyframes tipIn{from{opacity:0;transform:translateY(3px)}}
#tip-cast{display:block;width:100%;height:auto;margin-top:6px;border-radius:6px;
  background:radial-gradient(ellipse at center, rgba(30,26,40,.65), rgba(5,4,8,.9));
  border:1px solid rgba(201,162,39,.25)}
.tip-head{font-size:.85rem;font-weight:bold;margin-bottom:2px;color:var(--t-name)}
.tip-lv{font-size:.65rem;color:var(--t-num);font-weight:normal}
.tip-flavor{font-style:italic;color:var(--t-str);font-size:.7rem;margin-bottom:3px}
.tip-desc{color:var(--text);line-height:1.4}
.tip-sep{height:1px;background:linear-gradient(90deg,transparent,var(--brass),transparent);margin:5px 0}
.tip-row{display:flex;justify-content:space-between;gap:10px;padding:1px 0}
.tip-row > span{color:var(--dim);flex-shrink:0}
.tip-row > b{color:var(--t-num);text-align:right;font-weight:bold}
.tip-row.v > b{color:var(--t-var)}
.tip-row.t > b{color:var(--t-type)}
.tip-key{color:var(--t-key);font-weight:bold}

/* ===== MODAL — replaces every native confirm(). Stacks above #auth (100). ===== */
/* Opaque veil, no backdrop-filter: the 3D canvas is live underneath. */
#modal{position:fixed;inset:0;z-index:110;display:none;align-items:center;justify-content:center;
  padding:16px;background:rgba(5,3,1,.85)}
#modal.open{display:flex}
/* Every popup floats bare over the veil: title, text, buttons. Readability
   comes from text-shadow, not a card. */
.modal-card{width:min(400px,94vw);padding:18px;text-align:center;border-radius:10px;
  background:none !important;border:none !important;box-shadow:none !important;
  animation:modalIn .3s cubic-bezier(.2,.9,.3,1.2)}
@keyframes modalIn{from{opacity:0;transform:scale(.88) translateY(18px)}}
.modal-card .modal-sub,.modal-card .modal-title{text-shadow:0 2px 8px #000,0 0 18px rgba(0,0,0,.9)}
.modal-title{font-size:1.05rem;letter-spacing:2px;font-weight:bold;color:var(--gold)}
.modal-sub{font-size:.75rem;color:var(--t-str);font-style:italic;margin:5px 0 12px}
.modal-btns{display:flex;gap:16px;justify-content:center;flex-wrap:wrap;margin-top:10px}
.mbtn{padding:8px 16px;font-size:.78rem;font-weight:bold;letter-spacing:1px;border-radius:6px;
  border:1px solid var(--brass);background:linear-gradient(180deg,var(--wood-3),var(--wood-1));color:var(--text);transition:.12s}
.mbtn:hover{border-color:var(--gold-2);color:var(--gold);transform:translateY(-1px)}
.mbtn.danger:hover{border-color:var(--danger);color:var(--danger)}
.mbtn.primary{border-color:var(--gold-2);color:var(--gold);background:linear-gradient(180deg,#5b421f,#2f2211)}
/* 55px is exactly half the 110px source art — a clean 2:1 downscale */
.mbtn.sprite{background:none;border:none;box-shadow:none;padding:0;width:132px;height:55px}
.mbtn.sprite img{width:100%;height:100%;object-fit:contain;display:block}
.mbtn.sprite:hover{filter:brightness(1.08);transform:translateY(-1px)}
.modal-card.hs-modal{width:min(480px,94vw);background:none;border:none;box-shadow:none;
  animation:ovIn .28s ease}
.hs-modal .modal-title{text-shadow:0 2px 10px #000}
.modal-card.wywg{width:min(300px,86vw);background:none;border:none;box-shadow:none}
.wywg .modal-title{text-shadow:0 2px 10px #000}
.wywg-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:10px 0}
.wywg-cell{padding:8px;text-align:center;border:none;border-radius:10px;
  background:rgba(0,0,0,.35);backdrop-filter:blur(3px)}
.wywg-cell span{display:block;font-size:calc(.6rem * var(--ui-scale));color:var(--dim);letter-spacing:.1em}
.wywg-cell b{font-size:calc(1rem * var(--ui-scale));color:var(--t-num)}
.empty-msg{color:var(--dim);text-align:center;padding:26px 0;font-style:italic;font-size:.8rem}

/* ===== OVERLAY SCREENS — landing, main menu, pause, run end ===== */
#overlay{position:fixed;inset:0;z-index:95;display:none;align-items:center;justify-content:center;
  padding:20px;pointer-events:none}
#overlay.open{display:flex}
#overlay::before{content:'';position:absolute;inset:0;pointer-events:auto;
  background:radial-gradient(ellipse at center, rgba(6,7,14,.42) 0%, rgba(6,7,14,.72) 100%)}
/* main menu: lighter veil so the panning arena reads through */
#overlay.main::before{background:radial-gradient(ellipse at center, rgba(6,7,14,.2) 0%, rgba(6,7,14,.5) 100%)}

.ov-box{position:relative;pointer-events:auto;z-index:1;
  display:flex;flex-direction:column;align-items:center;gap:14px;
  max-width:min(440px,92vw);max-height:100%;text-align:center;
  animation:ovIn .28s cubic-bezier(.2,.9,.3,1.2)}
@keyframes ovIn{from{opacity:0;transform:translateY(14px) scale(.96)}to{opacity:1;transform:none}}

/* aspect-ratio reserves the box before logo.webp (480x315) decodes — without
   it the whole column collapses to zero height and jumps on every menu open. */
.ov-logo{width:min(150px,40vw);aspect-ratio:480/315;height:auto;
  filter:drop-shadow(0 3px 10px rgba(0,0,0,.7))}
.ov-title{font-size:1.5rem;letter-spacing:3px;color:var(--gold);
  text-shadow:0 2px 14px rgba(0,0,0,.7)}
#overlay.lose .ov-title{color:#e5533d}
#overlay.win .ov-title{color:#ffd970}
#overlay.main .ov-title{font-size:.86rem;letter-spacing:4px;text-transform:uppercase;
  color:var(--gold);opacity:.92;text-shadow:0 2px 8px #000}
.ov-stats{display:flex;flex-wrap:wrap;justify-content:center;gap:8px 18px;
  padding:10px 16px;border-radius:12px;background:rgba(0,0,0,.35);backdrop-filter:blur(3px)}
.ov-stats > div{display:flex;flex-direction:column;min-width:56px}
.ov-stats span{font-size:.6rem;letter-spacing:1px;color:var(--dim)}
.ov-stats b{font-size:1.05rem;color:#f0e6cf}
.ov-stats .ov-crystal b{color:var(--crystal)}

.ov-btns{display:grid;grid-template-columns:1fr;justify-items:center;gap:6px;margin-top:2px;
  transition:opacity .3s ease, transform .3s ease}

/* ===== THE PLAQUE — the ONLY sprite-button rule in the file =====
   Every plaque in the game is exactly --plaque-w x --plaque-h. There are no
   per-screen size overrides anywhere, on purpose: the art is cut to one
   aspect, so one rule keeps the menu, the pause screen, the mode picker, the
   run-end card and the login card visually identical. If a new screen needs a
   different size, change --plaque-h on that screen's container, never here. */
.sprite-btn{display:flex;align-items:center;justify-content:center;
  width:var(--plaque-w);height:var(--plaque-h);flex:0 0 auto;
  background:none;border:none;cursor:pointer;padding:0;
  transition:transform .12s}
.sprite-btn img{width:100%;height:100%;object-fit:contain;display:block;
  filter:drop-shadow(0 2px 5px rgba(0,0,0,.5));transition:filter .12s}
/* hover is a quiet lift, not a flare */
.sprite-btn:hover{transform:translateY(-2px) scale(1.02)}
.sprite-btn:hover img{filter:drop-shadow(0 2px 5px rgba(255,217,112,.12)) brightness(1.035)}
.sprite-btn:active{transform:translateY(-1px) scale(1.0)}

/* Animations switch — main menu only. NO PLATE AROUND IT: a bordered pill on
   the title screen read as a second, competing button next to the plaques
   (Mikey, v0.61). The tick box is the only chrome; the word is bare type. */
.bg-anim{display:inline-flex;align-items:center;gap:7px;margin-top:8px;padding:2px 4px;
  background:none;border:none;border-radius:0;
  cursor:pointer;pointer-events:auto;color:#d9c89f;
  font:inherit;font-size:.62rem;letter-spacing:1.4px;text-transform:uppercase;
  text-shadow:1px 1px 0 rgba(0,0,0,.95);
  transition:color .18s}
.bg-anim:hover{color:var(--gold)}
.bg-anim .bg-tick{width:12px;height:12px;flex:0 0 auto;border-radius:0;
  border:1px solid var(--brass);background:rgba(0,0,0,.55);
  display:flex;align-items:center;justify-content:center;
  font-size:.6rem;line-height:1;color:var(--gold)}
.bg-anim:hover .bg-tick{border-color:var(--gold-2)}
.bg-anim:not(.off) .bg-tick{background:var(--gold);color:#241503}

/* The build number, printed under the title-screen plaques so it can be read
   off the screen to confirm which version actually loaded. #build-badge stays
   the single source; this only displays it. */
.ov-version{margin-top:5px;font-size:.6rem;letter-spacing:2px;color:var(--dim);
  text-shadow:1px 1px 0 rgba(0,0,0,.95)}

/* run end: 2x2 stats, Restart stacked on Home. */
#overlay.runend .ov-stats{display:grid;grid-template-columns:repeat(2,minmax(96px,auto));
  gap:5px 14px;padding:7px 11px;justify-content:center}
#overlay.runend .ov-stats > div{align-items:center;text-align:center}
#overlay.runend .ov-stats span{font-size:.55rem}
#overlay.runend .ov-stats b{font-size:.9rem}

/* while a big menu is open the whole game HUD disappears */
body.menu-open #hud,
body.menu-open #dock,
body.menu-open #wave-countdown,
body.menu-open #wave-announce,
body.menu-open #toasts,
body.menu-open #levelup{display:none !important}

/* ===== DEV / VERSION ===== */
/* #build-badge is the single source of the version string (save.js parses it
   for the ?v= cache-buster). It stays in the DOM but is never drawn — the
   menus print the version themselves. */
#build-badge{display:none}
#perfhud{position:fixed;top:8px;left:8px;z-index:500;pointer-events:none;
  font:600 11px/1.5 Consolas,Menlo,monospace;color:#9fe8a0;text-align:left;
  background:rgba(6,8,4,.78);border:1px solid rgba(120,200,90,.4);border-radius:6px;
  padding:6px 9px;text-shadow:0 1px 2px #000;white-space:nowrap}
#perfhud b{color:#d6ffb8;font-size:12px}

/* ===== MEDIA QUERIES — the only ones in the file, in cascade order ===== */

@media (min-width:761px){
  #dock{max-width:474px}
}

@media (max-width:760px){
  html,body{font-size:calc(14px * var(--ui-scale))}
  #dock{max-height:70vh}
  #hud-name{font-size:.68rem}
  #hud-hp{height:14px}
  #hud-shield{width:clamp(70px,26vw,130px);height:6px}
  .wave-name{font-size:1.15rem}
  .ach-list{grid-template-columns:repeat(3,1fr)}
  .shop-grid{grid-template-columns:repeat(auto-fill,minmax(86px,1fr))}
  .tooltip{width:240px}
  .filter-btn,.shop-btn{min-height:30px}
  .tab-btn.tab-icon{height:calc(40px * var(--ui-scale))}
  /* tap-to-preview replaces hover on touch, so the popup stays available */
  .pv-pop{display:flex;width:min(372px, calc(100vw - 16px))}
  .pv-pop canvas{flex:0 0 140px;width:140px;height:140px}
}

/* Touch / compact: fixed device-fitted dock, taller panel, every control
   trimmed until the whole HUD fits a 360px phone. */
@media (hover:none), (max-width:760px){
  #panel{height:clamp(176px, 42vh, 228px); max-height:clamp(176px, 42vh, 228px)}
  #dock{left:50%; transform:translateX(-50%); width:calc(100vw - 8px)}
  #tabbar{touch-action:manipulation}
  /* resize handles kept catching stray fingers */
  #hud{flex-wrap:wrap; gap:2px; padding:3px 5px; max-width:calc(100vw - 10px)}
  #hud .grip{display:none}
  #hud-logo{height:17px}
  #hud-name{max-width:72px}
  #hud-hp{width:clamp(58px,19vw,96px)}
  .hud-pill{padding:2px 4px; gap:2px; font-size:.62rem}
  /* 40px minimum tap height — the sprite plaques measured 17px tall */
  #speed-ctl{gap:6px}
  #speed-ctl button{min-height:40px; padding:0 6px}
  #speed-ctl button img{height:15px}
  #btn-skip img{height:16px}
  /* a wrapped HUD is up to two rows tall, so the bands below it move down */
  #wave-countdown{top:calc(88px + env(safe-area-inset-top))}
  #toasts{top:calc(124px + env(safe-area-inset-top))}
  #levelup{top:calc(186px + env(safe-area-inset-top))}

  /* skills: tighter cards, same 4x4 count */
  .skill-grid{gap:3px}
  .skill-card{padding:4px 6px 8px; min-height:32px; gap:5px}
  .skill-card img{width:18px; height:18px}
  .sk-name{font-size:.56rem}
  .sk-lv{font-size:.66rem; padding:1px 5px}
  .sb-toggle{padding:4px 8px; font-size:.6rem}

  /* idle sanctum shares the UPGRADES panel — must fit, never clip */
  .menu-wrap{gap:4px}
  .idle-live{grid-template-columns:repeat(4,minmax(0,1fr)); gap:3px; margin-top:0}
  .idle-stat{padding:2px 4px}
  .idle-stat span{font-size:.5rem}
  .idle-stat b{font-size:.62rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
  .idle-row{margin-top:3px; gap:4px}
  .idle-row .idle-h{min-width:38px; font-size:.54rem}
  .idle-row .filter-btn{height:21px; min-width:21px; font-size:.54rem; padding:0 5px}
  .idle-row input{width:3.4em; padding:.1em; font-size:.66rem}
  /* five tabs stay big on a phone; the strip is the primary navigation */
  .tab-btn.tab-icon{height:calc(54px * var(--ui-scale))}
  .tab-btn.tab-icon img{max-height:calc(42px * var(--ui-scale))}
  .mode-list{width:min(280px,86vw)}
  /* the 11-arena picker is one row you swipe, not three rows that push the
     idle block off the panel */
  .idle-arenas{flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch}
  .idle-arenas::-webkit-scrollbar{display:none}
  .idle-arenas .filter-btn{flex-shrink:0; white-space:nowrap}
}

@media (hover:none){
  .spell-card:hover,.skill-card:hover,.shop-card:hover,.ach-row:hover,.tab-btn:hover img{transform:none}
}

@media (max-width:520px){
  /* one knob resizes every plaque on the screen */
  :root{--plaque-h:38px}
  .ov-title{font-size:1.2rem}
  .ov-logo{width:min(128px,36vw)}
}

/* Short viewports (landscape phones): a 6-row menu plus a logo does not fit
   390px of height, and MAIN MENU was rendering off the bottom edge. Shrink
   first; .ov-box scrolls only as an unreachable-content backstop. */
@media (prefers-reduced-motion:reduce){
  .sw.rainbow{animation:none}
  .wave-name{animation:none}
  .boss-tag{animation:none}
}

/* SHORT VIEWPORTS (heavy ctrl+ zoom, landscape phones): the logo goes first —
   the plaques are what the screen is for — then the plaques themselves shrink.
   One variable, so nothing can drift out of step with anything else. */
@media (max-height:520px){
  :root{--plaque-h:36px}
  #overlay{padding:8px}
  .ov-box{gap:6px; max-height:calc(100vh - 16px); overflow-y:auto; overscroll-behavior:contain}
  #overlay .ov-logo{display:none}
  .ov-title{font-size:1rem}
  .ov-stats{padding:6px 10px; gap:4px 12px}
  .mode-list{gap:4px}
  .ov-foot{margin-top:4px;gap:10px}
}
@media (max-height:380px){
  :root{--plaque-h:30px}
}
