:root {
  --bg: #f3f1e9; --surface: #ffffff; --surface-2: #eceee2; --border: #dcd8c9;
  --text: #171a15; --text-muted: #5d6157; --accent: #93690f; --accent-ink: #ffffff;
  --win: #1f7a4d; --loss: #b23b3b; --warn: #9c6f0d; --out: #9a3030; --chip-bg: #efe9d8;
  --pos-qb: #3a5a9c; --pos-rb: #1f7a4d; --pos-wr: #93690f; --pos-te: #7a4a9c; --pos-other: #5d6157;
  --shadow: 0 1px 2px rgba(20,20,10,.06), 0 6px 20px rgba(20,20,10,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13160f; --surface: #1b1f18; --surface-2: #20241c; --border: #2e3327;
    --text: #eeeee2; --text-muted: #9aa090; --accent: #d9ab4c; --accent-ink: #171a15;
    --win: #5fd191; --loss: #f0817e; --warn: #e0b055; --out: #f0817e; --chip-bg: #242820;
    --pos-qb: #7ea3e8; --pos-rb: #6fd19a; --pos-wr: #e0b055; --pos-te: #c79ae8; --pos-other: #9aa090;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px 'Source Sans 3', system-ui, -apple-system, sans-serif;
  padding-inline: 16px;
}
a { color: inherit; text-decoration: none; }
.app { max-width: 980px; margin: 0 auto; padding-block: 20px 48px; }
h1, h2, h3 { font-family: 'Oswald', system-ui, sans-serif; text-transform: uppercase; letter-spacing: .02em; text-wrap: balance; }
.tabular { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.you { color: var(--accent); }

/* ---- header ---- */
header.topbar {
  position: sticky; top: 0; background: var(--bg); z-index: 10;
  padding-block: 14px 10px; border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.brand-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 26px; margin: 0; font-weight: 700; line-height: 1.1; }
.brand .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.asof { font-size: 11.5px; color: var(--text-muted); background: var(--chip-bg); border: 1px solid var(--border); padding: 4px 10px; border-radius: 20px; white-space: nowrap; }

nav.tabs { display: flex; gap: 4px; margin-top: 14px; overflow-x: auto; padding-bottom: 2px; }
nav.tabs a {
  font-family: 'Oswald', system-ui, sans-serif; font-size: 13px; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 14px; border-radius: 8px; white-space: nowrap;
  transition: background .15s, color .15s;
}
nav.tabs a:hover { background: var(--surface-2); color: var(--text); }
nav.tabs a[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.tile .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.tile .v { font-family: 'Oswald'; font-size: 17px; font-weight: 600; margin-top: 3px; line-height: 1.25; }
.tile .v2 { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr; } }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-family: 'Oswald'; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; }
.team-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 28px; height: 28px; border-radius: 6px; flex: none; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-family: 'Oswald'; font-size: 11.5px; font-weight: 600; color: #fff; }
.team-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.owner-name { font-size: 11.5px; color: var(--text-muted); }
.rank { font-family: 'IBM Plex Mono'; font-size: 12.5px; color: var(--text-muted); width: 22px; display: inline-block; }
.pf-bar-wrap { background: var(--surface-2); border-radius: 4px; height: 6px; overflow: hidden; margin-top: 4px; }
.pf-bar { background: var(--accent); height: 100%; border-radius: 4px; }
.streak { font-family: 'IBM Plex Mono'; font-size: 12px; padding: 2px 6px; border-radius: 5px; background: var(--chip-bg); }
.streak.w { color: var(--win); }
.streak.l { color: var(--loss); }
.tw { overflow-x: auto; }
.p-meta { font-size: 11.5px; color: var(--text-muted); }

/* ---- controls ---- */
.controls-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
select, .seg button {
  font-family: 'Source Sans 3'; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
}
select { min-width: 220px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg.seg-full { display: flex; margin-bottom: 10px; }
.seg.seg-full button { flex: 1; }
.seg.seg-wrap { flex-wrap: wrap; }
.seg button { border: none; border-radius: 0; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---- rosters ---- */
.group-title { font-family: 'Oswald'; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 16px 0 6px; display: flex; align-items: center; gap: 8px; }
.group-title:first-child { margin-top: 0; }
.player-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.player-row:last-child { border-bottom: none; }
.slot { font-family: 'IBM Plex Mono'; font-size: 10.5px; color: var(--text-muted); width: 44px; flex: none; text-transform: uppercase; }
.pos-badge { font-family: 'IBM Plex Mono'; font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; color: #fff; flex: none; width: 30px; text-align: center; }
.pos-QB { background: var(--pos-qb); } .pos-RB { background: var(--pos-rb); }
.pos-WR { background: var(--pos-wr); color: #171a15; } .pos-TE { background: var(--pos-te); }
.pos-other { background: var(--pos-other); }
.p-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .p-meta { flex: none; }
.inj { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; margin-left: 6px; flex: none; background: var(--chip-bg); }
.inj-Q, .inj-D { color: var(--warn); }
.inj-Out, .inj-IR, .inj-PUP, .inj-NA, .inj-DNR, .inj-Sus { color: var(--out); }

/* ---- matchups ---- */
.matchup-week-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .mgrid { grid-template-columns: 1fr; } }
.mcard { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2); }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 5px; }
.mrow .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .pts { font-family: 'IBM Plex Mono'; font-size: 15px; font-weight: 600; }
.mrow.winner .name, .mrow.winner .pts { color: var(--win); }
.vs { text-align: center; font-size: 10px; color: var(--text-muted); letter-spacing: .1em; margin: 2px 0; }

/* ---- transactions ---- */
.txn-item { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.txn-item:last-child { border-bottom: none; }
.txn-date { font-size: 11px; color: var(--text-muted); width: 56px; flex: none; padding-top: 2px; }
.txn-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 5px; flex: none; height: fit-content; background: var(--chip-bg); width: 84px; text-align: center; }
.txn-waiver { color: var(--accent); } .txn-free_agent { color: var(--pos-rb); }
.txn-trade { color: var(--pos-te); } .txn-commissioner { color: var(--text-muted); }
.txn-body { flex: 1; min-width: 0; }
.txn-team { font-weight: 600; font-size: 13px; margin-top: 6px; }
.txn-team:first-child { margin-top: 0; }
.txn-line { font-size: 13px; margin-top: 3px; }
.add { color: var(--win); font-weight: 700; } .drop { color: var(--loss); font-weight: 700; }
.txn-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

/* ---- draft ---- */
details.round { border-bottom: 1px solid var(--border); padding-block: 8px; }
details.round:last-child { border-bottom: none; }
details.round summary { cursor: pointer; font-family: 'Oswald'; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; padding: 4px; list-style: none; }
details.round summary::-webkit-details-marker { display: none; }
details.round summary::before { content: "▸ "; color: var(--accent); }
details.round[open] summary::before { content: "▾ "; }
.pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 8px; }
.pick { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); }
.pick .pno { font-family: 'IBM Plex Mono'; font-size: 10px; color: var(--text-muted); }
.pick .pteam { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.pick .ppl { font-weight: 600; font-size: 13.5px; margin-top: 2px; }

/* ---- draft order ---- */
.do-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.do-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
.do-group { font-family: 'Oswald', system-ui, sans-serif; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 8px 0 3px; border-bottom: 1px solid var(--border); }
.do-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.do-row:last-child { border-bottom: none; }
.do-row.me { background: var(--chip-bg); margin-inline: -8px; padding-inline: 8px; border-radius: 8px; }
.do-pick { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 15px; color: var(--accent); text-align: center; }
.do-name { font-weight: 700; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.do-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.do-right { text-align: right; line-height: 1.2; }
.do-rec { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 13.5px; }
.do-pf { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.do-legend { font-size: 10.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.4; }
.bracket-wrap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 800px) { .bracket-wrap { grid-template-columns: 1fr; } }
.bracket-col { display: flex; flex-direction: column; gap: 10px; }
.bracket-round-title { font-family: 'Oswald'; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.bgame { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); }
.bgame-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.bgame-row { font-size: 13.5px; font-weight: 500; padding: 2px 0; display: flex; align-items: center; gap: 6px; }
.bgame-row.won { font-weight: 700; color: var(--win); }
.bseed { font-family: 'IBM Plex Mono'; font-size: 10.5px; color: var(--text-muted); width: 14px; flex: none; }
.bscore { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-muted); }

/* ---- trend chart ---- */
.web-filter-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.web-chip { font-family: 'IBM Plex Mono', monospace; font-size: 11px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 4px 9px; cursor: pointer; }
.web-chip:hover { border-color: var(--accent); }
.web-teamchips { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.web-team { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); padding: 4px 10px 4px 4px; cursor: pointer; font-size: 12px; text-align: left; min-width: 0; }
.web-team[aria-pressed="false"] { opacity: .45; }
.web-team[aria-pressed="true"] { border-color: var(--accent); background: var(--chip-bg); }
.web-dot { flex: none; width: 20px; height: 20px; border-radius: 10px; color: #fff; font-family: 'Oswald', system-ui, sans-serif; font-size: 8.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.web-tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.foot-note { font-size: 11.5px; color: var(--text-muted); text-align: center; margin-top: 24px; line-height: 1.6; }

/* ---- phone ---- */
@media (max-width: 640px) {
  header.topbar { position: static; padding-block: 12px 8px; }
  .tw table thead { display: none; }
  .tw table, .tw table tbody, .tw table tr, .tw table td { display: block; width: 100%; }
  .tw table { border-collapse: separate; border-spacing: 0; }
  .tw table tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); box-shadow: var(--shadow); }
  .tw table tr + tr { margin-top: 10px; }
  .tw table td { border-bottom: 1px solid var(--border); padding: 7px 0; text-align: left !important; }
  .tw table td:last-child { border-bottom: none; }
  .tw table td.cell-plain { padding-bottom: 10px; margin-bottom: 2px; }
  .tw table td[data-label]::before { content: attr(data-label); display: block; font-family: 'Oswald', system-ui, sans-serif; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 3px; }
  .tw table .pf-bar-wrap { max-width: 160px; }
  .txn-badge { width: auto; }
}

/* ---- trade web ---- */
.web-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.web-controls select { min-width: 0; flex: 1; padding: 6px 10px; font-size: 13px; }
.web-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 13.5px; }
.web-keylist { margin-top: 10px; border-top: 1px solid var(--border); }
.web-key { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.35; }
.web-num { flex: none; width: 18px; height: 18px; border-radius: 9px; color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.web-filter { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 8px; }
.web-filter summary { cursor: pointer; padding: 8px 12px; font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; list-style: none; }
.web-filter summary::-webkit-details-marker { display: none; }
.web-filter summary::after { content: "▾"; color: var(--accent); margin-left: 6px; }
.web-filter[open] summary::after { content: "▴"; }
.web-filter-body { padding: 0 10px 10px; }
.web-filter .seg button { padding: 5px 9px; font-size: 11.5px; }

/* ---- trend chart: tooltip, zoom controls, comparison panel ---- */
.tr-controls { margin-bottom: 8px; }
.tr-controls .seg button:disabled, .tr-controls .web-chip:disabled { opacity: .4; cursor: default; }
.web-chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tr-wrap { position: relative; }
.tr-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 280px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 7px 9px; font-size: 12px;
}
.tr-tip-h { font-family: 'Oswald', system-ui, sans-serif; text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; }
.tr-tip-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 6px; align-items: center; padding: 2px 0; }
.tr-tip-row .web-dot { width: 9px; height: 9px; border-radius: 5px; }
.tr-tip-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tr-d { font-family: 'IBM Plex Mono', monospace; font-size: 11px; min-width: 48px; text-align: right; }
.tr-tip-f { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); font-size: 10.5px; color: var(--text-muted); }
.good { color: var(--win); } .bad { color: var(--loss); }
.tr-hint { margin: 6px 0 10px; }
.tr-compare { margin-bottom: 12px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.cmp-head { margin-bottom: 6px; font-size: 13px; }
.cmp-simple { font-size: 13px; }
.cmp-row { display: grid; grid-template-columns: minmax(110px, 1.4fr) auto minmax(70px, auto) minmax(80px, 1fr); gap: 10px; align-items: center; padding: 5px 6px; border-radius: 6px; }
.cmp-row[role="button"] { cursor: pointer; }
.cmp-row[role="button"]:hover { background: var(--chip-bg); }
.cmp-row.is-base { outline: 1px dashed var(--accent); outline-offset: -1px; }
.cmp-team { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 600; }
.cmp-v { text-align: right; }
.cmp-delta { text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; font-weight: 600; }
.cmp-bar { position: relative; height: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.cmp-bar::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--text-muted); opacity: .6; }
.cmp-bar i { position: absolute; top: 0; bottom: 0; }
.cmp-bar i.good { background: var(--win); } .cmp-bar i.bad { background: var(--loss); }
.cmp-foot { margin-top: 8px; }
@media (max-width: 640px) {
  .cmp-row { grid-template-columns: 1fr auto auto; }
  .cmp-bar { display: none; }
}
