:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* qualified for league phase */
  --series-2: #eb6834;   /* still in qualifying */
  --track: #cde2fb;
  --brand: #eb172b;      /* SAFC red — chrome only, never data ink */
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --track: #184f95;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --track: #184f95;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header.site {
  background: var(--surface-1);
  border-bottom: 3px solid var(--brand);
  padding: 18px 24px 14px;
}
header.site h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
header.site h1 .accent { color: var(--brand); }
header.site .sub { color: var(--ink-2); margin-top: 2px; font-size: 13px; }

main { max-width: 1080px; margin: 0 auto; padding: 20px 24px 60px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.tile .label { font-size: 12px; color: var(--ink-2); }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* tabs */
nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 16px; flex-wrap: wrap; }
nav.tabs button {
  appearance: none; background: none; border: none;
  font: inherit; color: var(--ink-2); padding: 8px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav.tabs button.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
nav.tabs button:hover { color: var(--ink); }

/* filters */
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters input[type="search"], .filters select {
  font: inherit; color: var(--ink);
  background: var(--surface-1); border: 1px solid var(--baseline);
  border-radius: 7px; padding: 6px 10px;
}
.filters label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.legend { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--ink-2); margin-left: auto; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* probability table */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tablewrap { overflow-x: auto; }
table.probs { border-collapse: collapse; width: 100%; min-width: 720px; }
table.probs th, table.probs td { padding: 7px 10px; text-align: left; white-space: nowrap; }
table.probs thead th {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  border-bottom: 1px solid var(--grid);
  position: sticky; top: 0; background: var(--surface-1);
  cursor: pointer; user-select: none;
}
table.probs thead th.sorted { color: var(--ink); }
table.probs tbody tr { border-bottom: 1px solid var(--grid); }
table.probs tbody tr:last-child { border-bottom: none; }
table.probs tbody tr:hover { background: color-mix(in oklab, var(--surface-1) 92%, var(--ink)); }
table.probs td.num { font-variant-numeric: tabular-nums; text-align: right; }
table.probs th.num { text-align: right; }
.teamcell { display: flex; align-items: center; gap: 8px; }
.cc {
  font-size: 11px; color: var(--ink-2); background: var(--page);
  border: 1px solid var(--grid); border-radius: 4px; padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.stage { font-size: 12px; color: var(--muted); }

/* in-cell probability bar */
.barcell { min-width: 180px; }
.pbar { display: flex; align-items: center; gap: 8px; }
.pbar .trackk {
  display: block; flex: 1; height: 12px; background: none;
  border-radius: 0 4px 4px 0; position: relative;
}
.pbar .fill {
  display: block; height: 12px;
  border-radius: 0 4px 4px 0;   /* rounded data end, square baseline */
  background: var(--series-1);
  min-width: 2px;
}
.pbar .fill.chasing { background: var(--series-2); }
.pbar .val { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); width: 46px; text-align: right; }

/* pots grid */
.pots { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pot { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.pot h3 { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.pot ol { margin: 0; padding: 0; list-style: none; }
.pot li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 14px; border-bottom: 1px solid var(--grid); }
.pot li:last-child { border-bottom: none; }
.pot li .p { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.pot li.sunderland { font-weight: 700; }
.pot li.sunderland .nm { color: var(--brand); }
.pot li.ghost { color: var(--ink-2); }

/* brackets */
.rounds { display: flex; flex-direction: column; gap: 16px; }
.round h3 { margin: 0 0 6px; font-size: 15px; }
.round .path { color: var(--muted); font-weight: 400; }
.ties { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.tie {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px;
}
.tie .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.tie .row.winner { font-weight: 600; }
.tie .score { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tie .dates { color: var(--muted); font-size: 11px; margin-top: 3px; }
.tie .ref { color: var(--muted); font-style: italic; }

/* tooltip */
#tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--baseline); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; max-width: 280px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  display: none;
}
#tooltip h4 { margin: 0 0 4px; font-size: 13px; }
#tooltip .grid { display: grid; grid-template-columns: auto auto; gap: 1px 12px; }
#tooltip .grid .v { text-align: right; font-variant-numeric: tabular-nums; }
#tooltip .potmini { display: flex; gap: 2px; margin-top: 6px; }
#tooltip .potmini div { height: 8px; background: var(--series-1); border-radius: 2px; }

.about { max-width: 720px; color: var(--ink-2); }
.about h3 { color: var(--ink); }
.about code { background: var(--surface-1); border: 1px solid var(--grid); border-radius: 4px; padding: 0 4px; }

footer.upd { margin-top: 18px; color: var(--muted); font-size: 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.dot-live { color: var(--series-1); }
