/* Ninja Arena 3D — "arcade dojo" design system.

   One colour per meaning, so a 9-year-old can read state at a glance:
     cyan = you / primary action / selection   magenta = opponent, High level
     amber = points, score, costs, Mid         green = correct, win, Junior
     red = wrong, damage, overheat
   Stat colours are fixed app-wide: Speed cyan, Power orange, Strength green,
   Frame violet.

   Layout is decided by INPUT as well as width: touch controls and big hit
   targets follow `html.input-touch` (set from (pointer: coarse) in main.js), key
   hints follow `html.input-kbd` (set the moment a real keydown arrives). */

:root {
  --ink: #0a0d1c;
  --ink-deep: #05070e;
  --panel: #121731;
  --panel-2: #171d3b;
  --line: #1e2548;
  --line-2: #2b3464;
  --text: #e7eaf6;
  --dim: #8a92b8;
  --faint: #5b638c;

  --cyan: #22d3ee;
  --cyan-deep: #0e7490;
  --magenta: #f472b6;
  --amber: #fbbf24;
  --green: #22c55e;
  --red: #ef4444;

  --speed: #22d3ee;
  --power: #f97316;
  --strength: #22c55e;
  --frame: #a78bfa;

  --display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --cut: 12px;
  --radius: 4px;
  --gutter: clamp(16px, 3vw, 40px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The `hidden` attribute must always win. Without this, any class that sets
   `display` silently un-hides its element — which is exactly how the arena's
   end-of-match overlay sat over (and blurred) the entire fight. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(34, 211, 238, 0.09), transparent 60%),
    radial-gradient(800px 480px at 5% 110%, rgba(244, 114, 182, 0.07), transparent 60%),
    linear-gradient(rgba(30, 37, 72, 0.35) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, rgba(30, 37, 72, 0.35) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--ink);
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.disp { font-family: var(--display); }

/* ── Boot / fatal ───────────────────────────────────────────────────────── */
#app { min-height: 100vh; min-height: 100dvh; }
.boot { min-height: 100vh; display: grid; place-content: center; gap: 12px; text-align: center; }
.boot-title { font-family: var(--display); font-weight: 700; font-size: clamp(2rem, 7vw, 4rem); letter-spacing: 0.06em; color: var(--cyan); }
.boot-msg { color: var(--dim); }
#boot-error {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); z-index: 1000;
  background: #2a0f16; border: 1px solid var(--red); color: #fecaca;
  padding: 12px 16px; font-size: 0.9rem; border-radius: var(--radius);
}

/* ── App frame ──────────────────────────────────────────────────────────── */
.frame {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  animation: framein 0.22s ease-out;
}
@keyframes framein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.frame-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px var(--gutter) 24px;
  min-height: 0;
}

/* ── Top navigation + flow stepper ──────────────────────────────────────── */
.topnav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px var(--gutter);
  padding-top: calc(14px + var(--safe-t));
  border-bottom: 1px solid var(--line);
  min-height: 64px;
}
.topnav .spacer { flex: 1; }
.topnav-title { font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; }

.badge-na {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--cyan); color: var(--ink);
  font-family: var(--display); font-weight: 700; font-size: 0.8rem;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 700; letter-spacing: 0.14em; font-size: 0.85rem; }

.name-chip {
  font-family: var(--mono); font-weight: 700; font-size: 0.8rem;
  padding: 7px 12px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--panel); white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis;
}

.stepper { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center; min-width: 0; }
.step { display: flex; align-items: center; gap: 7px; font-family: var(--display); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.12em; color: var(--faint); white-space: nowrap; }
.step .num {
  width: 22px; height: 22px; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 3px;
  font-family: var(--mono); font-size: 0.7rem; color: var(--faint);
}
.step.done { color: var(--dim); }
.step.done .num { border-color: var(--cyan); color: var(--cyan); }
.step.now { color: var(--text); }
.step.now .num { background: var(--cyan); border-color: var(--cyan); color: var(--ink); font-weight: 700; }
.step-sep { width: 18px; height: 1px; background: var(--line-2); flex-shrink: 1; }
.step-compact { display: none; }

/* ── Buttons (chamfered: 12px cut on top-left + bottom-right) ───────────── */
.btn {
  --c: var(--cut);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  font-family: var(--display); font-weight: 700; font-size: 0.9rem;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text);
  background: var(--panel-2);
  box-shadow: inset 0 0 0 1px var(--line-2);
  clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
  transition: filter 0.12s, transform 0.12s, background 0.12s;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { background: var(--cyan); color: var(--ink-deep); box-shadow: 0 0 30px rgba(34, 211, 238, 0.35); }
.btn-commit { background: var(--amber); color: var(--ink-deep); box-shadow: 0 0 30px rgba(251, 191, 36, 0.3); }
.btn-outline-amber { background: transparent; color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.btn-lg { min-height: 60px; font-size: 1.15rem; letter-spacing: 0.14em; }
.btn-block { width: 100%; }
.btn:disabled {
  background: transparent; color: var(--faint); box-shadow: none; filter: none; transform: none;
  outline: 1px dashed var(--line-2); outline-offset: -1px;
}
.btn .kbd-hint { margin-left: auto; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; opacity: 0.7; }
.btn-back {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  font-family: var(--display); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.12em;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel);
}
.btn-back:hover { border-color: var(--cyan); }
.link-amber { font-family: var(--display); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.14em; color: var(--amber); padding: 8px 0; }
.link-amber:hover { text-decoration: underline; }

/* ── Keycap hints: hidden on touch unless a keyboard shows up ───────────── */
.kbd {
  display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 7px;
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700; color: var(--dim);
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; background: var(--ink);
}
html.input-touch:not(.input-kbd) .kbd,
html.input-touch:not(.input-kbd) .kbd-hint,
html.input-touch:not(.input-kbd) .key-only { display: none !important; }
.touch-only { display: none !important; }
html.input-touch .touch-only { display: revert !important; }

/* ── Panels, chips, segmented controls, tags ────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.eyebrow { font-family: var(--display); font-weight: 600; font-size: 0.75rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--cyan); }
.label { font-family: var(--display); font-weight: 600; font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); }
.h-screen { font-family: var(--display); font-weight: 700; font-size: clamp(1.6rem, 3.2vw, 2.4rem); letter-spacing: 0.01em; }
.sub { color: var(--dim); font-size: 0.95rem; margin-top: 6px; }

.seg { display: inline-flex; background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; gap: 3px; }
.seg button {
  min-width: 64px; min-height: 40px; padding: 0 14px;
  font-family: var(--mono); font-weight: 700; font-size: 0.85rem; color: var(--dim);
  border-radius: 3px;
}
.seg button:hover { color: var(--text); }
.seg button.sel { background: var(--cyan); color: var(--ink-deep); }
.seg.amber button.sel { background: var(--amber); }

.chip {
  min-height: 36px; padding: 0 14px;
  font-family: var(--display); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.12em;
  border: 1px solid var(--line-2); border-radius: 999px; color: var(--dim);
}
.chip:hover { color: var(--text); }
.chip.sel { color: var(--text); border-color: var(--text); }
.chip.lv-junior { color: var(--green); border-color: rgba(34, 197, 94, 0.5); }
.chip.lv-mid { color: var(--amber); border-color: rgba(251, 191, 36, 0.5); }
.chip.lv-high { color: var(--magenta); border-color: rgba(244, 114, 182, 0.5); }
.chip.lv-junior.sel { background: rgba(34, 197, 94, 0.15); border-color: var(--green); }
.chip.lv-mid.sel { background: rgba(251, 191, 36, 0.15); border-color: var(--amber); }
.chip.lv-high.sel { background: rgba(244, 114, 182, 0.15); border-color: var(--magenta); }
.tabs-amber { display: inline-flex; gap: 4px; }
.tabs-amber button { min-height: 34px; padding: 0 14px; font-family: var(--display); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.12em; color: var(--dim); border-radius: 3px; }
.tabs-amber button.sel { background: var(--amber); color: var(--ink-deep); }

.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  font-family: var(--display); font-weight: 700; font-size: 0.62rem; letter-spacing: 0.14em;
  border-radius: 3px; border: 1px solid currentColor; white-space: nowrap;
}
.tag.cyan { color: var(--cyan); background: rgba(34, 211, 238, 0.1); }
.tag.amber { color: var(--amber); background: rgba(251, 191, 36, 0.1); }
.tag.green { color: var(--green); background: rgba(34, 197, 94, 0.1); }
.tag.magenta { color: var(--magenta); background: rgba(244, 114, 182, 0.1); }
.tag.red { color: var(--red); background: rgba(239, 68, 68, 0.1); }
.tag.dim { color: var(--dim); }
.tag.lv-junior { color: var(--green); }
.tag.lv-mid { color: var(--amber); }
.tag.lv-high { color: var(--magenta); }

/* ── Stat bars (preview) and pips (upgrade) ─────────────────────────────── */
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.bar { display: grid; grid-template-columns: 76px 1fr 22px; align-items: center; gap: 8px; }
.bar .k { font-family: var(--display); font-weight: 600; font-size: 0.6rem; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; }
.bar .track { display: block; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 3px; background: var(--cyan); }
.bar .v { font-family: var(--mono); font-weight: 700; font-size: 0.72rem; text-align: right; }
.fill.f-speed { background: var(--speed); }
.fill.f-power { background: var(--power); }
.fill.f-strength { background: var(--strength); }
.fill.f-frame { background: var(--frame); }
.fill.f-magenta { background: var(--magenta); }
.bars.single { grid-template-columns: 1fr; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed; top: calc(16px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 900; pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 0.9rem; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toastin 0.2s ease-out;
}
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); flex-shrink: 0; }
.toast.ok { border-color: rgba(34, 197, 94, 0.5); }
.toast.ok::before { background: var(--green); }
.toast.warn { border-color: rgba(251, 191, 36, 0.55); }
.toast.warn::before { background: var(--amber); }
.toast.err { border-color: rgba(239, 68, 68, 0.55); background: #1d0f19; }
.toast.err::before { background: var(--red); }
@keyframes toastin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.spin {
  display: inline-block; width: 16px; height: 16px; vertical-align: -3px;
  border: 2px solid var(--line-2); border-top-color: var(--cyan); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--dim); padding: 40px 0; }

/* ── Modal + bottom sheet ───────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(5, 7, 14, 0.72);
  display: grid; place-items: center; padding: 16px;
  animation: framein 0.15s ease-out;
}
.modal {
  width: min(520px, 100%);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { font-family: var(--display); font-weight: 700; font-size: 1.5rem; }
.modal-head .spacer { flex: 1; }
.modal-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 22px; }

.sheet-back { align-items: end; padding: 0; }
.sheet {
  width: 100%; max-width: 640px;
  background: var(--panel); border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: 12px 12px 0 0; padding: 20px 18px calc(20px + var(--safe-b));
  animation: sheetin 0.2s ease-out;
}
.sheet::before { content: ""; display: block; width: 44px; height: 4px; border-radius: 4px; background: var(--line-2); margin: -6px auto 16px; }
@keyframes sheetin { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Code tiles (lobby code + join) ─────────────────────────────────────── */
.code-tiles { display: flex; gap: 10px; }
.code-tile {
  width: 72px; height: 86px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 2.6rem;
  background: var(--ink); border: 1px solid var(--cyan); border-radius: var(--radius);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.25), inset 0 0 12px rgba(34, 211, 238, 0.08);
}
.code-inputs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.code-inputs input {
  width: 100%; height: 72px; text-align: center; text-transform: uppercase;
  font-family: var(--mono); font-weight: 700; font-size: 2rem;
  background: var(--ink); border: 1px solid var(--line-2); border-radius: var(--radius); caret-color: var(--cyan);
}
.code-inputs input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 16px rgba(34, 211, 238, 0.3); }
.code-inputs input.filled { border-color: var(--line-2); }
.code-status { display: flex; align-items: center; gap: 8px; min-height: 22px; margin-top: 12px; font-size: 0.85rem; color: var(--dim); }
.code-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.code-status.ok::before { background: var(--amber); }
.code-status.err { color: var(--red); }
.code-status.err::before { background: var(--red); }
.code-status:empty { visibility: hidden; }

/* ═══════════════════════════════════════════════════════════════════════
   HOME (01 / M03)
   ═══════════════════════════════════════════════════════════════════════ */
.home-top { display: flex; align-items: center; justify-content: space-between; padding: 22px var(--gutter) 0; padding-top: calc(22px + var(--safe-t)); }
.home-top .school { font-size: 0.8rem; color: var(--dim); }
.home-grid { flex: 1; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 40px; padding: 30px var(--gutter) 0; align-items: center; align-content: center; }
.home-hero { display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.home-title { font-family: var(--display); font-weight: 700; line-height: 0.9; font-size: clamp(3.4rem, 8vw, 7.4rem); letter-spacing: -0.01em; margin: 6px 0 18px; }
.home-title .l2 { color: var(--cyan); text-shadow: 0 0 40px rgba(34, 211, 238, 0.35); }
.field { position: relative; }
.field input {
  width: 100%; height: 58px; padding: 0 130px 0 18px;
  font-family: var(--mono); font-weight: 700; font-size: 1.15rem;
  background: var(--ink); border: 1px solid var(--line-2); border-radius: var(--radius);
}
.field input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 20px rgba(34, 211, 238, 0.2); }
.field .hint { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 0.78rem; font-weight: 600; }
.field .hint.ok { color: var(--green); }
.field .hint.err { color: var(--red); }
.home-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-stage { position: relative; height: min(56vh, 520px); min-height: 300px; }
.home-stage .stage-3d { position: absolute; inset: 0; }
.home-steps { display: grid; grid-template-columns: repeat(3, 1fr) 1.1fr; gap: 12px; padding: 28px var(--gutter); padding-bottom: calc(28px + var(--safe-b)); }
.home-step { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.home-step .n { font-family: var(--mono); font-weight: 700; font-size: 1.8rem; }
.home-step b { display: block; font-family: var(--display); font-size: 0.85rem; letter-spacing: 0.12em; }
.home-step span { font-size: 0.8rem; color: var(--dim); }
.home-best { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-color: rgba(251, 191, 36, 0.45); background: linear-gradient(90deg, rgba(251, 191, 36, 0.08), transparent); }
.home-best .v { font-family: var(--mono); font-weight: 700; font-size: 1.5rem; }
.home-best .r { text-align: right; }

/* ── 3D stage shared chrome ─────────────────────────────────────────────── */
.stage-3d { position: relative; overflow: hidden; }
.stage-3d canvas { display: block; width: 100% !important; height: 100% !important; touch-action: pan-y; }
.stage-glow {
  position: absolute; left: 50%; bottom: 10%; width: 60%; aspect-ratio: 4 / 1; transform: translateX(-50%);
  border-radius: 50%; border: 2px solid rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.35), inset 0 0 30px rgba(34, 211, 238, 0.2);
  pointer-events: none;
}
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--dim); font-size: 0.9rem; }
.stage-hint { position: absolute; right: 16px; bottom: 12px; font-family: var(--mono); font-size: 0.72rem; color: var(--faint); pointer-events: none; }

/* ═══════════════════════════════════════════════════════════════════════
   LOADOUT — bot / gun / level / topic (04–07 / M04)
   ═══════════════════════════════════════════════════════════════════════ */
.pick-grid { flex: 1; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 28px; min-height: 0; }
.pick-stage { position: relative; min-height: 420px; }
.pick-stage .stage-3d { position: absolute; inset: 0; }
.pick-hero { position: relative; z-index: 2; pointer-events: none; max-width: 480px; }
.pick-hero .name { font-family: var(--display); font-weight: 700; font-size: clamp(3rem, 7vw, 6rem); line-height: 0.95; margin-top: 6px; }
.pick-hero p { color: var(--dim); margin-top: 8px; }
.hero-stats { position: absolute; left: 0; bottom: 0; z-index: 2; display: flex; gap: 36px; pointer-events: none; }
.hero-stats .label { margin-bottom: 4px; }
.hero-stats .v { font-family: var(--mono); font-weight: 700; font-size: 1.7rem; }

.pick-list { display: flex; flex-direction: column; gap: 10px; }
.pick-card {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  padding: 14px; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.pick-card:hover { border-color: var(--line-2); transform: translateX(-2px); }
.pick-card.sel { border: 2px solid var(--cyan); padding: 13px; box-shadow: 0 0 22px rgba(34, 211, 238, 0.22); background: linear-gradient(90deg, rgba(34, 211, 238, 0.06), transparent 60%), var(--panel); }
.pick-card .who { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.pick-card .who b { font-family: var(--display); font-size: 1.05rem; }
.pick-card .who small { font-size: 0.75rem; color: var(--dim); }
.pick-card .kbd { align-self: start; }
.avatar {
  width: 52px; height: 52px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--ink-deep);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.avatar.glyph { background: var(--ink); color: var(--cyan); box-shadow: inset 0 0 0 1px var(--line-2); font-family: var(--mono); }
.avatar.sm { width: 36px; height: 36px; font-size: 0.95rem; }

.foot {
  display: flex; align-items: center; gap: 16px;
  padding: 14px var(--gutter); padding-bottom: calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: rgba(10, 13, 28, 0.92); backdrop-filter: blur(6px);
  position: sticky; bottom: 0; z-index: 20;
}
.foot .spacer { flex: 1; }
.loadout-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--display); font-weight: 600; font-size: 0.75rem; letter-spacing: 0.12em; }
.loadout-line .label { margin-right: 6px; }
.loadout-line .set { color: var(--cyan); }
.loadout-line .set.amber { color: var(--amber); }
.loadout-line .unset { color: var(--faint); text-transform: lowercase; letter-spacing: 0.04em; }
.loadout-line .dot { color: var(--faint); }

/* level cards */
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.level-card {
  --hue: var(--green);
  position: relative; display: flex; flex-direction: column; gap: 12px; min-height: 280px;
  padding: 22px; text-align: left;
  background: linear-gradient(180deg, color-mix(in srgb, var(--hue) 14%, transparent), transparent 55%), var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.level-card.mid { --hue: var(--amber); }
.level-card.high { --hue: var(--magenta); }
.level-card:hover { border-color: color-mix(in srgb, var(--hue) 50%, var(--line)); }
.level-card.sel { border: 2px solid var(--hue); padding: 21px; box-shadow: 0 0 26px color-mix(in srgb, var(--hue) 30%, transparent); }
.level-card .eyebrow { color: var(--hue); }
.level-card .kbd { position: absolute; top: 18px; right: 18px; }
.level-card .name { font-family: var(--display); font-weight: 700; font-size: 2.6rem; line-height: 1; }
.level-card p { color: var(--dim); font-size: 0.92rem; }
.level-card .pts { margin-top: auto; display: flex; align-items: baseline; gap: 10px; }
.level-card .pts b { font-family: var(--mono); font-size: 3rem; color: var(--hue); line-height: 1; }
.level-card .pts span { font-family: var(--display); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.16em; color: var(--dim); }
.level-card .dashes { display: flex; gap: 5px; }
.level-card .dashes i { width: 16px; height: 3px; background: var(--hue); border-radius: 2px; }
.level-card .dashes i.off { background: var(--line-2); }
.timer-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding: 16px 20px; }
.timer-card b { font-family: var(--display); font-size: 0.8rem; letter-spacing: 0.14em; display: block; }
.timer-card span { font-size: 0.82rem; color: var(--dim); }

/* topic grid + loadout panel */
.topic-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 24px; align-content: start; }
.topic-card {
  display: flex; flex-direction: column; gap: 10px; min-height: 150px; padding: 18px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.topic-card:hover { border-color: var(--line-2); }
.topic-card.sel { border: 2px solid var(--cyan); padding: 17px; box-shadow: 0 0 22px rgba(34, 211, 238, 0.2); background: linear-gradient(180deg, rgba(34, 211, 238, 0.07), transparent 70%), var(--panel); }
.topic-card .avatar { width: 38px; height: 38px; font-size: 1rem; }
.topic-card.sel .avatar { background: var(--cyan); color: var(--ink-deep); box-shadow: none; }
.topic-card b { font-family: var(--display); font-size: 1.05rem; }
.topic-card span { font-size: 0.82rem; color: var(--dim); }
.loadout-panel { align-self: start; padding: 20px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 16px; }
.loadout-panel .label { margin-bottom: 10px; }
.lo-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lo-row:last-of-type { border-bottom: 0; }
.lo-row::before { content: ""; width: 3px; align-self: stretch; background: var(--cyan); border-radius: 2px; }
.lo-row.amber::before { background: var(--amber); }
.lo-row.unset::before { background: var(--line-2); }
.lo-row .k { font-family: var(--display); font-size: 0.6rem; letter-spacing: 0.16em; color: var(--dim); text-transform: uppercase; }
.lo-row .v { font-family: var(--display); font-weight: 700; font-size: 1rem; }
.lo-row .v.unset { color: var(--faint); font-weight: 500; }
.lo-row .edit { margin-left: auto; font-family: var(--display); font-weight: 700; font-size: 0.72rem; color: var(--cyan); padding: 8px 4px; }
.lo-row .edit:disabled { color: var(--faint); }
.loadout-panel .btn { margin-top: 14px; }
.host-note { font-size: 0.8rem; color: var(--dim); margin-top: 6px; }

/* ═══════════════════════════════════════════════════════════════════════
   QUIZ (08 / M05 / M11)
   ═══════════════════════════════════════════════════════════════════════ */
.quiz-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 18px var(--gutter) 0; padding-top: calc(18px + var(--safe-t)); }
.quiz-top .spacer { flex: 1; }
.stat-cards { display: flex; gap: 10px; }
.stat-card { min-width: 118px; padding: 9px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-card .label { font-size: 0.58rem; }
.stat-card .v { font-family: var(--mono); font-weight: 700; font-size: 1.45rem; line-height: 1.25; }
.stat-card.score .v { color: var(--amber); }
.stat-card.streak.hot { border-color: rgba(249, 115, 22, 0.6); background: rgba(249, 115, 22, 0.08); }
.stat-card.streak.hot .v { color: var(--power); }
.stat-card .v small { font-size: 0.7rem; margin-left: 4px; color: var(--amber); }
.timer-line { display: flex; align-items: center; gap: 18px; padding: 16px var(--gutter) 0; }
.timer-track { flex: 1; height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--cyan); border-radius: 6px; box-shadow: 0 0 12px rgba(34, 211, 238, 0.5); transition: width 0.1s linear, background 0.3s; }
.timer-fill.warn { background: var(--amber); box-shadow: 0 0 12px rgba(251, 191, 36, 0.5); }
.timer-fill.danger { background: var(--red); box-shadow: 0 0 12px rgba(239, 68, 68, 0.6); animation: pulse 0.6s ease infinite alternate; }
.timer-num { font-family: var(--mono); font-weight: 700; font-size: 1.4rem; min-width: 64px; text-align: right; }
.timer-num.danger { color: var(--red); }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.55; } }

.quiz-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 30px var(--gutter); padding-bottom: calc(30px + var(--safe-b)); min-height: 0; }
.q-block { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 100%; }
.q-label { font-family: var(--display); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.22em; color: var(--dim); text-transform: uppercase; }
.q-prompt {
  font-family: var(--mono); font-weight: 700; text-align: center; line-height: 1.1;
  font-size: clamp(2.4rem, 8vw, 7.5rem); max-width: 100%; overflow-wrap: anywhere;
}
.q-prompt.wordy { font-family: var(--body); font-weight: 700; font-size: clamp(1.3rem, 3.2vw, 2.75rem); line-height: 1.25; max-width: 1000px; }
.q-prompt.medium { font-size: clamp(2rem, 5.4vw, 4.8rem); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(980px, 100%); }
.option {
  display: flex; align-items: center; gap: 16px; min-height: 84px; padding: 0 22px; text-align: left;
  font-family: var(--mono); font-weight: 700; font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color 0.1s, background 0.1s, transform 0.1s, opacity 0.2s;
}
.option:hover:not(:disabled) { border-color: var(--cyan); transform: translateY(-2px); }
.option .kbd { flex-shrink: 0; }
.option .verdict { margin-left: auto; font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.16em; }
.option.correct { border: 2px solid var(--green); background: rgba(34, 197, 94, 0.1); box-shadow: 0 0 26px rgba(34, 197, 94, 0.25); }
.option.correct .verdict { color: var(--green); }
.option.correct .kbd { background: var(--green); color: var(--ink-deep); border-color: var(--green); }
.option.wrong { border: 2px solid var(--red); background: rgba(239, 68, 68, 0.08); animation: shake 0.3s; }
.option.wrong .verdict { color: var(--red); }
.option.dim { opacity: 0.4; }
.option:disabled { cursor: default; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.feedback { min-height: 58px; display: flex; align-items: center; justify-content: center; }
.fb-strip { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-radius: var(--radius); border: 1px solid; animation: framein 0.18s ease-out; }
.fb-strip.ok { border-color: rgba(34, 197, 94, 0.55); background: rgba(34, 197, 94, 0.08); }
.fb-strip.no { border-color: rgba(239, 68, 68, 0.55); background: rgba(239, 68, 68, 0.08); }
.fb-strip .big { font-family: var(--mono); font-weight: 700; font-size: 1.8rem; }
.fb-strip.ok .big { color: var(--green); }
.fb-strip.no .big { color: var(--red); font-size: 1.1rem; }
.fb-strip .part { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; padding: 3px 7px; border-radius: 3px; background: var(--ink); }
.fb-strip .part.spd { color: var(--amber); }
.fb-strip .part.stk { color: var(--power); }
.quiz-retry { display: flex; gap: 10px; justify-content: center; }

/* ═══════════════════════════════════════════════════════════════════════
   UPGRADE BAY (09 / M06)
   ═══════════════════════════════════════════════════════════════════════ */
.up-grid { flex: 1; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px; min-height: 0; }
.up-left { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.up-left .name { font-family: var(--display); font-weight: 700; font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1; }
.up-left .sub { margin-top: 0; }
.up-stage { position: relative; flex: 1; min-height: 300px; }
.up-stage .stage-3d { position: absolute; inset: 0; }
.derived { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.derived-cell { padding: 10px 10px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.derived-cell .label { font-size: 0.55rem; }
.derived-cell .v { font-family: var(--mono); font-weight: 700; font-size: 1.15rem; color: var(--cyan); }
.derived-cell .d { font-family: var(--mono); font-size: 0.68rem; color: var(--green); min-height: 1em; }
.up-right { display: flex; flex-direction: column; gap: 12px; }
.pool-card { padding: 16px 20px; border-color: rgba(251, 191, 36, 0.45); background: linear-gradient(90deg, rgba(251, 191, 36, 0.07), transparent 70%), var(--panel); }
.pool-card .row { display: flex; align-items: baseline; gap: 14px; }
.pool-card .v { font-family: var(--mono); font-weight: 700; font-size: 2.2rem; color: var(--amber); line-height: 1; }
.pool-card .of { margin-left: auto; font-family: var(--mono); font-size: 0.8rem; color: var(--dim); }
.pool-bar { height: 6px; margin-top: 12px; background: var(--line); border-radius: 4px; overflow: hidden; }
.pool-fill { height: 100%; width: 0; background: var(--amber); transition: width 0.2s; }
.stat-row {
  --sc: var(--speed);
  display: grid; grid-template-columns: 150px 1fr auto; gap: 18px; align-items: center;
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat-row[data-stat="power"] { --sc: var(--power); }
.stat-row[data-stat="strength"] { --sc: var(--strength); }
.stat-row[data-stat="frame"] { --sc: var(--frame); }
.stat-row .nm { display: flex; flex-direction: column; gap: 2px; }
.stat-row .nm b { font-family: var(--display); font-size: 0.95rem; letter-spacing: 0.08em; display: flex; align-items: center; gap: 8px; }
.stat-row .nm b::before { content: ""; width: 9px; height: 9px; background: var(--sc); border-radius: 2px; }
.stat-row .nm span { font-size: 0.75rem; color: var(--dim); }
.pips-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pips { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.pip { height: 18px; border-radius: 2px; background: var(--line); }
.pip.base { background: color-mix(in srgb, var(--sc) 45%, var(--line)); }
.pip.bought { background: var(--sc); box-shadow: 0 0 10px color-mix(in srgb, var(--sc) 55%, transparent); }
.pip.next { background: transparent; box-shadow: inset 0 0 0 2px var(--sc); }
.pip.pop { animation: pippop 0.3s ease-out; }
@keyframes pippop { 0% { transform: scaleY(1.6); } 100% { transform: none; } }
.pips-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.7rem; color: var(--dim); }
.pips-meta .plus { color: var(--green); margin-left: 6px; }
.pips-meta .next b { color: var(--amber); }
.steppers { display: flex; gap: 8px; }
.step-btn {
  width: 52px; height: 52px; display: grid; place-items: center; gap: 0;
  font-family: var(--mono); font-weight: 700; font-size: 1.3rem; line-height: 1;
  background: var(--ink); border: 1px solid var(--line-2); border-radius: var(--radius);
}
.step-btn.plus { background: var(--sc); color: var(--ink-deep); border-color: var(--sc); }
.step-btn.plus small { display: block; font-size: 0.55rem; margin-top: 2px; }
.step-btn:disabled { opacity: 0.3; }
.up-actions { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 10px; margin-top: 4px; }
.locked-note { font-size: 0.85rem; font-weight: 600; color: var(--green); text-align: center; padding: 4px 0; }

/* ═══════════════════════════════════════════════════════════════════════
   ARENA (10 / M01 / M02 / M10) — full-bleed, no page chrome
   ═══════════════════════════════════════════════════════════════════════ */
body.scene-arena { overflow: hidden; }
.arena {
  position: fixed; inset: 0; z-index: 10;
  background: var(--ink-deep);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.arena-canvas { position: absolute; inset: 0; }
.arena-canvas canvas { display: block; width: 100%; height: 100%; }
.arena-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); z-index: 4; }

.ahud-top {
  position: absolute; z-index: 5; top: calc(14px + var(--safe-t)); left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r));
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: start; pointer-events: none;
}
.fighter-card { padding: 10px 14px; background: rgba(10, 13, 28, 0.82); border: 1px solid var(--line-2); border-radius: var(--radius); }
.fighter-card .who { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.fighter-card .who b { font-family: var(--display); font-weight: 700; font-size: 0.9rem; letter-spacing: 0.1em; }
.fighter-card .who small { font-size: 0.72rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fighter-card .who .pct { margin-left: auto; font-family: var(--mono); font-weight: 700; font-size: 0.85rem; }
.fighter-card.you .who b { color: var(--cyan); }
.fighter-card.foe { text-align: right; }
.fighter-card.foe .who { flex-direction: row-reverse; }
.fighter-card.foe .who .pct { margin-left: 0; margin-right: auto; }
.fighter-card.foe .who b { color: var(--magenta); }
.hpbar { position: relative; height: 12px; background: rgba(30, 37, 72, 0.9); border-radius: 2px; overflow: hidden; }
.hpbar .hp { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; background: var(--cyan); transition: width 0.2s ease; }
.hpbar .hp.foe { left: auto; right: 0; background: var(--magenta); }
.hpbar .hp.low { animation: pulse 0.5s ease infinite alternate; }
.hpbar .ticks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(5, 7, 14, 0.85) calc(10% - 2px) 10%); }
.clock-card { min-width: 118px; padding: 8px 14px; text-align: center; background: rgba(10, 13, 28, 0.88); border: 1px solid var(--line-2); border-radius: var(--radius); }
.clock-card .t { font-family: var(--mono); font-weight: 700; font-size: 1.9rem; line-height: 1.1; }
.clock-card .t.danger { color: var(--red); }
.clock-card .label { font-size: 0.52rem; }
.clock-wrap { display: flex; gap: 8px; align-items: flex-start; }
.pause-btn {
  pointer-events: auto; width: 44px; height: 44px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; background: rgba(10, 13, 28, 0.88); border: 1px solid var(--line-2); border-radius: var(--radius);
}

.overheat-banner {
  position: absolute; z-index: 6; left: 50%; top: calc(96px + var(--safe-t)); transform: translateX(-50%);
  padding: 8px 18px; font-family: var(--display); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.14em; color: var(--red);
  background: rgba(40, 8, 14, 0.85); border: 1px solid var(--red); border-radius: var(--radius); white-space: nowrap; pointer-events: none;
  animation: pulse 0.35s ease infinite alternate;
}
.camp-banner {
  position: absolute; z-index: 6; left: 50%; top: calc(140px + var(--safe-t)); transform: translateX(-50%);
  padding: 9px 18px; font-family: var(--display); font-weight: 700; font-size: 0.9rem; letter-spacing: 0.1em; color: var(--amber);
  background: rgba(40, 28, 6, 0.9); border: 1px solid var(--amber); border-radius: var(--radius); white-space: nowrap; pointer-events: none;
}
.camp-banner.recovering { color: var(--green); border-color: var(--green); background: rgba(6, 40, 20, 0.9); }
.camp-banner.draining { color: var(--red); border-color: var(--red); background: rgba(40, 8, 14, 0.9); animation: pulse 0.35s ease infinite alternate; }
.camp-note { font-size: 0.85rem; color: var(--amber); margin: -4px 0 10px; }
.camp-note.foe { color: var(--dim); }
@media (max-height: 520px) { .camp-banner { top: calc(92px + var(--safe-t)); font-size: 0.72rem; padding: 6px 12px; } }
.overheat-banner .kbd { color: var(--ink); background: var(--red); border-color: var(--red); height: 20px; margin: 0 4px; }

.ahud-bottom-left {
  position: absolute; z-index: 5; left: calc(16px + var(--safe-l)); bottom: calc(16px + var(--safe-b));
  width: min(300px, 40vw); padding: 12px 14px; background: rgba(10, 13, 28, 0.82); border: 1px solid var(--line-2); border-radius: var(--radius); pointer-events: none;
}
.meter-head { display: flex; justify-content: space-between; font-family: var(--display); font-weight: 700; font-size: 0.62rem; letter-spacing: 0.16em; margin-bottom: 5px; }
.meter-head .k.heat { color: var(--red); }
.meter-head .k.dash { color: var(--cyan); }
.meter-head .v { font-family: var(--mono); }
.meter-head .v.ready { color: var(--green); }
.heat-pips { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; margin-bottom: 10px; }
.heat-pips i { height: 9px; background: var(--line); border-radius: 1px; }
.heat-pips i.on { background: var(--cyan); }
.heat-pips i.on.amber { background: var(--amber); }
.heat-pips i.on.red { background: var(--red); }
.dash-bar { height: 7px; background: var(--line); border-radius: 3px; overflow: hidden; }
.dash-bar div { height: 100%; background: var(--cyan); box-shadow: 0 0 10px rgba(34, 211, 238, 0.6); }

.key-legend {
  position: absolute; z-index: 5; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b));
  display: flex; gap: 8px; padding: 10px 12px; background: rgba(10, 13, 28, 0.82); border: 1px solid var(--line-2); border-radius: var(--radius);
}
.key-legend .k { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.key-legend .k .kbd { min-width: 46px; height: 28px; color: var(--text); }
.key-legend .k span { font-family: var(--display); font-size: 0.5rem; letter-spacing: 0.14em; color: var(--dim); }
.key-legend.small { padding: 0; }
.key-legend.small > .k { display: none; }
.key-legend .help { display: none; width: 40px; height: 40px; font-family: var(--mono); font-weight: 700; color: var(--dim); }
.key-legend.small .help { display: grid; place-items: center; }

.arena-fx { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; transform: translate(-50%, -100%);
  font-family: var(--mono); font-weight: 700; font-size: 1.35rem; color: #fff; white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}
.floater.head { color: var(--amber); }
.floater.head small { display: block; font-family: var(--display); font-size: 0.6rem; letter-spacing: 0.14em; text-align: center; }
.floater.foe-hit { color: var(--red); }

.crosshair { position: absolute; z-index: 4; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none; display: none; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: rgba(255, 255, 255, 0.85); }
.crosshair::before { left: 12px; top: 0; width: 2px; height: 26px; }
.crosshair::after { top: 12px; left: 0; height: 2px; width: 26px; }
.crosshair.on-target::before, .crosshair.on-target::after { background: var(--magenta); }

.arena-msg {
  position: absolute; inset: 0; z-index: 7;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(5, 7, 14, 0.6);
  font-family: var(--display); font-weight: 700; text-align: center;
  animation: framein 0.3s ease-out;
}
.arena-msg .big { font-size: clamp(3rem, 12vw, 7rem); line-height: 1; }
.arena-msg .big.win { color: var(--green); text-shadow: 0 0 40px rgba(34, 197, 94, 0.5); }
.arena-msg .big.loss { color: var(--red); text-shadow: 0 0 40px rgba(239, 68, 68, 0.5); }
.arena-msg .big.draw { color: var(--amber); }
.arena-msg .small { font-size: 0.85rem; letter-spacing: 0.22em; color: var(--dim); }
.arena-intro .big { color: var(--text); }

/* Pause menu */
.pause-menu { width: min(460px, 100%); }
.pause-menu h2 { font-family: var(--display); font-weight: 700; font-size: 1.6rem; margin-bottom: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row b { font-family: var(--display); font-size: 0.9rem; }
.set-row span { display: block; font-size: 0.78rem; color: var(--dim); }
.set-row input[type="range"] { width: 140px; accent-color: var(--cyan); }
.toggle { width: 52px; height: 30px; border-radius: 30px; background: var(--line-2); position: relative; flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--text); transition: transform 0.15s; }
.toggle.on { background: var(--cyan); }
.toggle.on::after { transform: translateX(22px); background: var(--ink); }
.pause-actions { display: grid; gap: 10px; margin-top: 18px; }

/* Touch controls (twin-stick). Right-handed by default; `.lefty` mirrors the
   button cluster (each button is flipped back so its label still reads). */
.touch-ui {
  --ring: clamp(130px, 26vmin, 210px);
  --ab: clamp(56px, 11vmin, 84px);
  --r0: calc(3vw + var(--safe-r));
  --b0: calc(3vh + 24px + var(--safe-b)); /* room for the caption under the ring */
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
}
html:not(.input-touch) .touch-ui { display: none; }
.move-zone { position: absolute; top: 0; bottom: 0; left: 0; width: 40%; pointer-events: auto; touch-action: none; }
.touch-ui.lefty .move-zone { left: auto; right: 0; }
.cluster { position: absolute; inset: 0; pointer-events: none; }
.touch-ui.lefty .cluster { transform: scaleX(-1); }
.touch-ui.lefty .fire-ring, .touch-ui.lefty .act-btn { transform: scaleX(-1); }
.touch-ui.lefty .act-btn.pressed { transform: scaleX(-1) scale(0.92); }
.stick {
  --size: clamp(120px, 24vmin, 200px);
  position: absolute; width: var(--size); height: var(--size); margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
  border-radius: 50%; border: 2px solid rgba(231, 234, 246, 0.25); background: rgba(10, 13, 28, 0.35);
  pointer-events: none; opacity: var(--ctl-opacity, 0.9); z-index: 2;
}
.stick .knob {
  position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; margin: -21% 0 0 -21%;
  border-radius: 50%; background: var(--cyan); box-shadow: 0 0 20px rgba(34, 211, 238, 0.6);
}
.stick-label { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-family: var(--display); font-weight: 700; font-size: 0.6rem; letter-spacing: 0.18em; color: var(--dim); white-space: nowrap; }
.fire-ring {
  position: absolute; right: var(--r0); bottom: var(--b0);
  width: var(--ring); height: var(--ring); border-radius: 50%;
  pointer-events: auto; opacity: var(--ctl-opacity, 0.9); touch-action: none;
}
.fire-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.fire-ring .core {
  position: absolute; left: 50%; top: 50%; width: 46%; height: 46%; transform: translate(-50%, -50%);
  display: grid; place-items: center; border-radius: 50%;
  font-family: var(--display); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.12em; color: #fff;
  background: var(--red); box-shadow: 0 0 26px rgba(239, 68, 68, 0.55);
  transition: transform 0.06s;
}
.fire-ring.active .core { transform: translate(calc(-50% + var(--ax, 0px)), calc(-50% + var(--ay, 0px))) scale(0.94); }
.fire-ring.locked .core { background: var(--line-2); box-shadow: none; color: var(--dim); }
.fire-ring .caption { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-family: var(--display); font-weight: 700; font-size: 0.58rem; letter-spacing: 0.16em; color: var(--dim); white-space: nowrap; }
.act-btn {
  position: absolute; width: var(--ab); height: var(--ab); border-radius: 50%;
  display: grid; place-items: center; text-align: center; line-height: 1.1; pointer-events: auto; touch-action: none;
  font-family: var(--display); font-weight: 700; font-size: 0.7rem; letter-spacing: 0.08em;
  background: rgba(10, 13, 28, 0.75); border: 2px solid var(--line-2); color: var(--text);
  opacity: var(--ctl-opacity, 0.9);
}
/* 16px+ gaps between controls so palms don't mis-fire */
.act-btn.jump { right: calc(var(--r0) + var(--ring) + 16px); bottom: var(--b0); }
.act-btn.dash { right: calc(var(--r0) + var(--ring) + 4px); bottom: calc(var(--b0) + var(--ab) + 18px); }
.act-btn.vent { right: calc(var(--r0) + var(--ring) * 0.3); bottom: calc(var(--b0) + var(--ring) + 16px); }
.act-btn svg { position: absolute; inset: -2px; width: calc(100% + 4px); height: calc(100% + 4px); transform: rotate(-90deg); pointer-events: none; }
.act-btn .cd { font-family: var(--mono); font-size: 0.66rem; color: var(--cyan); }
.act-btn.pressed { transform: scale(0.92); background: rgba(34, 211, 238, 0.2); }
.act-btn.dash { border-color: rgba(34, 211, 238, 0.35); color: var(--cyan); }
.act-btn.dash.cooling { color: var(--dim); }
.act-btn.vent { border-color: rgba(251, 191, 36, 0.6); color: var(--amber); }
.act-btn.vent.hot { animation: ventpulse 0.5s ease infinite alternate; }
@keyframes ventpulse { from { box-shadow: 0 0 0 rgba(251, 191, 36, 0); } to { box-shadow: 0 0 22px rgba(251, 191, 36, 0.7); } }

.pause-btn { display: none; }
html.input-touch .pause-btn { display: grid; }
html.input-touch .ahud-bottom-left { display: none; }

/* First-fight training bubble */
.tut-bubble {
  position: absolute; z-index: 6; left: 50%; top: calc(100px + var(--safe-t)); transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); padding: 12px 16px 12px 18px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  background: rgba(18, 23, 49, 0.94); border: 1px solid var(--cyan); border-radius: var(--radius);
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.25); font-size: 1rem; line-height: 1.5;
}
.tut-bubble .label { grid-column: 1; color: var(--cyan); }
.tut-bubble div { grid-column: 1; }
.tut-bubble .kbd { color: var(--text); margin: 0 2px; vertical-align: 1px; }
.tut-bubble .tut-skip { grid-column: 2; grid-row: 1 / span 2; font-family: var(--display); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.12em; color: var(--dim); padding: 10px; }
.tut-bubble.pop { animation: tutpop 0.25s ease-out; }
@keyframes tutpop { 0% { transform: translateX(-50%) scale(1.06); border-color: var(--green); } 100% { transform: translateX(-50%); } }
@media (max-height: 500px) { .tut-bubble { top: calc(72px + var(--safe-t)); font-size: 0.88rem; padding: 8px 12px; } }

.rotate-prompt {
  position: absolute; inset: 0; z-index: 30; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 30px; text-align: center;
  background: radial-gradient(circle at 50% 40%, rgba(34, 211, 238, 0.12), transparent 60%), var(--ink-deep);
}
.rotate-prompt .phone-ico {
  width: 64px; height: 100px; border: 3px solid var(--cyan); border-radius: 12px; box-shadow: 0 0 24px rgba(34, 211, 238, 0.4);
  animation: tilt 2s ease-in-out infinite;
}
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
.rotate-prompt h2 { font-family: var(--display); font-weight: 700; font-size: 1.7rem; }
.rotate-prompt p { color: var(--dim); max-width: 300px; }
.rotate-prompt .tag { margin-top: 6px; }
@media (orientation: portrait) and (max-width: 599px) {
  html.input-touch .rotate-prompt { display: flex; }
}

/* ═══════════════════════════════════════════════════════════════════════
   RESULT (11 / M07)
   ═══════════════════════════════════════════════════════════════════════ */
.result-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 50px var(--gutter) 24px; gap: 8px; }
.result-wrap.win { background: radial-gradient(700px 300px at 50% 0%, rgba(34, 197, 94, 0.16), transparent 70%); }
.result-wrap.loss { background: radial-gradient(700px 300px at 50% 0%, rgba(239, 68, 68, 0.14), transparent 70%); }
.result-wrap.draw { background: radial-gradient(700px 300px at 50% 0%, rgba(251, 191, 36, 0.13), transparent 70%); }
.outcome { font-family: var(--display); font-weight: 700; line-height: 1; font-size: clamp(3.6rem, 13vw, 9rem); }
.outcome.win { color: var(--green); text-shadow: 0 0 60px rgba(34, 197, 94, 0.45); }
.outcome.loss { color: var(--red); text-shadow: 0 0 60px rgba(239, 68, 68, 0.4); }
.outcome.draw { color: var(--amber); text-shadow: 0 0 60px rgba(251, 191, 36, 0.35); }
.result-wrap .eyebrow.win { color: var(--green); }
.result-wrap .eyebrow.loss { color: var(--red); }
.result-wrap .eyebrow.draw { color: var(--amber); }
.result-line { color: var(--dim); margin-bottom: 30px; text-align: center; }
.result-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: min(1000px, 100%); }
.result-card { padding: 20px 22px; }
.duel-head { display: flex; justify-content: space-between; margin-bottom: 18px; }
.duel-head .v { font-family: var(--mono); font-weight: 700; }
.duel-row { display: grid; grid-template-columns: 90px 1fr 48px; gap: 12px; align-items: center; margin-bottom: 14px; }
.duel-row b { font-family: var(--display); font-size: 0.85rem; letter-spacing: 0.1em; }
.duel-row.you b { color: var(--cyan); }
.duel-row.foe b { color: var(--magenta); }
.duel-row .track { height: 10px; background: var(--line); border-radius: 2px; overflow: hidden; }
.duel-row .track div { height: 100%; }
.duel-row.you .track div { background: var(--cyan); }
.duel-row.foe .track div { background: var(--magenta); }
.duel-row .pct { font-family: var(--mono); font-weight: 700; text-align: right; }
.duel-loadouts { font-size: 0.8rem; color: var(--dim); }
.breakdown.result-card { border-color: rgba(251, 191, 36, 0.45); }
.bd-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 0.92rem; }
.bd-row small { color: var(--dim); }
.bd-row .v { font-family: var(--mono); font-weight: 700; }
.bd-row .v.good { color: var(--green); }
.bd-total { display: flex; align-items: flex-end; justify-content: space-between; border-top: 1px solid var(--line-2); margin-top: 8px; padding-top: 14px; }
.bd-total .v { font-family: var(--mono); font-weight: 700; font-size: 2.8rem; color: var(--amber); line-height: 1; }
.bd-rank { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 0.82rem; color: var(--dim); flex-wrap: wrap; }
.result-actions { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 12px; width: min(1000px, 100%); margin-top: 26px; }
.standings { width: min(1000px, 100%); margin-top: 16px; padding: 18px 22px; }
.st-row { display: grid; grid-template-columns: 34px 1fr auto 90px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.st-row:last-child { border-bottom: 0; }
.st-row.me { color: var(--cyan); }
.st-row .rk { font-family: var(--mono); font-weight: 700; color: var(--dim); }
.st-row .nm { font-family: var(--mono); font-weight: 700; }
.st-row .sc { font-family: var(--mono); font-weight: 700; text-align: right; }

/* ═══════════════════════════════════════════════════════════════════════
   LEADERBOARD (12 / M08)
   ═══════════════════════════════════════════════════════════════════════ */
.lb-filters { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.lb-filters .levels { display: flex; gap: 6px; }
.lb-layout { flex: 1; display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
.podium { display: flex; flex-direction: column; gap: 12px; }
.pod {
  --pc: var(--amber);
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px; padding: 18px 20px;
  border: 1px solid color-mix(in srgb, var(--pc) 60%, transparent); border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc) 16%, transparent), transparent 80%), var(--panel);
}
.pod.p2 { --pc: #cbd5e1; }
.pod.p3 { --pc: var(--power); }
.pod.me { box-shadow: 0 0 0 2px var(--cyan); }
.pod .rk { font-family: var(--mono); font-weight: 700; font-size: 2.2rem; color: var(--pc); }
.pod b { font-family: var(--mono); font-size: 1.05rem; display: block; }
.pod small { font-size: 0.76rem; color: var(--dim); }
.pod .sc { font-family: var(--mono); font-weight: 700; font-size: 1.5rem; color: var(--pc); }
.lb-table { overflow: hidden; }
.lb-head, .lb-row { display: grid; grid-template-columns: 44px minmax(0, 1.4fr) 0.9fr 0.8fr 1.1fr 60px 90px; gap: 10px; align-items: center; padding: 0 18px; }
.lb-head { height: 42px; border-bottom: 1px solid var(--line); }
.lb-head span { font-family: var(--display); font-weight: 600; font-size: 0.6rem; letter-spacing: 0.16em; color: var(--dim); }
.lb-head span:last-child, .lb-row .sc { text-align: right; }
.lb-row { min-height: 50px; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.lb-row .rk { font-family: var(--mono); color: var(--dim); }
.lb-row .nm { font-family: var(--mono); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lv { font-family: var(--display); font-weight: 700; font-size: 0.7rem; letter-spacing: 0.12em; }
.lb-row .lv.junior { color: var(--green); }
.lb-row .lv.mid { color: var(--amber); }
.lb-row .lv.high { color: var(--magenta); }
.lb-row .win { font-family: var(--display); font-weight: 700; font-size: 0.72rem; color: var(--green); }
.lb-row .win.none { color: var(--faint); }
.lb-row .sc { font-family: var(--mono); font-weight: 700; }
.lb-row.me { background: rgba(34, 211, 238, 0.08); box-shadow: inset 3px 0 0 var(--cyan); }
.lb-row.me .nm { color: var(--cyan); }
.lb-row.pinned { position: sticky; bottom: 0; background: #0f2233; }
.lb-row .detail { display: none; }
.lb-empty { padding: 50px 20px; text-align: center; color: var(--dim); }

/* ═══════════════════════════════════════════════════════════════════════
   LOBBY (02 / 03 / M09)
   ═══════════════════════════════════════════════════════════════════════ */
.live { display: inline-flex; align-items: center; gap: 7px; font-family: var(--display); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.1em; color: var(--green); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1s ease infinite alternate; }
.live.off { color: var(--amber); }
.live.off::before { background: var(--amber); box-shadow: none; }
.lobby-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }
.code-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 10px 0 30px; }
.code-row .copy { min-height: 44px; padding: 0 16px; font-family: var(--display); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.12em; border: 1px solid var(--line-2); border-radius: var(--radius); }
.ninjas-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.ninjas-head .v { font-family: var(--mono); font-weight: 700; letter-spacing: 0.2em; }
.ninjas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.ninja { display: flex; align-items: center; gap: 14px; padding: 14px; }
.ninja.me { border-color: var(--cyan); background: linear-gradient(90deg, rgba(34, 211, 238, 0.08), transparent), var(--panel); }
.ninja .who { flex: 1; min-width: 0; }
.ninja .who b { display: block; font-family: var(--mono); font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ninja.me .who b { color: var(--cyan); }
.ninja .who small { font-size: 0.75rem; color: var(--dim); }
.ninja.open { border-style: dashed; background: transparent; }
.ninja.open .avatar { background: var(--panel-2); color: var(--faint); }
.ninja.open .who b { color: var(--faint); }
.settings-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.settings-card .head { display: flex; justify-content: space-between; align-items: center; }
.settings-card .body { display: flex; flex-direction: column; gap: 16px; }
.settings-card .head b { font-family: var(--display); font-size: 0.9rem; letter-spacing: 0.12em; }
.settings-card .seg { display: flex; }
.settings-card .seg button { flex: 1; min-width: 0; }
.settings-card .note { font-size: 0.82rem; color: var(--dim); }
.settings-card .note b { color: var(--text); }
.topic-select {
  width: 100%; height: 46px; padding: 0 12px; font-family: var(--display); font-weight: 600;
  background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
}
.settings-summary { display: none; }
.lobby-wait { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 0.9rem; }
.join-panel { max-width: 560px; margin: 40px auto 0; width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════
   BOT BRAIN — picture rules (When → Do), simple enough for a 5-year-old
   ═══════════════════════════════════════════════════════════════════════ */
.brain-page { width: min(760px, 100%); margin: 0 auto; }
.brain-ed { display: flex; flex-direction: column; gap: 10px; }
.brain-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.brain-title { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.5rem; }
.brain-title svg { color: var(--cyan); font-size: 1.3em; }
.brain-hint { font-family: var(--display); font-weight: 600; font-size: 0.75rem; letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; }
.brain-rules { display: flex; flex-direction: column; gap: 10px; }
.brain-rule {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 1.05rem; text-align: left; width: 100%;
}
.brain-rule .n { width: 26px; height: 26px; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 0.8rem; color: var(--dim); border: 1px solid var(--line-2); border-radius: 3px; flex-shrink: 0; }
.brain-rule .w { font-weight: 700; }
.brain-rule .arrow { color: var(--dim); font-weight: 700; }
.chip.when, .chip.do {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px;
  font-family: var(--body); font-weight: 700; font-size: 1rem; letter-spacing: 0; text-transform: none; border-radius: 999px;
}
.chip.when { color: var(--cyan); border-color: rgba(34, 211, 238, 0.5); background: rgba(34, 211, 238, 0.1); }
.chip.do { color: var(--green); border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.1); }
.chip.when svg, .chip.do svg { font-size: 1.5em; }
button.chip.when:hover, button.chip.do:hover { filter: brightness(1.2); }
.rule-tools { margin-left: auto; display: flex; gap: 6px; }
.mini { width: 36px; height: 36px; display: grid; place-items: center; font-weight: 700; border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--dim); background: var(--ink); }
.mini:hover:not(:disabled) { color: var(--text); border-color: var(--cyan); }
.mini:disabled { opacity: 0.3; }
.mini.del:hover { border-color: var(--red); color: var(--red); }
.rule-meta { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px 18px; padding-left: 36px; font-size: 0.8rem; color: var(--dim); }
.dots { display: inline-flex; align-items: center; gap: 4px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); display: inline-block; }
.dots i.on { background: var(--amber); }
.brain-rule.empty { justify-content: flex-start; color: var(--dim); border-style: dashed; background: transparent; font-weight: 600; min-height: 58px; }
.brain-rule.empty:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.brain-rule.empty:disabled { opacity: 0.4; }
.brain-rule.fallback { border-style: dashed; background: transparent; }
.brain-note { font-size: 0.8rem; color: var(--dim); }
.brain-tools { display: flex; justify-content: flex-end; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 8px; }
.preset { display: flex; flex-direction: column; gap: 6px; padding: 16px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.preset:hover { border-color: var(--cyan); }
.preset b { font-family: var(--display); font-size: 1.2rem; }
.preset > span { font-size: 0.88rem; color: var(--dim); }
.preset > .preset-rules { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; color: var(--cyan); font-size: 1.15rem; }
.preset-rules span { display: inline-flex; align-items: center; gap: 4px; }
.preset.blank { border-style: dashed; }
.learn-more { margin-top: 14px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.learn-more summary { cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.08em; color: var(--amber); }
.learn-more ul { margin: 12px 0 14px 18px; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; color: var(--dim); }
.learn-more ul b { color: var(--text); }
.learn-more i { color: var(--amber); font-style: normal; }
.py { margin-top: 8px; padding: 12px 14px; background: var(--ink-deep); border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--mono); font-size: 0.78rem; line-height: 1.6; white-space: pre; overflow-x: auto; color: var(--text); }

/* picture picker sheet */
.pic-sheet { max-width: 720px; }
.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pic {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 112px; padding: 12px 8px; text-align: center; font-weight: 700; font-size: 0.98rem;
  background: var(--ink); border: 1px solid var(--line-2); border-radius: var(--radius);
}
.pic .ico { font-size: 2.2rem; line-height: 1; }
.pic .ico.when { color: var(--cyan); }
.pic .ico.do { color: var(--green); }
.pic:hover:not(.blocked) { border-color: var(--cyan); transform: translateY(-2px); }
.pic.cur { border: 2px solid var(--cyan); }
.pic.blocked { opacity: 0.4; }
.pic .why { position: absolute; top: 6px; right: 8px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; background: var(--amber); color: var(--ink-deep); }
.pic-warn { margin-top: 12px; padding: 12px 14px; font-weight: 600; line-height: 1.45; color: var(--amber); background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.5); border-radius: var(--radius); }
.brain-modal { width: min(820px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }

/* in-fight reflex label + result debrief */
.reflex-flash {
  position: absolute; z-index: 6; left: 50%; bottom: calc(26% + var(--safe-b)); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; white-space: nowrap; pointer-events: none;
  font-family: var(--display); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.08em; color: var(--green);
  background: rgba(10, 13, 28, 0.88); border: 1px solid rgba(34, 197, 94, 0.6); border-radius: 999px;
  animation: reflexpop 0.9s ease-out forwards;
}
.reflex-flash svg { font-size: 1.2em; }
.reflex-flash .rn { color: var(--dim); }
@keyframes reflexpop { 0% { opacity: 0; transform: translateX(-50%) translateY(8px); } 15% { opacity: 1; transform: translateX(-50%); } 75% { opacity: 1; } 100% { opacity: 0; } }
#brain-box { width: min(1000px, 100%); }
#brain-box > .panel { width: 100%; }
.brain-debrief { width: min(1000px, 100%); margin-top: 16px; padding: 18px 22px; }
.brain-debrief .duel-head { margin-bottom: 10px; }
.moment { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.moment:last-child { border-bottom: 0; }
.moment .t { font-family: var(--mono); font-size: 0.78rem; color: var(--dim); min-width: 44px; }
.moment .say { flex: 1; min-width: 200px; }
.moment .verdict { font-size: 0.8rem; font-weight: 700; }
.moment .verdict.good { color: var(--green); }
.moment .verdict.bad { color: var(--amber); }
.thumbs { display: flex; gap: 6px; }
.thumb { width: 44px; height: 40px; font-size: 1.1rem; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--ink); }
.thumb.picked { border-color: var(--cyan); background: rgba(34, 211, 238, 0.15); }
.brain-nudge { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; width: min(1000px, 100%); margin-top: 16px; padding: 18px 22px; border-color: rgba(34, 211, 238, 0.5); background: linear-gradient(90deg, rgba(34, 211, 238, 0.08), transparent), var(--panel); }
.brain-nudge .ico { font-size: 2.2rem; color: var(--cyan); display: grid; }
.brain-nudge .txt { flex: 1; min-width: 200px; }
.brain-nudge b { font-family: var(--display); font-size: 1.1rem; display: block; }
.brain-nudge span { color: var(--dim); font-size: 0.9rem; }
.up-brain { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 0.9rem; color: var(--dim); }
.up-brain svg { color: var(--cyan); font-size: 1.4rem; }
.up-brain b { color: var(--text); }
.up-brain .link-amber { margin-left: auto; color: var(--cyan); }

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE — tablet (600–1023) and phone (<600)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1180px) {
  .step .lbl { display: none; }
  .step-sep { width: 10px; }
}

@media (max-width: 1023px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
  .home-stage { order: -1; height: 38vh; min-height: 240px; }
  .home-hero { max-width: none; }
  .home-steps { grid-template-columns: repeat(3, 1fr); }
  .home-steps .home-best { grid-column: 1 / -1; }

  .pick-grid { grid-template-columns: minmax(0, 1fr); }
  .pick-stage { min-height: 42vh; }
  .pick-list { display: grid; grid-template-columns: 1fr 1fr; }

  .topic-layout { grid-template-columns: minmax(0, 1fr); }
  .loadout-panel { position: static; }

  .up-grid { grid-template-columns: minmax(0, 1fr); }
  .up-stage { min-height: 280px; }

  .lb-layout { grid-template-columns: minmax(0, 1fr); }
  .podium { display: grid; grid-template-columns: repeat(3, 1fr); }
  .pod { grid-template-columns: auto 1fr; }
  .pod .sc { grid-column: 1 / -1; }

  .lobby-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .level-grid { grid-template-columns: 1fr; }
  .level-card { min-height: 0; }
  .level-card .pts b { font-size: 2.2rem; }
  .result-cards { grid-template-columns: 1fr; }
  .result-actions { grid-template-columns: 1fr 1fr; }
  .result-actions .btn-primary { grid-column: 1 / -1; order: -1; }
  .lb-head { display: none; }
  .lb-row { grid-template-columns: 36px 1fr auto; row-gap: 2px; padding: 10px 14px; }
  .lb-row .bot, .lb-row .lv, .lb-row .tp, .lb-row .win { display: none; }
  .lb-row .detail { display: block; grid-column: 2; font-size: 0.72rem; color: var(--dim); }
  .lb-row .sc { grid-row: 1 / span 2; grid-column: 3; }
  .podium { grid-template-columns: 1fr; }
  .pod { grid-template-columns: 44px 1fr auto; }
  .pod .sc { grid-column: auto; }
}

@media (max-width: 599px) {
  :root { --gutter: 16px; }
  .stepper .step, .stepper .step-sep { display: none; }
  .step-compact { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
  .step-compact .label { font-size: 0.6rem; }
  .step-compact b { font-family: var(--display); font-size: 1.05rem; }
  .step-segs { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
  .step-segs i { height: 3px; border-radius: 2px; background: var(--line-2); }
  .step-segs i.done { background: var(--cyan-deep); }
  .step-segs i.now { background: var(--cyan); }
  .topnav .name-chip { display: none; }
  .topnav { gap: 12px; }

  .home-top .school { display: none; }
  .home-title { font-size: 3.4rem; margin-bottom: 10px; }
  .home-steps { display: none; }
  .home-mini { display: flex !important; }
  .home-grid { padding-top: 10px; }
  .home-hero { padding-bottom: calc(20px + var(--safe-b)); }

  .frame-body { padding-top: 16px; }
  .pick-stage { min-height: 36vh; }
  .pick-hero .name { font-size: 2.8rem; }
  .hero-stats { gap: 22px; }
  .hero-stats .v { font-size: 1.3rem; }
  .pick-list { display: flex; flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; padding-bottom: 4px; }
  .pick-list .pick-card { flex: 0 0 auto; width: 88px; grid-template-columns: 1fr; justify-items: center; gap: 6px; padding: 10px 6px; scroll-snap-align: start; text-align: center; }
  .pick-list .pick-card.sel { padding: 9px 5px; }
  .pick-list .pick-card .bars, .pick-list .pick-card .kbd, .pick-list .pick-card .who small { display: none; }
  .pick-list .pick-card .who { margin: 0; justify-content: center; }
  .pick-list .pick-card .who b { font-size: 0.78rem; }
  .pick-list .avatar { width: 40px; height: 40px; font-size: 1rem; }
  .pick-detail { display: block !important; }
  .foot .loadout-line { display: none; }
  .foot .btn { flex: 1; }
  .foot .spacer { display: none; }

  .topic-grid { grid-template-columns: 1fr 1fr; }
  .topic-card { min-height: 0; }

  .quiz-top { gap: 8px; }
  .quiz-top .tags { display: none; }
  .stat-cards { width: 100%; }
  .stat-card { flex: 1; min-width: 0; padding: 8px 10px; }
  .stat-card .v { font-size: 1.2rem; }
  .quiz-main { justify-content: flex-start; padding-top: 20px; }
  .q-block { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; width: 100%; }
  .q-prompt { font-size: clamp(2.4rem, 13vw, 4.4rem); }
  .q-prompt.medium { font-size: clamp(1.8rem, 9vw, 3rem); }
  .options { margin-top: auto; }
  .option { min-height: 96px; justify-content: center; padding: 0 10px; }

  .up-grid { gap: 12px; }
  .up-left .name { font-size: 2.2rem; }
  .up-stage { flex: none; height: 26vh; min-height: 180px; }
  .pool-card { padding: 12px 14px; }
  .pool-card .v { font-size: 1.8rem; }
  .pool-card .of { font-size: 0.7rem; text-align: right; }
  .derived { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .derived-cell { padding: 6px; }
  .derived-cell .v { font-size: 0.9rem; }
  .stat-row { grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px; }
  .stat-row .pips-wrap { grid-column: 1; grid-row: 2; }
  .stat-row .steppers { grid-column: 2; grid-row: 1 / span 2; }
  .stat-row .nm span { display: none; }
  .up-actions { grid-template-columns: 56px 1fr; position: sticky; bottom: 0; padding: 10px 0 calc(10px + var(--safe-b)); background: var(--ink); }
  .up-actions .btn-random-txt { display: none; }
  .up-actions #btn-arena[disabled] { display: none; }
  .up-actions.fortified { grid-template-columns: 1fr; }
  .up-actions.fortified #btn-fortify, .up-actions.fortified #btn-random { display: none; }

  .code-tile { width: 44px; height: 58px; font-size: 1.7rem; }
  .code-tiles { gap: 6px; }
  .code-inputs { gap: 6px; }
  .code-inputs input { height: 60px; font-size: 1.6rem; }
  .settings-card.collapsible .body { display: none; }
  .settings-summary { display: flex; align-items: center; justify-content: space-between; }
  .lobby-start-bar { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-b)); background: var(--ink); }

  .result-wrap { padding-top: 34px; }
  .brain-rule { font-size: 0.95rem; gap: 8px; }
  .brain-rule .w, .brain-rule .arrow { display: none; }
  .rule-tools { margin-left: 0; }
  .rule-meta { padding-left: 0; }
  .pic-grid { grid-template-columns: repeat(2, 1fr); }
  .brain-title { font-size: 1.2rem; }
  .scene-leaderboard .topnav { flex-wrap: wrap; }
  .scene-leaderboard .topnav .spacer { display: none; }
  .lb-filters { width: 100%; flex-direction: column; align-items: stretch; gap: 10px; }
  .lb-filters .tabs-amber { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border-radius: var(--radius); padding: 3px; }
  .lb-filters .levels { overflow-x: auto; }
  .modal { padding: 20px; }
  .modal-actions { grid-template-columns: 1fr 1.6fr; }
}

/* Arena on short landscape screens (phones held sideways): slim HUD. */
@media (max-height: 520px) {
  .ahud-top { top: calc(8px + var(--safe-t)); gap: 8px; }
  .fighter-card { padding: 6px 10px; }
  .fighter-card .who { margin-bottom: 4px; }
  .fighter-card .who small { display: none; }
  .hpbar { height: 9px; }
  .clock-card { min-width: 80px; padding: 3px 10px; }
  .clock-card .t { font-size: 1.3rem; }
  .clock-card .label { display: none; }
  .pause-btn { width: 38px; height: 38px; }
  .overheat-banner { top: calc(58px + var(--safe-t)); font-size: 0.72rem; }
}
@media (max-width: 700px) {
  .ahud-top { gap: 6px; }
  .fighter-card .who small { display: none; }
  .clock-card { min-width: 76px; }
}

/* Touch: bigger hit targets everywhere (≥ 48 px). */
html.input-touch .btn { min-height: 56px; }
html.input-touch .seg button { min-height: 48px; }
html.input-touch .chip { min-height: 44px; }
html.input-touch .btn-back { min-height: 48px; }
html.input-touch .step-btn { width: 56px; height: 56px; }
html.input-touch .lo-row .edit { min-height: 44px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
