/* Dark plum is this page's own default look (the old R/Shiny app's palette,
   cleaned up), not the beige/olive suite palette every other tool in this
   repo defaults to -- see the plan. The three-way theme cycle (system/light/
   dark, driven by app.js's applyTheme) still works exactly like every other
   page here: this is the unconditional base, so "system" and the unset
   default both render dark plum regardless of the OS preference, and
   `[data-theme="light"]` is the one explicit escape hatch. Position colours
   (--pos-*) and the pitch gradient (--pitch-*) are lifted verbatim from
   tools/whatif_explorer/index.html's own dark-mode values -- no reason to
   re-derive a colour that already reads well on a dark surface. */
:root {
  color-scheme: dark;
  --surface-1:      #241a30;
  --surface-2:      #170f20;
  --text-primary:   #f5f0fa;
  --text-secondary: #c9bcd6;
  --text-muted:     #9385a3;
  --gridline:       #362a44;
  --border:         rgba(255,255,255,0.12);
  --good:           #3ddc7a;
  --good-bg:        #163a25;
  --warning:        #e0ab3d;
  --warning-bg:     #3a2c0d;
  --bad:            #ef5d7a;
  --bad-bg:         #3a1424;
  --accent-text:    #7fc8ff;
  --accent-bg:      #1c2f4a;
  --pos-gkp:        #3987e5;
  --pos-def:        #d95926;
  --pos-mid:        #199e70;
  --pos-fwd:        #c98500;
  --pitch-top:      #1c4a2e;
  --pitch-bottom:   #163a24;
  --pitch-line:     rgba(255,255,255,0.25);
  --pitch-text:     #ffffff;
  /* Standings-history chart: the same 8-hue categorical set as --pos-* above
     (slots 1-4 are literally the same hex values), extended to 8 for up to
     8 teams -- see tools/live_scores/README.md's "Standings History" section
     for the validated ordering this is drawn from. */
  --series-1:       #3987e5;
  --series-2:       #d95926;
  --series-3:       #199e70;
  --series-4:       #c98500;
  --series-5:       #d55181;
  --series-6:       #008300;
  --series-7:       #9085e9;
  --series-8:       #e66767;
  --chart-grid:     #362a44;
  --chart-axis:     #4a3c58;
}
:root[data-theme="light"] {
  color-scheme: light;
  --surface-1:      #ffffff;
  --surface-2:      #f6f2f8;
  --text-primary:   #1c1424;
  --text-secondary: #55495f;
  --text-muted:     #8a7d93;
  --gridline:       #e4dce8;
  --border:         rgba(28,20,36,0.12);
  --good:           #0ca34a;
  --good-bg:        #e5f6ea;
  --warning:        #b5790f;
  --warning-bg:     #fdf1d9;
  --bad:            #c22b4a;
  --bad-bg:         #fbe6ec;
  --accent-text:    #3d5ed8;
  --accent-bg:      #eaeefb;
  --pos-gkp:        #2a78d6;
  --pos-def:        #eb6834;
  --pos-mid:        #1baf7a;
  --pos-fwd:        #eda100;
  --pitch-top:      #d8ecdc;
  --pitch-bottom:   #c6e2cd;
  --pitch-line:     rgba(11,11,11,0.18);
  --pitch-text:     #0b0b0b;
  --series-1:       #2a78d6;
  --series-2:       #eb6834;
  --series-3:       #1baf7a;
  --series-4:       #eda100;
  --series-5:       #e87ba4;
  --series-6:       #008300;
  --series-7:       #4a3aa7;
  --series-8:       #e34948;
  --chart-grid:     #e4dce8;
  --chart-axis:     #cabdd4;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface-2);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
}

header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
header h1 { font-size: 18px; margin: 0; color: var(--accent-text); }

.control { display: flex; align-items: center; gap: 6px; }
.control label { color: var(--text-muted); font-size: 12px; }

/* GW quick-switch: two pills (Current/Next -- the two that matter most,
   always one click away) plus step buttons flanking the full jump-anywhere
   dropdown. Pill styling matches tools/whatif_explorer's existing
   `.gw-tabs` convention rather than inventing a new one. */
.gw-control { gap: 4px; }
.gw-tabs { display: flex; gap: 4px; }
.gw-tab {
  padding: 4px 10px; font-size: 12px; border-radius: 999px;
  background: var(--surface-1); color: var(--text-secondary);
}
.gw-tab.selected { background: var(--accent-text); border-color: var(--accent-text); color: var(--surface-2); font-weight: 600; }
.gw-tab:disabled { opacity: .4; cursor: default; }
.step-btn { padding: 4px 8px; font-size: 14px; line-height: 1; }

/* Live Scores tab only (its own toolbar row, not the global header) -- a
   pill toggle in the same `.gw-tab` visual language, `aria-pressed` driving
   the selected look the same way `.gw-tab.selected` does. */
.scores-toolbar { margin-bottom: 10px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.capsule-toggle {
  padding: 5px 14px; font-size: 12px; border-radius: 999px;
  background: var(--surface-1); color: var(--text-secondary);
}
.capsule-toggle[aria-pressed="true"] { background: var(--accent-text); border-color: var(--accent-text); color: var(--surface-2); font-weight: 600; }
.table-subview-toggle { display: flex; gap: 6px; }

input[type=text], select, button {
  font-family: inherit;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
}
input[type=text] { width: 70px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent-text); }
button.primary { background: var(--accent-text); color: var(--surface-2); border-color: var(--accent-text); font-weight: 600; }

.checkbox-control { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.squad-checkboxes { gap: 10px; flex-wrap: wrap; }
.squad-checkboxes label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }

#status-line { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.live-pulse {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bad); margin-right: 6px; animation: live-pulse 1.6s ease-in-out infinite;
}
.live-pulse[hidden] { display: none; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.tabs { display: flex; gap: 4px; padding: 6px 16px 0; border-bottom: 1px solid var(--border); }
.tab {
  border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0;
  background: none; color: var(--text-muted); padding: 6px 14px; font-size: 13px;
}
.tab.selected { background: var(--surface-1); color: var(--text-primary); border-color: var(--border); font-weight: 600; }

main { padding: 10px 12px; }

.error-banner {
  margin: 0 0 14px; padding: 8px 14px; border: 1px solid var(--bad);
  border-left-width: 4px; border-radius: 6px; color: var(--bad); font-size: 13px;
}

/* --- Pitch grid --- */
.pitch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 8px; }
.team-card { display: flex; flex-direction: column; gap: 2px; }
.team-header { display: flex; align-items: baseline; gap: 10px; font-size: 18px; padding: 2px 2px; }
.team-header .short-name { font-weight: 700; color: var(--accent-text); font-size: 24px; }
.team-header .points { font-weight: 700; font-size: 20px; }
.team-header .pp { color: var(--text-muted); font-size: 15px; }
.team-header .remaining { color: var(--text-muted); font-size: 15px; }
.team-header .rank-arrow.up { color: var(--good); }
.team-header .rank-arrow.down { color: var(--bad); }
.provisional-note { font-size: 11px; font-style: italic; color: var(--warning); padding: 0 2px 2px; }

/* Pitch + tokens, lifted from tools/whatif_explorer/index.html:139-186 and
   recoloured for the dark-plum default -- cleaner than the original mainly
   by dropping the boxed-in look: no card border, tighter padding so more
   pitches fit above the fold, bigger tokens so they still read easily. */
.pitch-wrap { background: linear-gradient(180deg, var(--pitch-top), var(--pitch-bottom)); border-radius: 8px; padding: 4px 2px 6px; position: relative; }
.pitch-wrap::before {
  content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 1px; background: var(--pitch-line);
}
.pitch-row { display: flex; justify-content: space-evenly; align-items: flex-start; margin: 2px 0; gap: 2px; }
.player-token { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: var(--pitch-text); padding: 3px; border-radius: 8px; width: 104px; cursor: pointer; }
.player-token:hover { background: rgba(0,0,0,0.15); }
.player-token:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.player-token.is-out { opacity: 0.45; }
.token-shirt { position: relative; width: 46px; height: 46px; border-radius: 50%; background: var(--accent-text); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; overflow: hidden; }
.token-shirt.GKP { background: var(--pos-gkp); }
.token-shirt.DEF { background: var(--pos-def); }
.token-shirt.MID { background: var(--pos-mid); }
.token-shirt.FWD { background: var(--pos-fwd); }
.token-shirt img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
/* Fixtures-tab only (see app.js's own fixtureToken) -- a wrapper around
   .token-shirt rather than a child of it, since .token-shirt's own
   overflow:hidden (cropping the player photo to a circle) would clip a
   badge poking out past its corner. */
.token-shirt-wrap { position: relative; display: inline-block; }
.token-owner { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px;
  padding: 0 3px; border-radius: 999px; background: var(--surface-1); color: var(--pitch-text);
  font-size: 10px; font-weight: 700; line-height: 1; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 0 0 1px var(--border); cursor: default; }
/* Inverted (background/text swapped) when that owner benched this player
   for the gameweek being viewed rather than starting him -- live_gameweek.
   _owner_benched_map, via fixtureToken's own owner_benched check. */
.token-owner.token-owner-benched { background: var(--pitch-text); color: var(--surface-1); }
.token-name { font-size: 14px; font-weight: 600; text-align: center; line-height: 1.15; }
.token-name.status-doubtful { color: var(--warning); }
.token-name.status-out { color: var(--bad); }
/* The row under the name: an upcoming fixture (if any) and/or the live
   points figure, coloured by pointsColorClass -- no separate "FT"/"live"
   text here, that's the corner badge's job only. */
.token-line { font-size: 13px; display: flex; gap: 4px; justify-content: center; align-items: baseline; flex-wrap: wrap; }
.token-upcoming { font-size: 10px; opacity: .75; }
.token-points { font-weight: 700; }
.token-points.pts-yellow { color: #ffd84d; }
.token-points.pts-green { color: var(--good); }
.token-points.pts-white { color: var(--pitch-text); }
.token-points.pts-grey { color: var(--pitch-text); opacity: .45; }
.token-points.pts-neutral { color: var(--pitch-text); opacity: .7; }
/* Anything not yet API-confirmed (a provisional BPS bonus, or the
   anticipate-points toggle's own additions) inside the "(X + ...)" points
   notation -- same --warning "liable to change" language `.provisional-note`
   and `.sub-arrow.provisional` already use elsewhere in this app. */
.pts-base { color: var(--pitch-text); }
.pts-bonus { color: var(--warning); font-weight: 700; }
.pts-anticipated { color: var(--accent-text); font-weight: 700; }
/* Clean-sheet shield, alongside a DEF/GKP's points -- green while it's
   secured or still on course, red once it's no longer possible. Never
   shown for MID/FWD (see clean_sheet_status's own position gate); currentColor
   lets one path do both colours via the modifier class. */
.cs-shield { width: 12px; height: 12px; flex: none; }
.cs-shield.cs-shield-green { color: var(--good); }
.cs-shield.cs-shield-red { color: var(--bad); }
.bench-strip { background: rgba(0,0,0,0.15); border-radius: 8px; padding: 4px 6px; margin-top: 2px; }
:root[data-theme="light"] .bench-strip { background: var(--surface-1); border: 1px solid var(--border); }
.bench-strip h3 { margin: 0 0 2px; font-size: 10px; color: var(--pitch-text); opacity: .7; text-transform: uppercase; }
.bench-strip .pitch-row { margin: 0; }

/* Fixtures tab: crest-vs-crest bar + two-club pitch detail. Reuses
   .pitch-wrap/.pitch-row/.token-shirt/.bench-strip verbatim (see
   fixtureToken/clubPitchBlock in app.js) -- these are the only new rules
   the tab needs beyond that. No probability/xMins numbers or toggle here --
   see app.js's own note on why that's a deliberate, scoped divergence from
   whatif_explorer's version of this tab. */
.fixture-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fixture-chip-btn { display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); cursor: pointer; font-size: 12px; }
.fixture-chip-btn.selected { border-color: var(--accent-text); background: var(--accent-bg); }
.fixture-chip-btn img { width: 20px; height: 20px; object-fit: contain; }
.fixture-chip-btn .kickoff { font-size: 10px; color: var(--text-muted); margin-left: 2px; }
/* justify-content: center + a capped club-block width, rather than
   flex: 1 -- on a wide screen flex: 1 stretched each pitch edge-to-edge
   into a flat, unrealistic rectangle (reported 2026-09-11); the individual
   player photos were never actually distorted (object-fit: cover already
   crops them correctly), it was the pitch panel itself losing any sensible
   aspect ratio. A fixed max-width keeps the pitch a believable shape and
   simply leaves empty space beside it on a wide screen -- ratio over full
   width, as asked. */
.fixture-detail { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.fixture-detail .club-block { flex: 0 1 560px; min-width: 300px; max-width: 560px; background: var(--surface-2); border-radius: 8px; padding: 8px; }
.fixture-detail .club-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.fixture-detail .club-header img { width: 24px; height: 24px; object-fit: contain; }
.fixture-detail .club-note { color: var(--text-muted); font-size: 11px; margin-top: 6px; }
.fixture-token-events { font-size: 11px; opacity: .85; }

#events-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px 0; }
#events-note { color: var(--warning); font-size: 12px; font-style: italic; margin-bottom: 10px; }

/* Live Events tab: a column per in-play match, natural (not full) width so
   up to five fit before the row has to scroll sideways -- 330px * 5 plus
   four 10px gaps is ~1690px, comfortable on a wide desktop; a sixth+ match
   scrolls rather than shrinking every column to fit, which would make the
   feed unreadable long before it'd make the row unscrollable. (330px is
   264px + 25%, widened 2026-09-13 to fit the substitution row's two
   photos and two names -- see .events-row-sub below.) */
/* `safe center`: centres the row of columns on the page when it's narrower
   than the viewport (1-4 live matches, the common case), but falls back to
   plain start alignment -- no centering, no clipped-off-the-left-edge
   columns -- the moment it overflows and needs the sideways scroll above.
   Plain `center` alone would clip the first column or two in that overflow
   case, since a centered flex container's own scroll origin sits mid-content. */
.events-controls { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.events-columns { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; justify-content: safe center; }
.events-column {
  flex: 0 0 330px; width: 330px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.events-header { display: flex; align-items: center; gap: 6px; }
.events-header-team { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; flex: 1; min-width: 0; }
.events-header-team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events-header-team img { width: 20px; height: 20px; object-fit: contain; flex: none; }
.events-header-team.away { justify-content: flex-end; text-align: right; }
.events-score { font-size: 16px; font-weight: 700; flex: none; padding: 0 4px; }
.events-elapsed { font-size: 11px; color: var(--text-muted); flex: none; }
.events-bonus { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 0; display: flex; flex-direction: column; gap: 4px; }
.events-bonus-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.events-bonus-row img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; }
.events-bonus-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events-bonus-crest { min-width: 22px; display: flex; justify-content: center; }
.events-bonus-crest img { width: 20px; height: 20px; object-fit: contain; border-radius: 0; }
.events-bonus-bps { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.events-bonus-points { min-width: 22px; text-align: center; color: var(--warning); font-weight: 700; }
.events-bonus-empty, .events-feed-empty { color: var(--text-muted); font-size: 11px; font-style: italic; }
/* Defcon section: a plain clickable div, not native <details>/<summary> --
   collapsed still shows content (the top 3, app.js's own defconVisible),
   which a closed <details> can't (it hides everything but the <summary>).
   Custom JS remembers each match's own open/closed state across the tab's
   own poll-driven re-renders (app.js's eventsDefconOpenState) -- see app.js's
   own note on why a plain re-render would otherwise reset it every 5s. Sits
   above .events-bonus, same row/photo/name shape as it. */
.events-defcon { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 0; }
.events-defcon-summary {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-secondary);
}
.events-defcon-chevron { color: var(--text-muted); font-size: 10px; }
.events-defcon-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.events-defcon-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.events-defcon-row img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; }
.events-defcon-row span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events-defcon-count { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.events-defcon-count.events-defcon-hit { color: var(--good); font-weight: 700; }
.events-defcon-empty { color: var(--text-muted); font-size: 11px; font-style: italic; }
/* Newest event at the top (app.js's diffLiveEvents unshifts) -- no reverse
   here, the feed's own DOM order already is chronological-newest-first. */
.events-feed { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.events-row { display: flex; align-items: center; gap: 6px; font-size: 12px; animation: events-row-in .3s ease-out; }
.events-row img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex: none; }
.events-row-crest { width: 22px; height: 22px; object-fit: contain; flex: none; }
.events-row-minute { flex: none; width: 30px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.events-row-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Substitution row: photo-out, its own name, an arrow, then photo-in and
   its own name -- each name sits directly after its own photo (not both
   photos stranded up front before a single combined label) and shares the
   row's remaining width evenly (flex: 1 1 0 on both, not flex: 1 on one),
   so a long name on either side doesn't starve the other's space before
   its own ellipsis kicks in. A slightly smaller font than every other row
   here (12px) is what keeps two real names readable in that split width. */
.events-row-sub-name { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.events-row-arrow { flex: none; color: var(--text-muted); }
.events-points { font-weight: 700; flex: none; }
.events-points.pts-good { color: var(--good); }
.events-points.pts-bad { color: var(--bad); }
@keyframes events-row-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Waivers tab -- ported verbatim from tools/waiver_viewer/style.css. Every
   custom property it reads (--good/--warning/--bad/--gridline/--accent-text/
   --border/--surface-1/2/--text-primary/secondary/muted) already exists in
   this file's own :root blocks with the same names, so no new tokens were
   needed -- only the component classes themselves, copied-not-recoloured
   since the values already resolve to this app's own palette. See app.js's
   own note on why the underlying data/polling logic is a live-API
   reimplementation rather than a literal copy, even though the CSS and
   markup are unchanged. */
.waiver-controls { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
#waiver-status-line { font-size: 12px; color: var(--text-muted); }
#waiver-status-line.waiting { color: var(--warning); }
#waiver-status-line.live { color: var(--good); }

.managers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.manager-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: relative;
}
.manager-card h3 { margin: 0 0 2px; font-size: 15px; padding-right: 34px; }
.manager-card .manager-name { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }

/* Top-right corner badge: this manager's total net points across every
   chain this gameweek (app.js's setWaiverManagerTotal/waiverChainNet) --
   the sum of the same figures each chain's own .txn-net line shows. Empty
   (no badge rendered) rather than "0" until at least one chain has a
   computable net. */
.manager-net {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  background: var(--surface-2);
  color: var(--text-muted);
}
.manager-net:empty { display: none; }
.manager-net.net-positive { background: var(--good-bg); color: var(--good); }
.manager-net.net-negative { background: var(--bad-bg); color: var(--bad); }

.txn-list { display: flex; flex-direction: column; gap: 5px; }
.txn-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 8px;
}
.txn-row.dim { opacity: 0.22; }

.player-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 76px;
  text-align: center;
  gap: 2px;
  border-radius: 8px;
  cursor: pointer;
}
.player-slot:hover { background: rgba(0,0,0,0.15); }
.player-slot:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.player-slot.empty-slot { visibility: hidden; cursor: default; }
/* A pass-through in a same-week chain (e.g. Maguire -> Khalaili -> Wieffer):
   Khalaili was never who the manager ended up with, so his slot reads at
   reduced opacity while the chain's two real ends stay full. */
.player-slot.transient { opacity: 0.4; }

.photo-frame {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.photo-frame.status-red { border-color: var(--bad); }
.photo-frame.status-amber { border-color: var(--warning); }

.player-name { font-size: 11.5px; line-height: 1.2; }
.player-fixture { font-size: 10.5px; color: var(--text-muted); }
.player-points { font-size: 10.5px; font-weight: 600; }

.arrow { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }

.empty-note { color: var(--text-muted); font-size: 12px; font-style: italic; }

.section-separator { border: none; border-top: 1px dashed var(--gridline); margin: 2px 0; }

/* The net-points line under a completed waiver/free-agency swap (or chain --
   see transactions.py's own docstring on chains) -- only shown once both the
   initial player out and the final player in have actually played the
   referenced gameweek. */
.txn-net {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  margin: -2px 0 2px;
  color: var(--text-muted);
}
.txn-net.net-positive { color: var(--good); }
.txn-net.net-negative { color: var(--bad); }

/* Play button: rows sit fully visible by default; a play pass adds
   .pre-play (hides the parts about to animate in) then, staggered by 0.5s
   per row, swaps it for .playing (which runs the reveal). A rejected row
   has no left/arrow/right choreography -- it just fades in as one piece,
   to its normal dimmed opacity rather than full. */
.txn-row.pre-play:not(.dim) .player-slot,
.txn-row.pre-play:not(.dim) .arrow { opacity: 0; }
.txn-row.pre-play.dim { opacity: 0; }

@keyframes waiver-viewer-slide-in-left {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes waiver-viewer-slide-in-right {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes waiver-viewer-slide-in-right-transient {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 0.4; transform: translateX(0); }
}
@keyframes waiver-viewer-arrow-swipe {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes waiver-viewer-fade-in-dim {
  from { opacity: 0; }
  to { opacity: 0.22; }
}

.txn-row.playing:not(.dim) .player-slot.slot-out {
  animation: waiver-viewer-slide-in-left 0.17s ease-out forwards;
}
.txn-row.playing:not(.dim) .arrow {
  animation: waiver-viewer-arrow-swipe 0.16s ease-out forwards;
  animation-delay: 0.17s;
}
.txn-row.playing:not(.dim) .player-slot.slot-in {
  animation: waiver-viewer-slide-in-right 0.17s ease-out forwards;
  animation-delay: 0.33s;
}
.txn-row.playing:not(.dim) .player-slot.slot-in.transient {
  animation-name: waiver-viewer-slide-in-right-transient;
}
.txn-row.playing.dim {
  animation: waiver-viewer-fade-in-dim 0.5s ease-out forwards;
}

/* State markers on a token */
.live-badge { position: absolute; top: 0; right: 0; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 999px; line-height: 1.4; color: #fff; }
.live-badge.in-play { background: var(--bad); animation: live-pulse 1.6s ease-in-out infinite; }
.live-badge.final { background: rgba(0,0,0,0.5); }
.live-badge.upcoming { background: rgba(0,0,0,0.4); font-weight: 500; }
.chip { display: inline-block; font-size: 9px; font-weight: 700; padding: 0 4px; border-radius: 3px; line-height: 1.5; }
.chip.blank { background: rgba(0,0,0,0.35); color: var(--pitch-text); opacity: .8; }
.chip.bonus-provisional { background: var(--warning-bg); color: var(--warning); }
.sub-arrow { font-size: 10px; opacity: .8; }
.sub-arrow.provisional { font-style: italic; }

/* --- League table --- */
#table-view { display: flex; flex-direction: column; align-items: center; }
#table-view[hidden] { display: none; }
#league-table { max-width: 820px; }
#pace-table-wrap { max-width: 100%; overflow-x: auto; }
#pace-table-wrap[hidden] { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; }
tr.league-row { cursor: pointer; }
tr.league-row:hover { background: var(--surface-1); }
tr.league-row-detail td { background: var(--surface-1); padding: 10px 16px; }
.rank-arrow.up { color: var(--good); }
.rank-arrow.down { color: var(--bad); }
.rank-arrow.same { color: var(--text-muted); }
table.breakdown { width: 100%; font-size: 12px; }
table.breakdown th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 2px 6px; }
table.breakdown td { padding: 2px 6px; border: none; }

/* --- Player modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  position: relative; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; max-width: 640px; width: 100%;
  max-height: 85vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 2px; font-size: 20px; }
.modal-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.modal-close {
  position: absolute; top: 10px; right: 10px; background: none; border: none;
  font-size: 22px; line-height: 1; color: var(--text-muted); padding: 4px 8px;
}
.modal-close:hover { color: var(--bad); border-color: transparent; }
.modal-close:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.modal-loading, .modal-error, .modal-empty { color: var(--text-muted); font-size: 13px; }
.modal-error { color: var(--bad); }

.modal-player-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 4px; }
.modal-photo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.modal-rank { color: var(--text-secondary); font-size: 12px; }

/* Fixture-state indicator, top-right of the modal (next to close) -- reads
   from the same fixturePlayState() classifier the pitch token's point
   colour uses, so the two can never disagree. */
.modal-badge {
  position: absolute; top: 14px; right: 44px; font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .02em;
}
.modal-badge:empty { display: none; }
.modal-badge.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.modal-badge.badge-live { background: var(--bad); color: #fff; animation: live-pulse 1.6s ease-in-out infinite; }
.modal-badge.badge-warning { background: var(--warning-bg); color: var(--warning); }
.modal-badge.badge-neutral { background: var(--surface-2); color: var(--text-primary); }

/* Live/complete stat grid: title above, value below, per tile -- zero
   values greyed out so the eye goes straight to what actually happened. */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 10px; margin-top: 4px; }
.stat-tile { text-align: center; padding: 8px 4px; border-radius: 8px; background: var(--surface-2); }
.stat-tile .stat-title { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin-bottom: 4px; }
.stat-tile .stat-value { font-size: 20px; font-weight: 700; }
.stat-tile.zero .stat-value { color: var(--text-muted); opacity: .5; }
.stat-tile.stat-points { grid-column: span 2; background: var(--accent-bg); }
.stat-tile.stat-points .stat-value { font-size: 28px; color: var(--accent-text); }
.stat-tile.stat-points.zero .stat-value { color: var(--accent-text); opacity: .5; }

table.modal-history { font-size: 12px; }
table.modal-history th, table.modal-history td { text-align: center; padding: 4px 6px; }
table.modal-history td:first-child, table.modal-history th:first-child { text-align: left; }
table.modal-history td:nth-child(2), table.modal-history th:nth-child(2) { text-align: left; }
table.modal-history tr.history-totals { border-top: 1px solid var(--border); font-weight: 700; }

/* --- Standings history --- */
#history-view { display: flex; flex-direction: column; gap: 10px; align-items: center; }
#history-view[hidden] { display: none; }
.history-controls { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.radio-control { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.radio-control input:checked + span { color: var(--text-primary); font-weight: 600; }
.history-chart-wrap { width: 100%; max-width: 980px; }
.history-chart-wrap svg { width: 100%; height: auto; display: block; }
.history-chart-wrap .chart-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px 0; }
.hgrid-line { stroke: var(--chart-grid); stroke-width: 1; }
.haxis-line { stroke: var(--chart-axis); stroke-width: 1; }
.haxis-label { fill: var(--text-muted); font-size: 11px; }
.href-line { stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
/* "Points from winning average" mode's two extra benchmark lines (2026-09-14)
   -- Average Spoon/WOAT -- reuse .href-line's own weight/dash by default,
   overriding only colour (both) and dash pattern (WOAT, so it's still
   distinguishable from Average Spoon even for a colour-blind viewer, not
   just by hue) -- same classes on both the chart path and its legend
   swatch (renderStandingsHistory), so the two can never visually disagree. */
.href-line.href-spoon { stroke: var(--warning); }
.href-line.href-woat { stroke: var(--bad); stroke-dasharray: 2 3; }
.href-label { fill: var(--text-muted); font-size: 11px; font-style: italic; }
.hseries-line { stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.hseries-dot { stroke: var(--surface-1); stroke-width: 2; }
.hseries-leader { stroke-width: .75; opacity: .6; fill: none; }
.hseries-label-name { font-size: 12px; font-weight: 700; }
.hseries-label-value { font-size: 12px; fill: var(--text-muted); }


/* --- Cup (only for leagues the server has it on for) -------------------------------------------- */
:root { --gold: #e5b83c; --gold-bg: #3a2f0d; --on-gold: #1c1424; }
:root[data-theme="light"] { --gold: #a87a08; --gold-bg: #fbf0cc; --on-gold: #ffffff; }

.cup-rounds { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cup-banner { display: flex; align-items: center; gap: 12px; font-size: 18px; margin-bottom: 12px; }
.cup-test { padding: 2px 10px; border-radius: 999px; background: var(--warning-bg); color: var(--warning); font-size: 12px; font-weight: 600; }
.cup-ties { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.cup-tie { background: var(--surface-1); border-radius: 14px; padding: 10px 14px 12px; box-shadow: inset 0 0 0 1px var(--gridline); }
.cup-tie table { width: 100%; border-collapse: collapse; }
.cup-tie th { font-size: 11px; font-weight: 500; color: var(--text-muted); text-align: right; padding: 0 0 4px 10px; }
.cup-tie th small { display: block; font-size: 10px; }
.cup-tie th.live { color: var(--good); }
.cup-tie td { padding: 4px 0 4px 10px; text-align: right; font-variant-numeric: tabular-nums; vertical-align: top; }
.cup-tie td.cup-name { text-align: left; padding-left: 0; }
.cup-side.out { opacity: 0.6; }
.cup-leg { color: var(--text-secondary); }
.cup-leg.live { color: var(--good); font-weight: 600; }
.cup-agg { font-size: 17px; font-weight: 700; color: var(--text-muted); }
.cup-agg.lead { color: var(--text-primary); }
.cup-short { display: inline-block; min-width: 28px; font-weight: 700; color: var(--accent-text); }
.cup-team { background: transparent; border: 0; padding: 4px 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cup-team:hover { color: var(--accent-text); }
.cup-blocks { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 0 0 2px 0; }
.cup-pips { display: inline-flex; gap: 3px; }
.cup-pip { display: inline-block; width: 11px; height: 11px; border-radius: 3px; box-sizing: border-box; }
.cup-pip-done { background: var(--text-secondary); }
.cup-pip-live { background: var(--good); }
.cup-pip-todo { border: 1.5px solid var(--text-muted); }
.cup-count { font-size: 12px; color: var(--text-secondary); }
.cup-count.live { color: var(--good); font-weight: 600; }
.cup-note { margin-top: 6px; padding: 6px 10px; border-radius: 10px; background: var(--gold-bg); color: var(--gold); font-size: 13px; font-weight: 600; }
.cup-byes, .cup-footnote { margin-top: 12px; color: var(--text-muted); font-size: 13px; }

/* On Live Scores: the viewed team's cup opponent is gold (its card and its tick-box). */
.team-card.cup-opponent { box-shadow: 0 0 0 2px var(--gold); border-radius: 12px; }
.team-card.cup-opponent .short-name { color: var(--gold); }
.squad-checkboxes label.cup-opponent { color: var(--gold); font-weight: 700; }
.cup-chip { margin-left: auto; align-self: center; padding: 2px 10px; border: 0; border-radius: 999px; background: var(--gold-bg); color: var(--gold); font-size: 12px; }
.cup-chip b { background: var(--gold); color: var(--on-gold); border-radius: 999px; padding: 0 8px; margin-right: 4px; }
.squad-checkboxes label { user-select: none; }
.cup-chip { display: inline-flex; align-items: flex-start; gap: 6px; text-align: left; border-radius: 14px; padding: 4px 12px; }
.cup-chip-text { display: flex; flex-direction: column; }
.cup-chip-text small { font-size: 11px; opacity: 0.85; }
.cup-kind { margin-bottom: 4px; font-size: 12px; color: var(--text-muted); }
.cup-side.through .cup-name button { color: var(--good); }
