:root {
  --bg: #0f1420;
  --panel: #182031;
  --panel-2: #1e2740;
  --line: #2b3550;
  --text: #e8edf6;
  --muted: #93a0bd;
  --accent: #4fd1a5;
  --accent-2: #6ba8ff;
  --missed: var(--accent); /* points left on the bench, and the players who would have scored them */
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.4;
}
main { max-width: 1100px; margin: 0 auto; padding: 32px 24px 48px; }
.loading { color: var(--muted); }
.league-head h1 { margin: 0; font-size: 26px; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; }
.league-head h1 a { color: inherit; text-decoration: none; }
.league-head .season { color: var(--muted); font-size: 16px; font-weight: 500; white-space: nowrap; }
.tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 16px; }
.segmented {
  display: inline-flex; padding: 3px; gap: 2px; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
}
.segmented button {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
  background: transparent; border: 0; border-radius: 6px; padding: 5px 12px; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: #06231b; }
.narrow-only { display: none; }
.card-head.title-row { align-items: center; flex-wrap: nowrap; }
.title-row h2 { min-width: 0; }
/* stacked: show one standings table at a time, swapped by the toggle */
/* narrow: one table at a time. The title select picks standings or matchups;
   within standings the toggle picks actual or optimal. */
@media (max-width: 820px) {
  .tables { grid-template-columns: minmax(0, 1fr); }
  #home[data-view="actual"] [data-card="optimal"],
  #home[data-view="optimal"] [data-card="actual"],
  #home[data-section="standings"] .matchups,
  #home[data-section="matchups"] .tables { display: none; }
  #home .matchups { margin-top: 16px; } /* same gap as the standings it replaces */
  .narrow-only { display: inline-block; }
  .segmented.narrow-only { display: inline-flex; }
  .wide-only { display: none; }
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px;
}
.card.error { border-color: #6b2b3a; }
.card h2 { margin: 0 0 2px; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
table.standings { width: 100%; border-collapse: collapse; font-size: 14px; }
.scroll { overflow-x: auto; }
table.standings th, table.standings td {
  text-align: right; padding: 8px; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
table.standings th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
table.standings th.rank, table.standings td.rank { text-align: center; width: 32px; color: var(--muted); }
table.standings th.team, table.standings td.team { text-align: left; }
.team-link { color: var(--text); text-decoration: none; font-weight: 600; }
.team-link:hover { color: var(--accent-2); }
td.team .mgr { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
td.record { font-weight: 700; }
table.standings tbody tr:hover { background: var(--panel-2); }
.mgr { color: var(--muted); font-weight: 400; font-size: 13px; }

/* matchups: one row per game, mirrored around "vs" */
.matchups { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.picker select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 14px; cursor: pointer;
}
.section-picker select { font-size: 16px; font-weight: 700; padding: 5px 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.game {
  display: grid; align-items: center; column-gap: 16px;
  grid-template-columns: minmax(0, 1fr) 9.5em 3.5em 9.5em minmax(0, 1fr);
  grid-template-areas: "ta sa vs sb tb";
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.game:last-child { border-bottom: 0; }
.ta { grid-area: ta; text-align: right; }
.tb { grid-area: tb; }
.sa { grid-area: sa; align-items: flex-end; }
.sb { grid-area: sb; align-items: flex-start; }
/* whole row opens the matchup; team links sit above the row link */
.game.linked { position: relative; border-radius: 8px; }
.game.linked:hover { background: var(--panel-2); }
.g-link { position: absolute; inset: 0; border-radius: 8px; }
.g-link:focus-visible { outline: 2px solid var(--accent-2); }
.g-team .team-link { position: relative; z-index: 1; }
.g-team .mgr { display: block; font-size: 12px; }
.g-score { display: flex; flex-direction: column; gap: 3px; font-variant-numeric: tabular-nums; }
.g-actual { font-size: 20px; font-weight: 700; line-height: 1.1; color: var(--muted); }
.g-actual.win { color: var(--text); }
.g-sub { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.sa .g-sub { flex-direction: row-reverse; } /* mirror: delta on the outside */
.missed-text { color: var(--missed); font-variant-numeric: tabular-nums; }
.g-sub .missed-text { font-size: 12px; }
.g-opt { font-style: italic; }
/* the best-lineup result differs from the real one: the optimal scores are the story */
.game.flips .g-opt { font-weight: 700; font-size: 14px; }
/* win/loss shown like the actual score (bright vs muted), leaving green to mean "missed" */
.g-opt.win { color: var(--text); }
.g-opt.loss { color: var(--muted); }
.g-vs { grid-area: vs; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.g-vs .tag { margin-left: 0; }

/* phones: stack the two teams, scores on the right */
@media (max-width: 560px) {
  .game {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "ta sa" "tb sb" "vs vs";
    row-gap: 8px; column-gap: 12px;
  }
  .ta { text-align: left; }
  .sb { align-items: flex-end; }
  .sa .g-sub { flex-direction: row; }
  .g-actual { font-size: 17px; }
  .g-vs > span:first-child { display: none; }
  .g-vs { align-items: flex-end; }
  .g-vs:not(:has(.tag)) { display: none; }
}

/* sub-pages */
.back { display: inline-block; margin: 14px 0 4px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--accent-2); }
.page-head { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 10px; margin: 6px 0 14px; }
.page-title { margin: 0; font-size: 22px; }
.page-head .mgr { font-size: 15px; }
#app > .card + .card { margin-top: 20px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--muted); font-size: 12px; }
.tile-sub .missed-text { margin-left: 4px; }
table.team-games th.wk, table.team-games td.wk { text-align: left; white-space: nowrap; }
table.team-games td.wk a { color: var(--muted); text-decoration: none; }
table.team-games td.res { white-space: nowrap; }
table.team-games .dash { color: var(--muted); margin: 0 2px; }
table.team-games b.w { color: var(--accent); }
table.team-games b.l { color: #ff7a8a; }
tr.linked { cursor: pointer; }

/* side-by-side lineups */
table.lineup-cmp { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.lineup-cmp th, table.lineup-cmp td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.lineup-cmp th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
table.lineup-cmp .pl.a { text-align: left; }
table.lineup-cmp .pl.b { text-align: right; }
table.lineup-cmp .pts { text-align: right; width: 4em; white-space: nowrap; }
table.lineup-cmp .pts.b { text-align: left; }
table.lineup-cmp .slot { text-align: center; width: 4.5em; color: var(--muted); font-size: 12px; font-weight: 600; background: var(--panel-2); }
table.lineup-cmp .pname { display: block; font-weight: 600; }
table.lineup-cmp .pmeta { display: block; color: var(--muted); font-size: 12px; }
table.lineup-cmp .empty { color: var(--muted); }
table.lineup-cmp tbody.total td { font-weight: 700; border-bottom-width: 2px; }
table.lineup-cmp tbody.total td.pts { font-size: 16px; }
table.lineup-cmp tbody.total td.win { color: var(--accent); }
table.lineup-cmp tr.section td { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding-top: 16px; background: none; text-align: center; }
table.lineup-cmp .promote .pname, table.lineup-cmp td.pts.promote { color: var(--missed); }
table.lineup-cmp td.pl.promote { box-shadow: inset 3px 0 0 var(--missed); }
table.lineup-cmp td.pl.b.promote { box-shadow: inset -3px 0 0 var(--missed); }
table.lineup-cmp .demote { opacity: .5; }
@media (max-width: 480px) {
  table.team-games .opt-col { display: none; } /* tiles carry the optimal numbers; keep Missed visible */
  table.lineup-cmp th, table.lineup-cmp td { padding: 6px 4px; font-size: 13px; }
  table.lineup-cmp .slot { width: 3.2em; font-size: 11px; }
  table.lineup-cmp .pts { width: 3.2em; }
  table.lineup-cmp .pmeta { font-size: 11px; }
  .page-title { font-size: 20px; }
}
.tag { margin-left: 0; }

/* phones: stack the two teams, scores on the right */
@media (max-width: 560px) {
  .game {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "ta sa" "tb sb" "vs vs";
    row-gap: 8px; column-gap: 12px;
  }
  .ta { text-align: left; }
  .sb { align-items: flex-end; }
  .sa .g-sub { flex-direction: row; }
  .g-actual { font-size: 17px; }
  .g-vs > span:first-child { display: none; }
  .g-vs { align-items: flex-end; }
  .g-vs:not(:has(.tag)) { display: none; }
}

/* team detail */
#detail:empty { display: none; }
.team-detail { margin-top: 20px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; }
.week { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.week-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.score-pair { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.score { color: var(--muted); font-size: 14px; }
.score b { color: var(--text); font-size: 18px; margin-left: 4px; }
.score.opt b { color: var(--accent); }
.delta { color: var(--accent-2); font-size: 13px; }
.lineups { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 12px; }
@media (max-width: 720px) { .lineups { grid-template-columns: 1fr; } }
.lineups h4 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lineups h5 { font-size: 12px; margin: 14px 0 6px; color: var(--muted); }
table.lineup { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lineup td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.lineup td.pos { color: var(--muted); width: 56px; font-size: 12px; font-weight: 600; }
table.lineup td.pts { text-align: right; font-variant-numeric: tabular-nums; }
table.lineup.bench td { opacity: .7; }
.tag { font-size: 11px; background: var(--accent-2); color: #06162e; padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
@media (max-width: 480px) {
  main { padding: 20px 16px 40px; }
  .league-head h1 { font-size: 21px; column-gap: 8px; }
  .league-head .season { font-size: 14px; }
  .card { padding: 14px 10px; }
  table.standings th, table.standings td { padding: 8px 5px; }
  table.has-missed .pa { display: none; } /* keep Missed on screen instead */
}
