:root {
  --bg: #0e1014; --panel: #161920; --panel-2: #1c2029; --line: #272b35; --fg: #eceef2; --muted: #8d939f;
  --accent: #e5322d; --good: #34c27a; --bad: #ff5d57;
  --c-standard: #5b93ff; --c-league_q: #f2a43a; --c-league_race: #3cc985; --c-long: #b48cff;
  --grid: #232733; --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f5f7; --panel: #ffffff; --panel-2: #f0f1f4; --line: #e2e4e9; --fg: #16181d; --muted: #6a707c;
    --good: #18864f; --bad: #d4302b; --c-standard: #2f6fdb; --c-league_q: #d9822b; --c-league_race: #1f9a62;
    --c-long: #7c5cd6; --grid: #eceef2; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top-in, .filters-in, .view, .foot { max-width: 1240px; margin: 0 auto; padding-inline: 16px; }
.top-in { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 22px/1 var(--display);
  letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.flag { width: 22px; height: 16px; border-radius: 3px; background:
  conic-gradient(var(--fg) 25%, transparent 0 50%, var(--fg) 0 75%, transparent 0) 0 0/8px 8px; border: 1px solid var(--fg); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.nav a.on { color: var(--fg); background: var(--panel-2); }

.filters { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.filters-in { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; padding-block: 10px; }
.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f > span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.f select, .f input { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 130px; }
.f input { min-width: 210px; }
.f select:focus, .f input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.updated { margin-left: auto; color: var(--muted); font-size: 12px; align-self: center; }
body:not(.racer-page) #f-racer-wrap { display: none; }

.view { padding-block: 20px 40px; display: flex; flex-direction: column; gap: 16px; }
h1.title { font: 700 clamp(30px, 5vw, 44px)/1 var(--display); text-transform: uppercase; letter-spacing: .01em; margin: 4px 0 0; }
.sub { color: var(--muted); margin: 0; }
h2 { font: 600 20px/1.1 var(--display); text-transform: uppercase; letter-spacing: .03em; margin: 0; }
.note { color: var(--muted); font-size: 12.5px; margin: 4px 0 12px; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; position: relative; }
.card.flush { padding: 16px 0 6px; }
.card.flush > h2, .card.flush > .note, .card.flush > .card-head { padding-inline: 16px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.card-head .ctl { display: flex; gap: 8px; align-items: center; }
.card-head .ctl input, .card-head .ctl select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 13px; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .l { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tile .v { font: 600 32px/1.1 var(--display); font-variant-numeric: tabular-nums; margin-top: 4px; }
.tile .s { font-size: 12px; color: var(--muted); }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }
.chip.standard { --c: var(--c-standard); } .chip.league_q { --c: var(--c-league_q); }
.chip.league_race { --c: var(--c-league_race); } .chip.long { --c: var(--c-long); }
.badge { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.badge b { font: 600 20px/1 var(--display); }

.tw { overflow: auto; max-height: 560px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .04em; text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
th.sort { cursor: pointer; user-select: none; } th.sort:hover { color: var(--fg); }
th[aria-sort=ascending]::after { content: " ▲"; } th[aria-sort=descending]::after { content: " ▼"; }
td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.t, td.t { text-align: left; }
th:first-child, td:first-child { padding-left: 16px; } th:last-child, td:last-child { padding-right: 16px; }
.card:not(.flush) th:first-child, .card:not(.flush) td:first-child { padding-left: 4px; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
tr.me td { background: var(--panel-2); font-weight: 600; }
td a { text-decoration: none; } td a:hover { text-decoration: underline; }
.win { color: var(--accent); font-weight: 700; }
.pb { color: var(--good); font-weight: 600; }
.muted { color: var(--muted); }
.rank { color: var(--muted); width: 1%; }
.p1 { color: #d9a400; } .p2 { color: #9aa3ad; } .p3 { color: #c07a43; }
.empty { color: var(--muted); padding: 24px 16px; text-align: center; }

.chart { width: 100%; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: var(--grid); }
.chart .domain { display: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.tip { position: fixed; pointer-events: none; z-index: 50; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); display: none; max-width: 280px; }
.tip .d { color: var(--muted); }

.lapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 3px; }
.lapgrid div { background: var(--panel-2); border-radius: 5px; padding: 3px 4px; text-align: center; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.lapgrid small { display: block; color: var(--muted); font-size: 10px; }
.racechart { width: 100%; border-radius: 8px; background: #fff; }

.steps { counter-reset: s; display: grid; gap: 14px; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; }
.step::before { counter-increment: s; content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font: 700 17px/1 var(--display); }
.step h3 { margin: 4px 0 4px; font-size: 15px; }
.step p, .step li { color: var(--muted); margin: 0 0 6px; }
code, .code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--fg); }
.copy { cursor: pointer; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.inline-form input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 240px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); }
.h2h-pick { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; }
.vs { font: 700 26px/1 var(--display); color: var(--muted); padding-bottom: 6px; }
.big2 { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; text-align: center; }
.big2 .n { font: 700 56px/1 var(--display); font-variant-numeric: tabular-nums; }
.big2 .who { color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; padding-block: 24px 40px; display: flex; gap: 6px; flex-wrap: wrap; }
.foot span { margin-right: auto; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

@media (max-width: 640px) {
  .top-in { gap: 10px; } .brand span:last-child { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .f { flex: 1 1 40%; } .f select, .f input { min-width: 0; width: 100%; }
  #f-racer-wrap { flex-basis: 100%; }
  .updated { display: none; }
  .hide-sm { display: none; }
  .tile .v { font-size: 26px; }
  .big2 .n { font-size: 42px; }
}
