/* --------------------------------------------------------------------------
   Potato Royale - UI shell.
   The canvas fills the viewport; every panel is an absolutely positioned
   overlay so the arena keeps rendering underneath (the shop is not a pause -
   in co-op you cannot stop the world for one player).

   Minimal by rule: one surface colour, one accent, borders only where two
   things would otherwise merge, uppercase only for tiny captions on numbers.
   Type: 11 (captions) / 13 (secondary) / 14 (body) / 16-20 (titles) / 28+.
   -------------------------------------------------------------------------- */

:root {
  --bg: #08090e;
  --panel: rgba(18, 20, 29, 0.94);
  --raised: rgba(255, 255, 255, 0.05);
  --raised-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.08);
  --txt: #eef0f6;
  --fg: #eef0f6;
  --dim: #a4aabb;
  --faint: #767d92;
  --accent: #ffc857;
  --accent-ink: #231903;
  --good: #7ee081;
  --bad: #ff6b85;
  --info: #7ea6ff;
  --mat: #8ee07f;
  --t1: #9aa3b4; --t2: #6ec1ff; --t3: #c084fc; --t4: #ffc857;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fredoka", ui-rounded, var(--font);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--txt);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hidden { display: none !important; }
.invisible { visibility: hidden; }
button { font-family: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.15; font-family: var(--display); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lbl {
  font-size: 11px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase; color: var(--faint);
}
.sub { margin: 4px 0 0; color: var(--dim); font-size: 13.5px; }
.hint { margin: 0; font-size: 13px; color: var(--dim); text-align: center; }
.err { margin: 0; color: var(--bad); font-size: 13.5px; min-height: 20px; text-align: center; font-weight: 600; }
.up { color: var(--good); }
.down { color: var(--bad); }
.empty { color: var(--faint); font-size: 13px; padding: 6px 2px; }

.icon { display: block; flex: none; width: 56px; height: 56px; }
.icon.sm { width: 36px; height: 36px; }
.icon.xs { width: 22px; height: 22px; }
.mat-ico {
  display: inline-block; width: 10px; height: 10px; flex: none; border-radius: 2px;
  background: var(--mat); transform: rotate(45deg); box-shadow: 0 0 8px rgba(142,224,127,.6);
}

/* ------------------------------- buttons -------------------------------- */
.btn {
  appearance: none; border: 0; background: var(--raised-2); color: var(--txt);
  min-height: 44px; padding: 10px 20px; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer; line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s ease, background .15s ease, filter .15s ease;
}
.btn:hover { background: rgba(255,255,255,.14); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { min-height: 50px; font-size: 16px; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--txt); background: var(--raised); }
.btn.tiny { min-height: 30px; padding: 4px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.wide { width: 100%; }
.btn:disabled, .btn:disabled:hover {
  cursor: not-allowed; transform: none; filter: none;
  background: var(--raised); color: var(--faint);
}
.btn.link {
  background: none; color: var(--dim); font-size: 13px; font-weight: 600;
  padding: 4px 6px; min-height: 0;
}
.btn.link:hover { color: var(--txt); background: none; }
.btn.link:disabled { opacity: .6; background: none; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.input {
  background: var(--raised); border: 1px solid transparent; border-radius: 12px;
  color: var(--txt); padding: 13px 16px; font-size: 16px; font-family: inherit;
  outline: none; width: 100%; text-align: center;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); }
#codeInput { text-transform: uppercase; letter-spacing: 8px; font-size: 26px; font-weight: 800; }

/* ------------------------------- screens -------------------------------- */
.screen {
  position: absolute; inset: 0; z-index: 20;
  /* Centred with auto margins on the first/last child, not justify-content:
     a screen taller than the viewport must scroll from its top, not clip it. */
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 18px; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 35%, rgba(12,14,22,.88), rgba(5,6,10,.97));
  backdrop-filter: blur(6px);
  overflow: auto;
}
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }

/* --------------------------------- menu --------------------------------- */
.menu-card { width: min(380px, 100%); text-align: center; }
.title {
  margin: 0; font-size: clamp(44px, 9vw, 64px); letter-spacing: 1px; line-height: .95;
  text-shadow: 0 6px 30px rgba(0,0,0,.6);
}
.title span { color: var(--accent); display: block; }
.title .threed {
  font-family: var(--font); font-size: 12px; font-weight: 800; letter-spacing: 2px;
  color: var(--bg); background: #7ec8ff; border-radius: 6px; padding: 2px 6px;
  vertical-align: top; margin-left: 6px; position: relative; top: 8px;
}
.tag { margin: 14px 0 28px; color: var(--dim); font-size: 14px; }
.menu-pane { display: flex; flex-direction: column; gap: 14px; }
.links { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.records { margin: 0; font-size: 12.5px; color: var(--faint); }
.credit { color: var(--faint); font-size: 12.5px; }
.spinner {
  width: 32px; height: 32px; margin: 6px auto; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#connTxt { color: var(--dim); margin: 0; }
.net-test {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 10px 14px; border-radius: 12px; font-size: 12.5px; line-height: 1.5;
  background: var(--raised); color: var(--dim);
}
.net-test b { font-size: 13.5px; color: var(--txt); }
.net-test.ok b { color: var(--good); }
.net-test.warn b { color: var(--accent); }
.net-test.bad b { color: var(--bad); }

/* ------------------------ lobby / character select ------------------------ */
.lobby { width: min(1000px, 100%); display: flex; flex-direction: column; gap: 18px; }
.lobby-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.lobby-top h2 { margin: 0; font-size: 30px; }
.room-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--raised); border-radius: 12px; padding: 6px 6px 6px 14px;
}
.room-chip b { font-size: 20px; letter-spacing: 4px; color: var(--accent); font-variant-numeric: tabular-nums; }

.stage-row { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.stage {
  --c: #7ec8ff;
  position: relative; aspect-ratio: 1 / 0.9; min-height: 260px; border-radius: 22px; overflow: hidden;
  /* closest-side keeps both glows inside the box, so it never shows an edge */
  background:
    radial-gradient(closest-side at 50% 74%, color-mix(in srgb, var(--c) 24%, transparent), transparent),
    radial-gradient(closest-side at 50% 45%, rgba(255,255,255,.045), transparent);
  transition: background .4s ease;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#charStage { cursor: grab; }
#charStage.dragging { cursor: grabbing; }
#charFallback { display: none; object-fit: contain; padding: 12%; }
.stage.flat #charFallback { display: block; }
.stage.flat #charStage { visibility: hidden; }
.stage.flat.locked #charFallback { filter: brightness(0) opacity(.6); }
.stage-hint {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  font-size: 11.5px; color: var(--faint); pointer-events: none;
}
.stage.flat .stage-hint { display: none; }

.char-info { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.epithet { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent); }
.char-info h3 { margin: -6px 0 0; font-size: 40px; }
.bio { margin: 0; color: var(--dim); font-size: 15px; line-height: 1.6; max-width: 46ch; }
.lock-note { margin: 0; color: var(--accent); font-size: 13.5px; font-weight: 600; }
.starter { display: flex; align-items: center; gap: 12px; }
.starter b { display: block; font-size: 14px; }
.starter small { display: block; color: var(--faint); font-size: 12.5px; line-height: 1.4; }
.char-best { margin: 0; font-size: 12.5px; color: var(--faint); }

.char-strip { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.char {
  --c: #7ec8ff;
  position: relative; width: 74px; padding: 6px 0 8px; border: 0; border-radius: 16px;
  background: transparent; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background .15s ease, transform .15s ease;
}
.char .portrait {
  width: 56px; height: 56px; border-radius: 50%; display: block;
  background: var(--raised); box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s ease;
}
.char .nm { font-size: 11.5px; font-weight: 600; color: var(--faint); }
.char:hover { background: var(--raised); }
.char:hover .nm { color: var(--dim); }
.char.view { transform: translateY(-3px); }
.char.view .portrait { box-shadow: 0 0 0 2px var(--c); }
.char.view .nm { color: var(--txt); }
.char.sel .nm::after { content: " \2022"; color: var(--accent); }
.char .lock-ico { display: none; position: absolute; top: 34px; left: 50%; transform: translate(-50%, -50%); font-size: 18px; }
.char.locked .portrait { filter: brightness(0) opacity(.5); }
.char.locked .lock-ico { display: block; }
.char .best-dot {
  position: absolute; top: 8px; right: 12px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
}
.char .best-dot.won { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.lobby-foot {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.lobby-people { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; flex: 1; min-width: 0; }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 190px; }
.player-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 3px 0; }
.player-list .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.player-list .pname small { color: var(--faint); font-size: 12px; margin-left: 2px; }
.player-list .tick { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--faint); }
.player-list .tick.ok { color: var(--good); }
.player-list .kick { margin-left: 6px; min-height: 24px; padding: 2px 8px; background: transparent; color: var(--bad); }
.player-list .kick:hover { background: rgba(255,107,133,.14); }
.player-list .kick.armed { background: var(--bad); color: #2b0a12; }

.lobby-opts { display: flex; gap: 22px; flex-wrap: wrap; }
.opt-group { display: flex; flex-direction: column; gap: 6px; max-width: 260px; }
.opt-desc { margin: 0; font-size: 12px; color: var(--faint); line-height: 1.4; }
.danger-opts { display: flex; gap: 2px; background: var(--raised); border-radius: 10px; padding: 3px; width: max-content; }
.danger-opts .dopt {
  min-width: 34px; padding: 6px 10px; border-radius: 8px; border: 0; background: transparent;
  color: var(--dim); font: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
}
.danger-opts .dopt:not(:disabled):hover { color: var(--txt); background: var(--raised); }
.danger-opts .dopt.on { background: var(--accent); color: var(--accent-ink); }
.danger-opts .dopt.locked { opacity: .35; cursor: not-allowed; }
.danger-opts .dopt:disabled:not(.on) { opacity: .5; cursor: default; }
.lobby-actions { display: flex; gap: 10px; align-items: center; }
.lobby-actions #btnReady { min-width: 150px; }

/* ------------------------------- stat chips ------------------------------ */
.sicon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.schip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px 3px 5px; border-radius: 999px;
  background: var(--raised); font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2;
}
.schip.up b { color: var(--good); }
.schip.down b { color: var(--bad); }
.schip small { font-weight: 500; color: var(--dim); margin-left: 2px; font-size: 10.5px; }
.schip.dps { background: rgba(255,200,87,.12); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips.center { justify-content: center; }
.chips.big .schip { font-size: 14px; padding: 4px 10px 4px 5px; }
.chips.big .sicon { width: 22px; height: 22px; }
.chips.mini { margin-top: 3px; gap: 3px; }
.chips.mini .schip { font-size: 11px; padding: 1px 6px 1px 2px; }
.chips.mini .sicon { width: 14px; height: 14px; }
.chips.scales .schip { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.cls-row { display: flex; flex-wrap: wrap; gap: 5px; }
.cls {
  display: inline-flex; align-items: baseline; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid; background: transparent;
}
.cls b { font-variant-numeric: tabular-nums; }
.cls small { font-weight: 500; letter-spacing: 0; color: var(--dim); font-size: 11px; }

/* --------------------------------- HUD ---------------------------------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.hud-top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); }
.wave-pill {
  position: relative; display: flex; align-items: baseline; gap: 12px;
  padding: 7px 18px 10px; border-radius: 14px; background: rgba(8,9,14,.62);
  backdrop-filter: blur(6px); white-space: nowrap;
}
.wave-lbl { font-size: 13px; color: var(--dim); font-weight: 600; }
.wave-lbl b { font-size: 20px; color: var(--txt); font-family: var(--display); font-variant-numeric: tabular-nums; }
.wave-time { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.wave-time b { font-size: 20px; color: var(--txt); font-family: var(--display); }
.hud-timer { position: absolute; left: 14px; right: 14px; bottom: 5px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
#timerFill { height: 100%; width: 100%; background: var(--info); transition: width .1s linear; }
#timerFill.low { background: var(--bad); }
.danger-tag {
  align-self: center; font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  padding: 2px 6px; border-radius: 6px; background: rgba(255,107,133,.18); color: var(--bad);
}

.hud-mats {
  position: absolute; top: 18px; right: 18px; display: flex; align-items: center; gap: 9px;
  font-family: var(--display); font-size: 22px; text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
.hud-mats b { font-weight: 600; font-variant-numeric: tabular-nums; }

.hud-self { position: absolute; left: 16px; bottom: 16px; width: min(300px, calc(100vw - 92px)); }
.hp-bar {
  position: relative; height: 22px; border-radius: 11px; overflow: hidden;
  background: rgba(8,9,14,.7); backdrop-filter: blur(6px);
}
#hpFill { position: absolute; inset: 0; width: 100%; background: #56c46a; transition: width .12s ease; }
#hpFill.low { background: #e5505f; }
.hp-lvl, #hpTxt {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center;
  font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
}
.hp-lvl { left: 10px; font-weight: 600; }
.hp-lvl b { margin-left: 3px; font-weight: 800; }
#hpTxt { right: 10px; }
.xp-bar { height: 3px; margin-top: 5px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
#xpFill { height: 100%; width: 0; background: #c084fc; transition: width .15s ease; }
.weapon-row { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.weapon-chip {
  --tier: var(--t1);
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: rgba(8,9,14,.62); box-shadow: inset 0 -2px 0 var(--tier);
}
.weapon-chip .icon { width: 26px; height: 26px; }

.team-panel { position: absolute; right: 18px; top: 58px; width: 150px; display: flex; flex-direction: column; gap: 8px; }
.team-row { font-size: 12.5px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.9); border-radius: 8px; }
.team-row .nm { display: flex; align-items: center; gap: 6px; }
.team-row .tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-row .nm small { color: var(--faint); font-weight: 500; }
.team-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.team-row .bar { height: 3px; margin-top: 4px; border-radius: 2px; background: rgba(255,255,255,.14); overflow: hidden; }
.team-row .bar i { display: block; height: 100%; background: var(--good); }
.team-row.down { opacity: .5; }
.team-row.down .bar i { background: var(--bad); }
.team-panel.pickable .team-row { pointer-events: auto; cursor: pointer; padding: 4px 6px; margin: -4px -6px; }
.team-panel.pickable .team-row:hover { background: rgba(255,255,255,.08); }

.net-badge {
  /* Below the wave pill, not on top of it - this only ever appears when
     something is wrong, which is the worst time to hide the HUD. */
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 10px; white-space: nowrap;
  background: rgba(60,14,26,.9); color: #ffc4d0; font-size: 13px; font-weight: 600;
}

/* ----------------------------- spectating ------------------------------- */
/* Lives inside #hud, which is pointer-events:none, so anything clickable in
   here has to opt back in. */
.spectate {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(400px, calc(100vw - 32px)); pointer-events: auto;
  background: var(--panel); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow); transition: bottom .15s ease;
}
/* A downed player can still have a level-up to spend, and that panel owns the
   bottom centre. Stack above it; its height is measured at render time. */
#app.lu-open .spectate { bottom: calc(var(--lu-h, 148px) + 32px); }
.spec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.spec-hint { font-size: 12px; color: var(--faint); text-align: right; }
.spec-main { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.spec-main .btn.tiny { min-width: 32px; }
.spec-who { flex: 1; min-width: 0; }
.spec-name { display: flex; align-items: center; gap: 7px; font-size: 15px; }
.spec-name .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.spec-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-bar { height: 4px; margin-top: 5px; border-radius: 2px; background: rgba(255,255,255,.12); overflow: hidden; }
.spec-bar i { display: block; height: 100%; background: var(--good); transition: width .12s linear; }
.spec-build { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.spec-build .lv { font-size: 11px; font-weight: 800; color: var(--accent); }
.spec-build .wp { font-size: 11.5px; color: var(--dim); background: var(--raised); border-radius: 6px; padding: 1px 7px; }
.spec-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.spec-picks { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.spec-pick {
  display: flex; align-items: center; gap: 5px; cursor: pointer; border: 0;
  background: var(--raised); border-radius: 8px; padding: 4px 9px; font-size: 12px; color: var(--dim);
}
.spec-pick:hover { color: var(--txt); }
.spec-pick.on { background: var(--accent); color: var(--accent-ink); }
.spec-pick .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* --------------------------------- shop --------------------------------- */
.shop { width: min(1100px, 100%); display: flex; flex-direction: column; gap: 18px; }
.shop-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.shop-head h2 { margin: 0; font-size: 30px; }
.shop-head .summary { display: block; margin-top: 2px; color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.shop-meta { display: flex; gap: 8px; }
.meta-pill {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; background: var(--raised);
}
.meta-pill b { font-family: var(--display); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meta-pill.mats b { color: var(--mat); }

.offers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.offer {
  --tier: var(--t1);
  position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 170px;
  background: var(--panel); border-radius: var(--radius); padding: 16px 14px 14px;
  box-shadow: inset 0 3px 0 var(--tier);
}
.offer.sold { opacity: .4; }
.offer.sold .icon { filter: grayscale(1); }
.offer.locked { box-shadow: inset 0 3px 0 var(--tier), inset 0 0 0 1px rgba(255,200,87,.5); }
.offer-head { display: flex; align-items: center; gap: 10px; padding-right: 26px; }
.offer-head .icon { width: 48px; height: 48px; }
.offer-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.offer .kind { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; white-space: nowrap; }
.offer h4 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.offer .wstat.icons { display: flex; flex-wrap: wrap; gap: 5px; }
.offer .wdesc { margin: 0; font-size: 12.5px; color: var(--dim); line-height: 1.45; }
.offer .wdesc.effect { color: var(--txt); font-size: 13.5px; font-weight: 500; }
.offer .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.offer .tag { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--raised); color: var(--dim); }
.offer .merge { font-size: 12.5px; line-height: 1.4; color: var(--good); }
.offer .merge b { color: #baffbd; }
/* Class, scaling and tags fold away until hover (or a tap on touch screens). */
.offer .more {
  display: none; flex-direction: column; gap: 7px;
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5;
  background: #1a1c27; border-radius: 12px; padding: 12px; box-shadow: var(--shadow);
}
.offer:hover .more, .offer.open .more, .offer:focus-within .more { display: flex; }
.offer .buy { margin-top: auto; width: 100%; }
.offer .lock {
  position: absolute; top: 10px; right: 8px; background: none; border: none;
  cursor: pointer; font-size: 14px; opacity: .35; padding: 5px; line-height: 1;
  transition: opacity .12s, transform .12s;
}
.offer .lock:hover { opacity: .85; }
.offer .lock.on { opacity: 1; transform: scale(1.1); }

.shop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.shop-actions .btn { min-width: 160px; }
.give-box {
  display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
  font-size: 13px; color: var(--dim);
}
.give-box select, .give-box input {
  background: var(--raised); color: var(--txt); border: 0;
  border-radius: 9px; padding: 7px 10px; font: inherit;
}
.give-box select option { background: #1a1c26; }
.give-box input { width: 76px; }
.give-box small { color: var(--faint); min-width: 170px; }

.tabs { display: none; gap: 2px; background: var(--raised); border-radius: 12px; padding: 3px; }
.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--dim); font-weight: 600; font-size: 13.5px;
  padding: 8px; border-radius: 9px; cursor: pointer;
}
.tabs button.on { background: var(--raised-2); color: var(--txt); }
.shop-lower { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.panel { display: flex; flex-direction: column; min-width: 0; }
.panel h3 {
  margin: 0 0 10px; font-family: var(--font); font-size: 11px; font-weight: 700;
  letter-spacing: 1.1px; text-transform: uppercase; color: var(--faint);
  display: flex; align-items: baseline; gap: 6px;
}
.panel h3 small { color: var(--faint); font-weight: 600; letter-spacing: 0; font-size: 12px; text-transform: none; }
.class-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.class-row .cls { padding: 3px 9px; }
.class-row .cls:not(.on) { opacity: .7; }
.class-row .empty { padding: 0; font-size: 12.5px; }
.inv-grid { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; }
.inv-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; padding: 5px 4px; border-radius: 10px; }
.inv-row:hover { background: var(--raised); }
.inv-row .wname { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.inv-row .wname small { color: var(--faint); font-size: 11.5px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.inv-row .lvl { color: var(--accent); font-size: 12px; }
.inv-row .sell { margin-left: auto; background: transparent; color: var(--dim); }
.inv-row .sell:hover { background: var(--raised-2); color: var(--txt); }
.stat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; max-width: 300px; max-height: 220px; overflow: auto; }
.stat-list div { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 2px; border-radius: 6px; }
.stat-list div b { margin-left: auto; font-variant-numeric: tabular-nums; }
.stat-list b.up { color: var(--good); }
.stat-list b.down { color: var(--bad); }
.stat-list div.changed { animation: stat-flash 1.6s ease-out; }
.stat-list div.gain b { color: var(--good); }
.stat-list div.loss b { color: var(--bad); }
.stat-list .delta {
  margin-left: auto; font-style: normal; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums;
  animation: stat-delta 1.6s ease-out forwards;
}
.stat-list .delta + b { margin-left: 6px; }
.stat-list div.gain .delta { color: var(--good); }
.stat-list div.loss .delta { color: var(--bad); }
@keyframes stat-flash { from { background: rgba(255,200,87,.18); } to { background: transparent; } }
@keyframes stat-delta { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

/* The level-up panel is non-blocking and lives at the bottom of the screen;
   when a pending choice survives into the shop, leave room for it. */
#app:has(.levelup:not(.hidden)) #shop { padding-bottom: calc(var(--lu-h, 190px) + 30px); }

/* ------------------------------- level up ------------------------------- */
.levelup {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 25; background: var(--panel); border-radius: 18px; padding: 14px 16px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
  backdrop-filter: blur(8px);
}
.levelup-head { font-size: 14px; color: var(--dim); margin-bottom: 6px; text-align: center; }
.levelup-head b { color: var(--accent); }
.lu-hint { font-size: 11.5px; color: var(--faint); text-align: center; margin: 0 0 10px; font-weight: 600; }
.lu-options { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.lu-opt {
  --tier: var(--t1);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--raised); border: 0; border-radius: 12px; box-shadow: inset 0 3px 0 var(--tier);
  padding: 12px 14px 10px; cursor: pointer; min-width: 104px; max-width: 150px; text-align: center; color: var(--txt);
  transition: background .12s, transform .12s;
}
.lu-opt:hover { background: var(--raised-2); transform: translateY(-2px); }
.lu-opt.t1 { background: rgba(110,193,255,.08); }
.lu-opt.t2 { background: rgba(192,132,252,.12); }
.lu-opt .sicon { width: 30px; height: 30px; }
.lu-opt .tier { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tier); }
.lu-opt .v { font-size: 18px; font-weight: 800; color: var(--good); font-variant-numeric: tabular-nums; }
.lu-opt .k { font-size: 11px; color: var(--dim); font-weight: 600; }
.lu-opt .d { font-size: 11px; line-height: 1.3; color: var(--faint); margin-top: 2px; }
.lu-opt .n { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.lu-opt .n b { color: var(--good); }

/* ------------------------------ game over ------------------------------- */
.over-card { width: min(420px, 100%); text-align: center; }
.over-card h2 { margin: 0; font-size: 44px; }
.best { margin: 8px 0 0; color: var(--accent); font-weight: 700; }
.quip {
  --c: #7ec8ff;
  display: flex; align-items: center; gap: 14px; margin: 22px 0 0; text-align: left;
  padding: 12px 18px 12px 10px; border-radius: 18px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 16%, transparent), transparent);
}
.quip canvas { width: 72px; height: 72px; flex: none; }
.quip blockquote { margin: 0; }
.quip p { margin: 0; font-family: var(--display); font-size: 18px; line-height: 1.3; }
.quip cite { display: block; margin-top: 4px; font-style: normal; font-size: 12px; color: var(--faint); }
.score-list { list-style: none; margin: 18px 0 22px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.score-list li { display: flex; gap: 10px; align-items: center; font-size: 14px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.score-list li:last-child { border-bottom: 0; }
.score-list .dot { width: 10px; height: 10px; border-radius: 50%; }
.score-list .k { margin-left: auto; color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.over-card .hint { margin-top: 12px; }

/* ----------------------------- modals ----------------------------------- */
/* A modal, not a screen: settings can be opened mid-wave and the arena keeps
   running behind it, like every other panel in this game. */
.modal {
  position: absolute; inset: 0; z-index: 35;
  display: flex; align-items: center; justify-content: center; padding: 20px 16px;
  background: rgba(4,5,10,.7); backdrop-filter: blur(4px); overflow: auto;
}
.modal-card {
  width: min(520px, 100%); background: #13151e; border-radius: 20px; box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 2px;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 26px; }
.set-row { display: flex; align-items: center; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-label { flex: 1; min-width: 0; }
.set-label b { display: block; font-size: 14.5px; }
.set-label small { display: block; color: var(--faint); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }
.set-row.disabled .set-label { opacity: .5; }
.set-ctl { display: flex; align-items: center; gap: 10px; flex: none; }
.set-ctl input[type=range] { width: 130px; accent-color: var(--accent); cursor: pointer; }
.set-ctl input[type=range]:disabled { cursor: default; opacity: .4; }
.set-ctl b { min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--dim); }
.seg { display: flex; flex: none; background: var(--raised); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  background: transparent; border: 0; padding: 7px 16px; cursor: pointer; border-radius: 8px;
  font-size: 13.5px; font-weight: 700; color: var(--dim);
}
.seg button:hover { color: var(--txt); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.toggle {
  flex: none; width: 44px; height: 26px; border-radius: 13px; cursor: pointer;
  background: var(--raised-2); border: 0; padding: 0; position: relative;
}
.toggle i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--faint); transition: left .13s ease, background .13s ease;
}
.toggle[aria-pressed=true] { background: rgba(255,200,87,.3); }
.toggle[aria-pressed=true] i { left: 21px; background: var(--accent); }
kbd {
  font: inherit; font-size: 11.5px; font-weight: 700; padding: 1px 5px;
  border-radius: 5px; background: var(--raised-2);
}

/* ------------------------------ story intro ------------------------------ */
.intro { z-index: 40; background: #05060a; }
.intro-card { width: min(760px, 100%); display: flex; flex-direction: column; gap: 18px; }
.intro-card.turn #introArt, .intro-card.turn .intro-text { animation: intro-in .45s ease both; }
.intro-card.turn .intro-text { animation-delay: .06s; }
@keyframes intro-in { from { opacity: 0; transform: translateY(10px); } }
#introArt { width: 100%; aspect-ratio: 880 / 360; height: auto; display: block; border-radius: 22px; background: radial-gradient(ellipse at 50% 40%, #171a26, #0a0b10); }
.intro-text { text-align: center; padding: 0 8px; }
.intro-text h2 { margin: 6px 0 10px; font-size: 34px; }
.intro-text p { margin: 0 auto; max-width: 56ch; color: var(--dim); font-size: 16px; line-height: 1.65; }
.intro-foot { display: flex; align-items: center; gap: 10px; }
.intro-foot .dots { flex: 1; display: flex; justify-content: center; gap: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--raised-2); cursor: pointer; transition: width .2s ease, background .2s ease; }
.dots i.on { width: 22px; border-radius: 4px; background: var(--accent); }
#introNext { min-width: 130px; }

/* -------------------------------- toasts -------------------------------- */
.toasts {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 45; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none;
}
.toast {
  background: rgba(16,18,26,.95); border-radius: 12px; padding: 9px 16px;
  font-size: 13.5px; font-weight: 600; animation: pop .25s ease; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.toast.warn { color: var(--accent); }
.toast.bad { color: #ffc4d0; }
.toast.good { color: var(--good); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }

/* ----------------------------- corner buttons ---------------------------- */
.mute {
  position: absolute; right: 14px; bottom: 14px; z-index: 25;
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer; border: 0;
  background: rgba(8,9,14,.55); color: var(--dim); font-size: 16px; backdrop-filter: blur(6px);
}
.mute:hover { color: var(--txt); background: rgba(255,255,255,.12); }
.mute.gear { right: 60px; font-size: 18px; line-height: 1; }
/* The menu has its own Settings link; one way in is enough. */
#app[data-screen=menu] .mute.gear { display: none; }
/* Character select owns the whole screen: no HUD, and the arena stays a hint. */
#app[data-screen=lobby] #hud, #app[data-screen=shop] #hud { display: none; }
#lobby { background: radial-gradient(ellipse at 35% 40%, #0e1019, #05060a); }

/* --------------------------- mobile stick ------------------------------- */
.stick {
  position: absolute; z-index: 12; width: 128px; height: 128px; border-radius: 50%;
  background: rgba(255,255,255,.05); border: 2px solid rgba(255,255,255,.12); pointer-events: none;
}
#stickNub {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px;
  margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.26);
}

/* Press P. Deliberately plain and out of the way - it is a measuring tool. */
.perf {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  z-index: 40; padding: 4px 10px; border-radius: 8px; background: rgba(0,0,0,.72);
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #9fe8b5; white-space: nowrap; pointer-events: none;
}

/* ------------------------------ narrow screens --------------------------- */
@media (max-width: 1000px) {
  .offers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs { display: flex; }
  .shop-lower { grid-template-columns: 1fr; }
  .shop-lower .panel.off { display: none; }
}
@media (max-width: 760px) {
  .stage-row { grid-template-columns: 1fr; gap: 14px; }
  .stage { aspect-ratio: 1 / 0.75; min-height: 220px; }
  .char-info { text-align: center; align-items: center; }
  .char-info h3 { font-size: 32px; }
  .char-info .chips { justify-content: center; }
  .starter { text-align: left; }
  .char-strip { order: 0; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding-bottom: 4px; }
  .char { flex: none; width: 66px; }
  .lobby-foot { flex-direction: column; align-items: stretch; }
  /* Ready stays in thumb reach however far the page scrolls. */
  .lobby-actions {
    position: sticky; bottom: -24px; z-index: 2; justify-content: stretch;
    margin: 0 -16px -24px; padding: 12px 16px 20px;
    background: linear-gradient(transparent, #05060a 30%);
  }
  #app[data-screen=lobby] .mute { display: none; }
  .lobby-actions .btn { flex: 1; }
  .team-panel { width: 120px; top: 54px; right: 12px; }
}
@media (max-width: 560px) {
  .lobby-top h2, .shop-head h2 { font-size: 24px; }
  .offers { grid-template-columns: 1fr; }
  .offer { min-height: 0; }
  .set-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .set-ctl input[type=range] { width: 180px; }
  .hud-mats { top: 64px; right: 14px; font-size: 18px; }
  .wave-pill { padding: 6px 14px 9px; gap: 10px; }
  .intro-text h2 { font-size: 26px; }
  .intro-text p { font-size: 14.5px; }
  .intro-foot { flex-wrap: wrap; }
  .intro-foot .dots { order: -1; flex-basis: 100%; margin-bottom: 4px; }
  .intro-foot .btn { flex: 1; }
}
