/* Layout: monochrome ink-on-paper; the rank icons are the only colour besides win/loss. Track hero, summary, standings + racer, trend + feed, then full match history. */
:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --ink: #111111;
  --ink-2: #4d4d4a;
  --ink-3: #8b8b86;
  --line: #e4e4e0;
  --lane: #ededea;
  --ghost: #c9c9c4;
  --hi: #f0f0ed;
  --win: #1d7a4f;
  --loss: #b8363b;
  --team-blue: #1f6fd6;
  --team-orange: #e07314;
  --font-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --font-body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f; --panel: #171717; --ink: #f2f2ef; --ink-2: #b3b3ae; --ink-3: #74746f;
    --line: #272726; --lane: #212120; --ghost: #3d3d3b; --hi: #222221;
    --win: #4cc28a; --loss: #ee6b6f; --team-blue: #4a93f0; --team-orange: #f08a33; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0f; --panel: #171717; --ink: #f2f2ef; --ink-2: #b3b3ae; --ink-3: #74746f;
  --line: #272726; --lane: #212120; --ghost: #3d3d3b; --hi: #222221;
  --win: #4cc28a; --loss: #ee6b6f; --team-blue: #4a93f0; --team-orange: #f08a33; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
img { max-width: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-body); }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; padding-block: 28px 56px; display: grid; gap: 20px; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.up { color: var(--win); } .down { color: var(--loss); }
.rank { width: 28px; height: 28px; object-fit: contain; flex: none; }

header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(30px, 5vw, 44px); line-height: 1; margin: 0; letter-spacing: -.01em; }
.search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 420px; }
.search input { width: 100%; min-width: 0; font: 500 15px var(--font-body); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.search button { font: 600 14px var(--font-body); color: var(--bg); background: var(--ink); border: 0; border-radius: 6px; padding: 9px 16px; cursor: pointer; }
.search input:focus-visible, .search button:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.search-msg { font-size: 13px; color: var(--ink-3); flex-basis: 100%; }
.search-msg:empty { display: none; }
.tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; margin-left: 8px; vertical-align: 3px; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.tabs button { font: 600 15px var(--font-display); letter-spacing: .02em; color: var(--ink-3); background: none; border: 0; padding: 10px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count { font: 600 11px var(--font-data); background: var(--ink); color: var(--bg); border-radius: 999px; padding: 1px 7px; }
.tab { display: grid; gap: 20px; }
#home { display: grid; gap: 20px; }

.live-sum { display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: 14px; color: var(--ink-2); }
.live-sum b { font-family: var(--font-display); font-size: 22px; color: var(--ink); margin-right: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.on { background: var(--win); }
.dot.live { background: var(--loss); }
@media (prefers-reduced-motion: no-preference) { .dot.live { animation: pulse 1.6s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .35; } }
.matches { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 20px; }
.match { display: grid; gap: 16px; }
.match-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.match-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.clock { display: flex; align-items: center; gap: 8px; font: 600 15px var(--font-data); }
.clock.ot { color: var(--loss); }
.board { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.board .side { display: grid; gap: 2px; }
.board .side:last-child { text-align: right; }
.board .score { font: 700 52px/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.board .state { font-size: 13px; font-weight: 600; text-align: center; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.blue { background: var(--team-blue); } .orange { background: var(--team-orange); }
.timeline { position: relative; height: 34px; }
.timeline .rail { position: absolute; left: 0; right: 0; top: 16px; height: 2px; background: var(--lane); }
.timeline .done { position: absolute; left: 0; top: 16px; height: 2px; background: var(--ink-3); }
.timeline .goal { position: absolute; top: 10px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; border: 2px solid var(--panel); }
.timeline .ticks { position: absolute; inset: auto 0 -6px 0; display: flex; justify-content: space-between; font: 11px var(--font-data); color: var(--ink-3); }
.squad { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.mate { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.mate > img { width: 36px; height: 36px; object-fit: contain; }
.mate .stakes { text-align: right; font: 12px var(--font-data); color: var(--ink-2); display: grid; }
.presence { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 4px 24px; }
.presence li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.presence li img { width: 26px; height: 26px; object-fit: contain; }
.presence .pn { font-weight: 600; }
.presence .ps { font-size: 12px; color: var(--ink-3); margin-left: auto; white-space: nowrap; }
.meta { color: var(--ink-2); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.meta b { color: var(--ink); font-weight: 600; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; min-width: 0; }
.panel h2 { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.panel .sub { color: var(--ink-3); font-size: 13px; margin: 0 0 12px; }
.scroll { overflow-x: auto; }

#track { display: block; width: 100%; height: auto; }
#track .lane-row { cursor: pointer; }
#track .lane-row:focus { outline: none; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.kpi { background: var(--panel); padding: 14px 18px; display: grid; gap: 2px; align-content: start; }
.kpi b { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.2; display: flex; align-items: center; gap: 8px; }
.kpi small { color: var(--ink-2); font-size: 13px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); padding: 0 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.r, td.r { text-align: right; }
.standings tbody tr { cursor: pointer; }
.standings tbody tr:hover td { background: var(--hi); }
.standings tbody tr.sel td { background: var(--hi); }
.standings tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--ink); }
tbody tr:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.pos { font-family: var(--font-display); font-weight: 700; color: var(--ink-3); width: 1%; }
tr.sel .pos { color: var(--ink); }
.who { display: flex; align-items: center; gap: 10px; }
.name { font-weight: 600; }
.tier { font-size: 12px; color: var(--ink-2); }
.streak { font-size: 12px; font-weight: 600; }
.spark { display: block; }

.driver-head { display: flex; align-items: center; gap: 14px; }
.driver-head > img { width: 64px; height: 64px; object-fit: contain; }
.driver-head h2 { font-size: 22px; margin: 0; }
.big { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1; margin-top: 14px; }
.big small { font-size: 14px; color: var(--ink-3); font-weight: 500; margin-left: 4px; }
.meter { height: 6px; background: var(--lane); border-radius: 3px; overflow: hidden; margin: 12px 0 6px; }
.meter i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 12px; margin: 16px 0 4px; }
.facts div { display: grid; gap: 1px; }
.facts b { font-family: var(--font-data); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pergame { display: grid; gap: 9px; margin-top: 16px; }
.pg { display: grid; grid-template-columns: 64px minmax(0, 1fr) 44px; align-items: center; gap: 10px; font-size: 13px; }
.pg .bar { position: relative; height: 6px; background: var(--lane); border-radius: 3px; }
.pg .bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 3px; }
.pg .bar em { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-3); }
.pg .num { text-align: right; }
.legend-note { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.legend-note em { display: inline-block; width: 2px; height: 12px; background: var(--ink-3); }
.link { display: inline-block; margin-top: 14px; color: var(--ink); font-weight: 600; font-size: 14px; text-underline-offset: 3px; }

.chart-wrap { position: relative; }
#trend { display: block; width: 100%; height: auto; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); }

.feed { list-style: none; padding: 0; margin: 0; display: grid; }
.feed li { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.res { font-family: var(--font-display); font-weight: 700; font-size: 13px; }
.feed .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .when { color: var(--ink-3); font-size: 12px; }

.hist-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { font: 600 13px var(--font-body); color: var(--ink-2); background: var(--panel); border: 0; padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; padding: 14px 0; border-block: 1px solid var(--line); margin-bottom: 8px; }
.totals div { display: grid; gap: 1px; }
.totals b { font-family: var(--font-data); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hist th { padding-top: 8px; }
.hist tr.day td { background: var(--hi); font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 6px 8px; }
.hist tr.day td span { font-weight: 500; color: var(--ink-3); margin-left: 8px; }
.hist .rk { display: flex; align-items: center; gap: 6px; }
.hist .rk img { width: 22px; height: 22px; }
.hist .promo { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink); }

.back { font: 600 14px var(--font-body); color: var(--ink); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; cursor: pointer; justify-self: start; }
.back:focus-visible, .linkbtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.linkbtn { font: 600 14px var(--font-body); color: var(--ink); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 24px; align-items: center; }
.hero > img { width: 112px; height: 112px; object-fit: contain; }
.hero h2 { font-family: var(--font-display); font-size: clamp(26px, 4vw, 36px); line-height: 1.1; margin: 0; }
.hero .elo { text-align: right; }
.hero .elo .big { margin: 0; }
.hero .meter { grid-column: 1 / -1; margin: 8px 0 0; }
.hero .note { grid-column: 1 / -1; }
@media (max-width: 600px) { .hero { grid-template-columns: auto minmax(0, 1fr); } .hero > img { width: 72px; height: 72px; } .hero .elo { text-align: left; grid-column: 1 / -1; } }
.p-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px 16px; }
.p-facts div { display: grid; gap: 1px; }
.p-facts b { font-family: var(--font-data); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.jits tbody tr { cursor: pointer; }
.jits tbody tr:hover td { background: var(--hi); }
.jits tr.out td { color: var(--ink-2); }
.jits tr.out .pos { color: var(--ink-3); }
.mate .name { cursor: pointer; }
.mate .name:hover { text-decoration: underline; text-underline-offset: 3px; }
.modes { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px; }
.mode { flex: none; display: grid; grid-template-columns: 30px auto; gap: 0 10px; align-items: center; text-align: left; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px 8px 8px; cursor: pointer; }
.mode .pl { grid-row: span 2; width: 30px; height: 30px; object-fit: contain; }
.mode .mn { font-weight: 600; font-size: 14px; }
.mode .me { display: flex; align-items: center; gap: 5px; font: 12px var(--font-data); color: var(--ink-2); }
.mode .me img { width: 18px; height: 18px; object-fit: contain; }
.mode:hover:not(:disabled) { border-color: var(--ink-3); }
.mode[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mode:disabled { opacity: .45; cursor: default; }
.mode:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.season { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 20px; align-items: center; }
.season > img { width: 64px; height: 64px; object-fit: contain; grid-row: span 2; }
.season h2 { margin: 0; font-size: 18px; }
.pips { display: flex; gap: 4px; }
.pips i { flex: 1; height: 8px; border-radius: 2px; background: var(--lane); max-width: 34px; }
.pips i.on { background: var(--ink); }
.ladder { display: flex; gap: 2px; grid-row: span 2; }
.ladder img { width: 30px; height: 30px; object-fit: contain; opacity: .25; filter: grayscale(1); }
.ladder img.got { opacity: 1; filter: none; }
@media (max-width: 700px) { .season { grid-template-columns: auto minmax(0, 1fr); } .ladder { grid-row: auto; grid-column: 1 / -1; flex-wrap: wrap; } }
footer { color: var(--ink-3); font-size: 12px; }
@media (prefers-reduced-motion: no-preference) { .meter i, .pg .bar i { transition: width .35s ease; } }
.trend-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin-bottom: 4px; }
.trend-head h2 { margin: 0; }
.trend-ctl { display: flex; align-items: center; gap: 12px; }
.trend-ctl .seg button { padding: 4px 10px; font-size: 12px; }
.trend-hit { cursor: crosshair; touch-action: pan-y; }
.face { border-radius: 50%; object-fit: cover; }
.mini { width: 16px; height: 16px; object-fit: contain; vertical-align: -3px; margin-right: 4px; }
.epic { font-weight: 400; font-size: 12px; color: var(--ink-3); margin-left: 4px; }
.m-stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.m-stats .kpi b { font-size: 30px; }
.m-result { font: 700 22px var(--font-display); letter-spacing: .04em; text-transform: uppercase; }
.m-board .side:last-child .label { justify-content: flex-end; display: flex; align-items: center; gap: 6px; }
.m-board .side:last-child .swatch { margin: 0; }
#m-recent { display: block; width: 100%; height: auto; }
.standing { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 16px; align-items: center; }
.standing > img { width: 72px; height: 72px; object-fit: contain; grid-row: span 2; }
.standing h2 { margin: 0; }
.div-pips { display: flex; gap: 4px; margin-top: 6px; }
.div-pips i { width: 26px; height: 6px; border-radius: 2px; background: var(--lane); }
.div-pips i.on { background: var(--ink); }
.hist a { color: inherit; text-underline-offset: 3px; }
.banner { border: 1px solid var(--loss); color: var(--ink); background: var(--panel); border-radius: 10px; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.banner button { font: 600 13px var(--font-body); color: var(--bg); background: var(--ink); border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.empty { color: var(--ink-3); font-size: 14px; padding: 12px 0; }
.loading { color: var(--ink-3); }

.rk-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.rk-controls .seg { flex-wrap: wrap; }
.rk-controls .seg button { padding: 5px 11px; }
.plat-badge { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--hi); border: 1px solid var(--line); color: var(--ink-2); font: 700 10px var(--font-display); letter-spacing: .04em; }
.rk-tier { display: inline-flex; align-items: center; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.ranked tr.rk-link { cursor: pointer; }
.ranked tbody tr.rk-link:hover td { background: var(--hi); }
.more { display: block; width: 100%; margin-top: 12px; padding: 10px; font: 600 14px var(--font-body); color: var(--ink); background: var(--hi); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.more:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.search-box { position: relative; flex: 1 1 220px; min-width: 0; }
.suggest { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 40px rgb(0 0 0 / .35); max-height: 360px; overflow-y: auto; }
.suggest li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--hi); }
.sg-face { width: 28px; height: 28px; }
.sg-names { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.sg-nick { font-weight: 600; }
.sg-epic { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.sg-rank { display: flex; align-items: center; font: 13px var(--font-data); color: var(--ink-2); }

.account { display: flex; align-items: center; gap: 10px; flex: none; }
.acct-face { width: 40px; height: 40px; padding: 0; border: 2px solid var(--line); border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--hi); color: var(--ink); font: 700 16px var(--font-display); }
.acct-face img { width: 100%; height: 100%; object-fit: cover; }
button.acct-face { cursor: pointer; transition: border-color .15s; }
button.acct-face:hover { border-color: var(--ink); }
button.acct-face:focus-visible, .acct-out:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.acct-text { display: grid; line-height: 1.25; }
.acct-name { font-weight: 600; }
.acct-out { justify-self: start; padding: 0; border: 0; background: none; color: var(--ink-3); font: 12px var(--font-body); cursor: pointer; }
.acct-out:hover { color: var(--ink); text-decoration: underline; }

/* $link welcome: avatar pops in with a ring, "Hello, name" rises, then the overlay fades out. */
.welcome { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 24px; background: var(--bg); }
.welcome-face { width: 136px; height: 136px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--hi); color: var(--ink); font: 700 54px var(--font-display); box-shadow: 0 0 0 5px var(--bg), 0 0 0 7px var(--ink); }
.welcome-face img { width: 100%; height: 100%; object-fit: cover; }
.welcome-text { margin: 0; color: var(--ink); font: 700 clamp(28px, 6vw, 46px) var(--font-display); letter-spacing: .01em; text-align: center; padding-inline: 16px; }
.welcome.play { animation: welcome-out .6s ease 2.6s forwards; }
.welcome.play .welcome-face { animation: welcome-face .8s cubic-bezier(.2, .9, .3, 1.15) both; }
.welcome.play .welcome-text { animation: welcome-text .6s ease .8s both; }
@keyframes welcome-face {
  0% { opacity: 0; transform: scale(.55); box-shadow: 0 0 0 0 var(--bg), 0 0 0 0 var(--ink); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; box-shadow: 0 0 0 5px var(--bg), 0 0 0 7px var(--ink); }
}
@keyframes welcome-text { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes welcome-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .welcome.play .welcome-face, .welcome.play .welcome-text { animation-duration: .01s; animation-delay: 0s; }
  .welcome.play { animation-duration: .3s; animation-delay: 1.8s; }
}

/* Phones: tables become cards. Each cell's --c/--r (set in the markup) places it on the card's grid; labels come from data-label. */
@media (max-width: 640px) {
  .wrap { padding-inline: 14px; gap: 14px; }
  #home, .tab { gap: 14px; }
  .panel { padding: 14px; }
  .scroll { overflow: visible; }
  .stack, .stack tbody { display: block; }
  .stack thead { display: none; }
  .stack tr { display: grid; gap: 8px 10px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .stack tr > td { display: block; grid-column: var(--c, auto); grid-row: var(--r, auto); padding: 0; border: 0; white-space: normal; text-align: left; min-width: 0; background: none; }
  .stack td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font: 600 10px var(--font-body); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
  .stack td.c-elo { text-align: right; font-size: 18px; font-weight: 600; }
  .stack .spark { width: 56px; height: 20px; }
  .stack td > div[style*="flex"] { gap: 4px !important; flex-wrap: wrap; }
  .standings tr { grid-template-columns: 22px repeat(4, minmax(0, 1fr)); }
  .jits tr, .ranked tr { grid-template-columns: 22px repeat(3, minmax(0, 1fr)); }
  .history tr { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px 8px; }
  .history tr.day, .history tr.day td, .stack td.empty { display: block; }
  .history td.na { display: none; }
  .standings tbody tr.sel td:first-child { box-shadow: none; }
  .standings tbody tr.sel { box-shadow: inset 3px 0 0 var(--ink); background: var(--hi); }
  .standings tbody tr.sel td, .standings tbody tr:hover td, .jits tbody tr:hover td { background: none; }
  .mode { flex: 1 1 calc(50% - 4px); }
  .hero .big { font-size: 34px; }
  .board .score { font-size: 40px; }
  .board { gap: 8px; }
  .feed li, .presence li { font-size: 13px; }
  .totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs { gap: 18px; }
  .account { order: -1; margin-left: auto; }
}

/* "While you were gone…" recap: story slides with a per-slide glow; every element rises in on its own --d delay. */
.recap { position: fixed; inset: 0; z-index: 90; background: var(--bg); color: var(--ink); overflow: hidden; cursor: pointer; animation: rc-fade .35s ease both; }
.recap.closing { animation: rc-fade-out .45s ease forwards; }
.recap-bars { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); left: 16px; right: 16px; display: flex; gap: 5px; z-index: 2; }
.recap-bars i { flex: 1; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 18%, transparent); overflow: hidden; position: relative; }
.recap-bars i::after { content: ""; position: absolute; inset: 0; background: var(--ink); transform: scaleX(0); transform-origin: left; }
.recap-bars i.done::after { transform: none; }
.recap-bars i.now::after { animation: rc-fill var(--ms) linear forwards; }
.recap-skip { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 28px); right: 16px; z-index: 2; font: 600 13px var(--font-body); color: var(--ink-2); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.recap-skip:hover, .recap-skip:focus-visible { color: var(--ink); border-color: var(--ink); outline: none; }
.recap-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 80px 20px 40px; }
.recap-stage::before { content: ""; position: absolute; width: min(90vw, 720px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--glow) 32%, transparent), transparent 65%); filter: blur(20px); animation: rc-glow 5s ease-in-out infinite alternate; pointer-events: none; }
.rc-slide { position: relative; display: grid; justify-items: center; gap: 14px; text-align: center; width: min(100%, 640px); }
.rc-kicker { margin: 0; font: 600 13px var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.rc-huge { margin: 0; font: 700 clamp(40px, 9vw, 84px)/1.02 var(--font-display); letter-spacing: -.01em; text-wrap: balance; }
.rc-title { margin: 0; font: 700 clamp(28px, 6vw, 48px)/1.1 var(--font-display); text-wrap: balance; }
.rc-sub { margin: 0; font-size: clamp(16px, 3.5vw, 20px); color: var(--ink-2); }
.rc-meta { margin: 0; font-size: 15px; color: var(--ink-2); }
.rc-num { font: 700 clamp(72px, 18vw, 150px)/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rc-name { margin: 0; font: 700 clamp(26px, 6vw, 40px) var(--font-display); }
.rc-word { display: inline-block; animation: rc-rise .7s cubic-bezier(.2, .8, .2, 1) var(--d) both; }
.recap .rise { animation: rc-rise .7s cubic-bezier(.2, .8, .2, 1) var(--d, 0s) both; }
.recap .pop { animation: rc-pop .8s cubic-bezier(.2, .9, .3, 1.2) .2s both; }
.rc-face { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center; background: var(--hi); font: 700 15px var(--font-display); }
.rc-face-xl { width: clamp(110px, 26vw, 150px); height: clamp(110px, 26vw, 150px); font-size: 52px; box-shadow: 0 0 0 5px var(--bg), 0 0 0 7px var(--glow); }
.rc-wl { width: min(100%, 420px); height: 12px; display: flex; gap: 3px; border-radius: 6px; overflow: hidden; }
.rc-wl .w { width: var(--w); background: var(--win); animation: rc-grow 1s cubic-bezier(.2, .8, .2, 1) 1s both; transform-origin: left; }
.rc-wl .l { flex: 1; background: var(--loss); }
.rc-line { width: min(100%, 360px); height: auto; overflow: visible; }
.rc-line path { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: rc-draw 1.4s ease .9s forwards; }
.rc-line.up path { stroke: var(--win); } .rc-line.down path { stroke: var(--loss); }
.rc-list, .rc-race { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; width: min(100%, 520px); }
.rc-list li, .rc-race li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--panel) 85%, transparent); border: 1px solid var(--line); text-align: left; }
.rc-li-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-li-meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.rc-rank { width: 30px; height: 30px; object-fit: contain; }
.rc-pos { font: 700 16px var(--font-display); color: var(--ink-3); width: 16px; }
.rc-bar { flex: 1.2; height: 6px; border-radius: 3px; background: var(--lane); overflow: hidden; }
.rc-bar i { display: block; height: 100%; width: var(--w); background: var(--ink); border-radius: 3px; transform-origin: left; animation: rc-grow .9s cubic-bezier(.2, .8, .2, 1) var(--d) both; }
.rc-shift { font: 600 12px var(--font-data); width: 30px; text-align: right; color: var(--ink-3); }
.rc-done { margin-top: 10px; font: 600 16px var(--font-body); color: var(--bg); background: var(--ink); border: 0; border-radius: 999px; padding: 12px 26px; cursor: pointer; }
.rc-done:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@keyframes rc-rise { from { opacity: 0; transform: translateY(18px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes rc-pop { 0% { opacity: 0; transform: scale(.5); } 100% { opacity: 1; transform: none; } }
@keyframes rc-grow { from { transform: scaleX(0); } to { transform: none; } }
@keyframes rc-draw { to { stroke-dashoffset: 0; } }
@keyframes rc-fill { to { transform: none; } }
@keyframes rc-glow { from { transform: scale(.85); opacity: .7; } to { transform: scale(1.1); opacity: 1; } }
@keyframes rc-fade { from { opacity: 0; } }
@keyframes rc-fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .recap .rise, .recap .pop, .rc-word, .rc-bar i, .rc-wl .w, .recap-stage::before { animation: none; }
  .rc-line path { animation: none; stroke-dashoffset: 0; }
}
@media (max-width: 640px) {
  .rc-li-meta { display: none; }
  .rc-race li { gap: 8px; padding: 9px 10px; }
}
