/* TAMU-Spor — phone-first design in Aggie maroon and white, light and dark themes. */

:root {
  /* Texas A&M: Aggie Maroon (#500000) and white */
  --bg: #f6f4f4;
  --card: #ffffff;
  --text: #1d1919;
  --muted: #6d6565;
  --line: #e5dfdf;
  --field: #ffffff;
  --bar: #500000;          /* top bar */
  --brand: #500000;        /* buttons, chosen chips and scores */
  --brand-dark: #3a0000;
  --brand-ink: #ffffff;
  --brand-text: #500000;   /* links and maroon text */
  --brand-soft: #f4e8e8;
  --ok: #1a7f3c;           /* success messages stay green: maroon would look like an error */
  --ok-soft: #e3f3e8;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info-soft: #e8f0fb;
  --info-ink: #1d4f91;
  --gk: #a16207;
  --def: #1d5fbf;
  --mid: #15803d;
  --fwd: #c2410c;
  --t1: #500000;           /* Team-1: maroon */
  --t1-ink: #ffffff;
  --t1-edge: #500000;
  --t2: #ffffff;           /* Team-2: white */
  --t2-ink: #1d1919;
  --t2-edge: #b9afaf;
  --grass: #3b8a3f;        /* the pitch: two stripes of grass, chalk lines, a marker for changes */
  --grass-2: #347d38;
  --chalk: rgba(255, 255, 255, 0.78);
  --pitch-mark: #fde047;
  --radius: 14px;
  --tabbar: 62px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141111;
    --card: #1f1a1a;
    --text: #f0eaea;
    --muted: #a69c9c;
    --line: #382f2f;
    --field: #181414;
    --bar: #500000;
    --brand: #8a1f2b;      /* lighter maroon: #500000 disappears on a dark page */
    --brand-dark: #6e1822;
    --brand-ink: #ffffff;
    --brand-text: #f2a7ae;
    --brand-soft: #3b1d21;
    --ok: #4ade80;
    --ok-soft: #173524;
    --danger: #f97066;
    --danger-soft: #3a1b18;
    --info-soft: #172a45;
    --info-ink: #a9c9f5;
    --gk: #eab308;
    --def: #6aa5f7;
    --mid: #4ade80;
    --fwd: #fb923c;
    --t1: #7a1a24;
    --t1-ink: #ffffff;
    --t1-edge: #c2646d;
    --t2: #f4f2f2;
    --t2-ink: #1d1919;
    --t2-edge: #f4f2f2;
    --grass: #21502a;
    --grass-2: #1d4825;
    --chalk: rgba(255, 255, 255, 0.5);
    --pitch-mark: #facc15;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand-text); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.5rem; line-height: 1.2; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
p { margin: 0 0 12px; }
.card-title { font-size: 1rem; margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.big { font-size: 2.2rem; font-weight: 700; line-height: 1; margin: 0; }
.count { font-size: 0.85rem; font-weight: 600; color: var(--muted); background: var(--line); border-radius: 999px; padding: 2px 9px; vertical-align: middle; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; }

/* --- Top bar and bottom menu ---------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bar); color: #ffffff;
}
.topbar a { color: inherit; text-decoration: none; }
.brand { margin-right: auto; font-weight: 700; font-size: 1.05rem; white-space: nowrap; } /* the rest goes right */
.who { min-width: 0; font-size: 0.9rem; opacity: 0.95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .tag { background: rgba(255, 255, 255, 0.22); color: inherit; }
/* "?": the help page, from every page (help.html) */
.help-link {
  position: relative; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 1.5px solid rgba(255, 255, 255, 0.75); border-radius: 50%;
  font-weight: 700; font-size: 0.95rem; line-height: 1;
}
.help-link::after { content: ""; position: absolute; inset: -8px; } /* a finger-sized target */
.help-link[aria-current="page"] { background: #ffffff; border-color: #ffffff; color: var(--bar); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1 1 0; max-width: 112px; min-height: var(--tabbar);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.7rem; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabbar a span { font-size: 1.25rem; line-height: 1; filter: grayscale(1); opacity: 0.7; }
.tabbar a.on { color: var(--brand-text); }
.tabbar a.on span { filter: none; opacity: 1; }

/* --- Cards and lists ------------------------------------------------------ */

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 12px;
}
.card > :last-child { margin-bottom: 0; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > * { margin: 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 120px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; }
.actions > .btn, .actions > form { flex: 1 1 140px; }
.actions > form > .btn { width: 100%; }

.list { list-style: none; padding: 4px 16px; }
.list li {
  display: flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.list .sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-weight: 400; }
.picklist, details.card > .list { padding: 0; margin: 0; }
.picklist .list-title { min-height: 36px; font-weight: 700; font-size: 0.9rem; }
ul.picklist + ul.picklist { margin-top: 10px; }
.picklist .check { flex: 1 1 auto; align-items: center; }

.players .name { font-weight: 600; }
.players .edit { flex: 0 0 30px; text-align: center; text-decoration: none; font-size: 1.1rem; padding: 6px 0; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.82rem; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }

/* Three scores side by side: DEF 6.5  MID 7.0  FWD 5.5 */
.area-scores, .my-row { display: inline-flex; gap: 8px; flex: 0 0 auto; }
.area-score { display: inline-flex; flex-direction: column; align-items: center; min-width: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.area-score small { font-size: 0.6rem; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; }

/* Rate list: whole row is a link */
.rate-list li { padding: 0; }
.row-link { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 6px 0; color: inherit; text-decoration: none; }
.row-link .name { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.chevron { flex: 0 0 auto; font-size: 1.4rem; color: var(--muted); line-height: 1; }

.my-scores { list-style: none; margin: 0 0 12px; padding: 0; }
.my-scores li { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.my-scores li:last-child { border-bottom: 0; }
.my-scores .label { flex: 0 0 90px; margin: 0; font-weight: 600; }
.my-scores strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }

.score-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.score-table th, .score-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.score-table thead th { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.score-table th:first-child { text-align: left; }
.score-table tr:last-child th, .score-table tr:last-child td { border-bottom: 0; }

/* --- Badges ----------------------------------------------------------------- */

.badges { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--muted);
}
.badge.pos-GK { background: var(--gk); }
.badge.pos-DEF { background: var(--def); }
.badge.pos-MID { background: var(--mid); }
.badge.pos-FWD { background: var(--fwd); }
@media (prefers-color-scheme: dark) { .badge { color: #10160f; } }

.tag {
  display: inline-block; font-size: 0.68rem; font-weight: 600; line-height: 1;
  padding: 3px 7px; border-radius: 999px; vertical-align: middle;
  background: var(--brand-soft); color: var(--brand-text);
}
.tag-muted { background: var(--line); color: var(--muted); }
.tag-new { background: var(--info-soft); color: var(--info-ink); }

.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; }
.pill-ok { background: var(--brand-soft); color: var(--brand-text); }

/* --- Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.btn:active { transform: translateY(1px); }
.btn-block { display: flex; width: 100%; margin-bottom: 12px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 0.88rem; border-radius: 10px; }

a:focus-visible, .btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-text) 55%, transparent);
  outline-offset: 2px;
}

/* --- Forms ------------------------------------------------------------------ */

label, .field { display: block; font-weight: 600; font-size: 0.92rem; }
.label { display: block; margin-bottom: 6px; }
.hint { display: block; font-weight: 400; font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

input:not([type="checkbox"]):not([type="radio"]), select {
  display: block; width: 100%; min-height: 46px; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--field); color: var(--text);
  font: inherit; font-size: 16px; /* iOS zooms in on fields below 16px */
}
input[readonly] { color: var(--muted); font-size: 0.85rem; }

.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--brand); }

/* Position choice: touch-friendly chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.chip span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 8px 16px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--field); font-weight: 600;
}
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand-text) 55%, transparent); outline-offset: 2px; }

details.card > summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
details.card[open] > summary { margin-bottom: 12px; }
details.card > .list + .stack { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Help page: a section per topic, opened by tapping its title */
details.help > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; list-style: none; }
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary::after { content: "›"; flex: 0 0 auto; font-size: 1.4rem; line-height: 1; color: var(--muted); transition: transform 0.15s; }
details.help[open] > summary::after { transform: rotate(90deg); }
.help ul, .help ol { margin: 0 0 12px; padding-left: 1.3em; }
.help li { margin-bottom: 6px; }
.help li:last-child { margin-bottom: 0; }
.help .legend { margin-bottom: 12px; }
.help-rights { margin: 0 0 12px; }
.help-rights dt { font-weight: 600; }
.help-rights dd { margin: 2px 0 10px; font-size: 0.9rem; color: var(--muted); }
.help code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; }

fieldset.card { min-width: 0; }
fieldset.options { margin: 0 0 12px; }
fieldset.options legend { float: left; width: 100%; padding: 0; margin-bottom: 8px; font-weight: 600; font-size: 0.92rem; }
fieldset.options .check { clear: both; margin-bottom: 10px; }
fieldset.options .check:last-child { margin-bottom: 0; }

/* Admin rights (superadmin, player page): the rights count only for an admin. */
fieldset.rights { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.rights legend { float: left; width: 100%; padding: 0; font-weight: 600; }
fieldset.rights .check { clear: both; }
.admin-rights:has(input[name="is_admin"]:not(:checked)) .rights { opacity: 0.45; }

/* --- Notices ---------------------------------------------------------------- */

.flash {
  display: block; padding: 12px 14px; border-radius: 12px; margin: 0 0 12px;
  font-size: 0.95rem; text-decoration: none;
  background: var(--info-soft); color: var(--info-ink);
}
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

.back { display: inline-block; font-size: 0.9rem; text-decoration: none; margin-bottom: 4px; }

/* --- Rating form -------------------------------------------------------------- */

.rate { padding: 10px 12px 12px; }
.rate legend { float: left; width: 100%; padding: 0; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.rate .skip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rate .skip label {
  display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px;
  border: 1.5px solid var(--line); border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.rate .skip input:checked + label { background: var(--line); color: var(--text); }
.rate .skip input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--brand-text) 55%, transparent); outline-offset: 1px; }
.rate .area-hint { clear: both; margin: -4px 0 8px; }
.scores { clear: both; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.scores input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scores label {
  display: flex; align-items: center; justify-content: center;
  height: 42px; border: 1.5px solid var(--line); border-radius: 9px;
  background: var(--field); font-size: 0.92rem; font-variant-numeric: tabular-nums; cursor: pointer;
}
.scores input:checked + label { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.scores input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--brand-text) 55%, transparent); outline-offset: 1px; }
fieldset[disabled] label { cursor: default; opacity: 0.75; }

.sticky-action {
  position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 5;
  padding: 10px 0 2px; background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.sticky-action .btn-block:last-child { margin-bottom: 8px; }
.sticky-action .row { margin-bottom: 8px; }
.sticky-action .row > .btn { flex: 1 1 0; }

/* --- Teams: Red and White ------------------------------------------------------ */

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot-red { background: var(--t1); box-shadow: inset 0 0 0 1.5px var(--t1-edge); }
.dot-white { background: var(--t2); box-shadow: inset 0 0 0 1.5px var(--t2-edge); }

.compare { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.compare th, .compare td { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.compare thead th { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.compare th:first-child { text-align: left; white-space: nowrap; }
.compare tbody tr:last-child th, .compare tbody tr:last-child td { border-bottom: 0; }
.compare td { font-weight: 700; font-size: 1.05rem; }
.compare th small { display: block; margin-left: 18px; font-size: 0.72rem; font-weight: 400; color: var(--muted); }
.compare .total { border-left: 1px solid var(--line); padding-left: 8px; }
.compare td.total { font-size: 1.15rem; }
.compare + .hint { margin-top: 6px; }
.note { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }

/* Balance bars: Team-1's share in maroon against Team-2's in white, per area and overall */
.balance {
  position: relative;
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 8px 10px;
  font-variant-numeric: tabular-nums;
}
.compare + .hint + .balance { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.balance-teams { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; margin: 0; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.balance-teams .dot-white { margin: 0 0 0 6px; }
.balance-area { font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; }
.balance-pct { font-size: 0.92rem; font-weight: 700; text-align: right; }
.balance-pct-red { color: var(--brand-text); }
.balance-bar {
  display: flex; height: 12px; overflow: hidden;
  background: var(--t2); border: 1px solid var(--t2-edge); border-radius: 999px;
}
.balance-bar > span { flex: 0 0 auto; background: var(--t1); }
.balance-line { grid-column: 1 / -1; border-top: 1px solid var(--line); }
.balance-area.overall { font-size: 0.82rem; color: var(--text); letter-spacing: 0; }
.balance-pct.overall { font-size: 1.05rem; }
.balance-bar.overall { height: 16px; }
.balance-note { margin: 0; }

.teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.team { margin: 0; padding: 0; overflow: hidden; }
.team header { padding: 9px 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.team h2 { margin: 0; font-size: 1rem; }
.team header span { font-size: 0.8rem; font-weight: 600; opacity: 0.9; }
.team-red { border-color: var(--t1-edge); }
.team-red header { background: var(--t1); color: var(--t1-ink); }
.team-white { border-color: var(--t2-edge); }
.team-white header { background: var(--t2); color: var(--t2-ink); border-bottom: 1px solid var(--t2-edge); }
.team ol { list-style: none; margin: 0; padding: 2px 10px 4px; }
.team li { display: flex; align-items: center; gap: 6px; min-height: 42px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.team li:last-child { border-bottom: 0; }
.team .name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.team .badge { width: 18px; height: 18px; font-size: 0.64rem; border-radius: 5px; }
.team .badges { gap: 2px; }
.team .tag { margin-left: 2px; }
.team .empty { color: var(--muted); font-size: 0.85rem; padding: 10px 0; }
li.changed .name { font-weight: 700; }

.move {
  flex: 0 0 auto; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 9px; background: var(--field); color: var(--text);
  font: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
}
.move:active { transform: translateY(1px); }

.unplaced li { gap: 8px; }
.unplaced .to { display: inline-flex; gap: 6px; flex: 0 0 auto; }
.btn-red { background: var(--t1); border-color: var(--t1-edge); color: var(--t1-ink); }
.btn-white { background: var(--t2); border-color: var(--t2-edge); color: var(--t2-ink); }

/* --- Teams: Pitch / List ----------------------------------------------------------------
   Two radio buttons and CSS show one view, no JavaScript (teams/_parts.html → team_views).
   Browsers without :has() show both views, one under the other, and no switch. */

.view-switch {
  display: none; position: relative; gap: 2px;
  width: max-content; margin: 0 auto 10px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.view-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.view-switch label {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 84px; min-height: 36px; padding: 6px 16px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.view-switch input:checked + label { background: var(--brand); color: var(--brand-ink); }
.view-switch input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--brand-text) 55%, transparent); outline-offset: 2px; }

/* A ⇄ move scrolls back to the player (#p-<id>): keep them clear of the sticky top bar */
.teams li, .unplaced li { scroll-margin-top: calc(60px + env(safe-area-inset-top)); }

@supports selector(:has(a)) {
  .view-switch { display: flex; }
  .views:has(.view-list:checked) .pitch-view,
  .views:not(:has(.view-list:checked)) .list-view { display: none; }

  /* Draft page, no view picked yet: the pitch, or the list while the address points at a
     player in it (a ⇄ move comes back to /teams#p-<id>). Picking a view ends that. */
  .views:not(:has(.view-input:checked)) .to-pitch { background: var(--brand); color: var(--brand-ink); }
  .views:not(:has(.view-input:checked)):has(.list-view :target) .pitch-view { display: none; }
  .views:not(:has(.view-input:checked)):has(.list-view :target) .list-view { display: block; }
  .views:not(:has(.view-input:checked)):has(.list-view :target) .to-pitch { background: none; color: var(--muted); }
  .views:not(:has(.view-input:checked)):has(.list-view :target) .to-list { background: var(--brand); color: var(--brand-ink); }
}

/* --- Teams: the pitch ----------------------------------------------------------------------
   Vertical, drawn in CSS: Team-1 in the top half, Team-2 in the bottom half, each in rows
   goalkeeper – defense – midfield – forward from its own goal. Names only. */

.pitch-card { padding: 0; overflow: hidden; }
.pitch-team { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; padding: 8px 12px; font-weight: 700; }
.pitch-team span { font-size: 0.8rem; font-weight: 600; opacity: 0.9; }
.pitch-team-red { background: var(--t1); color: var(--t1-ink); }
.pitch-team-white { background: var(--t2); color: var(--t2-ink); }

.pitch {
  position: relative; isolation: isolate; container-type: inline-size;
  display: grid; grid-template-rows: 1fr 1fr; /* two equal halves, as tall as the fuller one needs */
  padding: 12px;
  background: repeating-linear-gradient(to bottom, var(--grass) 0 8.333%, var(--grass-2) 8.333% 16.667%);
}

/* The lines: touchlines and goal lines, halfway line, centre circle, boxes, goals, corners */
.pitch-lines { position: absolute; inset: 10px; z-index: -1; border: 2px solid var(--chalk); }
.pitch-lines > * { position: absolute; border: 2px solid var(--chalk); } /* (0,1,0): the rules below win */
.pl-halfway { left: 0; right: 0; top: 50%; height: 0; border-width: 2px 0 0; transform: translateY(-1px); }
.pl-circle { left: 50%; top: 50%; width: 30%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); }
.pl-spot { left: 50%; top: 50%; width: 6px; height: 6px; border: 0; border-radius: 50%; background: var(--chalk); transform: translate(-50%, -50%); }
.pl-box { left: 20%; right: 20%; height: 15%; }
.pl-goal-area { left: 35%; right: 35%; height: 6%; }
.pl-arc { left: 39%; right: 39%; height: 4%; }
.pl-goal { left: 41%; right: 41%; height: 7px; }
.pl-box.pl-top, .pl-goal-area.pl-top { top: 0; border-top: 0; }
.pl-box.pl-bottom, .pl-goal-area.pl-bottom { bottom: 0; border-bottom: 0; }
.pl-arc.pl-top { top: 15%; border-top: 0; border-radius: 0 0 50% 50% / 0 0 100% 100%; }
.pl-arc.pl-bottom { bottom: 15%; border-bottom: 0; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.pl-goal.pl-top { top: -9px; border-bottom: 0; }
.pl-goal.pl-bottom { bottom: -9px; border-top: 0; }
.pl-corner { width: 12px; height: 12px; }
.pl-tl { left: 0; top: 0; border-width: 0 2px 2px 0; border-bottom-right-radius: 100%; }
.pl-tr { right: 0; top: 0; border-width: 0 0 2px 2px; border-bottom-left-radius: 100%; }
.pl-bl { left: 0; bottom: 0; border-width: 2px 2px 0 0; border-top-right-radius: 100%; }
.pl-br { right: 0; bottom: 0; border-width: 2px 0 0 2px; border-top-left-radius: 100%; }

/* The players: rows spread over each half, the forwards clear of the halfway line */
.pitch-half { display: flex; flex-direction: column; justify-content: space-around; gap: 6px; min-height: 216px; min-height: max(216px, 63cqw); padding: 4px 0; } /* a pitch's shape on wider screens too */
.pitch-half-red { padding-bottom: 22px; }
.pitch-half-white { padding-top: 22px; }
.pitch-row { min-height: 30px; }
.pitch-row ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; list-style: none; margin: 0; padding: 0; }
.pitch-chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 0; max-width: min(100%, 12.5rem); min-height: 30px; padding: 4px 11px;
  border: 1.5px solid; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; line-height: 1.15;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.pitch-chip-red { background: var(--t1); border-color: var(--t1-edge); color: var(--t1-ink); }
.pitch-chip-white { background: var(--t2); border-color: var(--t2-edge); color: var(--t2-ink); }
.pitch-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitch-chip .tag { flex: 0 0 auto; padding: 2px 5px; font-size: 0.6rem; }
.pitch-chip-changed { outline: 2.5px solid var(--pitch-mark); outline-offset: 1.5px; }
.pitch-keeper { border: 1.5px dashed var(--chalk); background: var(--grass-2); color: #ffffff; box-shadow: none; } /* hides the lines behind it */
.pitch-empty { margin: auto; color: #ffffff; font-weight: 600; opacity: 0.9; }

.changes { list-style: none; margin: 0; padding: 0; }
.changes li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.changes li:last-child { border-bottom: 0; }

.pick-count { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.pick-count strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
