:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --line-rest: rgba(137, 135, 129, 0.35);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  --home: var(--s1);
  --away: var(--s2);
  --ot: #c3c2b7;
  --shade: color-mix(in srgb, var(--away) 9%, var(--surface));
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --line-rest: rgba(137, 135, 129, 0.35);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
    --ot: #5b5a55;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --line-rest: rgba(137, 135, 129, 0.35);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --ot: #5b5a55;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 var(--font); }
.wrap { max-width: 960px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
header { padding-block: 24px 8px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 1.2rem; margin: 0 0 6px; }
.updated { color: var(--ink-2); margin: 0 0 12px; }
nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
nav a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--axis); }
nav a:hover { color: var(--ink); }
section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px 16px; margin-block: 16px; }
.lede { color: var(--ink-2); margin: 0 0 12px; }
.note { color: var(--ink-2); font-size: 0.9rem; }
.tag { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--axis); color: var(--ink-2); }
footer { color: var(--muted); font-size: 0.85rem; padding-block: 8px 32px; }

/* Next games */
.key { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); font-size: 0.85rem; margin-bottom: 8px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-home { background: var(--home); } .sw-ot { background: var(--ot); } .sw-away { background: var(--away); }
.day { font-weight: 600; margin: 14px 0 4px; color: var(--ink-2); font-size: 0.9rem; }
.game { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--grid); }
.game .teams { font-weight: 600; }
.game .time { color: var(--muted); font-weight: 400; margin-right: 6px; font-variant-numeric: tabular-nums; }
.game .meta { color: var(--ink-2); font-size: 0.85rem; text-align: right; font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; display: flex; gap: 2px; height: 22px; }
.bar > span { display: flex; align-items: center; justify-content: center; min-width: 0; font-size: 0.75rem; color: #fff; font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap; }
.bar > span:first-child { border-radius: 4px 0 0 4px; }
.bar > span:last-child { border-radius: 0 4px 4px 0; }
.bar .h { background: var(--home); } .bar .o { background: var(--ot); color: var(--ink); } .bar .a { background: var(--away); }

/* Tables */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--ink-2); font-weight: 600; font-size: 0.85rem; }
th.team, td.team { text-align: left; }
td.team { font-weight: 600; }
#forecast td { background: var(--row-bg, var(--surface)); }
#forecast th { background: var(--surface); }
#forecast .pos { position: sticky; left: 0; width: 4.4rem; min-width: 4.4rem; max-width: 4.4rem; text-align: center; }
#forecast th.team, #forecast td.team { position: sticky; left: 4.4rem; box-shadow: inset -1px 0 0 var(--grid); }
#forecast tr.bottom3 { --row-bg: var(--shade); }
#forecast td.now { text-align: left; }
.chg { display: inline-block; min-width: 2.2em; margin-left: 6px; font-size: 0.8rem; color: var(--ink-2); }
.chg.same { color: var(--muted); }
#forecast tr.zone td { text-align: left; padding: 1px 8px 3px; border-bottom: 0; border-top: 2px solid var(--axis); height: auto; }
#forecast tr.zone span { position: sticky; left: 8px; font-size: 0.72rem; color: var(--ink-2); }
.seg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.seg-label { color: var(--ink-2); font-size: 0.85rem; }
.seg .chip[aria-pressed="true"] { border-color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--ink-2); }
td.risk { position: relative; }
td.risk .fill { position: absolute; left: 0; top: 6px; bottom: 6px; background: var(--away); opacity: 0.18; border-radius: 0 4px 4px 0; }
td.risk span { position: relative; }

/* Timeline */
.dash-key { white-space: nowrap; margin-left: 8px; }
.ln { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--ink-2); vertical-align: middle; margin-right: 4px; }
.ln-dash { border-top-style: dashed; opacity: 0.6; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { font: inherit; font-size: 0.82rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--axis); background: transparent; color: var(--ink-2); cursor: pointer; min-height: 32px; }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--chip-color); box-shadow: inset 0 0 0 1px var(--chip-color); }
.chip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--chip-color, var(--line-rest)); }
.chart-box { position: relative; height: 360px; }

/* Scorecard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.stat { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.stat .v { font-size: 1.5rem; font-weight: 650; }
.stat .k { color: var(--ink-2); font-size: 0.85rem; }
.card-block + .card-block { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--grid); }
h3 { font-size: 1rem; margin: 0 0 4px; }

@media (max-width: 700px) {
  body { font-size: 14px; }
  section { padding: 14px 12px; }
  .chart-box { height: 300px; }
}
