/* Layout: one column of panels under a scoreboard-style header; stats table is the workhorse. */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --fg: #141821;
  --muted: #5b6475;
  --line: #dde2ea;
  --grid: #e9edf3;
  --axis: #9aa3b2;
  --off: #1d5fd1;
  --def: #e46f1b;
  --pos: #137a4b;
  --neg: #b4322b;
  --hi: #fff4d6;
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' fill='none' stroke='%235b6475' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --font-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --panel: #161a22; --fg: #e8ebf1; --muted: #98a1b2; --line: #2a303c;
    --grid: #222834; --axis: #5c6576; --off: #6b9cff; --def: #ff9a4d; --pos: #4cc38a; --neg: #ff7b72;
    --hi: #3a3220; --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' fill='none' stroke='%2398a1b2' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117; --panel: #161a22; --fg: #e8ebf1; --muted: #98a1b2; --line: #2a303c;
  --grid: #222834; --axis: #5c6576; --off: #6b9cff; --def: #ff9a4d; --pos: #4cc38a; --neg: #ff7b72;
  --hi: #3a3220; --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' fill='none' stroke='%2398a1b2' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font-body); }
.app { max-width: 1180px; margin-inline: auto; padding-block: 28px 48px; padding-inline: 20px; display: flex; flex-direction: column; gap: 18px; }

.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--fg); padding-bottom: 14px; }
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.eyebrow { font: 600 12px/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
h1 { font: 700 clamp(34px, 6vw, 56px)/0.95 var(--font-display); letter-spacing: .01em; text-transform: uppercase; margin: 0; text-wrap: balance; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
select, input[type="search"] { font: 500 14px var(--font-body); color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
select { appearance: none; -webkit-appearance: none; background-image: var(--caret); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; padding-right: 36px; cursor: pointer; }
select:hover { border-color: var(--axis); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { font: 500 14px var(--font-body); color: var(--muted); background: transparent; border: 0; padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--panel); }
.seg button:focus-visible { outline: 2px solid var(--off); outline-offset: -2px; }
select:focus-visible, input:focus-visible, th button:focus-visible { outline: 2px solid var(--off); outline-offset: 1px; }

.takeaway { margin: 0; font-size: 17px; max-width: 70ch; color: var(--muted); }
.takeaway b { color: var(--fg); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tile .big { font: 600 40px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
h2 { font: 600 22px/1.1 var(--font-display); text-transform: uppercase; letter-spacing: .03em; margin: 0; }
.note { margin: 0; font-size: 13px; color: var(--muted); max-width: 80ch; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span[hidden] { display: none; }
.sw { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }
.sw-off { background: var(--off); }
.sw-def { background: var(--def); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fg); display: inline-block; }

.chart { position: relative; min-height: 120px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font: 12px var(--font-body); }
.chart text.name { fill: var(--fg); font-size: 13px; }
.chart text.val { fill: var(--fg); font: 500 12px var(--font-num); }

.table-wrap { overflow: auto; max-height: 560px; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--panel); text-align: right; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); padding: 0; white-space: nowrap; z-index: 1; }
th button { font: inherit; color: inherit; background: none; border: 0; padding: 8px 10px; cursor: pointer; width: 100%; text-align: inherit; }
th:first-child, td:first-child { text-align: left; }
td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td.num { font-family: var(--font-num); font-size: 12.5px; }
td.pos { color: var(--pos); }
td.neg { color: var(--neg); }
td.total { font-weight: 600; }
td .away { color: var(--muted); font-size: 11px; margin-left: 6px; }
tbody tr:hover td { background: var(--grid); }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 18px; }
.leaders { margin: 0; padding: 0; list-style: none; counter-reset: lead; display: flex; flex-direction: column; }
.leaders li { counter-increment: lead; display: grid; grid-template-columns: 2ch 1fr auto auto; gap: 10px; align-items: baseline; padding: 6px 4px; border-bottom: 1px solid var(--grid); }
.leaders li::before { content: counter(lead); color: var(--muted); font: 500 12px var(--font-num); text-align: right; }
.leaders li.mine { background: var(--hi); border-radius: 6px; }
.leaders .team { color: var(--muted); font-size: 12px; }
.leaders .v { font: 500 13px var(--font-num); }

.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 18px; align-items: start; }
.method ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
#val-table td, #val-table th { text-align: left; }

.tip { position: fixed; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgb(0 0 0 / .18); padding: 8px 10px; font-size: 12px; z-index: 10; min-width: 140px; }
.tip .h { color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.tip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; font-family: var(--font-num); }
.tip .r span:first-child { font-family: var(--font-body); display: inline-flex; align-items: center; gap: 6px; }
.empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

@media (prefers-reduced-motion: no-preference) {
  .chart svg .bar { transition: opacity .15s; }
}
