:root {
  --bg: #f4efe9;
  --panel: #ffffff;
  --ink: #2b2b2b;
  --muted: #6e6a66;
  --line: #e3dbd2;
  --accent: #ff6600;
  --accent-soft: #ffe3d1;
  --second: #4a4a4a;
  --win: #ff6600;
  --header: #2b2b2b;
  --header-ink: #f4efe9;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514;
    --panel: #201f1d;
    --ink: #ece6df;
    --muted: #a39d96;
    --line: #34312e;
    --accent: #ff7a26;
    --accent-soft: #4a2a14;
    --second: #b9b2aa;
    --header: #0e0d0c;
    --header-ink: #ece6df;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161514; --panel: #201f1d; --ink: #ece6df; --muted: #a39d96; --line: #34312e;
  --accent: #ff7a26; --accent-soft: #4a2a14; --second: #b9b2aa; --header: #0e0d0c; --header-ink: #ece6df;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Raleway, system-ui, sans-serif;
  font-weight: 500;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.num, .mono, td.num { font-family: "Roboto Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.top { background: var(--header); color: var(--header-ink); padding: 28px 0 56px; border-bottom: 4px solid var(--accent); }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: var(--accent); font-weight: 700; }
h1 { margin: 4px 0 2px; font-size: clamp(28px, 5vw, 44px); font-weight: 800; letter-spacing: -.01em; }
.meta { margin: 0; opacity: .75; }

main { margin-top: -36px; padding-bottom: 40px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .v { font-size: 28px; font-weight: 800; line-height: 1.1; }
.tile .v small { font-size: 14px; font-weight: 600; color: var(--muted); }
.tile .k { color: var(--muted); font-size: 13px; }
.tile.hot .v { color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; min-width: 0; }
.card-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.card-head .hint { margin: 2px 0 10px; color: var(--muted); font-size: 13px; }
.card-head.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.two .card { margin-bottom: 16px; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }

.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font: 11px "Roboto Mono", monospace; }
.chart .grid { stroke: var(--line); }
.chart .axis { stroke: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

.tip {
  position: fixed; pointer-events: none; z-index: 10; background: var(--header); color: var(--header-ink);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; max-width: 260px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  opacity: 0; transition: opacity .1s;
}
.tip b { display: block; }

.repeat { padding: 10px 0; border-top: 1px solid var(--line); }
.repeat:first-child { border-top: 0; padding-top: 0; }
.repeat h3 { margin: 0 0 6px; font-size: 14px; font-weight: 700; }
.bar-row { display: grid; grid-template-columns: 44px 1fr 92px; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }
.bar { height: 14px; background: var(--second); border-radius: 3px; opacity: .55; }
.bar.best { background: var(--accent); opacity: 1; }
.delta { color: var(--accent); font-weight: 700; font-size: 12px; margin-left: 6px; }

.standings { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stand { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stand .pos { font-size: 26px; font-weight: 800; }
.stand.win .pos { color: var(--accent); }
.stand .sub { color: var(--muted); font-size: 13px; }
.pips { display: flex; gap: 3px; margin-top: 8px; }
.pips span { flex: 1; height: 18px; border-radius: 3px; background: var(--line); font: 10px/18px "Roboto Mono", monospace; text-align: center; color: var(--muted); }
.pips span.on { background: var(--accent-soft); color: var(--ink); }
.pips span.max { background: var(--accent); color: #fff; }

.filters button {
  font: inherit; font-size: 13px; border: 1px solid var(--line); background: transparent; color: var(--ink);
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th.num, td.num { text-align: right; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
tr.win td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.medal { display: inline-block; min-width: 22px; text-align: center; border-radius: 4px; font-weight: 700; padding: 0 4px; }
.medal.p1 { background: var(--accent); color: #fff; }
.medal.p2, .medal.p3 { background: var(--accent-soft); }
td a { color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; padding: 8px 2px; }
.foot a { color: inherit; }
.error { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }

/* ---------- landing ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hero { padding: 48px 0 72px; }
.hero h1 { font-size: clamp(34px, 7vw, 56px); }
.hero .meta { max-width: 560px; }
.search { display: flex; gap: 8px; margin-top: 22px; max-width: 560px; }
.search input {
  flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 8px;
  border: 2px solid transparent; background: var(--panel); color: var(--ink);
}
.search input:focus { outline: none; border-color: var(--accent); }
.search button {
  font: inherit; font-weight: 700; font-size: 16px; padding: 0 20px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.search button:hover { filter: brightness(1.08); }
.tip-line { margin: 10px 0 0; font-size: 13px; opacity: .6; }
.landing main { min-height: 30vh; margin-top: -36px; }
.landing #out:empty + .foot { padding-top: 48px; }
.loading { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.loading .sub { flex-basis: 100%; color: var(--muted); font-size: 13px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.riders { list-style: none; margin: 0; padding: 0; }
.riders li + li { border-top: 1px solid var(--line); }
.riders a { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 12px 6px; color: inherit; text-decoration: none; border-radius: 6px; }
.riders a:hover { background: var(--accent-soft); }
.rname { font-weight: 700; font-size: 16px; }
.rmeta { grid-column: 1; color: var(--muted); font-size: 13px; }
.go { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--accent); font-size: 20px; }
.back { color: var(--header-ink); opacity: .7; text-decoration: none; font-size: 13px; }
.back:hover { opacity: 1; }
.dns { font-family: Raleway, system-ui, sans-serif; font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }

/* ---------- Rouler bar (these pages live at rouler.dev/qnd) ---------- */
.rbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.rouler {
  display: inline-flex; align-items: center; gap: 8px; color: var(--header-ink); text-decoration: none;
  font: 800 16px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .08em;
}
.rouler img { border-radius: 6px; display: block; }
.rouler:hover { opacity: .85; }
.hero .rbar { margin-bottom: 28px; }

/* ---------- sources ---------- */
.src { display: inline-block; font: 700 10px/1 Raleway, system-ui, sans-serif; letter-spacing: .06em; padding: 3px 5px; border-radius: 4px; vertical-align: 1px; color: #fff; }
.src-qnd { background: var(--accent); }
.src-bwr { background: #c8102e; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.sources button {
  font: inherit; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.25); background: transparent; color: var(--header-ink);
}
.sources button[aria-pressed="true"] { background: var(--header-ink); color: var(--header); border-color: var(--header-ink); }
.sources .n { opacity: .6; font-weight: 500; margin-left: 2px; }
.acts { white-space: nowrap; text-align: right; }
.notme { font: inherit; font-size: 11px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; margin-left: 6px; cursor: pointer; opacity: 0; transition: opacity .1s; }
tr:hover .notme, .notme:focus { opacity: 1; }
@media (hover: none) { .notme { opacity: 1; } }
button.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.button-ghost { display: inline-block; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 13px; }
.button-ghost:hover { border-color: var(--accent); }
.foot p { margin: 6px 0; }
.pips span.drop { background: transparent; border: 1px dashed var(--line); text-decoration: line-through; opacity: .7; }
.rules-i { cursor: help; opacity: .7; }
