/* Theme tokens. :root holds the default (terminal); other themes override via [data-theme]. */
:root {
  --bg: #0a0c0a; --fg: #d7e5d2; --muted: #6f8268; --line: #1e281d; --panel: #0f130f;
  --accent: #39ff88; --promo: #39ff88; --rel: #ff4d4d;
  --heat-hi: #2ee66b; --heat-mid: #ffd23f; --heat-lo: #ff4d4d;
  --s1: #59c26b; --s2: #5b9bd5; --s3: #f39c3d; --s4: #ef6b6b; --s5: #5fd0c4; --s6: #e6c84a; --s7: #b98ad6; --s8: #ff9ec0;   /* chart lines */
  --font-ui: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --font-head: var(--font-ui); --font-num: var(--font-ui);
  --head-case: uppercase; --head-weight: 700; --head-track: .08em;
  --rule: 1px; --rule-strong: 1px; --radius: 0; --shadow: none;
  --fs: 12px; --pad-y: 3px; --pad-x: 8px;
}
[data-theme="broadcast"] {
  --bg: #0d1320; --fg: #eef2f8; --muted: #7d8aa3; --line: #1f2a40; --panel: #121a2b;
  --accent: #ff5a1f; --promo: #2ee6a6; --rel: #ff5a1f;
  --heat-hi: #2ee6a6; --heat-mid: #ffb020; --heat-lo: #ff4a2e;
  --s1: #2ee6a6; --s2: #5aa9ff; --s3: #ffb020; --s4: #ff6b5a; --s5: #52d6e0; --s6: #f2e04a; --s7: #c79bff; --s8: #ff9ec0;
  --font-ui: system-ui, "Segoe UI", Roboto, sans-serif;
  --font-head: Oswald, "Bebas Neue", Impact, "Arial Narrow", system-ui, sans-serif;
  --font-num: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --head-weight: 700; --head-track: .1em; --fs: 13px; --pad-y: 4px;
}
[data-theme="brutalist"] {
  --bg: #f3efe6; --fg: #000; --muted: #5c5a53; --line: #000; --panel: #fff;
  --accent: #ff2a00; --promo: #006b2e; --rel: #ff2a00;
  --heat-hi: #00b84a; --heat-mid: #ffc400; --heat-lo: #ff2a00;
  --s1: #1a7f37; --s2: #1f5fbf; --s3: #c2570c; --s4: #c62828; --s5: #0b8a82; --s6: #9a7b00; --s7: #7b3fa0; --s8: #c2185b;
  --font-ui: "Helvetica Neue", Arial, system-ui, sans-serif; --font-head: var(--font-ui);
  --font-num: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --head-weight: 900; --head-track: .02em; --rule: 1px; --rule-strong: 3px;
  --shadow: 4px 4px 0 #000; --fs: 13px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: var(--fs)/1.3 var(--font-ui);
       padding: 14px 16px 28px; }
main { max-width: 1500px; margin: 0 auto; }

header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 12px;
         padding-bottom: 8px; border-bottom: var(--rule-strong) solid var(--line); }
h1 { margin: 0; font: var(--head-weight) 18px/1 var(--font-head); text-transform: var(--head-case);
     letter-spacing: var(--head-track); }
h1 i { font-style: normal; color: var(--accent); }
.sub { color: var(--muted); font-size: 11px; flex: 1; }
.themes select { font: 600 10px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
  color: var(--fg); background-color: var(--panel); border: var(--rule) solid var(--line); border-radius: var(--radius);
  padding: 3px 22px 3px 8px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
.themes select:hover, .themes select:focus { border-color: var(--accent); outline: 0; }
.themes option { background: var(--panel); color: var(--fg); }

.leagues { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 980px) { .leagues { grid-template-columns: 1fr; } }

h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 6px;
     font: var(--head-weight) 14px/1 var(--font-head); text-transform: var(--head-case); letter-spacing: var(--head-track); }
h2 small { font: 400 11px var(--font-ui); color: var(--muted); text-transform: none; letter-spacing: 0; }

.strip { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: baseline; padding: 4px 8px; margin-bottom: 6px;
         background: var(--panel); border-left: 3px solid var(--accent); box-shadow: var(--shadow); }
.strip b { font-family: var(--font-head); text-transform: var(--head-case); letter-spacing: var(--head-track); color: var(--accent); }

.tbl { overflow-x: auto; background: var(--panel); border: var(--rule) solid var(--line); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; white-space: nowrap; font-family: var(--font-num); }
th, td { padding: var(--pad-y) var(--pad-x); text-align: right; border-bottom: var(--rule) solid var(--line); }
th { font: 600 10px var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
     border-bottom: var(--rule-strong) solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th.l, td.l { text-align: left; font-family: var(--font-ui); }
.rank { color: var(--muted); width: 1.8em; }
.owner { font-weight: 600; }
.dim { color: var(--muted); }
.pos { color: var(--promo); font-weight: 700; }
/* Wins slider: length = wins, color = position in the league (green most wins -> yellow -> red fewest).
   --up/--dn (0-100%) are set per row in JS; each theme sets --heat-hi/mid/lo. */
td.w, td.rec {
  --c: color-mix(in oklab,
    color-mix(in oklab, var(--heat-mid) calc(100% - var(--up, 0%)), var(--heat-hi) var(--up, 0%))
    calc(100% - var(--dn, 0%)), var(--heat-lo) var(--dn, 0%)); }
td.w { font-weight: 700; background: linear-gradient(var(--c), var(--c)) left bottom / var(--p) 4px no-repeat; }
/* Draft order record cell: a tinted block, softened so the text stays readable. */
td.rec { font-weight: 600; background: color-mix(in srgb, var(--c) 48%, transparent); }
tr.z-rel > td:first-child { box-shadow: inset 3px 0 0 var(--rel); }
tr.z-promo > td:first-child { box-shadow: inset 3px 0 0 var(--promo); }
td.live, th.live { color: var(--muted); font-style: italic; }
.wk { text-align: center; }

details { margin-top: 6px; background: var(--panel); border: var(--rule) solid var(--line); }
summary { cursor: pointer; padding: 3px 8px; font: 600 10px var(--font-ui); letter-spacing: .08em;
          text-transform: uppercase; color: var(--muted); user-select: none; list-style: none; }
summary::before { content: "+ "; color: var(--accent); }
details[open] > summary::before { content: "– "; }
details[open] > summary { border-bottom: var(--rule) solid var(--line); }
.scroll { overflow-x: auto; max-height: 360px; overflow-y: auto; }

.legend { margin-top: 18px; color: var(--muted); font-size: 11px; }
.legend i { font-style: normal; font-weight: 700; }
.err { padding: 12px; color: var(--rel); border: var(--rule) solid var(--rel); }

/* ---- links, resource pages ---- */
a { color: inherit; text-decoration: none; }
td a:hover, .strip a:hover, h2 a:hover, .crumbs a:hover, .meLink:hover { color: var(--accent); }
td.owner a, td a { border-bottom: 1px dotted transparent; }
td a:hover { border-bottom-color: var(--accent); }
h1 a:hover { color: inherit; }
.meLink { font: 700 11px var(--font-ui); letter-spacing: .06em; color: var(--accent); }
tr.me td.owner, tr.me td.owner a { color: var(--accent); }
tr.me td.owner::before { content: "★ "; color: var(--accent); }

.narrow { max-width: 760px; }
.crumbs { color: var(--muted); font-size: 11px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; }
h3 { margin: 16px 0 6px; font: 600 10px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h2.player { font-size: 22px; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
h2.player .who { margin-left: auto; font: 400 12px var(--font-ui); text-transform: none; letter-spacing: 0; }
.isme { color: var(--accent); font-weight: 700; }
button { font: 600 11px var(--font-ui); letter-spacing: .04em; padding: 3px 10px; background: transparent; color: var(--fg);
         border: var(--rule) solid var(--line); cursor: pointer; border-radius: var(--radius); }
button:hover { border-color: var(--accent); color: var(--accent); }
.zone { font: 700 10px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; padding: 1px 6px; border: var(--rule) solid currentColor; }
.zone.rel { color: var(--rel); } .zone.promo { color: var(--promo); }

.stats { display: flex; flex-wrap: wrap; border: var(--rule) solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.stat { padding: 6px 12px; border-right: var(--rule) solid var(--line); min-width: 74px; }
.stat:last-child { border-right: 0; }
.stat span { display: block; font: 600 10px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat b { font: 700 18px var(--font-num); }
.stat small { font-size: 11px; color: var(--muted); font-weight: 400; }

.chips { white-space: nowrap; }
.chip { display: inline-block; width: 1.5em; margin-right: 2px; text-align: center; font: 700 10px/1.6 var(--font-num); color: #000; }
.chip.w { background: var(--heat-hi); } .chip.l { background: var(--heat-lo); } .chip.t { background: var(--heat-mid); }
.chip.bye, .chip.pend { color: var(--muted); border: var(--rule) solid var(--line); line-height: 1.4; }
.chips.big .chip { width: 2.2em; font-size: 12px; margin-bottom: 4px; }

td.wrap { white-space: normal; line-height: 1.6; }
.mv { font-size: 10px; } .mv.up { color: var(--promo); } .mv.dn { color: var(--rel); }
tr.champ td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.gap { margin-top: 6px; }

/* ---- phones ---- */
.legend span { display: inline-block; margin-right: 16px; white-space: nowrap; }

@media (max-width: 980px) {
  /* a bare 1fr column grows to its widest table; minmax(0, 1fr) lets it shrink and the table scroll instead */
  .leagues { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  body { padding: 10px 12px 24px; }
  header { gap: 4px 12px; }
  h1 { font-size: 16px; }
  .sub { flex-basis: 100%; order: 3; }
  h2 { flex-wrap: wrap; }
  h2 small { flex-basis: 100%; }

  /* standings: drop the least useful columns; the rest fit */
  .c-gp, .c-t, .c-hist { display: none; }
  :root { --pad-x: 6px; --pad-y: 5px; --fs: 13px; }
  th { font-size: 9px; }

  /* easier to tap */
  summary { padding: 9px 10px; }
  .themes select { padding: 6px 24px 6px 10px; }
  button { padding: 6px 12px; }

  /* stat strips: three across, no ragged gaps */
  .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-right: 0; border-bottom: 0; }
  .stat { min-width: 0; padding: 6px 10px; border-right: var(--rule) solid var(--line); border-bottom: var(--rule) solid var(--line); }
  .stat b { font-size: 16px; }

  /* previous seasons: one card per season, teams on their own line */
  table.hist thead { display: none; }
  table.hist, table.hist tbody { display: block; }
  table.hist tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 7px 8px; border-bottom: var(--rule) solid var(--line); }
  table.hist tr:last-child { border-bottom: 0; }
  table.hist td { display: block; padding: 0; border: 0; text-align: left; }
  table.hist td:first-child { font-weight: 700; }
  table.hist td.lg::before { content: "Lg "; color: var(--muted); }
  table.hist td.tm { flex-basis: 100%; line-height: 1.7; }
  table.hist td.lgc { flex-basis: auto; }
  table.hist td.lgc.none { display: none; }
  table.hist td.lgc::before { content: "L" attr(data-lg) " "; color: var(--muted); }
  tr.champ td:first-child { box-shadow: none; }
  table.hist tr.champ { box-shadow: inset 3px 0 0 var(--accent); padding-left: 11px; }
}

/* ---- phones: make the main view fit on one screen ---- */
h2 .short, h2 .more { display: none; }
@media (max-width: 600px) {
  :root { --phone: 1; }   /* marker: lets the debug stamp confirm these rules reached the browser */
  /* extra room above the first tap target; env() also clears the clock/notch if the page is ever opened as a home-screen app */
  body { padding: max(16px, env(safe-area-inset-top)) 10px 14px; }
  header { margin-bottom: 6px; padding-bottom: 5px; gap: 2px 10px; align-items: center; }
  h1 { font-size: 15px; }
  .sub { flex-basis: 100%; order: 3; font-size: 10px; }
  .themes { margin-left: auto; }
  .themes select { padding: 4px 22px 4px 8px; font-size: 10px; }

  .leagues { gap: 10px; }
  .leagues h2 { flex-wrap: nowrap; margin-bottom: 3px; font-size: 13px; }
  .leagues h2 small { flex-basis: auto; margin-left: auto; font-size: 10px; }
  .leagues h2 .full { display: none; }
  .leagues h2 .short { display: inline; }
  .leagues h2 .more { display: inline; font: 400 10px var(--font-ui); color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 8px; }
  .leagues details { display: none; }       /* draft order and weekly grid live on the league page */
  .strip { margin-bottom: 3px; padding: 3px 8px; font-size: 11px; }

  :root { --pad-y: 3px; --pad-x: 6px; --fs: 12px; }
  .leagues th { padding-top: 3px; padding-bottom: 3px; }

  .legend { margin-top: 8px; font-size: 10px; }
  .legend span:nth-child(5) { display: none; }
}

/* taller phones have room to spare: looser rows and bigger tap targets */
@media (max-width: 600px) and (min-height: 760px) {
  :root { --pad-y: 6px; }
  .leagues { gap: 16px; }
  .leagues h2 { margin-bottom: 5px; }
  .strip { padding: 5px 8px; margin-bottom: 5px; }
}

#build { color: var(--accent); }
#build .stale { color: var(--rel); }

/* ---- standings chart ---- */
.chart svg { display: block; width: 100%; height: auto; max-width: 760px; }
.ch-grid { stroke: var(--line); } .ch-zero { stroke: var(--muted); }
.ch-ax { fill: var(--muted); font: 10px var(--font-ui); }
.ch-line { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-opacity: .8; }
.ch-line.me { stroke-width: 3.2; stroke-opacity: 1; }
.ch-hit { fill: none; stroke: transparent; stroke-width: 14; stroke-linejoin: round; cursor: pointer; }
.ch-lbl { font: 11px var(--font-ui); cursor: pointer; }
.ch-lbl.me { font-weight: 700; }
.chart[data-focus] .ch-line, .chart[data-focus] .ch-lbl { opacity: .18; }
.chart[data-focus] .on { opacity: 1; }
.chart[data-focus] .ch-line.on { stroke-width: 3.2; stroke-opacity: 1; }
.ch-readout { margin-top: 6px; min-height: 2.6em; color: var(--muted); font-size: 11px; }
[data-theme="brutalist"] .ch-grid { stroke-opacity: .22; }

.neg { color: var(--rel); font-weight: 700; }
.note { margin: 6px 0 0; max-width: 64ch; color: var(--muted); font-size: 11px; line-height: 1.5; }
.note a { color: inherit; text-decoration: underline; }

/* ---- weekly odds ---- */
.odds-nav { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.odds-nav b { min-width: 5.5em; text-align: center; font-family: var(--font-head); text-transform: var(--head-case); letter-spacing: var(--head-track); }
button:disabled { opacity: .3; cursor: default; }
button:disabled:hover { border-color: var(--line); color: var(--fg); }
.fav { font-weight: 700; }
.tag { font: 700 9px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); border: var(--rule) solid var(--accent); padding: 0 4px; }
.odds td small { font-size: 11px; }
