:root {
  color-scheme: dark;
  --bg-primary: #0B0F1F;
  --bg-panel: #1A1F3F;
  --bg-elevated: #252A50;
  --brand-violet: #7C3AED;
  --brand-gold: #FDCB3B;
  --race-cyan: #00E5FF;
  --race-orange: #FF9F1C;
  --race-teal: #24DAC9;
  --status-good: #24DAC9;
  --status-warning: #FF9F1C;
  --status-bad: #FF4D4D;
  --status-inactive: #64748B;
  --text-primary: #E8EDFF;
  --text-secondary: #94A3B8;
  --border-default: #333C65;
  --font-heading: 'Chakra Petch', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-pixel: 'Press Start 2P', monospace;
  --bg: var(--bg-primary); --panel: var(--bg-panel); --line: var(--border-default);
  --ink: var(--text-primary); --muted: var(--text-secondary); --mono: var(--font-mono);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 14px/1.65 var(--font-body); }
body::before { content: ''; position: absolute; inset: 0 0 auto; height: 430px; background: radial-gradient(ellipse at 65% 0%, #7c3aed12, transparent 65%); pointer-events: none; z-index: -1; }
a { color: inherit; text-decoration: none; }
button, select { font: inherit; color: inherit; }
button { border: 1px solid var(--line); border-radius: 6px; background: #252a5044; padding: 9px 13px; cursor: pointer; }
button:hover, .button-link:hover { border-color: var(--race-cyan); color: var(--race-cyan); }
button:disabled { opacity: .5; cursor: wait; }
a:focus-visible, button:focus-visible, select:focus-visible { outline: 2px solid var(--race-cyan); outline-offset: 4px; }
button, a, select { -webkit-tap-highlight-color: transparent; }
.shell { max-width: 1360px; margin: auto; padding: 0 40px; }
.topbar { height: 88px; display: flex; align-items: center; gap: 32px; border-bottom: 1px solid #333c6580; }
.brand { display: flex; align-items: center; gap: 12px; font: 700 18px var(--font-heading); letter-spacing: 2px; flex-shrink: 0; }
.brand-mark { width: 44px; height: 44px; filter: drop-shadow(0 0 10px #fdcb3b10); }
.brand small { display: block; margin-top: 3px; font: 9px var(--mono); letter-spacing: 1.6px; color: var(--muted); }
.topbar nav { display: flex; gap: 28px; margin-left: auto; }
.topbar nav a { color: var(--muted); font-size: 12px; transition: color .2s; }
.topbar nav a:hover, .topbar nav .selected { color: var(--ink); }
.topbar nav .selected { position: relative; }
.topbar nav .selected::after { content: ''; position: absolute; height: 2px; background: var(--brand-violet); left: 0; right: 0; bottom: -33px; }
.connection { display: flex; align-items: center; gap: 8px; padding-left: 24px; border-left: 1px solid var(--line); color: var(--muted); font: 10px var(--mono); text-transform: uppercase; white-space: nowrap; }
.signal { width: 6px; height: 6px; border-radius: 50%; background: var(--status-inactive); }
.signal.good { background: var(--race-cyan); box-shadow: 0 0 9px #00e5ff40; }
.signal.bad { background: var(--status-warning); }
.intro { position: relative; padding: 30px 0 22px; display: flex; align-items: center; justify-content: space-between; overflow: hidden; }
.intro::after { content: ''; position: absolute; width: 480px; height: 150px; bottom: 0; right: 0; background: url('/assets/skyline.svg') bottom right / contain no-repeat; opacity: .8; z-index: -1; }
.eyebrow { margin: 0 0 10px; font: 500 10px/1.5 var(--mono); letter-spacing: 1.6px; color: var(--muted); }
h1, h2, h3 { font-family: var(--font-heading); line-height: 1.12; margin: 0; }
h1 { font-size: clamp(40px, 5vw, 64px); font-weight: 700; letter-spacing: -1.7px; }
h2 { font-size: 27px; font-weight: 600; letter-spacing: -.5px; }
.title-dot { color: var(--brand-gold); }
.intro-copy { margin: 7px 0 0; font-size: 14px; color: var(--muted); }
.intro-copy strong { color: var(--ink); font-weight: 400; }
.edition { padding-right: 26px; text-align: right; }
.arcade-label { font: 8px/1.8 var(--font-pixel); color: var(--brand-gold); }
.edition p { color: var(--ink); font: 600 18px/1.4 var(--font-heading); margin: 12px 0 9px; }
.edition-coordinate { font: 9px var(--mono); letter-spacing: 1px; color: var(--muted); }
.pixel-track { position: relative; width: 230px; height: 22px; margin-top: 9px; }
.pixel-track img { position: absolute; left: 6px; bottom: 2px; width: 32px; image-rendering: pixelated; animation: trot 1.2s steps(2) infinite; }
.pixel-track span { position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: repeating-linear-gradient(90deg, #7c3aed88 0 12px, transparent 12px 20px); }
.pixel-track i { position: absolute; left: 215px; top: 5px; width: 9px; height: 9px; background: repeating-conic-gradient(#64748b 0 25%, transparent 0 50%) 0 0 / 6px 6px; opacity: .6; }
.track-grid { display: grid; grid-template-columns: minmax(270px, .68fr) minmax(0, 1.55fr); gap: 16px; }
.phase-card, .map-card, .panel { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.phase-card { position: relative; padding: 22px 24px 17px; background: linear-gradient(120deg, #242047, #171c36 72%); overflow: hidden; }
.phase-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-violet); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-top .eyebrow { margin: 0; font-size: 9px; }
.badge { color: var(--race-cyan); border: 1px solid #00e5ff44; background: #00e5ff07; border-radius: 4px; padding: 4px 7px; font: 8px var(--mono); letter-spacing: .6px; white-space: nowrap; }
.phase-heading { display: flex; align-items: center; gap: 9px; margin-top: 17px; }
.phase-heading h2 { color: var(--race-teal); font-size: 22px; letter-spacing: .5px; }
.live-orbit { width: 7px; height: 7px; border-radius: 50%; background: var(--race-teal); box-shadow: 0 0 0 4px #24dac911; }
.phase-card > p { color: var(--muted); font-size: 11px; margin: 8px 0; }
.phase-card > p.starting-line-count { color: var(--race-cyan); font: 9px var(--mono); margin: 10px 0 -5px; }
.phase-card > p.starting-line-names { color: var(--ink); font: 10px/1.55 var(--body); margin: 8px 0 0; min-height: 16px; overflow-wrap: anywhere; }
.hero-number { display: flex; gap: 12px; align-items: baseline; margin: 8px 0 15px; }
.hero-number > span:first-child { color: var(--ink); font: 500 42px/1.2 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.hero-number > span:last-child { color: var(--muted); font-size: 11px; }
.race-facts { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #333c6577; padding-top: 11px; gap: 10px; }
.race-facts span { color: var(--muted); font: 8px var(--mono); letter-spacing: .5px; }
.race-facts strong { display: block; color: #ccd3eb; font: 500 12px var(--mono); margin-top: 6px; }
.phase-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; font-size: 10px; color: var(--muted); }
.starting-lights { display: flex; gap: 4px; }
.starting-lights i { width: 5px; height: 5px; background: #64748b44; border-radius: 50%; }
.starting-lights i:last-child { background: var(--race-teal); }
.map-card { padding: 20px 22px 15px; min-width: 0; background: #11182b; }
.map-card .eyebrow { color: var(--race-cyan); }
.map-label { font: 9px var(--mono); color: var(--muted); }
.map-card canvas { display: block; width: 100%; height: 340px; image-rendering: pixelated; }
.map-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 9px var(--mono); color: var(--muted); }
.map-bottom > span:first-child { display: flex; align-items: center; gap: 6px; }
.map-zoom { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; color: var(--muted); font: 8px var(--mono); letter-spacing: .6px; }
.map-zoom input { width: min(180px, 45%); accent-color: var(--race-cyan); cursor: pointer; }
.map-zoom output { min-width: 34px; color: var(--race-cyan); text-align: right; font: 9px var(--mono); }
.map-tools { display: flex; justify-content: flex-end; align-items: center; gap: 28px; flex-wrap: wrap; }
.map-tools .map-zoom { margin-top: 12px; }
.map-zoom[hidden] { display: none; }
.legend-pig { display: inline-block; width: 5px; height: 5px; background: var(--brand-gold); margin-left: 8px; }
.legend-route { display: inline-block; width: 15px; height: 3px; border-radius: 2px; background: #258cff; margin-left: 8px; }
.legend-radius { display: inline-block; width: 12px; height: 12px; border: 1px dashed var(--race-cyan); border-radius: 50%; margin: 0 2px 0 8px; vertical-align: -4px; }
.telemetry-strip { display: flex; align-items: center; gap: 35px; padding: 17px 0; margin-bottom: 21px; border-bottom: 1px solid #333c6577; }
.telemetry-strip > div { display: flex; flex-direction: column; gap: 5px; }
.stat-label { font: 8px var(--mono); letter-spacing: 1px; color: var(--muted); }
.telemetry-strip strong { color: #c5d0e9; font: 11px var(--mono); }
.muted { font-size: 9px; color: var(--muted); }
.telemetry-strip .telemetry-message { margin-left: auto; color: var(--muted); font-size: 11px; font-style: italic; }
.error { background: #ff9f1c0a; border: 1px solid #ff9f1c55; color: #f3c382; border-radius: 6px; padding: 12px 16px; font-size: 12px; }
.board-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; align-items: start; gap: 20px; }
.leaderboard { padding: 23px 24px 0; min-height: 375px; background: #141a32; overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.section-heading .eyebrow { margin-bottom: 5px; font-size: 9px; }
.section-heading h2 { font-size: 27px; }
.subtle-label { font: 9px var(--mono); letter-spacing: .8px; color: var(--muted); text-align: right; }
.board-tabs { display: flex; gap: 25px; border-bottom: 1px solid #333c6577; margin-bottom: 8px; }
.board-tabs button { color: var(--muted); font-size: 11px; border: 0; border-bottom: 2px solid transparent; padding: 7px 0 11px; border-radius: 0; background: none; }
.board-tabs button.active { color: var(--race-cyan); border-bottom-color: var(--race-cyan); }
.table-head, .rank-row { display: grid; grid-template-columns: 34px minmax(120px, 1fr) 90px 73px 78px; gap: 12px; align-items: center; }
.table-head { padding: 11px 0 12px; color: var(--muted); font: 8px var(--mono); letter-spacing: .7px; }
.table-head > span:nth-child(n+3) { text-align: right; }
.rank-row { min-height: 68px; border-top: 1px solid #333c6559; position: relative; }
.rows { max-height: min(60vh, 476px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #64748b88 transparent; }
.rows::-webkit-scrollbar, .results-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.rows::-webkit-scrollbar-thumb, .results-scroll::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 8px; background: #64748b88; background-clip: padding-box; }
.rows::-webkit-scrollbar-track, .results-scroll::-webkit-scrollbar-track { background: transparent; }
.rank-row.rank-up { animation: rank-up-flash 1100ms ease-out; }
.rank-row.rank-down { animation: rank-down-flash 1100ms ease-out; }
@keyframes rank-up-flash { from { background: #24dac944; box-shadow: inset 3px 0 #24dac9; } to { background: transparent; box-shadow: inset 0 0 transparent; } }
@keyframes rank-down-flash { from { background: #ff9f1c33; box-shadow: inset 3px 0 #ff9f1c; } to { background: transparent; box-shadow: inset 0 0 transparent; } }
.rank-row .place { font: 500 13px var(--mono); color: var(--muted); }
.rank-row[data-place='1'] .place, .rank-row[data-place='1'] .metric { color: var(--brand-gold); }
.rank-row[data-place='2'] .place { color: #d4dceb; }
.rank-row[data-place='3'] .place { color: #ca9c80; }
.agent { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { flex-shrink: 0; height: 30px; width: 30px; display: grid; place-items: center; font: 12px var(--mono); background: #7c3aed18; color: #c4b4f5; border: 1px solid #7c3aed40; border-radius: 5px; }
.agent-text { min-width: 0; }
.agent-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.agent-detail { display: block; font: 9px var(--mono); color: var(--muted); margin-top: 5px; }
.agent-detail::before { content: ''; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--status-good); margin-right: 5px; vertical-align: 1px; }
.rank-row.warming .agent-detail::before { background: var(--status-inactive); }
.rank-row.uncertain .agent-detail::before { background: var(--status-warning); }
.rank-row.incomplete .agent-detail::before { background: var(--status-bad); }
.metric, .sample-count, .run-time { text-align: right; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.metric { color: var(--race-cyan); }
.metric small { display: block; color: var(--muted); font-size: 8px; margin-top: 3px; }
.sample-count, .run-time { color: #bec9e0; font-size: 10px; }
.rank-row.uncertain { opacity: .65; }
.rank-row.ready .agent-detail { color: var(--status-good); }
.rank-row.ready .agent-detail::before { background: var(--status-good); }
.board-footer { display: flex; justify-content: space-between; gap: 15px; border-top: 1px solid var(--line); margin-top: 8px; padding: 15px 0; color: var(--muted); font: 8px/1.7 var(--mono); }
.empty { min-height: 220px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 22px; color: var(--muted); }
.empty > span { color: var(--brand-gold); font-size: 37px; }
.empty h3 { font-size: 20px; color: var(--ink); margin: 7px 0; }
.empty p { max-width: 320px; font-size: 12px; }
.sidebar { display: grid; gap: 15px; }
.event-card { padding: 23px; background: linear-gradient(135deg, #20213b, #171c33); }
.event-card > .eyebrow { font-size: 8px; color: var(--brand-gold); }
.event-heading { display: flex; justify-content: space-between; align-items: start; }
.event-heading h2 { font-size: 31px; font-weight: 700; letter-spacing: -.5px; }
.event-heading > span { font-size: 33px; color: var(--brand-gold); }
.event-card > p:not(.eyebrow) { color: var(--muted); font-size: 11px; line-height: 1.8; margin: 13px 0; }
.date-toggle { display: flex; flex-direction: column; align-items: start; gap: 7px; width: 100%; text-align: left; padding: 14px 0; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; background: none; }
.date-toggle > span { font: 8px var(--mono); color: var(--muted); }
.date-toggle strong { color: var(--brand-gold); font: 500 11px/1.8 var(--mono); }
.date-toggle small { color: var(--muted); font: 8px var(--mono); }
.rules-date-toggle { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 2px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-elevated); color: var(--brand-gold); cursor: pointer; text-align: left; }
.rules-date-toggle strong { font: 500 12px/1.5 var(--mono); }
.rules-date-toggle small { color: var(--muted); font: 8px var(--mono); }
.rules-date-toggle:focus-visible { outline: 2px solid var(--race-cyan); outline-offset: 3px; }
.prizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 17px 0 10px; }
.prizes > div { border-left: 1px solid var(--line); padding-left: 10px; }
.prizes > div:first-child { border: 0; padding: 0; }
.prizes span { font: 7px var(--mono); color: var(--muted); }
.prizes strong { display: block; color: var(--brand-gold); font: 500 25px var(--mono); margin-top: 6px; }
.prizes small { font-size: 12px; }
.prize-note { color: var(--muted); font-size: 8px; }
.how-card { padding: 19px 23px; background: #17172e; border: 1px solid #7c3aed44; border-radius: 8px; }
.how-card .eyebrow { color: #b69bfa; font-size: 8px; }
.how-card p { font-size: 13px; margin: 8px 0 14px; }
.how-card a { display: flex; justify-content: space-between; font-size: 11px; color: #b69bfa; }
.records-section { margin: 35px 0; }
.record-grid { min-width: 0; border: 1px solid var(--line); background: #141a32; border-radius: 7px; overflow: hidden; }
.results-scroll { max-height: 430px; overflow: auto; }
.results-table { width: 100%; border-collapse: collapse; min-width: 590px; text-align: left; }
.results-table th { position: sticky; top: 0; z-index: 1; background: #1a1f3f; color: var(--muted); font: 8px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.results-table th, .results-table td { padding: 12px 16px; border-bottom: 1px solid #333c6566; }
.results-table th button { width: 100%; border: 0; border-radius: 0; padding: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-align: inherit; text-transform: inherit; white-space: nowrap; }
.results-table th button:hover { color: var(--race-cyan); }
.results-table td { font: 11px var(--mono); color: var(--text); }
.results-table td:first-child { font: 600 12px var(--body); overflow-wrap: anywhere; }
.results-table td:nth-child(n+3), .results-table th:nth-child(n+3) { text-align: right; }
.results-table tbody tr:last-child td { border-bottom: 0; }
.results-table tbody tr:hover { background: #202747; }
.results-table tbody tr.record-added { animation: record-added 1200ms ease-out; }
@keyframes record-added { from { background: #7c3aed44; } to { background: transparent; } }
.records-empty { font-size: 12px; color: var(--muted); padding: 15px 0; }
.rules-section { display: grid; grid-template-columns: 1fr 1.3fr; gap: 45px; padding: 28px; background: #141a32; }
.rules-section h2 { font-size: 30px; margin-bottom: 21px; }
.rules-section ol { list-style: none; padding: 0; margin: 0; }
.rules-section li { display: flex; gap: 18px; padding: 12px 0; border-bottom: 1px solid #333c6566; }
.rules-section li:first-child { padding-top: 0; }
.rules-section li:last-child { border: 0; padding-bottom: 0; }
.rules-section li > span { font: 11px var(--mono); color: var(--brand-violet); padding-top: 3px; }
.rules-section li strong { font-weight: 600; font-size: 12px; }
.rules-section li p { font-size: 11px; color: var(--muted); margin: 4px 0; }
.button-link { display: inline-flex; justify-content: space-between; align-items: center; gap: 30px; border: 1px solid #7c3aed77; background: #7c3aed13; border-radius: 5px; padding: 10px 15px; color: #c4b4f5; font-size: 11px; }
.podium { margin-top: 24px; padding: 26px; border-top-color: var(--brand-gold); background: linear-gradient(120deg, #262339, #171c33); }
.podium h2 { color: var(--brand-gold); margin-bottom: 22px; }
.podium-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.podium-grid strong { display: block; font: 600 23px var(--font-heading); overflow-wrap: anywhere; }
.podium-grid p { color: var(--muted); font: 11px/1.9 var(--mono); }
footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 1px solid #333c6580; padding: 25px 0; margin-top: 35px; color: var(--muted); font-size: 10px; }
.footer-brand { color: var(--ink); font: 600 12px var(--font-heading); letter-spacing: 1px; }
.footer-brand span { color: var(--muted); font-weight: 500; }
#sim-controls { display: flex; justify-content: space-between; gap: 15px; flex-wrap: wrap; margin-top: 15px; padding: 15px; border: 1px solid #ff9f1c55; border-radius: 7px; background: #ff9f1c08; }
#sim-controls > div:first-child { display: flex; flex-direction: column; gap: 5px; }
#sim-controls strong { font: 11px var(--mono); color: var(--race-orange); }
#sim-controls span { font-size: 10px; color: var(--muted); }
.control-row { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.control-row label { display: flex; flex-direction: column; gap: 4px; font-size: 9px; color: var(--muted); }
.control-row select { border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 7px; font-size: 11px; }
.control-row button { font-size: 11px; }
#play, #finish { border-color: #ff9f1c66; color: var(--race-orange); }
[hidden] { display: none !important; }
body.overlay { background: transparent; }
body.overlay .topbar, body.overlay .intro, body.overlay .track-grid, body.overlay .telemetry-strip, body.overlay .sidebar, body.overlay .records-section, body.overlay .rules-section, body.overlay footer { display: none; }
body.overlay .shell { padding: 20px; max-width: 850px; }
body.overlay .board-layout { display: block; }
body.overlay .leaderboard { background: #0b0f1fee; }
.rule-hero { display: flex; justify-content: space-between; align-items: center; padding: 48px 30px 35px 0; position: relative; }
.rule-hero::after { content: ''; position: absolute; inset: auto 0 0 auto; width: 480px; height: 150px; background: url('/assets/skyline.svg') bottom / contain no-repeat; z-index: -1; }
.rule-hero h1 { font-size: 58px; line-height: 1.06; }
.rule-hero .intro-copy { margin-top: 14px; }
.draft-tag { display: inline-block; border: 1px solid #7c3aed66; color: #b69bfa; border-radius: 3px; font: 8px var(--mono); letter-spacing: 1px; padding: 5px 8px; margin-top: 17px; }
.rules-pig { width: 160px; image-rendering: pixelated; transform: rotate(-4deg); filter: drop-shadow(0 8px 0 #0003); }
.rule-facts { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: #141a32; border-radius: 7px; padding: 20px 0; }
.rule-facts > div { border-left: 1px solid var(--line); padding: 0 25px; }
.rule-facts > div:first-child { border: 0; }
.rule-facts span { color: var(--muted); font: 9px var(--mono); letter-spacing: 1px; }
.rule-facts strong { display: block; margin-top: 9px; font: 500 28px var(--mono); color: var(--race-cyan); }
.rule-facts small { font-size: 10px; color: var(--muted); }
.rules-intro { display: flex; align-items: center; justify-content: space-between; gap: 35px; margin: 25px 0; }
.rules-intro p { max-width: 540px; font-size: 14px; color: #c3cce3; }
.rules-intro > span { color: var(--muted); font-size: 11px; max-width: 215px; text-align: right; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; counter-reset: rules; }
.rule-card { display: flex; align-items: start; gap: 18px; padding: 25px; background: #141a32; border: 1px solid var(--line); border-radius: 8px; }
.rule-number { color: #a485eb; font: 500 11px var(--mono); padding-top: 6px; }
.rule-card h2 { font-size: 24px; margin-bottom: 12px; }
.rule-card p { font-size: 12px; line-height: 1.95; color: var(--muted); margin: 0 0 10px; }
.rule-card p:last-child { margin-bottom: 0; }
.rule-card p strong { color: var(--ink); font-weight: 600; }
.rule-card:nth-child(4) { border-color: #00e5ff55; background: linear-gradient(140deg, #15223b, #141a32); }
.rule-card:nth-child(4) .rule-number { color: var(--race-cyan); }
.rule-card:last-child { grid-column: 1 / -1; border-color: #fdcb3b55; background: linear-gradient(100deg, #252337, #141a32); }
.rule-card:last-child .rule-number, .rule-card:last-child p strong { color: var(--brand-gold); }
.rule-cta { text-align: center; padding: 45px 20px 15px; }
.rule-cta h2 { font-size: 28px; margin: 16px 0 22px; }
@keyframes trot { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@media (max-width: 1100px) {
  .shell { padding: 0 28px; }
  .board-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
  .leaderboard { padding: 22px 18px 0; }
  .table-head, .rank-row { grid-template-columns: 26px minmax(80px, 1fr) 65px 57px 64px; gap: 9px; }
  .agent { gap: 7px; }
  .avatar { width: 25px; height: 28px; }
  .telemetry-strip .telemetry-message { display: none; }
  .map-bottom #map-caption { display: none; }
  .phase-card { padding: 20px; }
  .hero-number > span:first-child { font-size: 36px; }
  .hero-number > span:last-child { font-size: 10px; }
  .topbar nav { gap: 20px; }
}
@media (max-width: 800px) {
  .topbar { gap: 20px; height: 78px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand-mark { width: 37px; height: 37px; }
  .brand small { font-size: 7px; letter-spacing: 1px; }
  .topbar nav { gap: 17px; }
  .topbar nav a { font-size: 11px; }
  .topbar nav .selected::after { bottom: -29px; }
  .connection { padding-left: 15px; font-size: 8px; }
  .intro { padding-top: 27px; }
  .edition { padding-right: 0; }
  .edition p { font-size: 17px; }
  .edition .arcade-label { font-size: 6px; }
  .track-grid { grid-template-columns: minmax(235px, .7fr) minmax(0, 1.3fr); gap: 12px; }
  .phase-card .card-top { flex-wrap: wrap; gap: 8px; }
  .phase-heading h2 { font-size: 19px; }
  .hero-number { gap: 9px; }
  .map-card { padding: 20px 14px 15px; }
  .map-card .card-top { flex-wrap: wrap; gap: 6px; }
  .map-card canvas { height: 300px; }
  .map-bottom { font-size: 8px; }
  .telemetry-strip { justify-content: space-between; gap: 18px; }
  .board-layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1.2fr 1fr; align-items: start; }
  .how-card { min-height: 180px; }
  .rules-section { gap: 25px; padding: 25px; }
  .rules-section h2 { font-size: 25px; }
  .rule-hero h1 { font-size: 48px; }
  .rules-pig { width: 120px; }
  .rule-card { padding: 20px; gap: 13px; }
  .rule-card h2 { font-size: 21px; }
  .rule-facts > div { padding: 0 17px; }
  .rule-facts strong { font-size: 24px; }
}
@media (max-width: 560px) {
  .shell { padding: 0 18px; }
  .topbar { height: 75px; gap: 14px; flex-wrap: wrap; align-content: center; }
  .brand { font-size: 13px; letter-spacing: 1.5px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand small { font-size: 6px; }
  .topbar nav { gap: 14px; }
  .topbar nav a { font-size: 10px; }
  .topbar nav a:first-child, .topbar nav a:nth-child(3) { display: none; }
  .topbar nav .selected::after { bottom: -28px; }
  .connection { margin-left: auto; padding: 0; border: 0; font-size: 7px; }
  .intro { padding: 25px 0 19px; }
  .intro .eyebrow { font-size: 7px; letter-spacing: 1px; }
  h1 { font-size: 45px; letter-spacing: -1.3px; }
  .intro-copy { font-size: 12px; }
  .edition { display: none; }
  .intro::after { width: 220px; opacity: .5; }
  .pixel-track { margin-top: 13px; }
  .track-grid { grid-template-columns: 1fr; }
  .phase-card { padding: 20px; }
  .phase-card .card-top { flex-wrap: nowrap; }
  .phase-heading { margin-top: 13px; }
  .phase-heading h2 { font-size: 21px; }
  .hero-number { margin: 9px 0 13px; }
  .hero-number > span:first-child { font-size: 38px; }
  .hero-number > span:last-child { font-size: 11px; }
  .race-facts strong { font-size: 12px; }
  .phase-card > p { font-size: 11px; }
  .map-card { padding: 18px; }
  .map-card canvas { height: 260px; }
  .map-card .card-top { flex-wrap: nowrap; }
  .map-card .eyebrow, .map-label { font-size: 8px; }
  .map-bottom #map-caption { display: block; font-size: 7px; max-width: 100px; text-align: right; }
  .telemetry-strip { gap: 10px; margin-bottom: 12px; padding: 16px 0; }
  .stat-label { font-size: 6px; letter-spacing: .5px; }
  .telemetry-strip strong { font-size: 8px; }
  .muted { font-size: 7px; }
  .leaderboard { padding: 20px 14px 0; }
  .section-heading h2 { font-size: 25px; }
  .section-heading .eyebrow { font-size: 8px; }
  .subtle-label { font-size: 7px; }
  .table-head, .rank-row { grid-template-columns: 22px minmax(70px, 1fr) 58px 43px 49px; gap: 6px; }
  .table-head { font-size: 6px; }
  .avatar { display: none; }
  .agent-name { font-size: 11px; }
  .agent-detail { font-size: 7px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .metric { font-size: 11px; }
  .metric small { font-size: 7px; }
  .sample-count, .run-time { font-size: 8px; }
  .board-footer { font-size: 6px; }
  .sidebar { grid-template-columns: 1fr; }
  .how-card { display: none; }
  .event-card { padding: 22px; }
  .event-heading h2 { font-size: 28px; }
  .rules-section { grid-template-columns: 1fr; padding: 23px; }
  .rules-section h2 { font-size: 28px; }
  .podium-grid { grid-template-columns: 1fr; }
  footer { flex-wrap: wrap; gap: 14px; font-size: 9px; }
  footer > span { order: 3; flex-basis: 100%; }
  .footer-brand { font-size: 11px; }
  #sim-controls { padding: 13px; }
  #sim-controls span { font-size: 9px; }
  .control-row { width: 100%; }
  .control-row button, .control-row select { font-size: 10px; }
  .control-row label:first-child { max-width: 160px; }
  .rule-hero { padding: 33px 0 27px; }
  .rule-hero h1 { font-size: 40px; }
  .rule-hero .eyebrow { font-size: 7px; }
  .rule-hero::after { width: 240px; }
  .rules-pig { width: 72px; margin-left: -30px; align-self: end; margin-bottom: 30px; }
  .draft-tag { font-size: 7px; }
  .rule-facts { grid-template-columns: 1fr 1fr; padding: 0; overflow: hidden; }
  .rule-facts > div { padding: 15px 18px; }
  .rule-facts > div:nth-child(3) { border-left: 0; }
  .rule-facts > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .rule-facts span { font-size: 8px; }
  .rule-facts strong { font-size: 24px; }
  .rules-intro { display: block; margin: 21px 0; }
  .rules-intro p { font-size: 12px; }
  .rules-intro > span { display: block; max-width: none; text-align: left; font-size: 10px; }
  .rule-grid { grid-template-columns: 1fr; gap: 12px; }
  .rule-card { padding: 21px 17px; gap: 13px; }
  .rule-card h2 { font-size: 23px; }
  .rule-card p { font-size: 12px; line-height: 1.9; }
  .rule-cta { padding: 32px 10px 5px; }
  .rule-cta h2 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body[data-phase='GREEN FLAG'] .phase-heading h2 { color: var(--status-good); }
body[data-phase='GREEN FLAG'] .phase-card::before { background: var(--status-good); }
body[data-phase='FORMATION LAP'] .hero-number > span:first-child,
body[data-phase='PADDOCK OPEN'] .hero-number > span:first-child { color: var(--race-orange); }
body[data-phase='CHECKERED FLAG'] .phase-heading h2 { color: var(--brand-gold); }
body[data-phase='CANCELLED'] .phase-heading h2 { color: var(--status-bad); }
.final-countdown .hero-number > span:first-child { color: var(--race-orange); animation: last-seconds 1s ease-in-out infinite; }
@keyframes last-seconds { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .final-countdown .hero-number > span:first-child { animation: none; } }

.window-countdown { font: 600 clamp(20px, 3vw, 28px) var(--mono); font-variant-numeric: tabular-nums; color: var(--race-orange); letter-spacing: 1px; margin: 14px 0; }
.window-countdown-label { display: block; color: var(--muted); font-size: 8px; letter-spacing: 1.4px; font-weight: 700; }
.board-tabs { flex-wrap: wrap; }
body[data-phase="PADDOCK OPEN"] .hero-number > span:first-child, body[data-phase="FORMATION LAP"] .hero-number > span:first-child { font-size: clamp(25px, 3.2vw, 42px); letter-spacing: -1px; }

body[data-race-kind="practice"] .hero-number { flex-direction: column; align-items: flex-start; gap: 5px; }
body[data-race-kind="practice"] .hero-number > span:last-child { max-width: none; }
body.official-countdown .hero-number { flex-direction: column; align-items: flex-start; gap: 2px; }

.rows.prestart .rank-row, .table-head.prestart { grid-template-columns: 35px minmax(0, 1fr); }
.rows.prestart .metric, .rows.prestart .sample-count, .rows.prestart .run-time { display: none; }

.topbar nav { flex-wrap: wrap; gap: 16px; align-items: center; }
.topbar nav button { border: 0; border-radius: 0; padding: 12px 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.topbar nav button.active { color: var(--race-cyan); box-shadow: 0 2px var(--race-cyan); }
.race-history-card { padding: 24px; margin-bottom: 18px; }
.board-tabs:has(>button[hidden]:only-child) { display: none; }
@media (max-width: 700px) { .topbar { flex-wrap: wrap; } .topbar nav { order: 3; width: 100%; justify-content: space-between; gap: 8px; font-size: 11px; } }

/* Join page */
.join-hero { padding-bottom: 30px; }
.join-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 18px; margin: 8px 0 34px; }
.join-card { padding: 26px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(145deg, #1a1f3f, #11162d); }
.join-index, .join-prompt-label { display: block; color: var(--race-cyan); font: 10px var(--mono); letter-spacing: 1.4px; }
.join-card h2 { margin: 12px 0 8px; font: 700 27px/1.2 var(--font-heading); text-transform: uppercase; }
.join-card p { max-width: 58ch; color: var(--muted); }
.join-action { display: inline-flex; margin-top: 14px; }
.join-hosting-link { display: block; margin-top: 18px; border: 1px solid #333c65; border-radius: 7px; overflow: hidden; background: #0b0f1f; }
.join-hosting-link:focus-visible { outline: 2px solid var(--race-cyan); outline-offset: 4px; }
.join-hosting-image { display: block; width: 100%; height: auto; }
.join-prompt-wrap { margin-top: 21px; padding-top: 18px; border-top: 1px solid #333c6580; }
.join-prompt { margin: 10px 0 14px; padding: 15px; border: 1px solid #333c65; border-radius: 6px; background: #0b0f1f; color: var(--text-primary); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.join-copy-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.x-follow-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.x-follow { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid #333c65; border-radius: 6px; background: #0b0f1f; color: var(--text-primary); font-size: 12px; transition: border-color .18s ease, color .18s ease; }
.x-follow:hover { border-color: var(--race-cyan); color: var(--race-cyan); }
.x-follow > span { font-size: 15px; }
.copy-status { min-height: 1.4em; color: var(--status-good); font-size: 12px; }
.join-footer-note { display: flex; justify-content: space-between; align-items: center; padding: 22px 0 38px; border-top: 1px solid #333c6580; }
.join-footer-note a { color: var(--race-cyan); }
.join-footer-note a span { padding-left: 5px; }
@media (max-width: 800px) { .join-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .join-card { padding: 19px; } .join-footer-note { align-items: flex-start; gap: 15px; flex-direction: column; } }
