:root {
  /* SimuPhish brand blue/purple — sampled directly from the trident mark at
     simuphish.com, not picked by eye. Used for chrome that isn't tied to a
     specific scenario (idle screen, buttons, footer) — per-scenario accent
     colors stay on the separate validated categorical palette. */
  --brand-blue: #383886;
  --brand-purple: #7973b5;
  --brand-gradient: linear-gradient(135deg, var(--brand-blue), var(--brand-purple));
  --accent: var(--brand-purple);
  --bg: #05070b;
  --panel-bg: #0d1119;
  --panel-border: #1c2433;
  --text: #eef1f6;
  --text-dim: #8b96ab;
  /* Fixed status palette (dataviz skill, validated for the dark surface) —
     never themed per-level, so a status color never impersonates a level's
     own accent. */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --success: var(--status-good);
  --warning: var(--status-warning);
  --danger: var(--status-critical);
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* When a screen is taller than the window (short laptop screens, small
   browser windows) the page scrolls vertically — never sideways. */
html { overflow-x: hidden; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font-display);
}

/* The active screen fills the window above the footer (so short content
   stays centred) and grows past it when it needs to; the footer then simply
   follows the content. */
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.screen { display: none; flex-direction: column; position: relative; width: 100%; }
.screen.active { display: flex; flex: 1 0 auto; }

/* ---------- Branding footer ---------- */
/* In normal page flow (not fixed): at the bottom of the window when the screen
   fits, below the content when the page scrolls — never on top of it. */
.brand-footer {
  position: relative; z-index: 1; flex-shrink: 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px; padding: 14px 16px;
  font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim);
}
.brand-footer-mark { width: 18px; height: 18px; object-fit: contain; opacity: 0.85; }

/* ---------- Exit control (visible during briefing/active — abort to idle) ---------- */
.btn-exit {
  position: absolute; top: 20px; right: 24px; z-index: 60;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 8px 18px; border-radius: 999px; border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.35); color: var(--text-dim); cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-exit:hover { border-color: var(--danger); color: var(--danger); }
.brand-footer strong { color: var(--text); }

/* ---------- Idle / Attract ---------- */
/* Sizes step down on short windows so the whole attract screen still fits. */
#screen-idle {
  align-items: center; justify-content: center; text-align: center;
  gap: clamp(14px, 2.6vh, 28px); padding: 32px 24px;
  overflow: hidden; /* clips the decorative watermark only — the screen grows with its content */
}
/* Fixed to the window so the glow also runs behind the footer (no seam). */
.idle-glow {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 32% 28%, rgba(56,56,134,0.4), transparent 55%),
              radial-gradient(circle at 68% 62%, rgba(121,115,181,0.35), transparent 55%);
}
.idle-watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 820px; max-width: 90vw; opacity: 0.05; z-index: 0; pointer-events: none;
}
.idle-logo { width: clamp(130px, 18.5vh, 200px); z-index: 1; }
.idle-title { font-size: clamp(36px, min(6vw, 8vh), 72px); margin: 0; letter-spacing: 0.02em; z-index: 1; }
.idle-title .eyebrow { display: block; font-size: clamp(14px, 2.1vh, 22px); color: var(--accent); letter-spacing: 0.3em; text-transform: uppercase; margin-bottom: 8px; }
.idle-sub { color: var(--text-dim); font-size: clamp(16px, 2.1vh, 22px); max-width: 800px; z-index: 1; }
.mode-row { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(12px, 2.2vh, 24px); z-index: 1; }
.big-btn {
  font-family: var(--font-display); font-size: clamp(18px, 2.4vh, 26px); font-weight: 700;
  padding: clamp(14px, 2vh, 22px) clamp(24px, 3vw, 44px); border-radius: 16px; border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.big-btn:hover { background: var(--accent); transform: translateY(-2px); }
/* Secondary actions (Single Player, Cancel, New Game): solid dark fill and a
   clearly visible border so they read as buttons on any background. */
.big-btn.secondary { border-color: #46506a; background: rgba(5,7,11,0.75); }
#screen-idle .big-btn.secondary { border-color: rgba(121,115,181,0.85); }
#screen-idle .big-btn:not(.secondary) { border: none; background: var(--brand-gradient); }
#screen-idle .big-btn:not(.secondary):hover { filter: brightness(1.15); }
.idle-leaderboard { z-index: 1; margin-top: clamp(0px, 1.1vh, 12px); color: var(--text-dim); font-size: clamp(15px, 1.7vh, 18px); }
.idle-leaderboard b { color: var(--text); }
.btn-link {
  z-index: 1; margin-top: clamp(4px, 1.7vh, 18px); background: none; border: none; color: var(--text-dim);
  font-family: var(--font-display); font-size: 15px; text-decoration: underline;
  cursor: pointer; letter-spacing: 0.04em;
}
.btn-link:hover { color: var(--text); }

/* ---------- Intro video (button on the idle screen + popup) ---------- */
.intro-btn {
  z-index: 1; display: inline-flex; align-items: center; gap: 14px;
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 8px 28px 8px 8px; border-radius: 999px;
  border: 1px solid rgba(121,115,181,0.7); background: rgba(121,115,181,0.12);
  color: var(--text); cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.intro-btn:hover { background: rgba(121,115,181,0.28); transform: translateY(-2px); }
.intro-btn-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand-gradient); padding-left: 2px;
}
.intro-dialog {
  width: min(1280px, 92vw, calc(82vh * 16 / 9)); padding: 0; overflow: visible;
  border: 1px solid var(--panel-border); border-radius: 18px;
  background: #000; color: var(--text);
  box-shadow: 0 30px 120px rgba(0,0,0,0.7);
}
.intro-dialog::backdrop { background: rgba(3,5,9,0.85); backdrop-filter: blur(6px); }
.intro-video { display: block; width: 100%; max-height: 82vh; aspect-ratio: 16 / 9; background: #000; border-radius: 18px; }
.intro-close {
  position: absolute; top: -18px; right: -18px; z-index: 1;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--panel-border); background: var(--panel-bg); color: var(--text); cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.intro-close:hover { border-color: var(--danger); color: var(--danger); }
@media (max-width: 720px) { .intro-close { top: 8px; right: 8px; } }
.intro-error { margin: 0; padding: 16px 20px; text-align: center; font-size: 16px; color: var(--text-dim); }

/* ---------- Lobby ---------- */
#screen-lobby { align-items: center; justify-content: center; padding: 32px 24px; }
/* QR beside the details on wide screens, stacked above them on narrow ones. */
.lobby-grid { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(28px, 5vw, 80px); max-width: 100%; }
.qr-card { background: #fff; padding: clamp(12px, 1.8vh, 20px); border-radius: 20px; box-shadow: 0 0 60px rgba(229,56,77,0.25); }
.qr-card img { display: block; width: clamp(200px, 30vh, 320px); height: auto; aspect-ratio: 1; }
.lobby-info { max-width: 480px; min-width: 0; }
.lobby-info .eyebrow { color: var(--accent); letter-spacing: 0.3em; text-transform: uppercase; font-size: 16px; }
.lobby-info h2 { font-size: clamp(28px, 4vh, 40px); margin: 10px 0; }
.join-code { font-family: var(--font-mono); font-size: clamp(24px, 3vh, 32px); letter-spacing: 0.15em; color: var(--text); background: var(--panel-bg); border: 1px solid var(--panel-border); padding: 10px 18px; border-radius: 10px; display: inline-block; margin: 12px 0; }
.roster-count { font-family: var(--font-mono); color: var(--text-dim); margin-left: 6px; }
.roster-list { list-style: none; padding: 0; margin: 20px 0; display: flex; flex-direction: column; gap: 10px; }
.roster-list li { display: flex; align-items: center; gap: 10px; font-size: 20px; min-width: 0; }
.roster-list.crowded { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; margin: 14px 0; }
.roster-list.crowded li { font-size: 17px; }
.roster-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.roster-empty { color: var(--text-dim); font-size: 18px; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 20px; }

/* ---------- Briefing ---------- */
#screen-briefing {
  align-items: center; justify-content: center; text-align: center;
  gap: clamp(12px, 2.2vh, 24px); padding: 72px 24px 32px; /* top: clear of the Exit button */
}
.briefing-badge { color: var(--accent); text-transform: uppercase; letter-spacing: 0.3em; font-size: 16px; }
.briefing-title { font-size: clamp(30px, 4.8vh, 52px); margin: 0; }
.briefing-blurb { max-width: 900px; font-size: clamp(17px, 2.2vh, 24px); color: var(--text-dim); }
.briefing-avatars { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(14px, 2.6vh, 28px); margin-top: 10px; }
.avatar-chip { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.avatar-chip img { width: clamp(56px, 7.8vh, 84px); height: clamp(56px, 7.8vh, 84px); border-radius: 50%; border: 3px solid var(--panel-border); }
.briefing-countdown { font-family: var(--font-mono); font-size: clamp(56px, 8.9vh, 96px); color: var(--accent); }

/* ---------- Active round ---------- */
#screen-active { padding: 0 clamp(16px, 2.2vw, 40px) 24px; gap: 18px; }
/* Title, timer and Exit stay pinned at the top while the dashboard scrolls
   under them; the shadow in the page colour fades content out beneath it. */
.active-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-direction: column; gap: 18px;
  padding-top: clamp(14px, 2.6vh, 28px);
  background: var(--bg); box-shadow: 0 12px 12px -4px var(--bg);
}
.active-topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.active-scenario { display: flex; flex-direction: column; min-width: 0; }
.active-scenario .kicker { color: var(--accent); text-transform: uppercase; letter-spacing: 0.25em; font-size: 14px; }
.active-scenario h2 { margin: 4px 0 0; font-size: clamp(22px, 3vh, 32px); }
.active-controls { display: flex; align-items: center; gap: 16px; }
.active-controls .btn-exit { position: static; }
.timer-badge {
  font-family: var(--font-mono); font-size: clamp(34px, 5.2vh, 56px); font-weight: 700;
  border: 3px solid var(--accent); border-radius: 18px; padding: 6px clamp(16px, 1.5vw, 28px);
  background: rgba(255,255,255,0.03);
}
.timer-badge.critical { color: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }
.timer-badge.grace { color: var(--warning); border-color: var(--warning); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.55; } }

.overtime-banner {
  display: none; text-align: center; padding: 10px; border-radius: 10px;
  background: rgba(245,165,36,0.12); color: var(--warning); font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; font-size: 15px;
}
.overtime-banner.visible { display: block; }

/* With a big room the chips wrap onto their own line(s) under the bar. */
.progress-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-size: 16px; color: var(--text-dim); }
.progress-strip > span { white-space: nowrap; }
.progress-track { flex: 1; min-width: 240px; height: 8px; border-radius: 6px; background: var(--panel-border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.4s ease; }
.player-chips { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.player-chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--panel-border); color: var(--text-dim); }
.player-chip.submitted { border-color: var(--success); color: var(--success); }

/* ---------- Dashboard layout system ---------- */
/* One dynamic container per round; JS swaps both the class (layout-*) and
   the inner HTML based on scenario.dashboardLayout, so levels are
   structurally different, not just recolored. */
.dash-dynamic { display: flex; flex-direction: column; gap: 14px; }

.panel { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 16px; padding: 18px 22px; overflow: auto; }
.panel-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--accent); margin-bottom: 12px; display: block; }

/* minmax(0, …) lets a column shrink on a narrow window (a panel then scrolls
   its own content) instead of pushing the page sideways. */
.dash-row-2x2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-rows: 1fr 1fr; gap: 14px; min-height: 420px; }
.dash-row-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dash-row-3col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dash-row-1col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.dash-row-hero { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; min-height: 320px; }
@media (max-width: 1200px) {
  .dash-row-3col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .dash-row-2x2, .dash-row-2col, .dash-row-3col, .dash-row-hero { grid-template-columns: minmax(0, 1fr); }
  .dash-row-2x2 { grid-template-rows: none; min-height: 0; }
  .dash-row-hero { min-height: 0; }
}
.hero-col .hero-panel { height: 100%; }
.hero-col .preview-card { font-size: 1.1em; }
.rail-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.rail-col .rail-panel { flex: 1; }

/* ---------- KPI stat strip ---------- */
/* One row of tiles on a wide screen; wraps onto more rows when narrow. */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.kpi-tile {
  background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 14px;
  padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; text-align: center;
}
.kpi-value { font-family: var(--font-mono); font-size: 26px; font-weight: 700; }
.kpi-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-tile.success .kpi-value { color: var(--status-good); }
.kpi-tile.warning .kpi-value { color: var(--status-warning); }
.kpi-tile.danger .kpi-value { color: var(--status-critical); }

/* ---------- Department breakdown bar chart (single-hue sequential) ---------- */
.dept-chart { display: flex; flex-direction: column; gap: 12px; }
.dept-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 140px; align-items: center; gap: 10px; font-size: 15px; }
.dept-label { color: var(--text-dim); }
.dept-track { height: 14px; border-radius: 7px; background: rgba(255,255,255,0.06); overflow: hidden; }
.dept-fill { height: 100%; background: var(--accent); border-radius: 7px; }
.dept-value { font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); text-align: right; }

/* ---------- Kill chain (horizontal attack-progression stepper) ---------- */
.kill-chain-panel { padding-bottom: 10px; }
.kill-chain { display: flex; align-items: flex-start; gap: 4px; overflow-x: auto; padding: 6px 0 14px; }
.kill-chain-step { position: relative; flex: 1; min-width: 150px; padding-top: 22px; }
.kill-chain-step::before {
  content: ''; position: absolute; top: 8px; left: 50%; right: -50%; height: 2px; background: var(--panel-border);
}
.kill-chain-step:last-child::before { display: none; }
.kill-chain-dot { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 50%; background: var(--text-dim); z-index: 1; }
.kill-chain-step.info .kill-chain-dot { background: var(--accent); }
.kill-chain-step.warning .kill-chain-dot { background: var(--status-warning); }
.kill-chain-step.danger .kill-chain-dot { background: var(--status-critical); }
.kill-chain-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); text-align: center; }
.kill-chain-desc { font-size: 13px; text-align: center; margin-top: 4px; }

/* ---------- Extra panels ---------- */
.location-list, .system-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.location-list li, .system-list li { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.loc-flag { display: inline-flex; align-items: center; gap: 4px; color: var(--danger); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.loc-flag.ok { color: var(--success); }
.loc-flag svg { width: 12px; height: 12px; }
.sys-status { font-size: 11px; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; }
.sys-status.quarantined, .sys-status.compromised { background: rgba(239,68,68,0.15); color: var(--danger); }
.sys-status.scanning { background: rgba(245,165,36,0.15); color: var(--warning); }
.wire-details { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 15px; margin: 0; }
.wire-details dt { color: var(--text-dim); }
.wire-details dd { margin: 0; font-weight: 700; }
.wire-details .wire-status { color: var(--danger); }

.activity-table { width: 100%; border-collapse: collapse; font-size: 18px; }
.activity-table th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 13px; text-transform: uppercase; padding: 0 6px 8px; }
.activity-table th:not(:first-child), .activity-table td:not(:first-child) { text-align: center; }
/* The name cell stays a real table cell (a flex <td> drew its row line out of step with the others). */
.activity-table td { padding: 8px 6px; border-top: 1px solid var(--panel-border); vertical-align: middle; }
.activity-table .suspect-cell { white-space: nowrap; }
.activity-table img { width: 32px; height: 32px; border-radius: 50%; vertical-align: middle; margin-right: 10px; }
.mark { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 50%; }
.mark svg { display: block; }
.mark.yes { background: rgba(34,197,94,0.15); color: var(--success); }
.mark.no { background: rgba(239,68,68,0.12); color: var(--danger); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 26px; font-size: 16px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--text-dim); }
.timeline li.info::before { background: var(--accent); }
.timeline li.warning::before { background: var(--warning); }
.timeline li.danger::before { background: var(--danger); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 16px; bottom: -8px; width: 1px; background: var(--panel-border); }
.timeline li:last-child::after { display: none; }
.t-time { font-family: var(--font-mono); color: var(--text-dim); margin-right: 10px; }

.preview-card { border-radius: 12px; padding: 14px; background: rgba(255,255,255,0.02); border: 1px solid var(--panel-border); }
.preview-from { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.preview-subject { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.preview-body { font-size: 15px; color: var(--text-dim); margin-bottom: 12px; }
.preview-cta { display: inline-block; padding: 8px 18px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 700; }
.preview-qr-inline { background: #fff; padding: 10px; border-radius: 10px; display: inline-block; margin-top: 8px; }
.preview-qr-inline img { width: 120px; height: 120px; display: block; }

.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.alert-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; flex-shrink: 0; margin-top: 2px; }
.alert-badge.high { background: rgba(239,68,68,0.15); color: var(--danger); }
.alert-badge.medium { background: rgba(245,165,36,0.15); color: var(--warning); }
.alert-badge.low { background: rgba(139,150,171,0.15); color: var(--text-dim); }

/* ---------- Results ---------- */
#screen-results { align-items: center; justify-content: center; gap: clamp(10px, 2vh, 20px); text-align: center; padding: 32px 24px; }
#screen-results .eyebrow { color: var(--accent); letter-spacing: 0.3em; text-transform: uppercase; font-size: 16px; }
.results-headline { font-size: clamp(28px, 4.1vh, 44px); margin: 0; letter-spacing: 0.02em; }
.results-headline .accent-line { color: var(--accent); }
.results-sub { color: var(--text-dim); font-size: clamp(16px, 1.9vh, 20px); max-width: 700px; }
.standings { width: min(960px, 100%); display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.standing-row {
  display: grid; grid-template-columns: 60px minmax(0, 1fr) 140px 80px 170px 130px; column-gap: 16px; align-items: center; text-align: left;
  background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 12px; padding: 14px 20px; font-size: 18px;
}
.standing-time { font-family: var(--font-mono); color: var(--text-dim); }
.standing-time, .standing-score { text-align: right; } /* numbers line up down the column */
/* Compact two-column board for a big room (9–20 players). */
.standings.crowded {
  width: min(1600px, 100%); display: grid; gap: 6px 16px;
  grid-auto-flow: column; grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 10), auto); /* --rows set by tv.js */
}
.standings.crowded .standing-row { grid-template-columns: 48px minmax(0, 1fr) 120px 70px 110px; column-gap: 12px; padding: 7px 16px; font-size: 16px; }
.standings.crowded .standing-rank { font-size: 16px; }
.standings.crowded .standing-order { display: none; }
.standing-row.winner { border-color: var(--accent); box-shadow: 0 0 24px rgba(229,56,77,0.25); }
.standing-rank { font-family: var(--font-mono); color: var(--text-dim); font-size: 20px; }
.standing-name { text-align: left; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing-correct { display: flex; align-items: center; gap: 6px; }
.standing-correct.yes { color: var(--success); }
.standing-correct.no { color: var(--danger); }
.standing-score { font-family: var(--font-mono); font-weight: 700; }
/* Narrower windows: one column of standings, then a two-line row. */
@media (max-width: 1100px) {
  .standings.crowded { width: min(960px, 100%); grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
}
@media (max-width: 760px) {
  .standings .standing-row, .standings.crowded .standing-row { grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 2px 12px; padding: 10px 14px; font-size: 16px; }
  .standing-rank { grid-row: span 2; }
  .standing-correct { grid-column: 2; grid-row: 2; font-size: 14px; }
  .standing-time { grid-column: 3; grid-row: 1 / span 2; }
  .standing-score { grid-column: 4; grid-row: 1 / span 2; }
  .standing-order { display: none; }
}

.results-actions { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-top: 10px; }

/* ---------- Leaderboard ---------- */
#screen-leaderboard { align-items: center; justify-content: flex-start; gap: 16px; text-align: center; padding: clamp(20px, 3.7vh, 40px) 24px 0; }
#screen-leaderboard .eyebrow { color: var(--accent); letter-spacing: 0.3em; text-transform: uppercase; font-size: 16px; }
#screen-leaderboard h2 { margin: 0; font-size: clamp(28px, 3.7vh, 40px); }
.lb-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--panel-bg); border: 1px solid var(--panel-border); }
.lb-tab {
  font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 8px 22px; border-radius: 999px; border: none; background: transparent; color: var(--text-dim); cursor: pointer;
}
.lb-tab:hover { color: var(--text); }
.lb-tab.active { background: var(--accent); color: #fff; }
.lb-panel { width: min(1600px, 100%); padding: 4px; }
/* Back stays at the bottom of the window while a long list scrolls. */
.lb-actions {
  position: sticky; bottom: 0; z-index: 5; width: 100%; margin-top: 0;
  padding: 16px 0 24px;
  background: linear-gradient(180deg, transparent, var(--bg) 35%);
}
.leaderboard-table { width: min(760px, 100%); margin: 0 auto; border-collapse: collapse; font-size: 18px; }
.leaderboard-table th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 13px; text-transform: uppercase; padding: 0 12px 10px; }
.leaderboard-table td { padding: 10px 12px; border-top: 1px solid var(--panel-border); text-align: left; }
.leaderboard-table th:nth-child(2) { width: 100%; } /* name takes the spare width */
.leaderboard-table th:nth-child(n+3), .leaderboard-table td:nth-child(n+3) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.leaderboard-table tr:first-child td { color: var(--accent); font-weight: 700; }
.leaderboard-empty { color: var(--text-dim); font-size: 16px; }

/* One card per finished game, newest first, every player with score + time. */
.game-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr)); gap: 16px; align-items: start; }
.game-card { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 16px; padding: 16px 20px; text-align: left; }
.game-card.current { border-color: var(--accent); box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 25%, transparent); }
.game-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.game-number { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.game-meta { min-width: 0; font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-table { width: 100%; border-collapse: collapse; font-size: 16px; table-layout: fixed; }
.game-table th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; padding: 4px 6px 8px; }
.game-table th:nth-child(1) { width: 64px; }
.game-table th:nth-child(3) { width: 100px; }
.game-table th:nth-child(4) { width: 104px; }
.game-table td { padding: 7px 6px; border-top: 1px solid var(--panel-border); }
.game-table td:nth-child(3), .game-table td:nth-child(4) { font-family: var(--font-mono); white-space: nowrap; }
.game-table th:nth-child(n+3), .game-table td:nth-child(n+3) { text-align: right; }
.game-table tbody tr:first-child td { color: var(--accent); font-weight: 700; }
.game-table .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-table tbody tr td.lb-none { color: var(--text-dim); font-weight: 400; }

/* ---- connection + roster feedback ---- */
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding: 10px 16px; text-align: center; font-size: 18px; font-weight: 600;
  background: #b45309; color: #fff;
  transform: translateY(-100%); transition: transform .2s ease;
}
.conn-banner.visible { transform: translateY(0); }
.roster-list li.offline { opacity: .45; }
.roster-list li.offline .roster-dot { background: #8b96ab; }
