/* Layout concept: a scoreboard masthead over two stacked blocks: the league standings (chart + table) and the
   week's market (team picker, a grid of game tickets, market standings). One column, generous rhythm. */
:root {
  --bg: #EDF1EE;
  --surface: #FFFFFF;
  --ink: #14201A;
  --muted: #59665F;
  --line: #D2DBD4;
  --grid: #E3E9E4;
  --turf: #1C6B46;
  --turf-ink: #FFFFFF;
  --mast: #12241B;
  --mast-ink: #EEF5F0;
  --away: #B4532A;
  --home: #2D5DA6;
  --good: #12804A;
  --good-bg: #E1F2E7;
  --bad: #BE3B2E;
  --bad-bg: #FBE6E2;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --s-other: #8a948e;
  --display: "Teko", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(20, 32, 26, 0.05), 0 10px 24px -18px rgba(20, 32, 26, 0.45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1411; --surface: #161F1A; --ink: #E5EEE8; --muted: #98A69E; --line: #29352E; --grid: #222C26;
    --turf: #3DAA78; --turf-ink: #0E1411; --mast: #0A110D; --mast-ink: #E5EEE8;
    --away: #E2814F; --home: #719CE6; --good: #49C98A; --good-bg: #13301F; --bad: #EE7466; --bad-bg: #38201C;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --s-other: #6f7a74;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 24px -16px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1411; --surface: #161F1A; --ink: #E5EEE8; --muted: #98A69E; --line: #29352E; --grid: #222C26;
  --turf: #3DAA78; --turf-ink: #0E1411; --mast: #0A110D; --mast-ink: #E5EEE8;
  --away: #E2814F; --home: #719CE6; --good: #49C98A; --good-bg: #13301F; --bad: #EE7466; --bad-bg: #38201C;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --s-other: #6f7a74;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 24px -16px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--ink); }
body { margin: 0; font-family: var(--body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--turf); outline-offset: 2px; }
a { color: var(--turf); }
.num { font-variant-numeric: tabular-nums; }

.wrap {
  max-width: 1120px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- masthead ---------- */
.masthead { background: var(--mast); color: var(--mast-ink); border-bottom: 6px solid var(--turf); }
.masthead-inner { padding-block: 26px 20px; display: grid; gap: 2px; }
.masthead h1 {
  margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: 0.01em;
  font-size: clamp(48px, 9vw, 92px); line-height: 0.85; text-wrap: balance;
}
.masthead-sub { margin: 0; font-size: 17px; opacity: 0.82; }

/* ---------- blocks ---------- */
.block { padding-block: 34px 8px; }
.block-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px 20px; }
.block h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: clamp(38px, 6vw, 52px); line-height: 0.9; }
.source { margin: 6px 0 14px; color: var(--muted); font-size: 14px; }
.source.warn { color: var(--bad); }
.loading { color: var(--muted); }
.error-box { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: 14px 16px; font-weight: 600; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- chart ---------- */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 8px; box-shadow: var(--shadow); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 8px; }
.legend button {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 4px 12px 4px 10px; font-size: 14px; font-weight: 500; max-width: 100%;
}
.legend button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 700; }
.key { display: inline-block; width: 16px; height: 3px; border-radius: 2px; flex: none; }
.chart { position: relative; outline-offset: 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-label { fill: var(--muted); font-size: 12px; font-family: var(--body); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--line); stroke-width: 1.5; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; transition: opacity 120ms ease; }
.chart .dot { stroke: var(--surface); stroke-width: 2; transition: opacity 120ms ease; }
.chart .faded { opacity: 0.16; }
.tooltip {
  position: fixed; z-index: 20; pointer-events: none; min-width: 200px; max-width: min(320px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.45); padding: 10px 12px; font-size: 13px;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-row { display: grid; grid-template-columns: 16px auto 1fr; align-items: center; gap: 8px; padding: 1px 0; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }
.tooltip .tt-row span:last-child { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- standings table ---------- */
.table-scroll { overflow-x: auto; margin-top: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th { font-size: 13px; font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: right; width: 1%; color: var(--muted); }
th.team, td.team { text-align: left; }
td.team { font-weight: 600; }
.team .key { margin-right: 8px; vertical-align: middle; }
td.total { font-weight: 700; font-size: 17px; }
td.best { font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
td.neg { color: var(--bad); }
tr.me td { background: color-mix(in srgb, var(--turf) 9%, transparent); }

/* ---------- market ---------- */
.week-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.week-tabs button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 12px;
  font-family: var(--display); font-size: 22px; line-height: 1.1; font-weight: 600; color: var(--muted);
}
.week-tabs button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.how { margin: 12px 0 18px; }
.how summary { cursor: pointer; font-weight: 600; color: var(--turf); width: fit-content; }
.how-body { max-width: 68ch; color: var(--muted); }
.how-body p { margin: 8px 0; }
.how-body strong { color: var(--ink); }

.picker { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.picker h3 { margin: 0 0 10px; font-size: 18px; }
.member-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.member-chips button {
  border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-weight: 600;
}
.member-chips button:hover { border-color: var(--turf); }

.me-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 26px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow);
  position: sticky; top: max(0px, env(safe-area-inset-top, 0px)); z-index: 5;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.me-who { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.me-who strong { font-size: 18px; overflow-wrap: anywhere; }
.linkish { border: 0; background: none; padding: 0; color: var(--turf); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; font-size: 14px; }
.stat { display: grid; line-height: 1.15; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-family: var(--display); font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat b small { font-family: var(--body); font-size: 14px; font-weight: 700; margin-left: 4px; }
.up { color: var(--good); }
.down { color: var(--bad); }
.me-bar .stat:first-of-type { margin-left: auto; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; margin-top: 16px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px; color: var(--muted); margin-top: 16px; }

.ticket {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; gap: 12px; padding: 16px; align-content: start; min-width: 0;
}
.ticket.closed { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.ticket-head { display: grid; gap: 2px; }
.ticket-title { margin: 0; font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 0.95; overflow-wrap: anywhere; }
.ticket-title .at { color: var(--muted); font-weight: 500; font-size: 22px; margin: 0 4px; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); }
.badge { font-weight: 700; font-size: 13px; padding: 1px 9px; border-radius: 999px; background: var(--grid); color: var(--ink); }
.badge.live { background: var(--good-bg); color: var(--good); }
.badge.final { background: var(--ink); color: var(--bg); }

.odds { display: grid; gap: 6px; }
.odds-labels { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.odds-labels span { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; }
.odds-labels span:last-child { text-align: right; }
.odds-labels em { font-style: normal; font-family: var(--display); font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.side-away { color: var(--away); }
.side-home { color: var(--home); }
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--surface); }
.bar i { display: block; height: 100%; }
.bar i:first-child { background: var(--away); border-radius: 999px 0 0 999px; }
.bar i:last-child { background: var(--home); border-radius: 0 999px 999px 0; }
.spark { display: grid; gap: 2px; }
.spark svg { width: 100%; height: 44px; display: block; overflow: visible; }
.spark .mid { stroke: var(--grid); stroke-dasharray: 3 3; }
.spark .trace { fill: none; stroke: var(--home); stroke-width: 2; stroke-linejoin: round; }
.spark .end { fill: var(--home); stroke: var(--surface); stroke-width: 2; }
.spark-cap { font-size: 12px; color: var(--muted); }

.holding { font-size: 14px; background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.holding b { font-variant-numeric: tabular-nums; }
.result-line { font-weight: 600; }

.trade { display: grid; gap: 10px; border-top: 1px solid var(--grid); padding-top: 12px; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sides button {
  border: 2px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; text-align: left;
  display: grid; gap: 0; min-width: 0;
}
.sides button span { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sides button small { color: var(--muted); font-variant-numeric: tabular-nums; }
.sides button.away[aria-pressed="true"] { border-color: var(--away); box-shadow: inset 0 0 0 1px var(--away); }
.sides button.home[aria-pressed="true"] { border-color: var(--home); box-shadow: inset 0 0 0 1px var(--home); }
.trade-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: var(--bg); width: 38px; font-size: 20px; font-weight: 700; }
.stepper input { width: 64px; border: 0; text-align: center; font-weight: 700; font-size: 17px; background: var(--surface); font-variant-numeric: tabular-nums; }
.stepper input:focus { outline: none; }
.stepper:focus-within { outline: 3px solid var(--turf); outline-offset: 2px; }
.mini-link { border: 0; background: none; color: var(--turf); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 2px; }
.quote { font-size: 14px; color: var(--muted); min-height: 2.6em; }
.quote b { color: var(--ink); font-variant-numeric: tabular-nums; }
.quote.err { color: var(--bad); font-weight: 600; }
.go {
  border: 0; border-radius: 10px; background: var(--turf); color: var(--turf-ink); font-weight: 700; padding: 11px 14px; font-size: 16px;
}
.go:disabled { opacity: 0.45; cursor: not-allowed; }
.go.sell { background: var(--ink); color: var(--bg); }
.flash { font-size: 14px; font-weight: 700; padding: 6px 10px; border-radius: 8px; }
.flash.ok { background: var(--good-bg); color: var(--good); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.pick-first { font-size: 14px; color: var(--muted); border-top: 1px solid var(--grid); padding-top: 10px; margin: 0; }

.market-table-wrap { margin-top: 22px; }
.market-table-wrap h3 { margin: 0 0 8px; font-size: 18px; }
.market-note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.site-foot { padding-block: 34px 40px; font-size: 14px; color: var(--muted); }

@media (max-width: 640px) {
  .me-bar { gap: 8px 18px; }
  .me-bar .stat:first-of-type { margin-left: 0; }
  .stat b { font-size: 24px; }
  .ticket-title { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* row headers (team names) read as body text, not column labels */
tbody th { font-size: 15px; font-weight: 600; color: var(--ink); text-align: left; }
tr.me th, tr.me td { background: color-mix(in srgb, var(--turf) 10%, transparent); }

/* ---------- notices ---------- */
.file-warn { background: var(--bad-bg); color: var(--ink); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; }
.file-warn-title { margin: 0 0 4px; font-weight: 700; color: var(--bad); }
.file-warn ul { margin: 0; padding-left: 20px; font-size: 14px; }
.weekend { background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; }

/* footer link to Quadrivium */
.site-foot { padding-top: 24px; padding-bottom: 40px; text-align: center; color: var(--muted); font-size: 14px; }
.site-foot a { font-weight: 600; }
