:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e0e4ea;
  --text: #141a21;
  --muted: #5d6877;
  --accent: #d4621c;
  --accent-ink: #ffffff;
  --good: #11845b;
  --bad: #c9353c;
  --warn: #b7791f;
  --info: #2f6fdb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1d222b;
    --border: #2a313c;
    --text: #e6eaf0;
    --muted: #8e99a8;
    --accent: #f08a45;
    --accent-ink: #1a0f06;
    --good: #35c48a;
    --bad: #f0646a;
    --warn: #e8b54d;
    --info: #6b9cff;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, select, input {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.container { max-width: 1260px; margin: 0 auto; padding: 16px; }
.loading, .empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.error { padding: 16px; border: 1px solid var(--bad); border-radius: var(--radius); color: var(--bad); background: var(--surface); }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-ball { width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.status { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--good); }
.dot.stale { background: var(--warn); }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 40px; }

/* ---- generic ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 16px; }
.panel h3, .section-title { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.chip.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.chip.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chip.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--surface); padding: 6px 10px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }
.logo { width: 28px; height: 28px; object-fit: contain; flex: none; }
.logo.lg { width: 56px; height: 56px; }
.headshot { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }

/* ---- date bar ---- */
.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.datebar h2 { margin: 0 8px 0 0; font-size: 20px; }

/* ---- game cards ---- */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.game-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s; }
.game-card:hover { border-color: var(--accent); }
.gc-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.gc-head .live { color: var(--bad); font-weight: 700; }
.gc-table { display: grid; grid-template-columns: 1fr 70px 70px 64px; align-items: center; row-gap: 6px; column-gap: 6px; }
.gc-table .h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; text-align: center; }
.gc-team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gc-team .abbr { font-weight: 700; flex: none; }
.gc-team .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gc-team .score { margin-left: auto; font-weight: 700; font-size: 16px; padding-right: 6px; flex: none; }
.gc-team.winner .abbr, .gc-team.winner .score { color: var(--text); }
.gc-team.loser { color: var(--muted); }
.gc-line { text-align: center; background: var(--surface-2); border-radius: 6px; padding: 4px 0; font-weight: 600; }
.gc-line small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.gc-model { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; border-top: 1px dashed var(--border); padding-top: 8px; font-size: 12px; }
.gc-model b { font-weight: 600; }

/* ---- game detail ---- */
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 20px; }
.matchup .side { display: flex; align-items: center; gap: 12px; }
.matchup .side.home { justify-content: flex-end; text-align: right; }
.matchup .name { font-size: 20px; font-weight: 700; }
.matchup .meta { text-align: center; color: var(--muted); font-size: 12px; }
.matchup .bigscore { font-size: 32px; font-weight: 800; }
.winbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 8px 0 4px; }
.winbar span { display: block; height: 100%; }
.bet-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.tile { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 22px; font-weight: 700; margin: 4px 0; }
.tile .cmp { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.tile .cmp span:nth-child(odd) { color: var(--muted); }
.pick { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.data th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; position: sticky; top: 0; background: var(--surface); }
table.data th.sortable { cursor: pointer; }
table.data th.sorted { color: var(--text); }
table.data td.l, table.data th.l { text-align: left; }
table.data tr:hover td { background: var(--surface-2); }
table.data tr.clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; }
.player-cell { display: flex; align-items: center; gap: 8px; text-align: left; }
.player-cell .nm { font-weight: 600; }
.player-cell .sub { font-size: 11px; color: var(--muted); }
.up { color: var(--good); }
.down { color: var(--bad); }
.factor-table td:first-child { text-align: left; color: var(--muted); }
.factor-table td.better { font-weight: 700; }

/* ---- DvP heatmap ---- */
.heat td.cell { text-align: center; min-width: 74px; }
.heat .val { font-weight: 600; display: block; }
.heat .rk { font-size: 11px; color: var(--muted); }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend .bar { width: 160px; height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--bad) 55%, var(--surface)), var(--surface-2), color-mix(in srgb, var(--good) 55%, var(--surface))); }
.team-cell { display: flex; align-items: center; gap: 8px; text-align: left; }
.drawer { margin-top: 16px; }

/* ---- model page ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 14px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }

@media (max-width: 640px) {
  .container { padding: 12px; }
  .games { grid-template-columns: 1fr; }
  .gc-table { grid-template-columns: 1fr 60px 60px 56px; }
  .matchup { grid-template-columns: 1fr; text-align: center; }
  .matchup .side, .matchup .side.home { justify-content: center; text-align: center; }
  .status { display: none; }
}
.heat th { text-align: center; }
.heat th.l { text-align: left; }
.rk.fp { display: block; opacity: .8; }
.lineup table.data td, .lineup table.data th { padding: 5px 6px; }
