:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --home: #2a78d6;          /* categorical slot 1 */
  --away: #eb6834;          /* categorical slot 2 */
  --line: #2a78d6;
  --good: #0ca30c;
  --good-text: #006300;
  --bad: #d03b3b;
  --bad-text: #b02a2a;
  --chip: #f0efec;
  --accent-text: #1c5cab;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --raised: #1f1f1e;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9b9991;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --home: #3987e5;
    --away: #d95926;
    --line: #3987e5;
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --chip: #2a2a28;
    --accent-text: #86b6ef;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); line-height: 1.45; font-size: 15px; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 24px 0 4px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--text-2); font-weight: 600; }
p { margin: 0 0 8px; }
button, select { font: inherit; color: inherit; }

/* Header and tabs */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 14px; }
.meta { color: var(--muted); font-size: 13px; margin: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-top: 8px; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; padding: 8px 12px 10px; cursor: pointer; color: var(--text-2);
  border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.tabs button:hover { color: var(--text); }
.tabs button:focus-visible, .btn:focus-visible, select:focus-visible { outline: 2px solid var(--home); outline-offset: 2px; }

main { padding-top: 8px; padding-bottom: 24px; min-height: 60vh; }
.lead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 16px 0 12px; }
.lead h2 { margin: 0; }
.sub { color: var(--muted); font-size: 13px; }
.empty { color: var(--text-2); padding: 32px 0; text-align: center; }

/* Legend */
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 8px; border-radius: 2px; display: inline-block; }
.swatch.home { background: var(--home); }
.swatch.away { background: var(--away); }

/* Game cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card { background: var(--raised); border: 1px solid var(--border); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team.home { justify-content: flex-end; text-align: right; }
.team .abbr { font-weight: 600; }
.team .pct { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.team .pct.fav { color: var(--text); }
.team .pct:not(.fav) { color: var(--muted); }
.at { color: var(--muted); font-size: 13px; padding: 0 4px; }
.logo { width: 32px; height: 32px; flex: none; }
.logo.sm { width: 22px; height: 22px; }
.odds-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2);
  font-variant-numeric: tabular-nums; margin-top: 6px; }
.lead h2 .sub { font-weight: 400; margin-left: 6px; }
.bar { display: flex; gap: 2px; height: 8px; margin: 8px 0 10px; }
.bar span { display: block; height: 100%; }
.bar .away { background: var(--away); border-radius: 4px 0 0 4px; }
.bar .home { background: var(--home); border-radius: 0 4px 4px 0; }
.starters { font-size: 13px; color: var(--text-2); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.starters .home { text-align: right; }
.status { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--chip); color: var(--text-2); margin-left: 4px; vertical-align: 1px; }
.status.confirmed { color: var(--good-text); }
.final { font-weight: 600; color: var(--text); }

/* Outcome label: icon + text, never color alone */
.outcome { font-size: 13px; font-weight: 600; white-space: nowrap; }
.outcome.hit { color: var(--good-text); }
.outcome.miss { color: var(--bad-text); }

/* Controls */
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0 12px; }
.btn { background: var(--raised); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn:disabled { opacity: 0.4; cursor: default; }
select { background: var(--raised); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.day-label { font-weight: 600; min-width: 150px; text-align: center; }

/* Tables and result rows */
.table-wrap { overflow-x: auto; background: var(--raised); border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.team-cell { display: flex; align-items: center; gap: 8px; }
.team-cell .full { color: var(--text-2); }
.up { color: var(--good-text); }
.down { color: var(--bad-text); }
.flat { color: var(--muted); }
.date-head td { background: var(--chip); font-weight: 600; font-size: 13px; color: var(--text-2); }
.score { font-variant-numeric: tabular-nums; font-weight: 600; }
.ended { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--raised); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 2px; }
.tile .note { font-size: 12px; color: var(--muted); }

/* Charts */
.chart-box { background: var(--raised); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.chart-box p.sub { margin-bottom: 8px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
svg.chart .gridline { stroke: var(--grid); stroke-width: 1; }
svg.chart .baseline { stroke: var(--axis); stroke-width: 1; }
svg.chart .ref { stroke: var(--axis); stroke-width: 1; }
svg.chart .series { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .wash { fill: var(--line); opacity: 0.10; }
svg.chart .dot { fill: var(--line); stroke: var(--raised); stroke-width: 2; }
svg.chart .cross { stroke: var(--axis); stroke-width: 1; }
svg.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.table-toggle { background: none; border: 0; color: var(--accent-text); cursor: pointer; padding: 0; font-size: 13px; margin-top: 6px; }

/* Tooltip */
.tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); max-width: 240px;
}
.tip .t-title { font-weight: 600; }
.tip .t-row { color: var(--text-2); }

.foot { color: var(--muted); font-size: 13px; padding-top: 8px; padding-bottom: 32px; border-top: 1px solid var(--border); }

@media (max-width: 520px) {
  .team .pct { font-size: 19px; }
  .logo { width: 28px; height: 28px; }
  .day-label { min-width: 0; }
  .hide-sm { display: none; }
}
