/* ============================================================
   TD IDLE / RuneTD — tdidle.com
   Theme: aged oak, forged brass, rune-gold. Compact. Mobile-first.
   ------------------------------------------------------------
   LAYOUT CONTRACT (edit here, nowhere else):
     --ui-scale      global UI size knob (0.8 .. 1.3)
     --panel-alpha   Menu Transparency (Settings → Interface) — see v0.28 block
   Panel height: desktop min(34vh,196px) on #panel; mobile/touch
   clamp(176px,42vh,228px) in the v0.30/v0.33 media blocks. Tab-icon size is
   the v10 .tab-btn.tab-icon block. RULE: game/skills/settings tabs NEVER
   scroll on any device — content must fit the panel; only upgrades/shop/
   achievements (and 20+-card browsers) may scroll.
   ============================================================ */
:root{
  /* ---- scale knobs ---- */
  --ui-scale: 1;
  --radius: 8px;

  /* ---- WOOD / BROWN ---- */
  --wood-0:#120c07;   /* near-black bark        */
  --wood-1:#1e150d;   /* panel base             */
  --wood-2:#2b1f13;   /* card base              */
  --wood-3:#3a2a19;   /* raised surface         */
  --wood-4:#4d3823;   /* hover surface          */

  /* ---- BRASS / GOLD ---- */
  --brass:#8a6a35;    /* border default         */
  --brass-lit:#b98f45;/* border hover           */
  --gold:#ffd970;     /* primary accent text    */
  --gold-2:#c9a227;   /* accent border          */
  --gold-dim:#8f7328;

  /* ---- SEMANTIC TEXT COLORS (syntax-highlight style) ---- */
  --text:#ecdcc0;     /* body copy — parchment  */
  --dim:#9d8b70;      /* muted labels           */
  --t-name:#ffe9a8;   /* proper nouns / titles  */
  --t-type:#7fd4ff;   /* "type" strings (cyan)  */
  --t-num:#ffb347;    /* numbers / values       */
  --t-var:#c9a0ff;    /* variables / stats      */
  --t-str:#a3e07a;    /* flavor / strings       */
  --t-key:#ff9f6b;    /* keywords (BUFF, MAX)   */

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

  --font: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}
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;
  /* app-shell feel: nothing selectable, no iOS long-press callouts — typing
     fields opt back in below (main.js blocks the events belt-and-braces) */
  user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
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 (kills drag/save quirks on sprites) */
button img,a img{pointer-events:none}
.hidden{display:none!important}
::selection{background:var(--gold-2);color:#000}

/* ---------- 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);
}

#scene{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none}

/* ============================================================
   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}
/* v0.46 — the logo was 360px wide with a 28px gold bloom and a 5s float. Mikey:
   "way too big and it glows way too much". Half the size, a shadow you read as
   depth rather than glow, and it holds still. */
/* height:auto is LOAD-BEARING. index.html carries width="480" height="315" so
   the browser can reserve the box before decode; setting only `width` in CSS
   leaves that 315px height applied and the logo renders 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)}

/* gold click sparkle on the main-menu (auth) screen */
.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}
}
.auth-box{display:flex;flex-direction:column;gap:10px;width:min(300px,88vw);padding:12px;border-radius:var(--radius)}
/* The guest plaque is a peer of the sign-in routes, not an afterthought —
   same width, centred, with one clear break above it. */
.auth-guest{display:flex;justify-content:center;margin-top:2px}
.auth-guest .sprite-btn img{max-width:150px;height:auto}
.auth-box input{background:#0d0906;color:var(--text);border:1px solid var(--brass);border-radius:6px;
  padding:7px 10px;font-size:16px;font-family:var(--font);outline:none;
  align-self:center;width:min(240px,100%)}   /* 16px stays — iOS zooms smaller fonts */
.auth-box input:focus{border-color:var(--gold-2);box-shadow:0 0 0 2px rgba(201,162,39,.22)}
/* Collapses to nothing when there is no message, so the card does not carry a
   permanent 15px gap between the sign-in routes and the guest plaque. */
#auth-err{color:var(--danger);font-size:.82rem;text-align:center;line-height:1.35}
#auth-err:empty{display:none}

/* ---- the three sign-in routes: Google / Apple / Email ----
   All three are the same plaque so the card reads as one choice of three,
   not one real option plus some fallbacks. The email TEXT FIELD lives behind
   its button (#auth-email-form) and only exists once that route is picked. */
#g-btn-host{display:flex;justify-content:center;min-height:0}
#g-btn-host:empty{display:none}
.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}
.apple-btn{background:linear-gradient(180deg,#2c2c2e,#141416);color:#f2f2f4;border-color:#3a3a3c}
.email-btn{background:linear-gradient(180deg,#f0e6cf,#d9c89f);color:#2b1f13}
#auth-email-form{display:flex;flex-direction:column;gap:8px}
/* `hidden` is a UA-stylesheet rule on the ATTRIBUTE, so any class that sets
   display beats it — .g-btn{display:flex} left the hidden Apple/Email buttons
   fully visible. These put the attribute back in charge. */
.g-btn[hidden],#auth-email-form[hidden]{display:none}
.auth-back{background:none;border:none;color:var(--dim);font-size:.74rem;letter-spacing:.4px;
  padding:2px;cursor:pointer;transition:.13s}
.auth-back:hover{color:var(--gold)}

/* ---- auth chevron / hiscore drawer ---- */
#auth-chev{background:none;border:none;color:var(--gold);font-size:.78rem;letter-spacing:2px;
  display:flex;flex-direction:column;align-items:center;gap:1px;padding:4px 14px}
#auth-chev .cv{font-size:1.1rem;transition:transform .25s}
#auth-chev.open .cv{transform:rotate(180deg)}
#auth-drawer{width:min(330px,88vw);max-height:0;overflow:hidden;transition:max-height .3s ease;border-radius:var(--radius)}
#auth-drawer.open{max-height:44vh;overflow-y:auto}
.drawer-inner{padding:10px 12px}

/* ============================================================
   SPRITE BUTTONS
   ============================================================ */

/* ============================================================
   TOP HUD — one movable pod
   ============================================================ */
/* HUD sized ~30% down from the original (Mikey: top bar smaller by default) */
#hud{
  position:fixed;top:6px;left:50%;transform:translateX(-50%);z-index:26;
  display:flex;align-items:center;gap:4px;padding:3px 6px;border-radius:99px;
  cursor:grab;user-select:none;touch-action:none;max-width:96vw;
}
#hud.dragging{cursor:grabbing;filter:brightness(1.1)}
#hud .grip{color:var(--brass-lit);font-size:.58rem;letter-spacing:-2px;padding:0 2px;opacity:.6}
.hud-pill{display:flex;align-items:center;gap:4px;padding:3px 7px;font-size:.62rem;font-weight:bold;
  background:rgba(10,6,3,.55);border:1px solid var(--brass);border-radius:99px;white-space:nowrap}
.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;
  overflow:hidden;text-overflow:ellipsis}
#hud-hp{position:relative;width:clamp(68px,15vw,135px);height:12px;background:#0a0603;
  border:1px solid var(--brass);border-radius:99px;overflow:hidden;box-shadow:inset 0 2px 5px rgba(0,0,0,.8)}
#hud-hp-fill{position:absolute;inset:0;width:100%;transition:width .25s;border-radius:99px}
#hud-hp-text{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  font-size:.52rem;font-weight:bold;color:#fff;text-shadow:0 1px 2px #000}
#hud-logo{height:19px;filter:drop-shadow(0 2px 5px #000)}

/* ============================================================
   WAVE BANNER / COUNTDOWN
   ============================================================ */
#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:.8rem;letter-spacing:5px;color:var(--gold)}
.wave-name{font-size:1.7rem;font-weight:bold;text-shadow:0 3px 12px #000,0 0 22px currentColor;margin:3px 0}
.wave-desc{font-size:.8rem;color:var(--t-str);font-style:italic;text-shadow:0 2px 5px #000;max-width:480px;margin:0 auto}

#wave-countdown{position:fixed;top:52px;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 — borderless floating popups
   ============================================================ */
#toasts{position:fixed;left:50%;transform:translateX(-50%);z-index:40;
  display:flex;flex-direction:column-reverse;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)}

/* level-up splash */
#levelup{position:fixed;left:50%;top:34%;transform:translate(-50%,-50%);z-index:45;pointer-events:none;
  display:none;flex-direction:column;align-items:center;gap:4px}
#levelup.show{display:flex}   /* its animation is luInTop (top-anchored) below */
#levelup .lu-ico{width:70px;height:70px;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:.72rem;letter-spacing:5px;color:var(--gold);text-shadow:0 2px 6px #000}
#levelup .lu-n{font-size:1.5rem;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:120px;height:120px;border:2px 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
   ============================================================ */
#dock{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(8px + env(safe-area-inset-bottom));z-index:30;
  display:flex;flex-direction:column;align-items:stretch;
  width:min(560px, calc(100vw - 16px));pointer-events:none}
#dock > *{pointer-events:auto}
/* invisible RESIZE handles on the dock's edges/corners (see bindDockResize) */
.dock-rs{position:absolute;z-index:36;touch-action:none}
.dock-rs.rs-l{left:-6px;top:0;bottom:0;width:12px;cursor:ew-resize}
.dock-rs.rs-r{right:-6px;top:0;bottom:0;width:12px;cursor:ew-resize}
.dock-rs.rs-t{left:12px;right:12px;top:-6px;height:12px;cursor:ns-resize}
.dock-rs.rs-tl{left:-7px;top:-7px;width:16px;height:16px;cursor:nwse-resize}
.dock-rs.rs-tr{right:-7px;top:-7px;width:16px;height:16px;cursor:nesw-resize}
#tabbar{display:flex;justify-content:stretch;gap:2px;
  padding:4px 5px;border-radius:var(--radius) var(--radius) 0 0;
  background:linear-gradient(180deg,var(--wood-2),var(--wood-1));
  border:1.5px solid var(--brass);border-bottom:none;
  box-shadow:0 -4px 18px rgba(0,0,0,.45)}
.tab-btn{flex:1;min-width:0;padding:3px 1px;font-size:.52rem;letter-spacing:.5px;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);
  transition:all .12s;overflow:hidden}
.tab-btn img{height:calc(20px * 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))}

/* ============================================================
   PANEL — always docked at the bottom (no float, no resize, no detach)
   ============================================================ */
#panel{
  position:relative;z-index:25;
  /* ONE height for every tab, sized so the SKILLS grid (4 rows) fits EXACTLY —
     176px grid + 2×9px padding + 2px border. Taller tabs scroll inside
     #panel-content; the tab bar never jumps. The battlefield is the show. */
  height:min(34vh, 196px);
  max-height:min(34vh, 196px);
  display:none;flex-direction:column;border-radius:0 0 var(--radius) var(--radius);
  overflow:hidden;
}
#panel.open{display:flex}
/* tabs sit flush on top of the open panel; rounded when closed */
#dock:has(#panel.open) #tabbar{border-radius:var(--radius) var(--radius) 0 0}
#dock:not(:has(#panel.open)) #tabbar{border-radius:var(--radius);border-bottom:1.5px solid var(--brass)}

/* title bar hidden — clicking the tab already toggles the panel, so the
   repeated title + ✕ ("window within a window") is redundant. Kept in the DOM
   (just hidden) so the JS that still writes #panel-title / binds #panel-close
   never hits a null reference. Panel content now sits flush under the tabs. */
#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}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar{display:flex;flex-wrap:wrap;gap:3px;margin-bottom:8px}
.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)}
.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 — compact spell rows
   ============================================================ */
.spell-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(54px,1fr));gap:3px}
.spell-card{--el:#4adfff;--elglow:#7fd4ff;position:relative;padding:5px 6px;border-radius:6px;
  background:linear-gradient(160deg,var(--wood-2),var(--wood-1));
  border:1px solid var(--brass);border-left:3px solid var(--el);
  transition:.11s;overflow:hidden;display:flex;flex-direction:column;gap:4px}
.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.owned{background:linear-gradient(160deg,#3a2a19,var(--wood-1))}

.sc-icon{width:20px;height:20px;object-fit:contain;flex-shrink:0;filter:drop-shadow(0 2px 4px #000)}

.sc-name{font-size:.7rem;font-weight:bold;color:var(--elglow);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.15}

.sc-lv{font-size:.65rem;font-weight:bold;color:var(--t-num);background:rgba(0,0,0,.45);
  padding:1px 5px;border-radius:99px;border:1px solid var(--gold-dim);flex-shrink:0}

/* ============================================================
   SKILLS
   ============================================================ */
.skill-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:5px}
.skill-card{--el:#4adfff;padding:7px 5px;text-align:center;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(-2px);border-color:var(--el);
  box-shadow:0 5px 14px rgba(0,0,0,.5),0 0 12px color-mix(in srgb,var(--el) 30%,transparent)}
.skill-card img{width:30px;height:30px;object-fit:contain;filter:drop-shadow(0 2px 5px #000)}
.sk-name{font-size:.75rem;font-weight:bold;margin-top:2px}
.sk-lv{font-size:.68rem;color:var(--t-num);margin:1px 0 3px}
.sk-bar{height:5px;background:#0a0603;border-radius:99px;overflow:hidden;border:1px solid rgba(0,0,0,.7)}
.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)}

/* ============================================================
   ACHIEVEMENTS — dense chips
   ============================================================ */
/* 5-wide compact chips — name ellipsizes, the full story lives on hover */
.ach-list{display:grid;grid-template-columns:repeat(5,1fr);gap:3px}
@media (max-width:760px){ .ach-list{grid-template-columns:repeat(3,1fr)} }
.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)}
/* taller than the old 5px sliver so the unlocked count can 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
   ============================================================ */
/* Compact cards — normalised to the same density as the SKILLS grid so every
   tab reads the same. One card style covers every category (skins, auras,
   trails, titles, toppers, sounds, arenas). */
.shop-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:4px}
.shop-card{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)}
.sw.rainbow{background:conic-gradient(#ff4d3b,#ffd93b,#5fd44a,#4adfff,#c44bff,#ff4d3b);animation:swspin 4s linear infinite}
@keyframes swspin{to{filter:hue-rotate(360deg)}}
.shop-name{font-size:.64rem;font-weight:bold;color:var(--t-name);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.shop-btn{width:100%;margin-top:4px;padding:3px;font-size:.6rem;font-weight:bold;letter-spacing:.5px;
  border-radius:5px;border:1px solid var(--brass);background:var(--wood-3);color:var(--text);transition:.11s}
.shop-btn.buy{border-color:var(--crystal);color:var(--crystal)}
.shop-btn.buy:hover{background:var(--crystal);color:#fff;box-shadow:0 0 10px rgba(196,75,255,.4)}
.shop-btn.poor{color:var(--dim);opacity:.55;cursor:not-allowed}
.shop-btn.own{border-color:var(--arc);color:var(--arc)}
.shop-btn.own:hover{background:var(--arc);color:#000}
.shop-btn.eq{border-color:var(--gold-2);color:var(--gold);background:#5b421f;cursor:default}
/* EQUIP / EQUIPPED as wooden plaques — the plaque IS the button */
.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))}

/* ============================================================
   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-h{font-size:.7rem;letter-spacing:3px;color:var(--gold);margin-bottom:7px;
  border-bottom:1px solid var(--brass);padding-bottom:4px}
.menu-btn-row{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.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)}
/* v0.28: rows shrunk to the minimum — text + control, nothing more, so the
   SETTINGS tab always fits its panel with zero scrolling */
.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}
.dev-btn{padding:5px 9px;font-size:.66rem;letter-spacing:1px;border-radius:5px;
  background:#2a1633;color:var(--crystal);border:1px dashed var(--crystal)}
.dev-btn:hover{background:var(--crystal);color:#fff}
.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}

/* ============================================================
   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()
   ============================================================ */
#modal{position:fixed;inset:0;z-index:90;display:none;align-items:center;justify-content:center;padding:16px;
  background:rgba(5,3,1,.75);backdrop-filter:blur(3px)}
#modal.open{display:flex}
/* NO BACKGROUND BOXES — every popup floats bare over the dark page veil:
   just title, text and buttons. Readability comes from text-shadow, not a
   card. (The veil behind #modal already dims the scene.) */
.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)}

.empty-msg{color:var(--dim);text-align:center;padding:26px 0;font-style:italic;font-size:.8rem}

/* ============================================================
   MOBILE / TOUCH
   ============================================================ */
@media (hover:none){
  .spell-card:hover,.skill-card:hover,.shop-card:hover,.ach-row:hover,.tab-btn:hover img{transform:none}
  .tab-btn{padding:2px}
}
@media (max-width:760px){
  #dock{left:50%;transform:translateX(-50%);width:calc(100vw - 10px)}
  html,body{font-size:calc(14px * var(--ui-scale))}
  #hud{gap:4px;padding:4px 6px;top:5px}
  #hud-logo{display:none}
  #hud-name{max-width:96px;font-size:.68rem}
  .hud-pill{padding:3px 7px;font-size:.72rem}
  #hud-hp{width:clamp(70px,26vw,130px);height:14px}
  .wave-name{font-size:1.25rem}
  .spell-grid{grid-template-columns:repeat(auto-fill,minmax(104px,1fr))}
  .skill-grid{grid-template-columns:repeat(auto-fill,minmax(78px,1fr))}
  .shop-grid{grid-template-columns:repeat(auto-fill,minmax(86px,1fr))}
  .tooltip{width:240px}
  /* touch targets stay >=30px */
  .filter-btn,.shop-btn{min-height:30px}
  /* no floating window on phones — always docked */
}
@media (max-width:400px){
  .tab-btn{font-size:0}      /* icon-only on tiny screens */
  .tab-btn img{height:26px}
}

/* ============================================================
   v2 additions — speed controls, idle tab, boss rush, previews,
   offline report, square menu buttons, auth extras
   ============================================================ */

/* ---- top-right: speed + skip ---- */
#speed-ctl{
  display:flex; gap:5px; margin-left:4px;
}
#speed-ctl button{
  min-width:calc(1.6rem * var(--ui-scale)); height:calc(1.2rem * var(--ui-scale));
  padding:0 .3em; border-radius:6px; cursor:pointer;
  font:700 calc(.54rem * var(--ui-scale))/1 var(--font);
  color:var(--gold); letter-spacing:.03em;
  background:linear-gradient(180deg, var(--wood-3), var(--wood-4));
  border:1.5px solid var(--brass); box-shadow:0 1px 4px rgba(0,0,0,.4);
}
#speed-ctl button:hover{ filter:brightness(1.18); }
#btn-skip{ padding:0 4px; background:none !important; border:none !important; box-shadow:none !important; }
#btn-skip img{ height:calc(20px * var(--ui-scale)); display:block; filter:drop-shadow(0 2px 5px rgba(0,0,0,.6)); }
#speed-ctl button.active{
  color:#1a1206; background:linear-gradient(180deg, var(--gold), #c9992a);
  border-color:#ffe9a8; box-shadow:0 0 12px rgba(255,217,59,.4);
}

/* ---- menu buttons: compact squares ---- */
.menu-btn-row{ display:flex; flex-wrap:wrap; gap:8px; }

/* ---- idle tab ---- */
.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:7px 9px; 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)); }

/* ---- boss rush ---- */

/* ---- shop 3D preview: see .pv-pop below ---- */
.shop-card{ position:relative; }

/* ---- "while you were gone" ---- */
.wywg-grid{ display:grid; grid-template-columns:1fr 1fr; gap:7px; margin:10px 0; }
.wywg-cell{
  padding:9px; border-radius:9px; text-align:center;
  background:rgba(0,0,0,.3); border:1px solid var(--wood-4);
}
.wywg-cell span{ display:block; font-size:calc(.6rem * var(--ui-scale)); color:var(--dim); letter-spacing:.1em; }
.wywg-cell b{ font-size:calc(1.05rem * var(--ui-scale)); color:var(--t-num); }

/* ---- auth extras ---- */
/* guest entrance — tucked into the card's bottom-right corner */
.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 }
.auth-guest .sprite-btn{ height:38px; padding:2px }
.auth-guest .sprite-btn img{ height:100%; width:auto }
.auth-ver{ text-align:center; font-size:.66rem; letter-spacing:2px; color:#6b573a; margin-top:2px }
.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); }

@media (max-width:760px){
  #btn-speed{ min-width:2.1rem; height:1.55rem; font-size:.64rem; }
  
}

/* ---- v3: square-compact spell cards ---- */
.spell-card{padding:4px 5px}

/* ---- shop preview popup: 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}

/* ---- mana shield bar (under HP) ---- */
#hud-shield{
  position:relative;width:clamp(90px,20vw,190px);height:7px;margin-top:2px;
  background:#050a12;border:1px solid #2a4a6a;border-radius:99px;overflow:hidden;
}
#hud-shield-fill{
  position:absolute;inset:0;width:100%;transition:width .25s;border-radius:99px;
  background:linear-gradient(90deg,#2a6ab0,#7fd4ff);
  box-shadow:0 0 8px rgba(127,212,255,.5) inset;
}
@media (max-width:760px){ #hud-shield{width:clamp(70px,26vw,130px);height:6px} }

@media (max-width:760px){ .pv-pop{ display:none } }  /* no hover on touch */

/* ---- v4: SQUARE spell cards — icon + cost; everything else on hover.
        v6: much denser — small boxes, small icons, more cards per row. ---- */
.spell-card{aspect-ratio:1/1;display:flex;flex-direction:column;align-items:center;justify-content:space-between;
  padding:3px 3px 3px;text-align:center;border-left-width:2px}

.sc-icon{width:17px;height:17px}

.sc-name{font-size:.48rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
                     /* type lives in the hover tooltip now */
.sc-lv{position:absolute;top:2px;right:2px;font-size:.48rem;padding:0 3px}

@media (max-width:760px){ .spell-grid{grid-template-columns:repeat(auto-fill,minmax(48px,1fr))} }

/* dock stays clear of the speed buttons on small screens */
@media (max-width:760px){ #dock{max-height:70vh} }

/* ============================================================
   v5 — icon-only tabs, idle lobby, resize handles, mob polish
   ============================================================ */

/* image tabs have no text: let the icon fill the button */
.tab-btn:has(img){ padding:2px }
.tab-btn img{ height:calc(26px * var(--ui-scale)); max-width:100%; width:auto; }
.tab-btn.active img{ transform:scale(1.06) }

/* resize handles must be grabbable while docked, on every edge */
/* west edge is the useful one when docked bottom-right */

/* ============================================================
   v6 — GAME tab: mode picker + per-mode panels
   ============================================================ */
.mode-seg{
  display:flex; gap:5px; margin-bottom:10px;
  padding:2px; border-radius:10px;
}
.mode-seg-btn{
  flex:1; padding:4px; border-radius:8px; cursor:pointer;
  background:none; border:none; transition:all .12s; opacity:.72;
  height:calc(46px * var(--ui-scale));
}
/* every mode plaque fills the SAME box — equal flex width × fixed height,
   art scaled to fit, so all five render identically */
.mode-seg-btn img{ width:100%; height:100%; object-fit:contain;
  display:block; margin:0 auto; filter:drop-shadow(0 2px 5px rgba(0,0,0,.5)); }
.mode-seg-btn:hover{ filter:brightness(1.12); opacity:1; transform:translateY(-1px); }
.mode-seg-btn.active{
  opacity:1;
  filter:drop-shadow(0 0 8px rgba(255,217,112,.55)) brightness(1.08);
}

/* ============================================================
   v7 — combined top bar, bottom-center dock, icon tabs
   ============================================================ */
/* HUD is the single top bar now — flex so speed-ctl sits inline at the end */
#hud{ flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none; }
#hud::-webkit-scrollbar{ display:none; }

/* draggable grip on the bottom dock */

/* icon-only tabs: the icon IS the button — no wood chrome.
   EVERY tab gets the exact same box (flex:1 width × fixed height) and the
   plaque scales to FIT that box — so mixed source-art sizes all render
   identically, and the row rescales left/right when the dock is resized.
   overflow:visible — the hover/active glow must breathe past the button
   edges, not get chopped off left and right. */
.tab-btn.tab-icon{
  background:none !important; border:none !important; box-shadow:none !important;
  padding:2px !important; display:flex; align-items:center; justify-content:center;
  overflow:visible;
}
.tab-btn.tab-icon img{
  width:100%; height:100%; max-height:calc(34px * 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); }

/* ============================================================
   OVERLAY SCREENS — pause menu, main menu, end screen
   Transparent, borderless, sprite buttons, compact.
   ============================================================ */
#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);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}}

.ov-logo{width:min(150px,40vw);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}

.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:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-top:4px;
  transition:opacity .3s ease, transform .3s ease}
/* (The v0.17 boot gate lived here. Deleted in v0.45: the menu no longer waits
   on a world build, so there is nothing to hide the buttons for.) */
.sprite-btn{display:flex;align-items:center;justify-content:center;
  background:none;border:none;cursor:pointer;padding:4px;height:64px;
  transition:transform .12s}
.sprite-btn img{height:100%;width:auto;filter:drop-shadow(0 2px 5px rgba(0,0,0,.5));transition:filter .12s}
/* hover: a QUIET lift — gentle rise, soft gold breath, no hard halo */
.sprite-btn:hover{transform:translateY(-2px) scale(1.02)}
/* v0.54: was a 7px gold bloom at brightness 1.07 and it read as the button
   flaring rather than lifting. Half the glow, half the brighten. */
.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)}

/* run-end screen: Restart & Home as a matched pair — one identical box, both
   sprites DOWNSCALED from native (never upscaled → never blurry). Box aspect
   (~2.24) sits between the two arts so neither stretches noticeably. */
#overlay.runend .ov-btns .sprite-btn{width:112px;height:50px;padding:0}
#overlay.runend .ov-btns .sprite-btn img{width:100%;height:100%;object-fit:fill;display:block}

/* run-end stats: a tidy 2×2 grid — Rounds / Slain / Gold / Crystals */
#overlay.runend .ov-stats{display:grid;grid-template-columns:repeat(2,minmax(96px,auto));
  gap:10px 30px;justify-content:center}
#overlay.runend .ov-stats > div{align-items:center;text-align:center}

/* ---- BACKGROUND ANIMATION SWITCH (v0.44) ----
   Sits under the menu plaques. Intentionally the quietest thing on the screen:
   a hairline slider and one line of small caps, so it reads as an option rather
   than a fourth button competing with PLAY. It fades in with the rest of the
   menu (boot gate) and grows a gold edge only on hover. */
.bg-anim{display:flex;align-items:center;gap:9px;margin-top:6px;padding:7px 15px;
  background:rgba(0,0,0,.5);border:1px solid var(--brass);border-radius:999px;
  cursor:pointer;pointer-events:auto;color:#d9c89f;
  font:inherit;font-size:.72rem;letter-spacing:1.4px;text-transform:uppercase;
  text-shadow:0 1px 3px rgba(0,0,0,.9);
  backdrop-filter:blur(3px);transition:border-color .18s,color .18s,background .18s}
.bg-anim:hover{border-color:var(--brass-lit);color:var(--gold);background:rgba(0,0,0,.62)}
.bg-anim .bg-sw{position:relative;width:26px;height:13px;border-radius:999px;flex:0 0 auto;
  background:linear-gradient(180deg,#4a3a12,#7a5f1d);box-shadow:inset 0 1px 3px rgba(0,0,0,.75);
  transition:background .2s}
.bg-anim .bg-sw i{position:absolute;top:1.5px;left:14px;width:10px;height:10px;border-radius:50%;
  background:linear-gradient(180deg,#ffe9a8,#c9a227);box-shadow:0 1px 3px rgba(0,0,0,.6);
  transition:left .2s cubic-bezier(.3,.9,.4,1.2),background .2s}
.bg-anim.off .bg-sw{background:linear-gradient(180deg,#1a1109,#2b1f13)}
.bg-anim.off .bg-sw i{left:1.5px;background:linear-gradient(180deg,#8a7c66,#5b5044)}
.bg-anim{transition:opacity .3s ease, border-color .18s, color .18s, background .18s}
/* Touch: keep it visually tiny but make it an actually hittable target. */
@media (max-width:520px){ .bg-anim{font-size:.68rem;padding:8px 14px;letter-spacing:1px;margin-top:6px} }

/* main menu: a clean 3×2 grid. Buttons are HEIGHT-locked small (≤ half native
   PNG size) so they always downscale — never upscale-blur — and the plaques
   all render the same size regardless of art width. */
#overlay.main .ov-btns{display:grid;grid-template-columns:repeat(3,1fr);gap:8px 10px;
  width:min(330px,86vw);justify-items:center}
#overlay.main .ov-btns .sprite-btn{width:100%;height:40px;padding:2px}
#overlay.main .ov-btns .sprite-btn img{width:100%;height:100%;object-fit:contain}

@media (max-width:520px){
  .sprite-btn{height:52px}
  .ov-title{font-size:1.2rem}
  .ov-logo{width:min(128px,36vw)}
  /* keep the 3×2 grid on phones; the grid controls sizing, so ignore the fixed heights above */
  #overlay.main .ov-btns{gap:6px;width:min(290px,86vw)}
  #overlay.main .ov-btns .sprite-btn{height:auto}
  #overlay.runend .ov-btns .sprite-btn{width:100px;height:45px}
  #overlay.runend .ov-stats{gap:8px 20px}
}

/* ============================================================
   MENU MODE — while the main menu or run-end screen is open,
   the entire game HUD disappears: clean cinematic arena only.
   ============================================================ */
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 }

/* crisper touch: no 300ms tap delay, no accidental double-tap zoom */
button, .tab-btn, .sprite-btn, .mode-seg-btn{ touch-action:manipulation; -webkit-tap-highlight-color:transparent; }

/* ============================================================
   VERSION BADGE — always visible, every screen (login, menu, in-game).
   Lets you confirm at a glance which build the browser is actually running.
   ============================================================ */
#build-badge{
  position:fixed; left:10px; bottom:8px; z-index:9999; pointer-events:none;
  font-family:var(--font); font-size:12px; font-weight:700; letter-spacing:1.5px;
  color:#ffe1a0; background:rgba(12,8,4,.6); border:1px solid rgba(255,217,112,.4);
  border-radius:6px; padding:3px 8px; text-shadow:0 1px 2px #000;
}

/* ============================================================
   v0.05 — landing flow, auth as modal, menu polish
   ============================================================ */

/* the auth card as a small MODAL over the landing menu / demo battle */
/* The login card sits ON TOP of the landing menu (auth z100 / overlay z95). At
   62% the whole menu bled through it — ghost PLAY/LOG IN plaques behind the
   Google button, a second ENABLE ANIMATIONS pill, and the version printed twice.
   It has to actually cover what is underneath. */
#auth.modal-mode{ background:rgba(6,5,10,.955); backdrop-filter:blur(7px); }
#auth.modal-mode #auth-logo{ width:min(120px,32vw); margin-bottom:2px; }
#auth.modal-mode #auth-chev,
#auth.modal-mode #auth-drawer,
#auth.modal-mode .auth-legal{ display:none }   /* the menu behind covers these */
#auth-close{
  display:none; position:absolute; top:6px; right:6px; width:26px; height:26px;
  border-radius:6px; background:var(--wood-2); border:1px solid var(--brass);
  color:var(--dim); font-size:.8rem; 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 }
.auth-box{ position:relative }

/* pause (Esc) menu uses the SAME 3×2 grid as the main menu */
#overlay.pause .ov-btns{display:grid;grid-template-columns:repeat(3,1fr);gap:8px 10px;
  width:min(330px,86vw)}
#overlay.pause .ov-btns .sprite-btn{width:100%;height:auto;padding:2px}
#overlay.pause .ov-btns .sprite-btn img{width:100%;height:auto}

/* version line inside the big menus */
.ov-version{ font-size:.68rem; letter-spacing:2px; color:var(--dim); opacity:.8; margin-top:2px;
  text-shadow:0 1px 3px #000 }

/* GAME tab: clicking a mode pops the little confirm window at the button.
   SAVED RUN appears only when a stash exists — hover shows the run's stats. */
.mode-seg-btn{ position:relative }
.mode-actions .saved-run-btn{ height:calc(38px * var(--ui-scale)) }
.mode-pop{ position:fixed; z-index:96; padding:6px 9px 7px; border-radius:9px;
  background:linear-gradient(180deg,rgba(24,16,9,.97),rgba(14,9,5,.97));
  border:1px solid var(--brass); box-shadow:0 8px 24px rgba(0,0,0,.6) }
.mode-pop .mp-title{ font-size:.6rem; letter-spacing:2px; color:var(--gold);
  text-align:center; margin-bottom:5px }
.mp-btns{ display:flex; gap:7px; justify-content:center }
.mp-btn{ background:none; border:none; padding:0; height:32px; cursor:pointer; transition:filter .1s }
.mp-btn img{ height:100%; width:auto; display:block }
.mp-btn:hover{ filter:brightness(1.12) }

/* GAME + SETTINGS tabs may NEVER scroll — everything must fit the panel */
#panel-content:has(.mode-seg){ overflow-y:hidden }
#panel-content:has(.set-cats){ overflow-y:hidden }
#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) .seg-choice .seg-opt{ padding:2px 8px }
#panel-content:has(.set-cats) .menu-note{ font-size:.64rem; line-height:1.5 }
/* …so the idle panel under the picker is squeezed extra tight */
#panel-content:has(.mode-seg) .menu-box{ padding:5px 7px }
#panel-content:has(.mode-seg) .idle-row{ margin-top:4px }
#panel-content:has(.mode-seg) .idle-stat{ padding:3px 6px }

/* toasts + level-ups live at the TOP now — clean fading text under the HUD,
   never boxes over the bottom dock */
#toasts{ top:calc(52px + env(safe-area-inset-top)); bottom:auto;
  flex-direction:column; }
#levelup{ top:auto; top:calc(96px + env(safe-area-inset-top)); transform:translate(-50%,0); }
#levelup.show{ 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:46px; height:46px }
#levelup .lu-n{ font-size:1.1rem }

/* ============================================================
   v0.06 — calm camera, tighter menus, mobile-first end screen
   ============================================================ */

/* corner badge retired — the version now lives inside the menus themselves
   (the element stays in the DOM as the single source of the version string) */
#build-badge{ display:none }

/* run-end: SKINNY & TALL for phones — stats squished into a tight 2×2,
   Restart stacked on top of Home */
#overlay.runend .ov-stats{ gap:6px 16px; padding:8px 12px }
#overlay.runend .ov-stats span{ font-size:.55rem }
#overlay.runend .ov-stats b{ font-size:.9rem }
#overlay.runend .ov-btns{ flex-direction:column; align-items:center; gap:8px }

/* GAME tab: PLAY + RESTART pinned under the mode picker */
.mode-actions{ display:flex; gap:6px; margin:6px 0 8px }

/* idle spellbook fold-away header */
.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) }

/* reduce-motion checkbox on the big menus */
/* hiscores hover card: per-skill LV · XP · world rank grid */
.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) }

/* ============================================================
   v7 — menu/settings/skills/upgrades button rework, top-100
   hiscores, perf HUD, dev-tools restyle
   ============================================================ */

/* modals must stack ABOVE the menu overlays (hiscores/help/confirms open from the main menu) */
#modal{z-index:110}

/* ---- UPGRADES: the whole card IS the buy button ---- */
.spell-grid{grid-template-columns:repeat(auto-fill,minmax(58px,1fr));gap:4px}
.spell-card{cursor:pointer;justify-content:center;gap:2px;padding:4px 3px;user-select:none}
.spell-card .sc-icon{width:16px;height:16px;margin:0 auto}
.spell-card .sc-name{font-size:.52rem;line-height:1.25}
.sc-cost{width:100%;text-align:center;font-size:.56rem;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}
.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)}

/* ---- SKILLS: compact 4×4 — icon · name · level, thin XP bar on the floor ---- */
.skill-grid{grid-template-columns:repeat(4,1fr);gap:4px}
.skill-card{position:relative;display:flex;align-items:center;gap:6px;text-align:left;
  padding:6px 8px 10px;min-height:38px}
.skill-card img{width:22px;height:22px;flex-shrink:0}
.sk-mid{flex:1;min-width:0}
.sk-name{font-size:.62rem;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}
.skill-card .sk-bar{position:absolute;left:4px;right:4px;bottom:3px;height:3px;margin:0}
.skill-card:hover{transform:translateY(-1px);border-color:var(--el);background:var(--wood-4);
  box-shadow:0 0 10px rgba(255,255,255,.06)}
@media (max-width:760px){ .skill-grid{grid-template-columns:repeat(4,1fr)} }

/* ---- SETTINGS: category buttons in a compact 3-wide grid ---- */
/* 7 plaques (audio…profile) in a tight 4-wide grid — every button one box */
.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}

/* ---- MENU tab: sprites + formal buttons ---- */

.menu-btn-row{justify-content:center}
.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-note-acc{text-align:center}

/* dev buttons keep the house colors now — no purple, no dashed border */
.dev-btn{background:linear-gradient(170deg,var(--wood-3),var(--wood-1));color:var(--gold);
  border:1px solid var(--brass);border-style:solid}
.dev-btn:hover{background:var(--wood-4);color:var(--gold);border-color:var(--gold-2)}

/* ---- HIGH SCORES: top-100 board + pinned "you" row ---- */
.hs-wrap{max-height:100%;overflow:auto}
.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;backdrop-filter:blur(2px);z-index:1}
.hs-you-inline{color:var(--gold)}
.modal-card.hs-modal{width:min(480px,94vw)}
.hs-modal-body{max-height:56vh;overflow:auto;text-align:left;margin-top:6px}

/* ---- PERF HUD (dev tools) — always on top, even over the title menu ---- */
#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}

/* ============================================================
   v8 — draggable dock, cooler round text
   ============================================================ */

/* ---- draggable bottom dock ---- */
#tabbar{cursor:grab;touch-action:none}
#tabbar:active{cursor:grabbing}
#dock.dragging{opacity:.96;filter:brightness(1.05)}
#dock.dragging #tabbar{cursor:grabbing;box-shadow:0 0 0 1px var(--gold-2),0 -4px 22px rgba(0,0,0,.6)}
/* the tab buttons keep a pointer cursor — they're still tappable */
.tab-btn{cursor:pointer}

/* ---- cooler round / wave banner ---- */
.wave-round{font-size:.92rem;letter-spacing:8px;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:2.05rem;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)}}
.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-desc{font-size:.86rem;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}
@media (max-width:760px){ .wave-name{font-size:1.5rem} .wave-round{letter-spacing:5px} }

/* ============================================================
   v9 — XP toggle + drops, cleaner tab bar, dock left/right,
   nicer level-up, segmented settings control
   ============================================================ */

/* ---- XP toggle in the top bar: glow = on, dim = off (no checkbox) ---- */
#btn-xp{ letter-spacing:.08em; }
#btn-xp:not(.on){ color:var(--dim); opacity:.6; filter:grayscale(.5); }
#btn-xp.on{
  color:#0d1a08; border-color:#bff29a;
  background:linear-gradient(180deg,#8fe06a,#4f9a2e);
  box-shadow:0 0 12px rgba(126,224,90,.55), inset 0 1px 0 rgba(255,255,255,.3);
  text-shadow:0 1px 0 rgba(255,255,255,.25);
}
#btn-xp.on:hover{ filter:brightness(1.1); }

/* ---- cleaner tab bar: no chrome, bigger icons, hugging the panel ---- */
#tabbar{ background:none !important; border:none !important; box-shadow:none !important;
  padding:1px 2px !important; gap:2px; height:auto; }
#dock:has(#panel.open) #tabbar, #dock:not(:has(#panel.open)) #tabbar{
  border:none !important; border-radius:0 !important; }
/* tab-icon SIZE lives in the v10 block below (.tab-btn.tab-icon height knob) */

/* ---- nicer level-up splash ---- */
#levelup .lu-ico{ width:82px; height:82px; }
#levelup .lu-t{ font-size:.8rem; letter-spacing:6px; }
#levelup .lu-n{ font-size:1.7rem; letter-spacing:1px; }
#levelup .lu-ring{ width:150px; height:150px; border-width:3px; }

/* ============================================================
   DOCK ON LEFT / RIGHT  — vertical tab column + tall side panel
   ============================================================ */
body.dock-left #dock, body.dock-right #dock{
  left:auto; right:auto; bottom:auto; top:50%;
  transform:translateY(-50%);
  flex-direction:row; align-items:center;
  width:auto; height:auto;
}
body.dock-left  #dock{ left:6px; }
body.dock-right #dock{ right:6px; flex-direction:row-reverse; }

body.dock-left #tabbar, body.dock-right #tabbar{
  flex-direction:column; width:auto; height:auto; justify-content:center; gap:3px;
}
body.dock-left .tab-btn.tab-icon, body.dock-right .tab-btn.tab-icon{ flex:0 0 auto; }

body.dock-left #panel.open, body.dock-right #panel.open{
  height:min(90vh,760px); max-height:90vh;
  width:min(360px,74vw);
  border-radius:var(--radius) !important;
  box-shadow:0 8px 30px rgba(0,0,0,.55);
}
/* a hair of separation between the tab column and the side panel */
body.dock-left  #panel.open{ margin-left:4px; }
body.dock-right #panel.open{ margin-right:4px; }

/* ---- segmented choice (settings: menu position) ---- */
.seg-choice{ display:flex; gap:4px; }
.seg-opt{ padding:5px 9px; font-size:.62rem; letter-spacing:.06em; border-radius:5px;
  color:var(--dim); background:linear-gradient(170deg,var(--wood-3),var(--wood-1));
  border:1px solid var(--brass); white-space:nowrap; }
.seg-opt:hover{ border-color:var(--gold-2); color:var(--text); }
.seg-opt.active{ color:#241503; border-color:#ffe9a8; font-weight:700;
  background:linear-gradient(180deg,var(--gold),#c9992a); }

/* side-dock panels are narrow — let the fixed 4-col skill grid shrink cards
   instead of overflowing (name already truncates) */
.skill-card{ min-width:0; }
.skill-card .sk-mid{ min-width:0; overflow:hidden; }

/* ============================================================
   v10 — uniform bigger tabs, iOS safe-areas, delete-account
   ============================================================ */

/* ---- 7 tabs: every button the SAME size box, icons bigger, nearly touching ---- */
#tabbar{ gap:3px !important; }
.tab-btn.tab-icon{ flex:1 1 0; min-width:0; height:calc(47px * var(--ui-scale)); }  /* ~10% down (was 52px) */
.tab-btn.tab-icon img{ width:100%; height:100%; object-fit:contain; }
@media (max-width:760px){ .tab-btn.tab-icon{ height:calc(40px * var(--ui-scale)); } }
/* side docks: a uniform vertical column of identical boxes */
body.dock-left .tab-btn.tab-icon, body.dock-right .tab-btn.tab-icon{
  flex:none; width:calc(94px * var(--ui-scale)); height:calc(40px * var(--ui-scale)); }

/* ---- iPhone notch / home-indicator safe areas ---- */
#hud{ top:calc(8px + env(safe-area-inset-top, 0px)); }
body.dock-left  #dock{ left:calc(6px + env(safe-area-inset-left, 0px)); }
body.dock-right #dock{ right:calc(6px + env(safe-area-inset-right, 0px)); }

/* ============================================================
   v0.11/v0.12 — text-first boot, email-only login, borderless
   title menus, transparent hiscores, logo click-glow
   ============================================================ */

/* ---- INSTANT BOOT (v0.45) — the title screen is a blurred still, not a 3D
   scene. The canvas stays hidden until the world both EXISTS (.on, set once
   Scene3D.init has run) and is WANTED (body.scene-live — animations switched
   on, or the player has entered the game). ---- */
#scene{ opacity:0; transition:opacity .9s ease; pointer-events:none }
body.scene-live #scene.on{ opacity:1; pointer-events:auto }

/* v0.46 — the default backdrop is DARK, and nothing else. The blurred arena
   photo it replaced read as a smeary mess ("what is this horrible background").
   One warm bloom behind the logo, one deep vignette at the edges, zero bytes,
   zero decode, zero paint cost. */
#static-bg{position:fixed;inset:0;z-index:-1;transition:opacity .6s ease;
  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%)}
/* once the live world is showing, the still is redundant — drop it so the
   compositor stops blending a full-screen layer every frame */
body.scene-live #static-bg{opacity:0}

/* ---- login card: NO wood box — bare inputs over the dark veil, like the
   other title menus. The in-game sprite button is the submit. ---- */
.auth-box{ background:none; border:none; box-shadow:none; padding:10px }
#auth.modal-mode .auth-box{ background:none; border:none; box-shadow:none }
.auth-box input{ background:rgba(10,6,3,.72); text-align:center }
#auth-submit.sprite-btn{
  align-self:center; height:calc(52px * var(--ui-scale)); padding:2px;
  background:none; border:none; box-shadow:none;
}
#auth-submit.sprite-btn img{ height:100%; width:auto }

/* ---- hiscores modal: nothing behind the text but the dark page veil ---- */
.modal-card.hs-modal{ background:none; border:none; box-shadow:none; animation:ovIn .28s ease }
.hs-modal .modal-title{ text-shadow:0 2px 10px #000 }
/* the Log In sprite under the board (logged-out only) */
.hs-login.sprite-btn{ height:56px; margin:8px auto 0; display:flex }

/* ---- logo click-glow on the big menus (and the login screen) — SUBTLE ---- */
.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) }
}

/* ============================================================
   v0.12 — auth ✕ off the card, matched welcome text, skinny
   offline report, calmer wave banner, sprite PLAY/RESTART,
   compact idle tab
   ============================================================ */

/* the auth modal's close ✕ sits in the SCREEN corner, not on the card
   (it used to overlap the Google button) */
#auth.modal-mode #auth-close{
  position:fixed; top:calc(12px + env(safe-area-inset-top,0px)); right:14px;
  width:34px; height:34px; font-size:1rem; border-radius:8px;
}

/* welcome line on the main menu: smaller, small-caps gold — matches the
   game's own headers instead of shouting */
#overlay.main .ov-title{
  font-size:.86rem; letter-spacing:4px; text-transform:uppercase;
  color:var(--gold); opacity:.92;
  text-shadow:0 2px 8px #000;
}

/* "while you were gone": tall & skinny — phone-first */
/* WHILE AFK — small borderless popup, run-end style: no wood card, stat
   boxes in a 2-col grid, sprite buttons underneath. */
.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{ grid-template-columns:1fr 1fr; gap:8px }
.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 }
.wywg-cell b{ font-size:calc(1rem * var(--ui-scale)) }
/* modal sprite buttons (Collect / Idle / Confirm / Cancel …): ONE fixed box —
   55px is exactly half the 110px source art, a clean 2:1 downscale = crisp. */
.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) }
/* sprite variants of the menu text buttons (privacy / terms / dev crystals) */
.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) }
/* DELETE ACCOUNT — a deliberately smaller plaque, tinted danger-red on hover */
.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 }

/* UPGRADES → the FILTERS fold button (the Choose plaque); gold dot = live filter */
.filters-toggle{ display:inline-flex; align-items:center; gap:4px }
.filters-toggle .ftog-cv{ color:var(--gold); font-size:.7rem }
.filters-toggle .fdot{ color:var(--gold); font-size:.55rem; vertical-align:middle }

/* SETTINGS → the TDIdle about plaque (houses Privacy & Terms) */
.about-legal{ display:flex; gap:10px; justify-content:center; margin-top:10px }
.about-legal .menu-txt-btn.sprite{ height:38px }

/* branded section-header plaques (MODE / SELECT / PROFILE) — small, centered,
   non-interactive framing for a tab's content. */

/* achievement filter bar: ALL / LOCKED / UNLOCKED as sprite plaques.
   The plaque IS the button — no wooden box behind it. Unpicked plaques dim
   back; the active one lights to full colour. */
.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) }
/* sprite filter bars (shop cats · achievements): EVERY plaque one equal box,
   equal spacing — flex shares the row, art fits inside */
.filter-sprites{ gap:5px; align-items:center; flex-wrap:nowrap }
/* flex-basis 0 → every button gets an IDENTICAL share regardless of content
   (text buttons like Floor Runes used to come out wider than the plaques) */
.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 }
/* HUD mini-controls as sprites: 1x/2x · XP */
#btn-speed,#btn-xp{ background:none !important; border:none !important; box-shadow:none !important; padding:0 2px; min-width:0 !important; height:auto !important }
#btn-speed img,#btn-xp img{ height:calc(19px * var(--ui-scale)); display:block; filter:drop-shadow(0 2px 4px rgba(0,0,0,.6)) }
#btn-xp:not(.on) img{ filter:grayscale(1) brightness(.55) }
#btn-speed.active img{ filter:drop-shadow(0 0 7px rgba(255,217,59,.9)) }

/* round-start banner: calmer, smaller */
.wave-round{ font-size:.72rem; letter-spacing:6px }
.wave-name{ font-size:1.45rem }
.wave-desc{ font-size:.76rem }
@media (max-width:760px){ .wave-name{ font-size:1.15rem } }

/* GAME tab: PLAY / RESTART are the sprite-sheet buttons now */
.mode-actions{ justify-content:center; align-items:center; gap:10px }
.mode-actions .sprite-btn{ height:calc(46px * var(--ui-scale)); padding:2px }
.mode-actions .sprite-btn img{ height:100% }

/* IDLE panel: one compact box — stats grid + inline wave/arena rows */
.idle-stat{ padding:5px 8px }
.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 }

/* ============================================================
   v0.27 — ICON-ONLY upgrade cards. The icon IS the card: it fills
   the box, with just the gold cost beneath. Names/details live in
   the hover tooltip. (Per-spell icon art drops straight into .sc-icon.)
   ============================================================ */
.spell-card{ gap:1px; padding:3px 2px }
.spell-card .sc-icon{ width:78%; height:auto; max-height:68%; flex:1; object-fit:contain; margin:0 auto }
.sc-cost{ font-size:.6rem }

/* ============================================================
   v0.28 — CLEAN DOCK. The tab bar itself stays fully transparent
   (the v9 no-chrome !important rules own it); the PANEL is one flat
   dark surface, and --panel-alpha (Settings → Interface → Menu
   Transparency) fades it see-through while text/buttons stay solid.
   ============================================================ */
:root{ --panel-alpha:1 }
#panel.wood{
  background:linear-gradient(180deg, rgba(20,14,8,var(--panel-alpha)), rgba(12,8,4,var(--panel-alpha)));
  border:1.5px solid rgba(138,106,53, calc(.45 + .55 * var(--panel-alpha)));
  box-shadow:0 8px 26px rgba(0,0,0,.4);
  /* ALL FOUR corners rounded — the tab bar above is transparent, so a square
     top edge read as "cut off". The panel is one clean rounded card. */
  border-radius:12px;
}

/* ============================================================
   v0.30 — MOBILE OVERHAUL. Touch devices get a fixed, device-fitted
   dock (no drag, no resize), a taller base panel sized so SKILLS
   fits with ZERO scrolling (game/skills/settings never scroll;
   upgrades/shop/achievements may), tap-to-preview in the shop, and
   uniformly sized plaques everywhere (the button PNGs now share one
   canonical aspect, so every object-fit box renders them equal).
   ============================================================ */

/* the SKILLS mastery grid is the no-scroll yardstick (its detail
   spellbook still scrolls — it's a 20-card browser, like Upgrades) */
#panel-content:has(.skill-grid){ overflow-y:hidden }

@media (hover:none), (max-width:760px){
  /* taller base panel: skills' 4 rows + headroom for UI-scale. This is THE
     one height for every tab — the tab bar never jumps. */
  #panel{ height:clamp(196px, 46vh, 250px); max-height:clamp(196px, 46vh, 250px) }
  /* no resize handles on touch — they kept catching stray fingers */
  .dock-rs{ display:none }
  /* the dock fits the device, centered; only the panel opens/closes */
  #dock{ left:50%; transform:translateX(-50%); width:calc(100vw - 8px) }
  #tabbar{ touch-action:manipulation }
  /* HUD must FIT the device — no sideways scroll: drop the grip, shave the
     pills and the sprite mini-buttons until the whole pod fits a 360px phone */
  #hud .grip{ display:none }
  #hud{ gap:3px }
  .hud-pill{ padding:3px 5px; gap:3px; font-size:.66rem }
  #hud-hp{ width:clamp(64px,22vw,110px) }
  #btn-speed img,#btn-xp img{ height:16px }
  #btn-skip img{ height:17px }
}

/* shop 3D preview ON for touch now — tap the card, tap away to close
   (this overrides the old blanket display:none for small screens) */
@media (max-width:760px){
  .pv-pop{ display:flex; width:min(372px, calc(100vw - 16px)) }
  .pv-pop canvas{ flex:0 0 140px; width:140px; height:140px }
}

/* run-end Restart/Home: contain, never stretch — with the normalized art
   both render identically inside the shared box */
#overlay.runend .ov-btns .sprite-btn img{ object-fit:contain }

/* ============================================================
   v0.33 — ☰ menu button, 1×6 main menu, "choose a mode" header,
   tighter mobile panel (smaller menu, same boxes), idle tab fit
   ============================================================ */

/* the HUD logo IS the menu button (☰ retired) — visible on EVERY device */
#hud-logo{ display:block !important }

/* EVERY big overlay menu — main menu, landing AND the pause (Esc) menu — is
   one clean 1×6 vertical column of IDENTICAL rows. Fixed row height so a
   full column + logo still fits a short phone. */
#overlay.main .ov-btns, #overlay.pause .ov-btns{
  display:grid; grid-template-columns:1fr; gap:7px;
  width:min(200px,58vw); justify-items:center }
#overlay.main .ov-btns .sprite-btn, #overlay.pause .ov-btns .sprite-btn{
  width:100%; height:44px; padding:2px }
#overlay.main .ov-btns .sprite-btn img, #overlay.pause .ov-btns .sprite-btn img{
  width:100%; height:100%; object-fit:contain }
@media (max-width:520px){
  #overlay.main .ov-btns, #overlay.pause .ov-btns{ gap:5px; width:min(190px,58vw) }
  #overlay.main .ov-btns .sprite-btn, #overlay.pause .ov-btns .sprite-btn{ height:38px }
}

/* GAME tab header: one slim gold line — the first thing a new player reads
   after pressing Play. Text only; a plaque here covered the panel content. */
.mode-choose{ display:flex; align-items:center; justify-content:center;
  margin-bottom:5px }
.mode-choose span{ font-size:.64rem; letter-spacing:3px; font-style:italic;
  color:var(--gold); text-shadow:0 1px 3px #000 }

/* MOBILE: the menu itself gets SMALLER (boxes stay) — panel trimmed, skills
   cards compacted so the 4×4 grid fits the trimmed panel with zero scroll,
   and the GAME tab's idle block squeezed so nothing is ever cut off. */
@media (hover:none), (max-width:760px){
  #panel{ height:clamp(176px, 42vh, 228px); max-height:clamp(176px, 42vh, 228px) }
  /* skills: tighter cards, same count */
  .skill-card{ padding:4px 6px 8px; min-height:32px; gap:5px }
  .skill-card img{ width:18px; height:18px }
  .sk-lv{ font-size:.66rem; padding:1px 5px }
  .sk-name{ font-size:.56rem }
  .skill-grid{ gap:3px }
  /* game tab: slimmer header + picker */
  .mode-choose{ margin-bottom:2px }
  .mode-seg{ margin-bottom:4px }
  .mode-seg-btn{ height:calc(38px * var(--ui-scale)) }
  /* idle block: one-row stats, small controls — must fit, never clip */
  #panel-content:has(.mode-seg) .menu-wrap{ gap:4px }
  #panel-content:has(.mode-seg) .idle-live{ grid-template-columns:repeat(4,minmax(0,1fr)); gap:3px; margin-top:0 }
  #panel-content:has(.mode-seg) .idle-stat{ padding:2px 4px }
  #panel-content:has(.mode-seg) .idle-stat span{ font-size:.5rem }
  #panel-content:has(.mode-seg) .idle-stat b{ font-size:.62rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
  #panel-content:has(.mode-seg) .idle-row{ margin-top:3px; gap:4px }
  #panel-content:has(.mode-seg) .idle-row .idle-h{ min-width:38px; font-size:.54rem }
  #panel-content:has(.mode-seg) .idle-row .filter-btn{ height:21px; min-width:21px; font-size:.54rem; padding:0 5px }
  #panel-content:has(.mode-seg) .idle-row input{ width:3.4em; padding:.1em; font-size:.66rem }
  #panel-content:has(.mode-seg) .menu-box{ padding:4px 6px }
  .sb-toggle{ padding:4px 8px; font-size:.6rem }
  /* the 11-arena picker: ONE row you swipe sideways — it was wrapping into
     three tall rows and pushing the whole idle block off the panel bottom */
  .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 }
  /* open idle spellbook = a 60-card browser → it may scroll (same rule as the
     skills detail view); the closed game tab still never scrolls */
  #panel-content:has(.mode-seg):has(.spell-grid){ overflow-y:auto }
  /* HUD with the ☰ button: one more shave so it can never sideways-scroll */
  #hud{ gap:2px; padding:3px 5px }
  .hud-pill{ padding:2px 4px; gap:2px; font-size:.62rem }
  #hud-name{ max-width:72px }
  #hud-hp{ width:clamp(58px,19vw,96px) }
  #hud-logo{ height:17px }
  #btn-speed img,#btn-xp img{ height:15px }
  #btn-skip img{ height:16px }
}


/* ===== v0.40 — thinner 6-tab dock + the 2-over-3 mode grid ===== */
/* Squeeze the tab strip: tighter buttons, tabs nearly touching. Hover pop
   stays inside the strip (overflow visible, no clipping). */
#tabbar{gap:1px;overflow:visible}
.tab-btn{padding:2px 0 1px;font-size:.48rem;letter-spacing:.35px}
.tab-btn img{height:calc(17px * var(--ui-scale))}
/* Desktop only: pull the whole dock in — mobile keeps its full-width rule */
@media (min-width:761px){ #dock{max-width:474px} }

/* GAME tab body: the panel is a fixed 228px (house rule 4 — it must never
   scroll) and the mode picker is only ~90px of that, so it sat pinned to the
   top of a tall empty box. Scoped with :has() to the game tab specifically —
   #panel-content is shared with upgrades/shop/achievements, which DO scroll and
   must keep their top alignment. Browsers without :has() simply keep the old
   layout; nothing breaks. */
#panel-content:has(> .mode-seg){display:flex;flex-direction:column;
  justify-content:center;gap:12px;height:100%}

/* GAME tab — 5 modes as 2 on top (Survival · Idle), 3 below
   (Boss Rush · Relentless · Endless). Sprite buttons, wrap-proof. */
/* Size by HEIGHT, never by width. These plaques are all ~2.85:1, so a fixed
   height makes every mode button identical and lets width follow the art.
   The old `max-width:100%;height:auto` let a 245px-wide cell render an 86px-tall
   image inside a 38px button — it overflowed by 48px and the two rows sat on
   top of each other, with row 1 visibly larger than row 2. */
.mode-seg{display:grid !important;grid-template-columns:repeat(6,1fr);
  gap:6px 8px;align-items:center;justify-items:center}
.mode-seg-btn{min-width:0;height:auto;padding:0;display:flex;
  align-items:center;justify-content:center;background:none;border:none}
.mode-seg-btn:nth-child(-n+2){grid-column:span 3}
.mode-seg-btn:nth-child(n+3){grid-column:span 2}
.mode-seg-btn img{height:calc(40px * var(--ui-scale));width:auto;max-width:100%;
  object-fit:contain;display:block}
.mode-seg-btn:hover{transform:translateY(-1px)}
.mode-seg-btn.active img{filter:drop-shadow(0 2px 6px rgba(255,217,112,.35))}
