/* PRODIGEEK ARENA — shared structure.
   Layout and components only. Every colour, font, radius and texture comes from the
   tokens below, which the theme (arcade.css) redefines. */
:root {
  color-scheme: dark;
  --bg: oklch(16% 0.012 170); --bg-2: oklch(19% 0.014 170);
  --surface: oklch(21% 0.014 170); --surface-2: oklch(25% 0.016 170); --surface-3: oklch(30% 0.018 170);
  --line: oklch(32% 0.02 170); --line-strong: oklch(45% 0.03 170);
  --ink: oklch(96% 0.01 170); --ink-2: oklch(80% 0.015 170); --ink-3: oklch(66% 0.02 170);
  --brand: oklch(78% 0.19 155); --brand-ink: oklch(18% 0.04 160); --brand-soft: oklch(78% 0.19 155 / .14);
  --a: oklch(78% 0.13 225); --a-ink: oklch(18% 0.04 230); --a-soft: oklch(78% 0.13 225 / .14);
  --b: oklch(72% 0.19 350); --b-ink: oklch(18% 0.05 350); --b-soft: oklch(72% 0.19 350 / .14);
  --danger: oklch(68% 0.2 25); --warn: oklch(85% 0.15 85);
  --font-display: system-ui, sans-serif; --font-body: system-ui, sans-serif; --font-num: ui-monospace, monospace;
  --display-weight: 750; --display-case: none; --display-tracking: -0.02em;
  --label-case: uppercase; --label-tracking: 0.08em; --label-weight: 600; --label-font: var(--font-body);
  --radius-s: 6px; --radius-m: 12px; --radius-l: 20px; --border-w: 1px;
  --shadow-1: 0 1px 0 oklch(100% 0 0 / .04) inset, 0 1px 2px oklch(0% 0 0 / .3);
  --shadow-2: 0 1px 0 oklch(100% 0 0 / .05) inset, 0 12px 32px -12px oklch(0% 0 0 / .6);
  --focus: var(--brand);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1); --dur: 220ms;
  --gutter: clamp(12px, 2.4vw, 28px); --gap: clamp(12px, 1.6vw, 20px);
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }
@media (pointer: fine) { html { overscroll-behavior: none; } }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.5 var(--font-body); font-kerning: normal;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
button, a, input, [role="button"] { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: var(--display-weight); text-transform: var(--display-case); letter-spacing: var(--display-tracking); line-height: 1.05; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-s); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; background: var(--brand); color: var(--brand-ink); border-radius: var(--radius-s); font-weight: 700; text-decoration: none; transition: top var(--dur) var(--ease-out); }
.skip-link:focus { top: 12px; }

/* Shared label voice: small caps-like kicker text. */
.stage-kicker, .eyebrow, .chat-eyebrow, .idle-eyebrow, .fighter-topline, .fighter-label, .timer-caption,
.step-name, .count-pill, .section-note, .slot-sub, .live-status, .online-pill, .footer, .bout-legend, .field-hint,
.chat-time, .chat-name, .pause-meta, .vote-total {
  font-family: var(--label-font); letter-spacing: var(--label-tracking); text-transform: var(--label-case); font-weight: var(--label-weight); font-size: .75rem; line-height: 1.3;
}
.section-note, .slot-sub, .vote-total, .pause-meta, .field-hint, .chat-time { text-transform: none; letter-spacing: 0; font-weight: 500; }
.section-note, .vote-total, .pause-meta, .field-hint, .footer { font-family: var(--font-body); font-size: .82rem; }

/* ---------- Background art (the theme paints .backdrop-art and particles) ---------- */
.fx-environment { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.backdrop-art { position: absolute; inset: 0; }
.shell { position: relative; z-index: 1; max-width: 1680px; margin: 0 auto; padding: 0 var(--gutter) env(safe-area-inset-bottom, 0px); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); padding-top: env(safe-area-inset-top, 0px);
  background: var(--topbar-bg, var(--bg)); border-bottom: var(--border-w) solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand-logo { width: 32px; height: auto; }
.brand-word { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); text-transform: uppercase; font-size: 1.05rem; line-height: 1; white-space: nowrap; }
.brand-arena { color: var(--brand); }
.live-status { display: flex; align-items: center; gap: 8px; margin-inline: auto; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: var(--border-w) solid var(--line); white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
body:not([data-phase="idle"]):not([data-phase="completed"]) .live-status .live-dot { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in oklch, var(--danger) 25%, transparent); }
body[data-paused="true"] .live-status .live-dot { background: var(--warn); box-shadow: none; }
.live-sep { color: var(--ink-3); }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.online-pill { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.profile-btn {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: var(--radius-m);
  background: var(--surface); border: var(--border-w) solid var(--line-strong); font-weight: 600; font-size: .9rem;
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.profile-btn:hover { background: var(--surface-2); border-color: var(--brand); }
.profile-mark { width: 10px; height: 10px; border-radius: 3px; background: var(--brand); transform: rotate(45deg); }
body[data-nick="none"] .profile-btn { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
body[data-nick="none"] .profile-mark { background: var(--brand-ink); }
#profileLabel { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Layout ---------- */
.layout {
  display: grid; gap: var(--gap); padding-block: var(--gap) calc(var(--gap) * 2);
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr) minmax(320px, 370px);
  grid-template-areas: "schedule stage chat" "schedule archive chat";
  grid-template-rows: auto 1fr; align-items: start;
}
.stage { grid-area: stage; } .schedule { grid-area: schedule; } .archive { grid-area: archive; } .chat { grid-area: chat; }
.schedule { position: sticky; top: calc(var(--topbar-h) + var(--gap)); max-height: calc(100dvh - var(--topbar-h) - var(--gap) * 2); display: flex; flex-direction: column; }
.chat { position: sticky; top: calc(var(--topbar-h) + var(--gap)); height: calc(100dvh - var(--topbar-h) - var(--gap) * 2); }

/* Panels */
.stage, .schedule, .vault, .null-sector, .chat {
  background: var(--panel-bg, var(--surface)); border: var(--border-w) solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-1);
}
.section-head { display: flex; align-items: center; gap: 10px; }
.section-head h2 { font-size: 1.15rem; }
.count-pill { white-space: nowrap; margin-left: auto; min-width: 28px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
.section-note { color: var(--ink-3); margin-top: 4px; }

/* ---------- Stage ---------- */
.stage { padding: clamp(14px, 2vw, 24px); display: grid; gap: 14px; position: relative; isolation: isolate; }
.stage-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
body[data-phase="idle"] .stage-head, body[data-phase="completed"] .stage-head, body[data-phase="idle"] .phase-steps, body[data-phase="completed"] .phase-steps {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}
.stage-kicker { color: var(--brand); font-variant-numeric: tabular-nums; }
.stage-title { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.4rem); margin-top: 6px; }
.stage-hint { color: var(--ink-2); margin-top: 6px; max-width: 60ch; }

.timer { display: grid; justify-items: end; gap: 4px; min-width: 150px; }
.timer-caption { color: var(--ink-3); }
.timer-value { font-family: var(--font-num); font-weight: 700; font-size: clamp(2rem, 1.5rem + 1.6vw, 2.9rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.timer-value.urgent { color: var(--danger); }
.timer-track { width: 100%; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.timer-track i { display: block; height: 100%; background: var(--brand); transform-origin: left; transform: scaleX(0); transition: transform .35s linear; }
body[data-phase="voting"] .timer-track i { background: var(--ink); }
body[data-paused="true"] .timer-track i { background: var(--warn); }

.phase-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; counter-reset: none; }
.phase-steps li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-s); color: var(--ink-3); background: var(--surface-2); border: var(--border-w) solid transparent; }
.step-index { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font: 700 .7rem/1 var(--font-num); border: 1px solid currentColor; flex: none; }
body[data-phase="reveal"] [data-step="reveal"], body[data-phase="voting"] [data-step="voting"], body[data-phase="result"] [data-step="result"] { color: var(--ink); border-color: var(--brand); background: var(--brand-soft); }
body[data-phase="reveal"] [data-step="reveal"] .step-index, body[data-phase="voting"] [data-step="voting"] .step-index, body[data-phase="result"] [data-step="result"] .step-index { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
body[data-phase="voting"] [data-step="reveal"], body[data-phase="result"] [data-step="reveal"], body[data-phase="result"] [data-step="voting"] { color: var(--ink-2); }

.arena-frame { position: relative; border-radius: var(--radius-m); min-height: 320px; }
.arena-decor { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.arena-decor > * { display: none; }
.arena-content { position: relative; z-index: 1; }

/* Duel */
.combat-players { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: clamp(8px, 1.4vw, 18px); align-items: stretch; }
.fighter {
  --side: var(--a); --side-ink: var(--a-ink); --side-soft: var(--a-soft);
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: clamp(14px, 2vw, 22px) clamp(12px, 1.6vw, 20px); min-height: 300px;
  background: var(--fighter-bg, var(--surface-2)); border: var(--border-w) solid var(--line-strong); border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.fighter.right { --side: var(--b); --side-ink: var(--b-ink); --side-soft: var(--b-soft); }
.fighter-topline { display: flex; align-items: center; gap: 8px; align-self: stretch; color: var(--side); }
.channel-badge { display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius-s); background: var(--side); color: var(--side-ink); font: 800 .8rem/1 var(--font-display); letter-spacing: 0; }
.fighter-flag { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.fighter.victory .fighter-flag { background: var(--brand); color: var(--brand-ink); }
.fighter-emoji { display: grid; place-items: center; width: clamp(84px, 9vw, 132px); aspect-ratio: 1; margin: 6px 0 4px; font-size: clamp(3rem, 2rem + 3vw, 4.6rem); line-height: 1; border-radius: var(--radius-m); background: var(--side-soft); overflow: hidden; }
.fighter-emoji img { width: 100%; height: 100%; object-fit: contain; }
.unknown-mark { font-family: var(--font-display); font-weight: 800; color: var(--side); }
.fighter-label { color: var(--ink-3); }
.fighter-name { font-size: clamp(1.1rem, .9rem + .9vw, 1.6rem); line-height: 1.12; overflow-wrap: anywhere; }
.fighter-price { font-family: var(--font-num); font-weight: 700; font-size: 1.15rem; padding: 4px 12px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.fighter.victory { border-color: var(--brand); }
.fighter.defeat { opacity: .55; }
.vote-btn {
  margin-top: auto; align-self: stretch; min-height: 48px; padding: 10px 14px; border: 0; border-radius: var(--radius-s);
  background: var(--side); color: var(--side-ink); font-family: var(--font-display); font-weight: 800; letter-spacing: .02em; font-size: .95rem; text-transform: uppercase;
  transition: transform 120ms var(--ease-out), filter var(--dur) var(--ease-out), background-color var(--dur);
}
/* Stretched hit area: the whole card votes. */
.vote-btn::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-m); }
.vote-btn:not(:disabled):hover { filter: brightness(1.08); }
.vote-btn:not(:disabled):active { transform: scale(.98); }
.fighter:has(.vote-btn:not(:disabled)):hover { transform: translateY(-3px); border-color: var(--side); }
.vote-btn:disabled { background: var(--surface-3); color: var(--ink-3); }
.vote-btn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.vote-btn:focus-visible { outline-offset: 2px; }
.fighter.voted { border-color: var(--brand); }

.versus { display: grid; place-items: center; }
.versus-core { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface); border: var(--border-w) solid var(--line-strong); font: 800 1rem/1 var(--font-display); letter-spacing: .02em; }
.versus-core--paused { color: var(--warn); border-color: var(--warn); }

.vote-total { text-align: center; color: var(--ink-2); margin-top: 14px; font-variant-numeric: tabular-nums; }

/* Verdict */
.verdict { display: grid; gap: 10px; justify-items: center; margin-top: 16px; text-align: center; }
.result-callout { font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.05rem, .9rem + .7vw, 1.4rem); text-transform: var(--display-case); }
.split-bar { display: flex; width: 100%; height: 40px; border-radius: var(--radius-s); overflow: hidden; background: var(--surface-3); font-variant-numeric: tabular-nums; }
.split-bar span { flex: var(--pct) 0 0; min-width: max-content; display: flex; align-items: center; gap: 6px; padding: 0 12px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.split-bar span[style*="--pct:0"] { display: none; }
.split-a { background: var(--a); color: var(--a-ink); }
.split-b { background: var(--b); color: var(--b-ink); justify-content: flex-end; }
.split-bar b { font: 800 1rem/1 var(--font-num); }
.result-sub { color: var(--ink-2); font-size: .9rem; }
.winner-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: var(--radius-s); background: var(--brand); color: var(--brand-ink); font-weight: 700; text-decoration: none; }

/* Pause */
.pause-layer { position: absolute; inset: -6px; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; text-align: center; border-radius: var(--radius-m); background: color-mix(in oklch, var(--bg) 82%, transparent); backdrop-filter: blur(3px); }
.pause-emblem { position: relative; display: grid; place-items: center; width: 92px; height: 92px; }
.pause-emblem-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px dashed var(--warn); animation: pauseStasisRing 14s linear infinite; }
.pause-emblem-icon { display: flex; gap: 10px; }
.pause-emblem-icon i { width: 10px; height: 34px; border-radius: 3px; background: var(--warn); }
.pause-status { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.3rem; text-transform: uppercase; }
.pause-meta { color: var(--ink-2); }
@keyframes pauseStasisRing { to { transform: rotate(360deg); } }

/* Idle / completed */
.idle-panel { display: grid; justify-items: center; text-align: center; gap: 12px; padding: clamp(28px, 5vw, 64px) clamp(12px, 3vw, 40px); }
.core-idle-mark { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; border: var(--border-w) solid var(--line-strong); color: var(--brand); font-size: 1.6rem; }
.idle-eyebrow { color: var(--brand); }
.idle-panel h2 { font-size: clamp(2rem, 1.2rem + 3.4vw, 3.8rem); }
.idle-lead { color: var(--ink-2); max-width: 46ch; font-size: 1.05rem; }
.how-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: min(100%, 640px); counter-reset: how; text-align: left; }
.how-steps li { counter-increment: how; display: grid; gap: 4px; padding: 14px; border-radius: var(--radius-m); background: var(--surface-2); border: var(--border-w) solid var(--line); font-size: .88rem; color: var(--ink-2); }
.how-steps li::before { content: "0" counter(how); font: 700 .75rem/1 var(--font-num); color: var(--brand); }
.how-steps b { color: var(--ink); font-family: var(--font-display); font-size: 1rem; text-transform: var(--display-case); }
.standby-count { color: var(--ink-3); font: 600 .8rem/1 var(--font-num); letter-spacing: .06em; text-transform: uppercase; }
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border: 0; border-radius: var(--radius-s);
  background: var(--brand); color: var(--brand-ink); font-family: var(--font-display); font-weight: 800; letter-spacing: .02em; text-decoration: none; text-transform: var(--display-case);
  transition: filter var(--dur) var(--ease-out), transform 120ms var(--ease-out);
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(.98); }
body[data-nick="set"] .idle-cta[data-action="profile"] { display: none; }

/* ---------- Schedule (bouts) ---------- */
.schedule { padding: 16px; gap: 10px; }
.schedule-toggle { display: none; }
.bout-legend { display: flex; align-items: center; gap: 6px; color: var(--ink-3); }
.legend-a, .legend-b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; color: var(--a-ink); background: var(--a); font: 800 .65rem/1 var(--font-display); }
.legend-b { color: var(--b-ink); background: var(--b); }
.legend-sep { margin-inline: 4px; }
.bouts { list-style: none; margin: 0; padding: 0 4px 0 0; display: grid; gap: 6px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.bout { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px; border-radius: var(--radius-m); border: var(--border-w) solid transparent; }
.bout-num { font: 700 .75rem/1 var(--font-num); color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums; }
.bout--current { background: var(--brand-soft); border-color: var(--brand); }
.bout--current .bout-num { color: var(--brand); }
.bout-pair { display: grid; gap: 2px; position: relative; }
.bout-vs { position: absolute; right: 8px; top: 50%; translate: 0 -50%; font: 700 .6rem/1 var(--font-num); color: var(--ink-3); text-transform: uppercase; display: none; }
.slot { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 4px 8px 4px 4px; border-radius: var(--radius-s); text-decoration: none; min-height: 40px; }
.slot::before { content: ""; position: absolute; left: -2px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--a); }
.slot--right::before { background: var(--b); }
.slot-thumb { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-s); background: var(--surface-2); font-size: 1.05rem; overflow: hidden; }
.slot-thumb img { width: 100%; height: 100%; object-fit: cover; }
.slot-thumb .unknown-mark { color: var(--ink-3); font-size: .9rem; }
.slot-info { min-width: 0; }
.slot-name { font-weight: 600; font-size: .86rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-sub { color: var(--ink-3); font-size: .72rem; }
.slot-check { font-size: .7rem; color: var(--ink-3); }
.slot.done .slot-name { color: var(--ink-2); }
.slot.slot-loser .slot-name { text-decoration: line-through; text-decoration-color: var(--ink-3); color: var(--ink-3); }
.slot.slot-winner .slot-check { color: var(--brand); }
.slot-winner-price { color: var(--brand); font-family: var(--font-num); font-weight: 700; }
.slot.current .slot-check { color: var(--danger); }
.roster .slot.slot-link, .slot.slot-link { cursor: pointer; transition: background-color var(--dur) var(--ease-out); }
.slot.slot-link:hover { background: var(--surface-2); }
.slot.slot-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.slot.slot-link .slot-open { color: var(--brand); font-weight: 700; }

/* ---------- Archive ---------- */
.archive { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--gap); }
.vault, .null-sector { padding: 16px; }
.medals { display: grid; gap: 6px; margin-top: 12px; }
.medal { display: grid; grid-template-columns: 26px 36px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; min-height: 52px; padding: 8px 12px 8px 8px; border-radius: var(--radius-m); background: var(--surface-2); border: var(--border-w) solid var(--line); text-decoration: none; }
.medal-pos { font: 700 .75rem/1 var(--font-num); color: var(--ink-3); text-align: center; }
.medal-emoji { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-s); background: var(--brand-soft); font-size: 1.2rem; overflow: hidden; }
.medal-emoji img { width: 100%; height: 100%; object-fit: cover; }
.medal-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.medal-price { font: 700 .9rem/1 var(--font-num); color: var(--brand); font-variant-numeric: tabular-nums; }
.medal-open { color: var(--brand); font-weight: 800; }
.medal-link { transition: border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out); }
.medal-link:hover { border-color: var(--brand); background: var(--surface-3); }
.pit-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pit-member { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-3); font-size: .85rem; text-decoration: line-through; text-decoration-color: color-mix(in oklch, var(--ink-3) 60%, transparent); }
.pit-pos { font: 700 .7rem/1 var(--font-num); text-decoration: none; }
.empty-line { color: var(--ink-3); font-size: .9rem; padding: 10px 0; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.chat-header h2 { font-size: 1.25rem; }
.chat-eyebrow { display: flex; align-items: center; gap: 6px; color: var(--danger); margin-bottom: 4px; }
.chat-eyebrow .live-dot { background: var(--danger); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-m); background: var(--surface-2); border: var(--border-w) solid var(--line); }
.chat .chat-close { display: none; }
.chat-announcement { display: flex; gap: 10px; align-items: flex-start; margin: 0 12px; padding: 10px 12px; border-radius: var(--radius-m); background: var(--brand-soft); font-size: .82rem; color: var(--ink-2); }
.chat-announcement b { color: var(--brand); }
.bot-mark { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 3px; background: var(--brand); transform: rotate(45deg); }
.chat-feed { flex: 1; min-height: 0; -webkit-mask-image: linear-gradient(transparent, #000 18px); mask-image: linear-gradient(transparent, #000 18px); overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.chat-iframe { flex: 1; border: 0; width: 100%; min-height: 0; }
.chat-msg { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 6px 8px; border-radius: var(--radius-s); }
.chat-name { font-size: .8rem; text-transform: none; letter-spacing: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { color: var(--ink-3); font-size: .7rem; align-self: center; justify-self: start; font-variant-numeric: tabular-nums; }
.chat-body { grid-column: 1 / -1; font-size: .92rem; line-height: 1.4; overflow-wrap: anywhere; color: var(--ink); }
.chat-msg.bot { background: var(--brand-soft); margin-block: 4px; }
.chat-msg.bot .chat-body { color: var(--ink-2); font-size: .85rem; }
.chat-msg--mine { background: var(--surface-2); }
.chat-footer { position: relative; padding: 10px 12px 12px; border-top: var(--border-w) solid var(--line); }
#chatForm { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 6px; }
#chatInput { min-width: 0; height: 44px; padding: 0 12px; border-radius: var(--radius-s); border: var(--border-w) solid var(--line-strong); background: var(--bg-2); font-size: 16px; }
#chatInput::placeholder { color: var(--ink-3); }
#chatInput:focus-visible { outline-offset: 0; }
.comms-emoji-toggle, .send-btn { height: 44px; border-radius: var(--radius-s); border: var(--border-w) solid var(--line-strong); background: var(--surface-2); font-size: 1.15rem; }
.send-btn { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-size: .95rem; }
#chatNote { margin-top: 6px; color: var(--ink-3); font-size: .72rem; }
.comms-emoji-picker { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); z-index: 5; padding: 10px; border-radius: var(--radius-m); background: var(--surface-3); border: var(--border-w) solid var(--line-strong); box-shadow: var(--shadow-2); max-height: 280px; overflow-y: auto; overscroll-behavior: contain; }
.comms-emoji-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: .85rem; }
.comms-emoji-close { width: 36px; height: 36px; border-radius: var(--radius-s); background: transparent; border: 0; }
.comms-emoji-group-title { margin: 8px 0 4px; color: var(--ink-3); font-size: .7rem; letter-spacing: var(--label-tracking); }
.comms-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; }
.comms-emoji-choice { height: 38px; border: 0; border-radius: var(--radius-s); background: transparent; font-size: 1.3rem; }
.comms-emoji-choice:hover { background: var(--surface-2); }

.chat-fab { display: none; }
.mobile-backdrop { display: none; }

/* ---------- Footer, dialog, toast ---------- */
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 18px 0 28px; color: var(--ink-3); border-top: var(--border-w) solid var(--line); text-transform: none; letter-spacing: 0; font-weight: 500; }
.footer-version { font-family: var(--font-num); margin-left: 6px; }

.modal { width: min(440px, calc(100vw - 32px)); padding: 0; border: var(--border-w) solid var(--line-strong); border-radius: var(--radius-l); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }
.modal::backdrop { background: color-mix(in oklch, var(--bg) 70%, transparent); backdrop-filter: blur(4px); }
.modal form { position: relative; display: grid; gap: 10px; padding: 28px 24px 24px; }
.modal h2 { font-size: 1.6rem; }
.modal p { color: var(--ink-2); font-size: .95rem; }
.modal .eyebrow { color: var(--brand); font-size: .75rem; }
.modal label { margin-top: 6px; font-weight: 600; font-size: .85rem; }
.modal input { height: 48px; padding: 0 14px; border-radius: var(--radius-s); border: var(--border-w) solid var(--line-strong); background: var(--bg-2); font-size: 16px; }
.modal .field-hint { color: var(--ink-3); }
.modal .primary-btn { margin-top: 6px; }
.modal-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: var(--radius-m); background: transparent; color: var(--ink-2); }
.modal[open] { animation: modalIn 260ms var(--ease-out); }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60; translate: -50% 16px; max-width: min(92vw, 460px); padding: 12px 18px; border-radius: var(--radius-m); background: var(--ink); color: var(--bg); font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease-out), translate var(--dur) var(--ease-out); }
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- Responsive ---------- */
@media(max-width:1300px) {
  .layout { grid-template-columns: minmax(250px, 290px) minmax(0, 1fr); grid-template-areas: "schedule stage" "schedule archive"; }
  .chat { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); height: auto; border-radius: 0; z-index: 31; transform: translateX(102%); transition: transform 320ms var(--ease-out); visibility: hidden; }
  .chat.open { transform: none; visibility: visible; }
  .chat .chat-close { display: grid; }
  .mobile-backdrop { position: fixed; inset: 0; z-index:30; background: color-mix(in oklch, var(--bg) 65%, transparent); opacity: 0; pointer-events: none; transition: opacity var(--dur); display: block; }
  .mobile-backdrop.visible { opacity: 1; pointer-events: auto; }
  .chat-fab { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--brand); color: var(--brand-ink); font-weight: 800; letter-spacing: .04em; box-shadow: var(--shadow-2); }
  .chat-fab-icon { width: 10px; height: 10px; border-radius: 3px; background: currentColor; transform: rotate(45deg); }
  .chat-unread { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: white; font-size: .75rem; display: grid; place-items: center; }
  .chat-unread[hidden] { display: none; }
}
@media(max-width:1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "schedule" "archive"; }
  .schedule { position: static; max-height: none; }
  .schedule-toggle { display: inline-flex; align-items: center; margin-left: 4px; min-height: 36px; padding: 0 10px; border-radius: var(--radius-s); border: var(--border-w) solid var(--line-strong); background: transparent; font-size: .8rem; font-weight: 600; white-space: nowrap; }
  .bouts { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); overflow: visible; }
  body:not([data-phase="completed"]) .schedule:not(.expanded) .bout--finished, body:not([data-phase="completed"]) .schedule:not(.expanded) .bout--skipped,
  .schedule:not(.expanded) .bout--queued ~ .bout--queued ~ .bout--queued ~ .bout--queued { display: none; }
}
@media(max-width:720px) {
  :root { --topbar-h: 56px; }
  .online-pill, .live-sep, #roundLabel { display: none; }
  #profileLabel { max-width: 11ch; }
  .stage-kicker, .fighter-topline, .timer-caption, .count-pill, .bout-legend, .live-status { font-size: .68rem; }
  .brand-word { font-size: .95rem; }
  .brand-name { display: none; }
  .profile-btn { padding: 0 10px; }
  .stage { padding: 12px; gap: 10px; border-radius: var(--radius-m); }
  .stage-head { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .stage-title { font-size: 1.35rem; }
  .stage-hint { font-size: .88rem; }
  .timer { grid-template-columns: 1fr auto; align-items: center; justify-items: start; min-width: 0; column-gap: 12px; row-gap: 6px; }
  .timer-value { font-size: 1.7rem; grid-row: 1; grid-column: 2; }
  .timer-track { grid-column: 1 / -1; width: 100%; }
  .phase-steps li { padding: 6px 4px; gap: 6px; justify-content: center; }
  .step-index { display: none; }
  .step-name { font-size: .62rem; white-space: nowrap; }
  .combat-players { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; position: relative; }
  .versus { position: absolute; left: 50%; top: 66px; translate: -50% 0; z-index: 2; }
  .versus-core { width: 40px; height: 40px; font-size: .78rem; }
  .fighter { min-height: 0; padding: 12px 10px; gap: 6px; }
  .fighter-topline { font-size: .66rem; gap: 6px; }
  .fighter-flag { display: none; }
  .fighter-emoji { width: 76px; font-size: 2.8rem; }
  .fighter-label { font-size: .64rem; }
  .fighter-name { font-size: 1rem; }
  .vote-btn { font-size: .8rem; padding: 10px 6px; }
  .how-steps { grid-template-columns: 1fr; }
  .archive { grid-template-columns: 1fr; }
  .bouts { grid-template-columns: 1fr; }
  .split-bar span { font-size: .7rem; padding: 0 8px; }
}
@media(prefers-reduced-motion:reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* V1.3.2 — Mobile COMMS must be usable above its backdrop, with a real
   viewport-sized composer and without overflow from long headings/content. */
@media (max-width:1300px) {
  body.comms-open { overflow:hidden; }
  body.comms-open > #chatFab { opacity:0; visibility:hidden; pointer-events:none; }
  #chatPanel.chat {
    inset:0 0 0 auto;
    width:min(420px, 100vw);
    max-width:100vw;
    height:100dvh;
    max-height:100dvh;
    min-width:0;
    overscroll-behavior:contain;
  }
  #chatPanel .chat-header, #chatPanel .chat-announcement,
  #chatPanel .chat-feed, #chatPanel .chat-footer { min-width:0; }
  #chatPanel .chat-header { flex-shrink:0; }
  #chatPanel .chat-announcement { flex-shrink:0; }
  #chatPanel .chat-announcement p, #chatPanel .chat-msg,
  #chatPanel .chat-body, #chatPanel #chatNote { overflow-wrap:anywhere; min-width:0; }
  #chatPanel .chat-footer {
    flex-shrink:0;
    background:var(--panel-bg, var(--surface));
    padding-bottom:calc(12px + env(safe-area-inset-bottom, 0px));
  }
  #chatPanel #chatForm { width:100%; min-width:0; }
  #chatPanel #chatInput { width:100%; min-width:0; }
}
@media (max-width:720px) {
  html, body { max-width:100%; overflow-x:clip; }
  .shell, .layout, .layout > *, .stage, .schedule, .archive { min-width:0; }
  .topbar { min-width:0; gap:8px; }
  .topbar .brand { flex:0 0 auto; min-width:0; }
  .topbar .live-status {
    flex:1 1 auto; min-width:0; max-width:none; margin-inline:0;
    overflow:hidden; padding-inline:7px; gap:5px;
  }
  .topbar #eventLabel { display:block; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .topbar .top-actions { flex:0 1 auto; min-width:0; }
  .topbar .profile-btn { min-width:0; max-width:min(140px, 32vw); }
  .topbar #profileLabel { max-width:100%; min-width:0; }
  .schedule .section-head { flex-wrap:wrap; min-width:0; }
  .schedule .section-head h2 { min-width:0; }
  .schedule .schedule-toggle { margin-left:auto; }
  .chat { width:100vw !important; }
}
@media (max-width:420px) {
  .topbar .brand-word { font-size:.83rem; }
  .topbar .brand-logo { width:26px; }
  .topbar .live-status { font-size:.65rem; }
  .schedule { padding:12px 10px; }
  .schedule .section-head { column-gap:6px; row-gap:10px; }
  .schedule .section-head .count-pill { margin-left:auto; }
  .schedule .schedule-toggle { margin-left:0; }
}
