/* ---------- tokens ---------- */
:root {
  --bg: #0d0e11; --panel: #15171b; --panel-2: #1b1e23; --line: #25282e; --line-2: #33373f;
  --ink: #f3f4f6; --ink-2: #c8ccd3; --muted: #8a8f99; --faint: #5a5f69;
  --accent: #f2b705; --accent-ink: #1a1300;
  --win: #38d27a; --loss: #ff5c6c; --win-bg: rgba(56,210,122,.12); --loss-bg: rgba(255,92,108,.12);
  --shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 1px 2px rgba(0,0,0,.35);
  --row-hover: rgba(255,255,255,.03); --row-open: rgba(255,255,255,.045);
  --topbar: rgba(13,14,17,.86);
  --display: "Barlow Condensed", "Inter", system-ui, sans-serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"], :root:not([data-theme="dark"]).auto-light {
  --bg: #f4f4f1; --panel: #ffffff; --panel-2: #f7f7f5; --line: #e5e5e1; --line-2: #d3d3ce;
  --ink: #131417; --ink-2: #34373e; --muted: #6f7380; --faint: #a3a7b0;
  --accent: #e8b100; --accent-ink: #1a1300;
  --win: #178a45; --loss: #c8303f; --win-bg: rgba(23,138,69,.1); --loss-bg: rgba(200,48,63,.1);
  --shadow: 0 1px 2px rgba(20,22,28,.05), 0 8px 24px -16px rgba(20,22,28,.18);
  --row-hover: rgba(20,22,28,.03); --row-open: rgba(20,22,28,.045);
  --topbar: rgba(244,244,241,.86);
  color-scheme: light;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font: 14.5px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
.page { max-width: 1160px; margin: 0 auto; padding: 0 24px 72px; }
button, select, input { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
.show-sm { display: none; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--topbar); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.wordmark { font: 800 22px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
select {
  appearance: none; -webkit-appearance: none; height: 34px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8f99' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
  border: 1px solid var(--line); border-radius: 8px; padding: 0 28px 0 11px; font-weight: 600; font-size: 13.5px; color: var(--ink); cursor: pointer;
}
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 600; font-size: 13px; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--panel-2); border-color: var(--line-2); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn svg { flex: none; }
#theme .moon { display: none; }
:root[data-theme="light"] #theme .moon, :root.auto-light:not([data-theme="dark"]) #theme .moon { display: block; }
:root[data-theme="light"] #theme .sun, :root.auto-light:not([data-theme="dark"]) #theme .sun { display: none; }

/* ---------- page head ---------- */
.pagehead { padding: 36px 0 24px; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font: 700 12px/1 var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.eyebrow .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .7; }
h1 { font: 800 clamp(40px, 6vw, 60px)/1 var(--display); letter-spacing: -.005em; text-transform: uppercase; margin: 8px 0 8px; }
.lede { margin: 8px 0 0; color: var(--muted); max-width: 64ch; font-size: 14px; }
.weeks { margin-top: 22px; }
.weeks-track { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.weeks-track::-webkit-scrollbar { display: none; }
.wk { flex: none; min-width: 46px; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font: 700 15px/1 var(--display); letter-spacing: .04em; cursor: pointer; color: var(--ink-2); position: relative; transition: all .12s; }
.wk:hover { border-color: var(--line-2); color: var(--ink); }
.wk.active { background: var(--ink); color: var(--bg); border-color: transparent; }
.wk.pre { font-size: 12.5px; letter-spacing: .12em; }
.wk.live::after { content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--loss); border: 2px solid var(--bg); }

/* ---------- champion banner (seasons with a title game) ---------- */
.champion { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.champion:empty { display: none; }
.champ { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); cursor: pointer; position: relative; overflow: hidden; }
.champ::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.champ.runner::before { background: var(--muted); }
.champ.runner .champ-trophy, .champ.runner .champ-label { color: var(--muted); }
.champ:hover { border-color: var(--line-2); }
.champ-trophy { color: var(--accent); flex: none; display: flex; }
.champ-logo { width: 44px; height: 44px; object-fit: contain; flex: none; }
.champ-text { flex: 1; min-width: 0; }
.champ-label { font: 700 11px/1 var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.champ-name { font: 700 22px/1.1 var(--display); text-transform: uppercase; margin-top: 3px; }
.champ-rec { font: 600 14px var(--body); text-transform: none; color: var(--muted); margin-left: 6px; }
.champ-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.champ-stats { display: flex; gap: 18px; flex: none; }
.champ-stats .stat b { font-size: 22px; }
.trophy { font-size: 13px; margin-left: 4px; }
@media (max-width: 1000px) { .champion { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .champ { flex-wrap: wrap; } .champ-stats { width: 100%; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--line); } }

/* ---------- spotlight ---------- */
.spotlight { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.spotlight:empty { display: none; }
.spot { position: relative; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); padding: 18px 18px 16px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .12s, transform .12s; overflow: hidden; }
.spot::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--team); }
.spot:hover { border-color: var(--line-2); transform: translateY(-1px); }
.spot-top { display: flex; justify-content: space-between; align-items: center; }
.spot-rank { font: 800 44px/1 var(--display); color: var(--team); letter-spacing: -.02em; }
.spot-logo { width: 52px; height: 52px; object-fit: contain; }
.spot-name { font: 700 24px/1.05 var(--display); text-transform: uppercase; letter-spacing: .01em; margin-top: 12px; }
.spot-sub { display: flex; gap: 10px; align-items: center; margin-top: 4px; font-size: 13px; color: var(--muted); }
.spot-sub b { color: var(--ink); font-weight: 600; }
.spot-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.spot-rating span, .spot-note span { display: block; font: 700 10.5px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.spot-rating b { font: 700 28px/1 var(--display); font-variant-numeric: tabular-nums; }
.spot-note { min-width: 0; text-align: right; }
.spot-note b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-note i { font-style: normal; color: var(--muted); font-weight: 500; }
.spot-pre { grid-column: 1 / -1; padding: 20px; border-radius: 14px; border: 1px dashed var(--line-2); color: var(--muted); text-align: center; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: flex-end; margin-bottom: 12px; }
.pagehead-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.pagehead-row h1 { margin-bottom: 0; }
.pagehead-row .seg { margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { height: 36px; padding: 0 16px; border: 0; background: transparent; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--ink); color: var(--bg); }
body.conf-mode .champion { display: none; }
.conf-badge { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font: 700 10.5px/1 var(--display); letter-spacing: .04em; color: var(--ink-2); flex: none; }
.gref .conf-badge { width: 24px; height: 24px; font-size: 9px; }
.conf-badge.big { width: 52px; height: 52px; font-size: 16px; border-radius: 12px; }
.conf-logo { width: 34px; height: 30px; object-fit: contain; flex: none; }
.conf-logo.small { width: 24px; height: 22px; }
.conf-logo.big { width: 72px; height: 52px; object-fit: contain; object-position: right center; }
.detail-inner.conf { grid-template-columns: minmax(0, 1fr) 320px; }
.conf-side { display: grid; gap: 12px; }
.search { display: flex; align-items: center; gap: 8px; height: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; color: var(--muted); }
.search input { border: 0; background: transparent; width: 170px; outline: none; color: var(--ink); }
.search:focus-within { border-color: var(--line-2); color: var(--ink); }

/* ---------- table ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: clip; }
.status { color: var(--muted); font-size: 13px; padding: 10px 16px 0; }
body.loading .status { color: var(--accent); font-weight: 600; }
body.loading .card table, body.loading .spotlight { opacity: .45; transition: opacity .2s; }
.status:empty { display: none; }
.status.error { color: var(--loss); }
table.rankings { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rankings th { text-align: left; padding: 13px 12px; font: 700 11px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-2); background: var(--panel); position: sticky; top: 58px; z-index: 2; }
.rankings td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rankings tbody tr:last-child td { border-bottom: 0; }
.rankings tr.team { cursor: pointer; }
.rankings tr.team:hover td { background: var(--row-hover); }
.rankings tr.team.open td { background: var(--row-open); border-bottom-color: transparent; }
.c-rank, .c-delta, .c-rec, .c-rating, .c-sos { text-align: right !important; white-space: nowrap; }
.c-rank { width: 56px; } .c-delta { width: 62px; } .c-rating { width: 96px; } .c-rec { width: 84px; } .c-sos { width: 118px; } .c-win, .c-loss { width: 20%; }
body.conf-mode .c-win { width: 34%; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "▼"; font-size: 8px; margin-left: 5px; opacity: 0; transition: opacity .12s; }
th.sortable:hover::after { opacity: .4; }
th.sortable.sorted { color: var(--ink); }
th.sortable.sorted::after { opacity: 1; }
th.sortable.sorted.asc::after { content: "▲"; }
td.c-rank { font: 700 19px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
td.c-rank .tie { font-size: 11px; color: var(--muted); font-family: var(--body); font-weight: 600; margin-right: 2px; }
td.c-team { padding-left: 10px; }
.teamcell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.teamcell > div { min-width: 0; }
.teambar { width: 3px; height: 28px; border-radius: 2px; background: var(--team); flex: none; }
.logo { width: 30px; height: 30px; object-fit: contain; flex: none; }
.logo.ph { border-radius: 50%; background: var(--line-2); }
.tname { font-weight: 600; font-size: 15px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tconf { font-size: 11.5px; color: var(--muted); line-height: 1.2; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.c-rec { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
b.rating { font: 700 18px/1 var(--display); font-variant-numeric: tabular-nums; }
.se { font-size: 10.5px; color: var(--faint); font-weight: 500; margin-left: 5px; font-variant-numeric: tabular-nums; font-family: var(--body); }
.stat b .se { font-size: 11px; }
.bar { width: 48px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; flex: none; display: inline-block; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--faint); }
.delta { display: inline-block; min-width: 34px; text-align: center; padding: 3px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--win); background: var(--win-bg); }
.delta.down { color: var(--loss); background: var(--loss-bg); }
.delta.flat { color: var(--faint); }
.sos { font-variant-numeric: tabular-nums; font-weight: 600; }
.sos small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.gref { display: flex; align-items: center; gap: 8px; white-space: nowrap; min-width: 0; }
.gref > span:not(.r) { overflow: hidden; text-overflow: ellipsis; }
.gref .logo { width: 20px; height: 20px; }
.gref .r { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.gref .nf { color: var(--muted); font-size: 11px; }
.none { color: var(--faint); }
.pos { color: var(--win); } .neg { color: var(--loss); }

/* ---------- detail ---------- */
tr.detail td { padding: 0; background: var(--row-open); }
.detail-inner { padding: 6px 20px 22px 24px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px 28px; align-items: start; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; }
.stat span { font: 700 10.5px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.stat b { font: 700 20px/1 var(--display); font-variant-numeric: tabular-nums; }
.logwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table.log { width: 100%; border-collapse: collapse; font-size: 13px; }
table.log th { text-align: left; padding: 8px 10px; font: 700 10.5px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--panel-2); position: static; }
table.log td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.log tr:last-child td { border-bottom: 0; }
table.log .num { text-align: right; font-variant-numeric: tabular-nums; }
.res { display: inline-block; min-width: 20px; text-align: center; padding: 2px 6px; border-radius: 6px; font-weight: 800; font-size: 11.5px; margin-right: 6px; }
.res.W { color: var(--win); background: var(--win-bg); } .res.L { color: var(--loss); background: var(--loss-bg); }
.pct { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.pct .bar { width: 48px; height: 5px; }
.pct .bar i { background: var(--faint); }
.pct.quality b { color: var(--win); } .pct.bad b { color: var(--loss); }
.chg { display: inline-flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; }
.chg b { font-weight: 700; }
.chg.pos b { color: var(--win); } .chg.neg b { color: var(--loss); } .chg.flat b { color: var(--muted); }
.chg small { font-size: 10.5px; font-weight: 700; }
.spark-wrap { border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 6px; background: var(--panel); position: relative; }
.spark-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; min-height: 40px; }
.spark-tip { font-size: 12px; line-height: 1.35; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.spark-tip b { color: var(--ink); }
.spark { width: 100%; height: 150px; display: block; cursor: crosshair; }
.spark .path { fill: none; stroke: var(--team, var(--accent)); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.spark .area { fill: var(--team, var(--accent)); opacity: .1; pointer-events: none; }
.spark .pt { fill: var(--team, var(--accent)); stroke: var(--panel); stroke-width: 2; transition: r .1s; }
.spark .pt.hot { r: 5.5; stroke: var(--ink); }
.spark .grid { stroke: var(--line); stroke-width: 1; }
.spark .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.spark text { font: 600 10px var(--body); fill: var(--muted); pointer-events: none; }
.spark .axis-title { font-size: 9px; fill: var(--faint); }

/* ---------- modals ---------- */
.modal { border: 0; padding: 0; background: transparent; max-width: min(92vw, 560px); width: 100%; color: var(--ink); }
.modal:has(.wide) { max-width: min(92vw, 720px); }
.modal::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.modal-inner { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); margin: 0; display: flex; flex-direction: column; max-height: 86vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font: 700 26px/1 var(--display); text-transform: uppercase; letter-spacing: .02em; }
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.slider { display: block; margin: 6px 0 18px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-bottom: 4px; }
.slider-head b { font: 700 18px/1 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--accent); margin: 2px 0 4px; }
.slider small { display: block; color: var(--muted); font-size: 12.5px; }
.prose p, .prose li { color: var(--ink-2); }
.prose b { color: var(--ink); }
.prose ol { padding-left: 20px; }

/* ---------- footer ---------- */
.foot { color: var(--muted); font-size: 12px; margin-top: 16px; padding: 0 4px; }
.foot b { color: var(--ink-2); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { .hide-md { display: none; } }
@media (max-width: 640px) {
  .page, .topbar-inner { padding-left: 14px; padding-right: 14px; }
  .hide-sm { display: none; } .show-sm { display: inline; }
  .brand-sub { display: none; } .wordmark { font-size: 18px; letter-spacing: .04em; } .topbar-actions { gap: 4px; } select { min-width: 0; padding-right: 24px; }
  .btn.ghost { padding: 0 10px; }
  .pagehead { padding-top: 24px; }
  .spotlight { grid-template-columns: 1fr; gap: 10px; }
  .spot { padding: 14px; }
  .spot-rank { font-size: 34px; } .spot-logo { width: 42px; height: 42px; } .spot-name { font-size: 20px; margin-top: 8px; }
  .rankings th { top: 58px; }
  .rankings th, .rankings td { padding-left: 8px; padding-right: 8px; }
  .c-rating { width: 70px; } .c-rec { width: 60px; } .c-rank { width: 44px; } .c-delta { width: 50px; }
  .detail-inner, .detail-inner.conf { padding: 8px 10px 16px; grid-template-columns: 1fr; }
  .search input { width: 110px; }
}
