/* The Oval Office · Squad Builder 2027 · mock-up v3 (v2 base + calmer v3 layer at the end) */
:root {
  --navy: #0a0e27; --navy-2: #161a3f; --purple: #8b5cf6; --action: #7c3aed; --action-hover: #6d28d9;
  --tint: #f5f3ff; --surface: #f8fafc; --text: #0f172a; --muted: #475569; --border: #e2e8f0; --white: #fff;
  --ok: #15803d; --ok-bg: #f0fdf4; --warn: #92400e; --warn-bg: #fffbeb; --err: #b91c1c; --err-bg: #fef2f2;
  --grass-1: #3aa04b; --grass-2: #33924a;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.07);
  --font-head: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-label: 'Syne', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --shirt: 46px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); color: var(--text); background: var(--surface); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
a { color: var(--action); }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); font-weight: 400; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; border-radius: 6px; }
.topbar :focus-visible, .summary :focus-visible, .pitch :focus-visible { outline-color: #fde047; }
.skip-link { position: absolute; left: 12px; top: -80px; background: var(--action); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 100; text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 8px; }

/* ---------- Top bar ---------- */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 18px; padding: 8px 18px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; font-family: var(--font-head); font-weight: 800; }
.brand-ball { width: 32px; height: 32px; }
.tb-meta { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.tb-title { font-size: 1.05rem; font-weight: 700; color: #e9e5ff; letter-spacing: -.01em; }
.tb-up { color: rgba(255,255,255,.8); font-size: .8rem; font-weight: 600; text-decoration: none; white-space: nowrap; background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer; }
#intercomOpen { display: none; }
@media (max-width: 1023px) { #intercomOpen { display: inline-flex; align-items: center; } }
.tb-up:hover { color: #fff; text-decoration: underline; }
.tb-data { color: #a5b4fc; font-size: .78rem; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.tag-sample { background: #fbbf24; color: var(--navy); }
.tb-actions { margin-left: auto; display: flex; gap: 6px; }
.tb-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 11px; border-radius: 9px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: #fff; font-weight: 600; font-size: .85rem; cursor: pointer; }
.tb-btn:hover { background: rgba(255,255,255,.14); }
.tb-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tb-btn-primary { background: var(--action); border-color: var(--action); }
.tb-btn-primary:hover { background: var(--action-hover); }
.lbl-short { display: none; }
@media (max-width: 1023px) { .lbl-long { display: none; } .lbl-short { display: inline; } }
.mock-badge { font-family: var(--font-label); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: #fbbf24; color: var(--navy); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

/* ---------- Summary strip ---------- */
.summary { background: linear-gradient(180deg, var(--navy) 0%, #1b1446 100%); color: #fff; display: flex; align-items: stretch; gap: 10px; padding: 0 18px 12px; }
.sum-points { background: linear-gradient(135deg, #a78bfa 0%, var(--action) 60%, #5b21b6 100%); border-radius: 14px; padding: 8px 18px; display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 10px; align-items: baseline; box-shadow: 0 6px 18px rgba(124,58,237,.35); min-width: 220px; }
.sum-points strong { font-family: var(--font-head); font-size: 2.2rem; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; grid-row: 1 / 3; grid-column: 2; align-self: center; }
.sum-points .sum-lbl { color: #ede9fe; grid-column: 1; }
.sum-points .sum-sub { color: #ddd6fe; grid-column: 1; font-size: .7rem; max-width: 120px; }
.sum-item { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 7px 14px; display: grid; align-content: center; min-width: 130px; }
.sum-lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #c4b5fd; font-weight: 700; }
.sum-item strong { font-family: var(--font-head); font-size: 1.25rem; line-height: 1.15; }
.sum-sub { font-size: .74rem; color: #cbd5e1; }
.minibar { display: block; height: 6px; border-radius: 999px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: 4px; }
.minibar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a78bfa, #22d3ee); border-radius: 999px; transition: width .25s; }
#sumBudgetBox.over strong { color: #fca5a5; } #sumBudgetBox.over .minibar span { background: #ef4444; }
#sumNationBox.bad { background: rgba(239,68,68,.18); border-color: rgba(248,113,113,.6); } #sumNationBox.bad strong { color: #fecaca; }
#sumNationBox.full strong { color: #fde68a; }
.sum-deadline { margin-left: auto; }
.model-switch { border: 0; margin: 0; padding: 0; align-self: center; }
.model-switch legend { font-size: .68rem; font-weight: 700; color: #c4b5fd; text-transform: uppercase; letter-spacing: .08em; padding: 0; margin-bottom: 3px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.summary .seg { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.06); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { min-width: 40px; min-height: 38px; display: grid; place-items: center; font-weight: 700; cursor: pointer; color: #cbd5e1; border-right: 1px solid rgba(255,255,255,.15); }
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: var(--action); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid #fde047; outline-offset: -3px; }
.seg-buttons button { min-height: 36px; padding: 4px 14px; border: 0; border-right: 1px solid var(--border); background: #fff; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg-buttons button:last-child { border-right: 0; }
.seg-buttons button[aria-pressed="true"] { background: var(--navy); color: #fff; }

/* ---------- Buttons / fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 9px 15px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; line-height: 1.2; text-decoration: none; }
.btn-sm { min-height: 36px; padding: 5px 12px; font-size: .85rem; }
.btn-primary { background: var(--action); color: #fff; } .btn-primary:hover { background: var(--action-hover); }
.btn-secondary { background: var(--tint); color: var(--action-hover); border-color: #ddd6fe; } .btn-secondary:hover { background: #ede9fe; }
.btn-ghost { background: #fff; color: var(--muted); border-color: var(--border); } .btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.icon-btn { border: 1px solid var(--border); background: #fff; border-radius: 9px; width: 40px; height: 40px; cursor: pointer; font-size: 1rem; flex: none; }
.icon-btn:hover { background: var(--surface); }
.field { display: grid; gap: 3px; margin: 0 0 10px; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend, .picker-filters label { font-weight: 600; font-size: .8rem; padding: 0; }
input[type="text"], input[type="search"], input[type="number"], select { min-height: 40px; border: 1px solid #cbd5e1; border-radius: 9px; padding: 6px 10px; background: #fff; width: 100%; }
input:hover, select:hover { border-color: #94a3b8; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 20px; height: 20px; accent-color: var(--action); margin: 0; }
.check label { font-weight: 500; font-size: .88rem; }
.budget-input-row { display: grid; grid-template-columns: 1fr 84px; gap: 10px; align-items: center; }
input[type="range"] { accent-color: var(--action); width: 100%; height: 28px; }
.help { color: var(--muted); font-size: .8rem; margin: 6px 0 0; }
.mini-title { font-family: var(--font-body); font-size: .82rem; font-weight: 700; margin: 12px 0 6px; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; font-size: .72rem; background: var(--tint); color: var(--action); border-radius: 999px; padding: 0 6px; }

/* ---------- Nation chip / status / badges ---------- */
.nat { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
.flag { width: 16px; height: 11px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(15,23,42,.18); flex: none; display: inline-block; overflow: hidden; background: #fff; vertical-align: middle; }
.code-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 22px; padding: 0 5px; border-radius: 5px; font-size: .68rem; font-weight: 800; letter-spacing: .04em; color: #fff; }
.cc-ENG { background: #fff; color: #c8102e; box-shadow: inset 0 0 0 1.5px #c8102e; } .cc-FRA { background: #1d2b5a; } .cc-IRE { background: #0b7a3e; }
.cc-ITA { background: #1f6fd1; } .cc-SCO { background: #1b2a5a; box-shadow: inset 0 -3px 0 #fff; } .cc-WAL { background: #c8102e; }
.status { display: inline-block; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.status-start { background: var(--ok-bg); color: var(--ok); } .status-bench { background: var(--tint); color: var(--action-hover); }
.status-out { background: #f1f5f9; color: var(--muted); } .status-unknown { background: var(--warn-bg); color: var(--warn); }
.noprice { display: inline-block; font-style: italic; font-size: .7rem; font-weight: 700; color: var(--warn); background: var(--warn-bg); border: 1px dashed #f59e0b; padding: 0 5px; border-radius: 6px; white-space: nowrap; }
.diff { display: inline-block; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.diff-kind { background: var(--ok-bg); color: var(--ok); } .diff-fair { background: #f1f5f9; color: var(--muted); } .diff-tough { background: var(--err-bg); color: var(--err); }

/* ---------- Shirts ---------- */
.shirt { display: block; width: var(--shirt); height: var(--shirt); overflow: visible; filter: drop-shadow(0 1px 1.5px rgba(15,23,42,.35)); }
.pc-shirt .shirt { filter: none; }
.kit-ENG { --kit-body: #ffffff; --kit-sleeve: #ffffff; --kit-collar: #1b2a6b; --kit-trim: #c8102e; --kit-cuff: #1b2a6b; --kit-hem: #c8102e; --kit-panel: #f1f3f8; --kit-stroke: #1b2a6b; }
.kit-FRA { --kit-body: #1f3478; --kit-sleeve: #1f3478; --kit-collar: #ffffff; --kit-trim: #e1251b; --kit-cuff: #e1251b; --kit-hem: #e1251b; --kit-panel: #27408c; --kit-stroke: #0b1230; --kit-ring: #e1251b; }
.kit-IRE { --kit-body: #0b7a3e; --kit-sleeve: #0b7a3e; --kit-collar: #075c2e; --kit-trim: #ffffff; --kit-cuff: #075c2e; --kit-hem: #075c2e; --kit-panel: #0e8a47; --kit-stroke: #04381c; }
.kit-ITA { --kit-body: #1f6fd1; --kit-sleeve: #1f6fd1; --kit-collar: #ffffff; --kit-trim: #ffffff; --kit-cuff: #0f4fa3; --kit-hem: #0f4fa3; --kit-panel: #2a7ce0; --kit-stroke: #0a3577; }
.kit-SCO { --kit-body: #111b3d; --kit-sleeve: #111b3d; --kit-collar: #ffffff; --kit-yoke: #ffffff; --kit-trim: #ffffff; --kit-cuff: #ffffff; --kit-hem: #8b7cc8; --kit-panel: #17224a; --kit-stroke: #060b1f; --kit-ring: #ffffff; }
.kit-WAL { --kit-body: #c8102e; --kit-sleeve: #c8102e; --kit-collar: #ffffff; --kit-trim: #ffffff; --kit-cuff: #ffffff; --kit-hem: #a50d26; --kit-panel: #d81a39; --kit-stroke: #5c0714; }
.shirt-mini { --shirt: 26px; }

/* ---------- App shell ---------- */
.app { display: grid; gap: 12px; padding: 12px; }
.mobile-only { display: none !important; }

/* ---------- Picker ---------- */
.picker { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.picker-head { padding: 12px 12px 6px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.picker-head h2 { font-size: 1.05rem; }
.picker-target { margin: 0; background: var(--tint); border: 1px solid #c4b5fd; color: var(--action-hover); border-radius: 9px; padding: 6px 8px 6px 10px; font-size: .82rem; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.picker-target button { border: 0; background: #fff; border-radius: 7px; min-height: 30px; padding: 2px 9px; font-weight: 700; color: var(--action-hover); cursor: pointer; font-size: .78rem; }
.picker-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.picker-filters select { min-height: 36px; padding: 4px 8px; }
.picker-more { margin: 0; font-size: .75rem; color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 4px 8px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.picker-more button { border: 0; background: none; color: var(--action-hover); font-weight: 700; cursor: pointer; font-size: .75rem; min-height: 28px; }
.picker-count { margin: 0; font-size: .75rem; color: var(--muted); }
.picker-cols, .prow { display: grid; grid-template-columns: 28px minmax(0, 1fr) 26px 46px 36px 34px; gap: 6px; align-items: center; }
.picker-cols { padding: 6px 12px; font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--border); background: var(--surface); }
.picker-cols span:nth-child(n+4) { text-align: right; }
.picker-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.prow { padding: 5px 12px; border-bottom: 1px solid #f1f5f9; font-size: .84rem; min-height: 44px; }
.prow:hover { background: #fbfaff; }
.prow.in-team { background: var(--tint); }
.prow .pn { min-width: 0; }
.prow .pn button { border: 0; background: none; padding: 0; font-weight: 700; cursor: pointer; text-align: left; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.2; display: block; color: var(--text); font-size: .84rem; }
.prow .pn button:hover { color: var(--action-hover); text-decoration: underline; }
.prow .pn small { display: block; font-size: .68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .ps { font-size: .7rem; font-weight: 700; color: var(--muted); }
.prow .pp, .prow .px { text-align: right; font-variant-numeric: tabular-nums; }
.prow .px { font-weight: 800; }
.add-btn { width: 32px; height: 32px; border-radius: 999px; border: 0; background: var(--action); color: #fff; font-size: 1.15rem; font-weight: 700; cursor: pointer; display: grid; place-items: center; justify-self: end; }
.add-btn:hover { background: var(--action-hover); }
.add-btn[data-state="in"] { background: #fff; color: var(--action-hover); box-shadow: inset 0 0 0 1.5px #c4b5fd; font-size: .9rem; }
.add-btn[aria-disabled="true"] { background: #e2e8f0; color: #64748b; cursor: not-allowed; }
.picker-foot { padding: 8px 12px; border-top: 1px solid var(--border); }
.picker-empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- Stage ---------- */
.stage { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 8px; }
.stage-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.stale-note { margin: 0; background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; border-radius: 9px; padding: 6px 10px; font-size: .8rem; }
.pitch-view { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 8px; }

/* Rugby pitch */
.pitch { position: relative; border-radius: 16px; overflow: hidden; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px; box-shadow: var(--shadow);
  background: repeating-linear-gradient(115deg, rgba(255,255,255,.035) 0 14px, transparent 14px 28px), linear-gradient(135deg, #0a0e27 0%, #1e1b4b 45%, #4c1d95 75%, #7c3aed 100%); }
.pitch-surface { position: absolute; inset: 10px 12px; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 2px rgba(255,255,255,.12), 0 6px 20px rgba(0,0,0,.35); background: repeating-linear-gradient(180deg, var(--grass-1) 0, var(--grass-1) 4.1666%, var(--grass-2) 4.1666%, var(--grass-2) 8.3333%); }
.pitch-surface::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 60% at 50% 0%, rgba(255,255,255,.12), transparent 60%), linear-gradient(90deg, rgba(0,0,0,.14), transparent 12%, transparent 88%, rgba(0,0,0,.14)); }
.pitch-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.pitch-lines .ln { stroke: rgba(255,255,255,.85); stroke-width: 2; fill: none; vector-effect: non-scaling-stroke; }
.pitch-lines .ln-try { stroke-width: 3; }
.pitch-lines .ln-half { stroke-width: 2.5; }
.pitch-lines .ln-dash { stroke-dasharray: 10 8; }
.pitch-lines .ln-faint { stroke: rgba(255,255,255,.4); stroke-width: 1.5; }
.pitch-lines .ln-post { stroke: #fff; stroke-width: 3; }
.pitch-lines .ingoal { fill: rgba(0,0,0,.10); }
.pitch-mark { position: absolute; left: 1.2%; font-family: var(--font-head); font-weight: 800; color: rgba(255,255,255,.55); font-size: .7rem; transform: translateY(-50%); }
.pm-22t { top: 26.5%; } .pm-10t { top: 41.6%; } .pm-half { top: 50%; } .pm-10b { top: 58.4%; } .pm-22b { top: 73.5%; }
.pitch-rows { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: space-around; padding: 10px 8px; min-height: 0; }
.prow-pitch { display: flex; justify-content: center; gap: clamp(6px, 2.2%, 22px); }
.pcard-wrap { position: relative; width: clamp(84px, 13vw, 124px); }
.pcard { width: 100%; border: 0; padding: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; color: var(--text); border-radius: 8px; }
.pcard .pc-shirt { display: block; filter: drop-shadow(0 0 1px rgba(255,255,255,.5)) drop-shadow(0 3px 4px rgba(0,0,0,.38)); margin-bottom: 1px; transition: transform .15s; }
.pcard:hover .pc-shirt { transform: translateY(-2px); }
.pc-label { display: flex; flex-direction: column; align-items: center; max-width: 100%; min-width: 72%; background: rgba(10,14,39,.85); color: #fff; border-radius: 6px; padding: 2px 7px 3px; box-shadow: 0 2px 6px rgba(10,14,39,.35); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.pc-name { display: flex; align-items: baseline; justify-content: center; gap: 4px; max-width: 100%; font-weight: 700; font-size: .76rem; line-height: 1.25; white-space: nowrap; }
.pc-sur { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pc-code { flex: none; font-size: .58rem; font-weight: 700; letter-spacing: .06em; color: #a5b4fc; }
.pc-stat { display: block; max-width: 100%; color: #cbd5e1; font-size: .68rem; font-weight: 500; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.pc-stat b { color: #fff; font-weight: 700; }
.pcard.violation .pc-label { background: rgba(185,28,28,.92); box-shadow: 0 0 0 2px #fecaca, 0 2px 6px rgba(10,14,39,.35); }
.pcard.violation .pc-code, .pcard.violation .pc-stat { color: #fee2e2; }
.pcard.empty .pc-label { background: rgba(10,14,39,.55); }
.pcard.empty .pc-name { font-weight: 600; color: #e2e8f0; }
.pcard.empty .pc-stat { color: #c4b5fd; }
.pcard.empty.targeted .pc-label { background: #fde047; }
.pcard.empty.targeted .pc-name, .pcard.empty.targeted .pc-stat { color: var(--navy); }
.pcard.empty.targeted .pc-shirt { filter: drop-shadow(0 0 8px #fde047); }
.pcard.empty.targeted .shirt-empty { --pulse: 1; }
.pcard-wrap.targeted::before { content: ''; position: absolute; inset: -6px -4px; border-radius: 12px; box-shadow: 0 0 0 3px #fde047, 0 0 22px rgba(253,224,71,.6); pointer-events: none; }
.badge-c, .badge-ss, .badge-lock { position: absolute; top: 0; height: 20px; min-width: 20px; padding: 0 5px; border-radius: 999px; font-size: .66rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff; pointer-events: none; }
.badge-c { left: calc(50% - var(--shirt) / 2 - 14px); background: var(--navy); color: #fff; }
.badge-ss { right: calc(50% - var(--shirt) / 2 - 14px); background: #fbbf24; color: var(--navy); }
.badge-lock { right: calc(50% - var(--shirt) / 2 - 14px); background: var(--action); color: #fff; }
.badge-lock svg { width: 11px; height: 11px; fill: none; stroke: #fff; stroke-width: 2.5; }
.pc-remove { position: absolute; top: -4px; right: -2px; width: 24px; height: 24px; border-radius: 999px; border: 0; background: #fff; color: var(--err); font-size: .7rem; font-weight: 800; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.3); opacity: 0; }
.pcard-wrap:hover .pc-remove, .pcard-wrap:focus-within .pc-remove { opacity: 1; }

/* Bench / Super Sub */
.bench { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, #0a0e27 0%, #2e1065 60%, #6d28d9 100%); color: #fff; border-radius: 14px; padding: 8px 14px; --shirt: 40px; box-shadow: var(--shadow); }
.bench-label { font-family: var(--font-head); font-weight: 800; font-size: .9rem; color: #fff; }
.bench-label small { display: block; font-family: var(--font-body); font-weight: 500; color: #c4b5fd; font-size: .72rem; max-width: 170px; }
.bench .pcard-wrap { width: 118px; }
.bench-cap { margin-left: auto; text-align: right; font-size: .8rem; color: #c4b5fd; }
.bench-cap strong { display: block; color: #fff; font-size: .9rem; }

/* Pills (mobile Forwards / Backs focus) */
.pills { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 10px 10px 4px; }
.pills-bottom { padding: 4px 10px 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 3px 10px 3px 6px; border-radius: 999px; border: 0; background: rgba(255,255,255,.92); color: var(--navy); font-weight: 700; font-size: .74rem; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.25); max-width: 112px; }
.pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill .dot { width: 14px; height: 14px; border-radius: 999px; flex: none; background: var(--kit-body); box-shadow: inset 0 0 0 2.5px var(--kit-ring, var(--kit-collar)), 0 0 0 1px rgba(15,23,42,.35); }
.pill.empty { background: rgba(255,255,255,.35); color: #fff; border: 1.5px dashed rgba(255,255,255,.8); box-shadow: none; font-weight: 600; }
.pill.empty .dot { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.9); }
.pill.cap { box-shadow: 0 0 0 2px var(--navy), 0 1px 3px rgba(0,0,0,.25); }
.pills-label { width: 100%; text-align: center; font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.8); font-weight: 700; }

/* ---------- List view (FPL-style) ---------- */
.list-view { position: relative; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; flex: 1; min-height: 0; }
.lv-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.lv-table thead th { position: sticky; top: 0; background: #fff; z-index: 1; font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: right; padding: 8px 10px; border-bottom: 2px solid var(--border); }
.lv-table thead th:first-child { text-align: left; }
.lv-group th { text-align: left; font-family: var(--font-head); font-size: .95rem; padding: 12px 12px 6px; background: var(--surface); color: var(--navy); border-bottom: 1px solid var(--border); }
.lv-table td { padding: 6px 10px; border-bottom: 1px solid #eef2f7; text-align: right; font-variant-numeric: tabular-nums; }
.lv-table td:first-child { text-align: left; }
.lv-player { display: flex; align-items: center; gap: 10px; --shirt: 32px; }
.lv-player button.p-name { font-size: .9rem; }
.lv-player small { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .72rem; }
.lv-role { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 999px; font-size: .64rem; font-weight: 800; padding: 0 5px; margin-left: 4px; }
.lv-role.c { background: var(--navy); color: #fff; } .lv-role.ss { background: #fbbf24; color: var(--navy); }
.lv-empty-btn { border: 1.5px dashed #c4b5fd; background: var(--tint); color: var(--action-hover); border-radius: 8px; min-height: 36px; padding: 4px 12px; font-weight: 700; cursor: pointer; }
.row-x { border: 1px solid var(--border); background: #fff; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; color: var(--err); font-weight: 800; }
.p-name { border: 0; background: none; padding: 0; text-align: left; font-weight: 700; cursor: pointer; color: var(--text); text-decoration: underline; text-decoration-color: #ddd6fe; text-underline-offset: 3px; }
.p-name:hover { color: var(--action-hover); text-decoration-color: var(--action); }

/* ---------- Rail ---------- */
.rail { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tabs { display: grid; grid-template-columns: 1fr 1fr 1.25fr; background: var(--surface); border-bottom: 1px solid var(--border); padding: 4px; gap: 2px; }
.tabs [role="tab"] { min-height: 38px; border: 0; background: transparent; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--muted); font-size: .8rem; position: relative; }
.tabs [role="tab"][aria-selected="true"] { background: #fff; color: var(--action-hover); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.tab-dot { position: absolute; top: 6px; right: 8px; width: 8px; height: 8px; border-radius: 999px; background: var(--err); }
.rail-body { padding: 12px; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rule { display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; font-size: .82rem; padding: 7px 9px; border-radius: 9px; }
.rule .ico { width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; font-size: .7rem; font-weight: 800; color: #fff; }
.rule-ok { background: var(--ok-bg); } .rule-ok .ico { background: var(--ok); }
.rule-warn { background: var(--warn-bg); color: #78350f; } .rule-warn .ico { background: #d97706; }
.rule-err { background: var(--err-bg); color: #7f1d1d; } .rule-err .ico { background: var(--err); }
.rule-info { background: var(--surface); color: var(--muted); } .rule-info .ico { background: #94a3b8; }
.nation-counts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.nation-counts li { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 3px 7px; font-size: .8rem; }
.nation-counts li.full { border-color: #fcd34d; background: var(--warn-bg); }
.nation-counts li.over { border-color: #fca5a5; background: var(--err-bg); color: var(--err); font-weight: 700; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.chips .none { color: var(--muted); font-size: .8rem; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 1px 3px 1px 9px; font-size: .8rem; }
.chip button { border: 0; background: transparent; width: 28px; height: 28px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.chip.lock { border-color: #ddd6fe; background: var(--tint); } .chip.ban { border-color: #fecaca; background: var(--err-bg); }
.auto-result { margin-top: 10px; font-size: .84rem; }
.auto-result .ok { background: var(--tint); border: 1px solid #ddd6fe; border-radius: 9px; padding: 8px 10px; }
.auto-result .bad { background: var(--err-bg); border: 1px solid #fecaca; color: var(--err); border-radius: 9px; padding: 8px 10px; }
.suggest { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.suggest li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 9px; padding: 5px 6px 5px 6px; font-size: .82rem; --shirt: 26px; }
.suggest .s-name { font-weight: 700; display: block; }
.suggest .s-meta { color: var(--muted); font-size: .72rem; display: block; }
.suggest .btn { min-height: 32px; padding: 4px 10px; font-size: .78rem; }
.suggest .current { border-color: #c4b5fd; background: var(--tint); }
.suggest .none { color: var(--muted); border-style: dashed; display: block; padding: 8px; }
.share-field { margin-top: 10px; }

/* ---------- Full-screen stats table ---------- */
dialog.stats { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--surface); color: var(--text); }
dialog.stats[open] { display: flex; flex-direction: column; }
dialog.stats::backdrop { background: var(--navy); }
.stats-head { background: #fff; border-bottom: 1px solid var(--border); padding: 10px 16px 6px; flex: none; }
.stats-titlebar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stats-titlebar h2 { font-size: 1.2rem; }
.stats-team { margin: 0; font-size: .82rem; color: var(--muted); }
.stats-status { margin: 0 0 0 auto; font-size: .8rem; color: var(--action-hover); font-weight: 600; min-height: 1em; }
.stats-filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr) 1.3fr auto auto; gap: 10px; align-items: end; margin-top: 8px; }
.stats-filters .field { margin: 0; }
.stats-filters .f-tbc { align-self: center; margin-top: 18px; }
.price-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; color: var(--muted); font-size: .8rem; }
.stats-count { margin: 6px 0 0; font-size: .78rem; color: var(--muted); }
.stats-scroll { position: relative; flex: 1; overflow: auto; min-height: 0; overscroll-behavior: contain; background: #fff; }
.stats-table { border-collapse: separate; border-spacing: 0; font-size: .84rem; min-width: 100%; }
.stats-table th, .stats-table td { padding: 7px 10px; border-bottom: 1px solid #eef2f7; background: #fff; white-space: nowrap; text-align: left; }
.stats-table thead th { position: sticky; top: 0; z-index: 2; background: #f8fafc; font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--border); vertical-align: bottom; }
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-table .sticky-col { position: sticky; left: 0; z-index: 1; min-width: 170px; max-width: 210px; white-space: normal; box-shadow: 6px 0 8px -6px rgba(15,23,42,.25); border-right: 1px solid var(--border); }
.stats-table thead .sticky-col { z-index: 3; }
.stats-table tbody th { font-weight: 400; }
.stats-table tr.in-team th, .stats-table tr.in-team td { background: #faf8ff; }
.stats-table tr.banned th, .stats-table tr.banned td { color: #94a3b8; }
.stats-table tr.current th, .stats-table tr.current td { background: var(--tint); }
.stats-table .cur-model { color: var(--action-hover); font-weight: 800; }
.th-btn { border: 0; background: none; padding: 2px 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; font-weight: 700; text-align: inherit; }
.th-btn::after { content: ' ↕'; color: #cbd5e1; }
th[aria-sort="ascending"] .th-btn::after { content: ' ↑'; color: var(--action); }
th[aria-sort="descending"] .th-btn::after { content: ' ↓'; color: var(--action); }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--action-hover) !important; }
.st-player { display: flex; align-items: center; gap: 8px; --shirt: 26px; }
.st-player small { display: flex; gap: 5px; align-items: center; margin-top: 1px; }
.actions { display: flex; gap: 5px; }
.act { min-height: 32px; min-width: 44px; padding: 3px 9px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: .76rem; font-weight: 700; color: var(--text); }
.act:hover { border-color: var(--purple); }
.act-add { background: var(--action); color: #fff; border-color: var(--action); }
.act-add[data-state="in"] { background: #fff; color: var(--action-hover); border-color: #c4b5fd; }
.act[aria-pressed="true"].act-lock { background: var(--tint); color: var(--action-hover); border-color: var(--action); }
.act[aria-pressed="true"].act-ban { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.act[aria-disabled="true"], .act[disabled] { opacity: .45; cursor: not-allowed; }
#statsEmpty { text-align: center; padding: 40px 16px; color: var(--muted); }
#statsEmpty h3 { color: var(--text); margin-bottom: 4px; }

/* ---------- Bottom sheet (mobile) ---------- */
html.sheet-open, html.sheet-open body { overflow: hidden; }
dialog.sheet { position: fixed; inset: auto 0 0 0; margin: 0; padding: 0; border: 0; width: 100%; max-width: 100%; max-height: 72vh; max-height: 72dvh; border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(10,14,39,.35); color: var(--text); background: #fff; overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet::backdrop { background: rgba(10,14,39,.45); }
dialog.sheet.expanded { max-height: 100vh; max-height: 100dvh; height: 100vh; height: 100dvh; border-radius: 0; }
.sheet-head { padding: 8px 14px 6px; border-bottom: 1px solid var(--border); flex: none; background: linear-gradient(180deg, var(--tint), #fff); }
.sheet-grab { display: block; width: 44px; height: 5px; border-radius: 999px; background: #c4b5fd; margin: 0 auto 8px; }
.sheet.expanded .sheet-grab { display: none; }
.sheet-titlebar { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sheet-titlebar h2 { font-size: 1.15rem; }
.sheet-sub { margin: 2px 0 0; font-size: .78rem; color: var(--muted); }
.sheet-btns { display: flex; gap: 6px; flex: none; }
.sheet-controls { display: grid; grid-template-columns: 1fr 104px; gap: 8px; margin-top: 8px; }
.sheet-count { margin: 6px 0 0; font-size: .75rem; color: var(--muted); }
.sheet-scroll { position: relative; flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-list .prow { grid-template-columns: 34px minmax(0, 1fr) 46px 40px 76px; padding: 6px 14px; --shirt: 30px; }
.sheet-pick { min-height: 34px; padding: 3px 10px; border-radius: 8px; border: 1px solid var(--action); background: var(--action); color: #fff; font-weight: 700; font-size: .76rem; cursor: pointer; justify-self: end; }
.sheet-pick[disabled] { background: #fff; color: var(--muted); border-color: var(--border); cursor: default; }
.prow.current { background: var(--tint); }

/* ---------- Dialogs ---------- */
dialog.dialog { border: 0; padding: 0; border-radius: 18px; width: min(600px, calc(100vw - 20px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(10,14,39,.45); color: var(--text); }
dialog.dialog::backdrop { background: rgba(10,14,39,.6); }
.dialog-body { padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.d-hero { display: flex; gap: 14px; align-items: center; --shirt: 64px; }
.d-hero .pc-shirt { filter: drop-shadow(0 3px 5px rgba(0,0,0,.25)); }
.dialog-head h2 { font-size: 1.35rem; }
.d-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: .84rem; color: var(--muted); }
.d-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 12px 0; }
.d-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 9px; }
.d-stat span { display: block; font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.d-stat strong { font-family: var(--font-head); font-size: 1.15rem; }
.d-section { margin-top: 12px; }
.d-section h3 { font-size: .92rem; margin-bottom: 6px; font-family: var(--font-body); font-weight: 700; }
.explain { width: 100%; border-collapse: collapse; font-size: .84rem; }
.explain td { padding: 5px 4px; border-bottom: 1px solid var(--border); }
.explain td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.explain tr.total td { border-bottom: 0; font-weight: 800; font-size: .98rem; color: var(--action-hover); }
.explain .why { display: block; color: var(--muted); font-size: .74rem; font-weight: 400; }
.model-bars { display: grid; gap: 5px; }
.mbar { display: grid; grid-template-columns: 96px 1fr 48px; gap: 8px; align-items: center; font-size: .84rem; }
.mbar label { font-weight: 700; display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.mbar input { accent-color: var(--action); width: 18px; height: 18px; margin: 0; }
.mbar .track { height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.mbar .fill { display: block; height: 100%; background: #c4b5fd; border-radius: 999px; }
.mbar.current .fill { background: var(--action); }
.mbar .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.d-note { font-size: .76rem; color: var(--muted); margin: 8px 0 0; }
.checklist { padding-left: 0; list-style: none; display: grid; gap: 5px; margin: 12px 0; }
.checklist li { display: grid; grid-template-columns: 24px 26px 1fr auto; gap: 9px; align-items: center; border: 1px solid var(--border); border-radius: 9px; padding: 6px 9px; font-size: .86rem; --shirt: 26px; }
.checklist input { width: 20px; height: 20px; accent-color: var(--action); }
.checklist .grp { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; display: block; }
.checklist li:has(input:checked) { background: var(--ok-bg); }
.checklist li:has(input:checked) .who { text-decoration: line-through; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(150%); background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(10,14,39,.35); max-width: min(560px, calc(100vw - 24px)); font-size: .88rem; transition: transform .25s, visibility .25s; z-index: 50; visibility: hidden; }
.toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.toast.err { background: var(--err); }
.footer { padding: 10px 18px 24px; color: var(--muted); font-size: .76rem; }

/* ---------- Desktop: one view, no page scroll (>= 1024px) ---------- */
@media (min-width: 1024px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .app { flex: 1; min-height: 0; grid-template-columns: clamp(318px, 24vw, 350px) minmax(0, 1fr) clamp(262px, 21vw, 310px); padding: 10px 12px 12px; gap: 10px; grid-template-rows: minmax(0, 1fr); }
  .footer { display: none; }
  .picker, .rail, .stage { min-height: 0; }
  .pitch-rows { container-type: size; }
  .pitch-rows { padding: 4px 8px; }
  .pitch-rows .pcard-wrap { --shirt: clamp(30px, calc(100cqh / 6 - 42px), 66px); width: clamp(88px, calc(100cqw / 3 - 26px), 128px); }
  .summary { padding-bottom: 10px; }
  .sum-points { padding: 6px 16px; }
  .sum-points strong { font-size: 2rem; }
  .bench { padding: 4px 14px; --shirt: 34px; }
}
@media (min-width: 1024px) and (max-width: 1320px) {
  .tb-btn span { display: none; }
  .tb-btn-primary .lbl-long { display: inline; }
  .tb-data { display: none; }
  .sum-points { min-width: 190px; }
  .sum-item { min-width: 112px; padding: 6px 10px; }
}

/* ---------- Tablet + mobile (< 1024px) ---------- */
@media (max-width: 1023px) {
  .mobile-only { display: inline-flex !important; }
  .picker { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .tb-actions { order: 3; width: 100%; margin: 0; display: grid; grid-template-columns: 1fr 1fr 1fr 2.2fr; gap: 6px; }
  .tb-btn { justify-content: center; padding: 6px 8px; font-size: .8rem; }
  .tb-btn-primary span { white-space: nowrap; }
  .tb-data { display: none; }
  .summary { flex-wrap: wrap; padding: 0 12px 12px; gap: 8px; }
  .sum-points { flex: 1 1 100%; min-width: 0; grid-template-columns: auto 1fr; }
  .sum-points strong { justify-self: end; }
  .sum-item { flex: 1 1 calc(33% - 8px); min-width: 0; }
  .sum-deadline { margin-left: 0; flex: 1 1 0; min-width: 0; }
  .model-switch { flex: none; }
  .model-switch .seg label { min-width: 34px; }
  .app { grid-template-columns: 1fr; padding: 10px; }
  .stage-bar { gap: 6px; }
  .stage-actions { margin-left: 0; width: 100%; }
  .pitch { min-height: 560px; }
  .pitch-rows { gap: 12px; padding: 14px 6px; justify-content: space-between; }
  .pcard-wrap { width: calc((100vw - 64px) / 3); max-width: 124px; --shirt: 46px; }
  .pc-remove { display: none; }
  .bench { flex-wrap: wrap; }
  .rail { max-height: none; }
  .rail-body { overflow: visible; }
  .stats-filters { grid-template-columns: 1fr 1fr; }
  .stats-filters .f-search, .stats-filters .f-price { grid-column: 1 / -1; }
  .stats-titlebar h2 { font-size: 1.05rem; }
  .stats-status { width: 100%; margin: 0; }
  .d-grid { grid-template-columns: repeat(2, 1fr); }
  dialog.dialog { width: calc(100vw - 14px); }
  .dialog-body { padding: 14px; }
  /* focus views: big cards for the chosen half */
  .pitch.focus-forwards, .pitch.focus-backs { min-height: 470px; }
  .pitch.focus-forwards .pitch-rows, .pitch.focus-backs .pitch-rows { justify-content: space-evenly; }
  .pitch.focus-forwards .pcard-wrap, .pitch.focus-backs .pcard-wrap { --shirt: 64px; max-width: 128px; }
  .pitch.focus-forwards .pc-name, .pitch.focus-backs .pc-name { font-size: .82rem; }
  .pitch.focus-forwards .pc-stat, .pitch.focus-backs .pc-stat { font-size: .72rem; }
}
@media (max-width: 420px) {
  .sum-points strong { font-size: 1.9rem; }
  .sum-item strong { font-size: 1.05rem; }
  .seg-buttons button { padding: 4px 10px; font-size: .82rem; }
  .stage-bar .seg-buttons { flex: 1 1 auto; }
  #focusSeg { width: 100%; } #focusSeg button { flex: 1; }
  .stage-actions .btn-sm { flex: 1 1 auto; padding: 5px 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* detail dialog: explanation and model comparison side by side on wide screens so it fits 1280x800 */
#detail { width: min(860px, calc(100vw - 20px)); }
.d-cols { display: grid; gap: 0 22px; }
@media (min-width: 900px) {
  .d-cols { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
  #detail .dialog-body { padding: 16px 20px; }
  #detail .d-grid { margin: 10px 0 4px; }
  #detail .explain td { padding: 4px 4px; }
  #detail .mbar { grid-template-columns: 88px 1fr 40px; }
}

/* =====================================================================
   v3 layer: calmer header, one Share menu, fixture pills, captain line,
   Super Sub slot, simpler picker/table/detail
   ===================================================================== */
/* slim top bar */
.topbar { gap: 12px; padding: 6px 16px; min-height: 46px; }
.brand-ball { width: 28px; height: 28px; }
.brand-name { font-size: .95rem; }
.tb-sep { width: 1px; height: 20px; background: rgba(255,255,255,.2); }
.tb-title { font-size: 1rem; font-weight: 700; color: #e9e5ff; }
.share-wrap { position: relative; margin-left: auto; }
.tb-btn .caret { font-size: .7rem; opacity: .8; }
.share-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; list-style: none; margin: 0; padding: 6px; background: #fff; color: var(--text); border-radius: 12px; box-shadow: 0 14px 40px rgba(10,14,39,.3); min-width: 250px; }
.share-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.share-menu button:hover, .share-menu button:focus-visible { background: var(--tint); outline: none; }
.share-menu strong { display: block; font-size: .88rem; }
.share-menu small { display: block; font-size: .74rem; color: var(--muted); }

/* compact stats strip */
.strip { background: var(--navy-2); color: #fff; display: flex; align-items: center; gap: 4px 22px; padding: 6px 16px; border-top: 1px solid rgba(255,255,255,.06); }
.strip :focus-visible { outline-color: #fde047; }
.st { display: flex; flex-direction: column; justify-content: center; position: relative; }
.st-row { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.st-val { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.st-val-big { font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.st-lbl { font-size: .74rem; color: #c4b5fd; font-weight: 600; white-space: nowrap; }
.st-xp-btn { display: flex; align-items: baseline; gap: 8px; background: none; border: 0; color: #fff; padding: 2px 4px; margin: -2px -4px; border-radius: 8px; cursor: pointer; }
.st-xp-btn:hover { background: rgba(255,255,255,.07); }
.st-xp-btn .info { margin-left: 4px; color: #a78bfa; font-size: .8rem; }
.xp-pop { position: absolute; left: 0; top: calc(100% + 8px); z-index: 40; background: #fff; color: var(--text); border-radius: 12px; box-shadow: 0 14px 40px rgba(10,14,39,.3); padding: 10px 12px; min-width: 240px; font-size: .84rem; }
.xp-pop table { width: 100%; border-collapse: collapse; }
.xp-pop td { padding: 3px 0; } .xp-pop td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.xp-pop tr.total td { border-top: 1px solid var(--border); padding-top: 6px; font-weight: 800; color: var(--action-hover); }
.minibar { display: block; width: 92px; height: 4px; background: rgba(255,255,255,.15); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.minibar span { display: block; height: 100%; background: #a78bfa; border-radius: 999px; }
.st-budget.over .st-val { color: #fca5a5; } .st-budget.over .minibar span { background: #f87171; }
.st-deadline { margin-left: auto; }
.st-deadline .st-lbl { color: #cbd5e1; }
.st-deadline .st-val { font-size: .95rem; }
.st-chips { display: flex; gap: 6px; }
.st-chips:empty { display: none; }
.nchip { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: #fef3c7; color: #78350f; white-space: nowrap; }
.nchip.bad { background: #fee2e2; color: #991b1b; }
.nchip .flag { width: 14px; height: 10px; }

/* footnote: a slim single line on desktop too */
.footer { padding: 4px 16px 6px; font-size: .7rem; color: #64748b; }

/* fixture pill: v FRA, colour = difficulty (meaning in aria-label/title) */
.fx { display: inline-flex; align-items: center; gap: 3px; font-size: .7rem; font-weight: 800; padding: 2px 7px; border-radius: 999px; white-space: nowrap; letter-spacing: .02em; line-height: 1.35; }
.fx .flag { width: 14px; height: 10px; }
.fx-kind { background: #dcfce7; color: #166534; box-shadow: inset 0 0 0 1px #86efac; }
.fx-tough { background: #fee2e2; color: #991b1b; box-shadow: inset 0 0 0 1px #fca5a5; }
.fx-fair { background: #f1f5f9; color: #475569; box-shadow: inset 0 0 0 1px #cbd5e1; }
.fx-none { color: #94a3b8; }
.nd { color: #94a3b8; }

/* below the pitch: Captain line + Super Sub slot, clearly separate */
.below-pitch { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 10px; margin-top: 8px; }
.captain-line { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-left: 4px solid #f59e0b; border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow); font-size: .9rem; min-width: 0; }
.cl-badge { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #f59e0b; color: var(--navy); font-weight: 800; display: grid; place-items: center; font-family: var(--font-head); }
.cl-badge.empty { background: #fef3c7; color: #b45309; border: 1px dashed #f59e0b; }
.cl-text { min-width: 0; flex: 1; line-height: 1.25; }
.cl-lbl { color: var(--muted); font-weight: 600; }
.cl-mult { color: #b45309; font-weight: 700; white-space: nowrap; }
.cl-xp { display: block; font-size: .74rem; color: var(--muted); }
.cl-change { flex: none; border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 5px 10px; font-weight: 700; font-size: .78rem; cursor: pointer; min-height: 32px; }
.cl-change:hover { border-color: var(--purple); color: var(--action-hover); }
.cl-change[disabled] { opacity: .5; cursor: not-allowed; }
.bench { margin-top: 0; }
.bench-label { display: flex; align-items: center; gap: 9px; }
.bench-label small { max-width: 150px; }
.bench-tag { flex: none; background: #fbbf24; color: var(--navy); border-radius: 7px; font-size: .7rem; font-weight: 800; padding: 3px 6px; font-family: var(--font-body); }
.bench .pcard-wrap { margin-left: auto; }

/* compact picker: shirt | name | pos | fixture | price | xP | + */
.picker-cols, .prow { grid-template-columns: 26px minmax(0, 1fr) 22px 48px 40px 34px 30px; gap: 5px; }
.prow .pf { justify-self: start; }
.sheet-list .prow { grid-template-columns: 32px minmax(0, 1fr) 50px 42px 38px 74px; gap: 6px; }

/* stats table: 2027 columns are quiet until rounds exist */
.stats-table th.y27, .stats-table td.y27 { background: #fcfcfe; }
.stats-table thead th.y27 { color: #94a3b8; }
.stats-filters { grid-template-columns: 2fr 1fr 1fr auto; max-width: 860px; }

/* detail panel (v3) */
#detail { width: min(640px, calc(100vw - 20px)); }
#detail .dialog-body { padding: 16px 20px; }
.d-grid { grid-template-columns: repeat(4, 1fr); margin: 12px 0 4px; }
.d-stat strong { font-size: 1.3rem; display: block; }
.d-stat em { font-style: normal; font-size: .66rem; color: #94a3b8; }
.d-season { margin: 2px 0 8px; font-size: .74rem; color: var(--muted); }
.d-minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.d-mini { border: 1px solid var(--border); border-radius: 9px; padding: 5px 8px; }
.d-mini span { display: block; font-size: .62rem; color: var(--muted); font-weight: 600; line-height: 1.2; }
.d-mini strong { font-size: .98rem; font-variant-numeric: tabular-nums; }
.chart { display: block; width: 100%; height: auto; max-height: 190px; }
.ch-grid { stroke: #e2e8f0; stroke-width: 1; } .ch-zero { stroke: #cbd5e1; }
.ch-ax { font-size: 11px; fill: #64748b; font-family: var(--font-body); }
.ch-dnp { fill: #94a3b8; }
.ch-ax-up { fill: var(--action-hover); font-weight: 700; }
.ch-line { fill: none; stroke: var(--action); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { fill: var(--action); stroke: #fff; stroke-width: 2; }
.ch-val { font-size: 11px; font-weight: 700; fill: #1e1b4b; font-family: var(--font-body); }
.ch-val-up { fill: var(--action-hover); }
.ch-up { fill: #fff; stroke: var(--action); stroke-width: 2; stroke-dasharray: 3 2; }
.ch-up-line { stroke: var(--action); stroke-width: 2; stroke-dasharray: 5 4; opacity: .7; }
.ch-gap { font-size: 10px; fill: #94a3b8; font-style: italic; font-family: var(--font-body); }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }

@media (min-width: 1024px) {
  .footer { display: block; flex: none; }
  .app { padding: 8px 12px 4px; }
  .below-pitch { flex: none; }
}
@media (max-width: 1023px) {
  .topbar { flex-wrap: nowrap; gap: 10px; padding: 6px 12px; }
  .brand-name { display: none; }
  .tb-sep { display: none; }
  .tb-btn span:not(.caret) { display: inline; }
  .strip { flex-wrap: nowrap; overflow-x: auto; gap: 14px; padding: 6px 12px; scrollbar-width: none; }
  .strip::-webkit-scrollbar { display: none; }
  .st-val-big { font-size: 1.3rem; }
  .st-xp-btn .info { display: none; }
  .minibar { width: 56px; height: 3px; margin-top: 2px; }
  .st-deadline { margin-left: 0; }
  .st-deadline .st-val { font-size: .9rem; }
  .st-lbl { font-size: .7rem; }
  .xp-pop { position: fixed; left: 10px; right: 10px; top: auto; min-width: 0; }
  .below-pitch { grid-template-columns: 1fr; }
  .d-minis { grid-template-columns: repeat(3, 1fr); }
  .d-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-filters { grid-template-columns: 1fr 1fr; }
}
.xp-pop strong { display: block; margin-bottom: 4px; color: var(--action-hover); } .xp-pop span { display: block; color: var(--muted); }
.strip { position: relative; }
.tb-deadline { display: none; }
.nchip-m { display: none; }
@media (max-width: 1023px) {
  .tb-deadline { display: inline; margin-left: auto; font-size: .78rem; font-weight: 700; color: #c4b5fd; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .share-wrap { margin-left: 0; }
  .strip .st-deadline { display: none; }
  .strip { gap: 16px; }
  .st-chips .nchip { display: none; }
  .st-chips .nchip-m { display: inline-flex; margin-left: auto; padding: 3px 8px; }
  .st-chips { margin-left: auto; }
  #sumPicked + .st-lbl { display: none; }
}
/* captain line + Super Sub: one line each, calmer type */
.captain-line { white-space: nowrap; }
.cl-text { overflow: hidden; text-overflow: ellipsis; }
.cl-xp { display: inline; margin-left: 6px; }
.bench-label { font-size: .88rem; }
.bench-label small { max-width: 210px; font-size: .72rem; }
.d-stat span { text-transform: none; letter-spacing: 0; font-size: .72rem; }
@media (max-width: 1023px) {
  .strip { gap: 12px; padding: 6px 10px; }
  .st-val-big { font-size: 1.2rem; }
  .st-xp-btn { gap: 4px; }
  .st-val { font-size: .95rem; }
  .nchip-m { font-size: .7rem; }
}
.cl-xp { display: none; }
@media (min-width: 1024px) { .below-pitch { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.sheet-pick { white-space: nowrap; }
@media (max-width: 1023px) {
  .captain-line { white-space: normal; }
  .cl-text { overflow: visible; }
}

/* status lifecycle */
.status-tbc { background: #f1f5f9; color: #475569; box-shadow: inset 0 0 0 1px #cbd5e1; }
.st-hint { margin-left: 4px; padding: 0 4px; border-radius: 4px; background: rgba(15,23,42,.08); font-size: .62rem; font-weight: 700; color: inherit; opacity: .85; }
.auto-note { margin: 6px 0 0; font-size: .76rem; color: var(--muted); }

/* provisional xP (TBC players: from last-round status) */
.xp-prov { font-style: italic; color: #64748b; font-weight: 600; white-space: nowrap; }
.prov-tag { display: inline-block; margin-left: 4px; font-size: .58rem; font-style: normal; font-weight: 700; letter-spacing: .02em; color: #6d28d9; background: #f5f3ff; border: 1px dashed #c4b5fd; border-radius: 4px; padding: 0 3px; vertical-align: 1px; }
.prow .px .xp-prov { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.prow .px .prov-tag { margin: 1px 0 0; font-size: .5rem; padding: 0 2px; }
.pc-stat b.xp-prov { color: #cbd5e1; font-style: italic; }
.noprice { font-size: .66rem; color: var(--muted); background: #f8fafc; border: 1px dashed #cbd5e1; }
.prow .pp .noprice { white-space: normal; font-size: .55rem; line-height: 1.05; padding: 1px 2px; text-align: center; max-width: 100%; }
.prow .pp { min-width: 0; }

/* Phone and tablet. Desktop (1024 and up) flattens these wrappers so the
   header and the stats strip stay on their own rows, exactly as before. */
@media (min-width: 1024px) {
  .mast, .tb-heading, .tb-links { display: contents; }
  .mast-break { display: none; }
}

/* Narrow screens: one compact title row, then links that wrap inside the bar.
   Nothing in the header uses the viewport width, so the page itself does not
   scroll sideways. */
@media (max-width: 1023px) {
  html, body { max-width: 100%; }
  .mast {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 6px;
    row-gap: 2px;
    max-width: 100%;
    background: var(--navy);
    color: #fff;
    padding: 8px 10px 8px;
  }
  .topbar, .strip, .tb-links { display: contents; }
  .brand { order: 1; flex: none; }
  .tb-heading {
    order: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    gap: 1px;
  }
  .tb-heading .tb-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tb-heading .tb-kicker { font-size: .62rem; line-height: 1.15; white-space: normal; letter-spacing: .04em; }
  .st-budget { order: 3; flex: none; align-items: flex-end; }
  .st:has(#sumPicked) { order: 4; flex: none; }
  .mast-break { order: 5; display: block; flex: 0 0 100%; width: 0; height: 0; overflow: hidden; }
  .st-xp { order: 6; flex: none; }
  .tb-up { order: 7; }
  .tb-rules { order: 8; }
  .tb-deadline { order: 9; margin-left: 0; }
  .share-wrap { order: 10; flex: none; margin-left: auto; }
  .mobile-only[hidden] { display: none !important; }
  .st-chips { order: 11; flex: 1 1 100%; min-width: 0; margin-left: 0; }
  .st-chips:empty { display: none; }
  .mast .tb-up, .mast .tb-rules, .mast .tb-deadline {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    margin-left: 0;
    flex: none;
    white-space: nowrap;
  }
  .mast .st-val-big { font-size: 1.05rem; }
  .mast .st-xp-btn { gap: 4px; min-height: 32px; }
  .mast .minibar { width: 100%; max-width: 72px; }

  .app { min-width: 0; max-width: 100%; padding: 8px; }
  .stage, .pitch-view, .rail, .below-pitch, .list-view { min-width: 0; max-width: 100%; }
  .stage-bar { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 0; max-width: 100%; }
  .stage-bar .seg { display: flex; width: 100%; max-width: 100%; min-width: 0; }
  .stage-bar .seg-buttons button { flex: 1 1 0; min-width: 0; padding: 6px 4px; text-align: center; }
  .stage-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    width: 100%;
    max-width: 100%;
    margin: 0;
    gap: 6px;
  }
  .stage-actions .btn { width: 100%; min-width: 0; }

  .pitch { width: 100%; max-width: 100%; min-height: 520px; padding: 6px; }
  .pitch-surface { inset: 6px; }
  .pitch-rows { width: 100%; min-width: 0; padding: 8px 2px; gap: 4px; }
  .prow-pitch { width: 100%; min-width: 0; justify-content: center; gap: 4px; }
  .pitch-rows .pcard-wrap { flex: 1 1 0; width: auto; min-width: 0; max-width: 148px; }
  .pitch-rows .pcard, .pitch-rows .pc-label, .pitch-rows .pc-name, .pitch-rows .pc-stat { min-width: 0; max-width: 100%; }
  .pitch-rows .pc-label { width: 100%; padding: 2px 3px 3px; }
  .pitch-rows .pc-name { font-size: .74rem; }
  .pitch-rows .pc-stat { font-size: .64rem; }
  .pitch.focus-forwards .pcard-wrap, .pitch.focus-backs .pcard-wrap { max-width: 160px; }

  .below-pitch { width: 100%; min-width: 0; }
  .captain-line { max-width: 100%; min-width: 0; flex-wrap: wrap; gap: 6px 8px; white-space: normal; }
  .cl-text { flex: 1 1 8rem; min-width: 0; overflow: hidden; }
  .cl-mult { white-space: normal; }
  .bench { max-width: 100%; min-width: 0; flex-wrap: nowrap; gap: 8px; padding: 8px 10px; }
  .bench-label { flex: 1 1 auto; min-width: 0; }
  .bench-label small { max-width: none; white-space: normal; }
  .bench .pcard-wrap { flex: 0 0 auto; width: 92px; max-width: 38%; margin-left: 0; }

  .list-view { overflow: auto; }
  .lv-table { width: 100%; table-layout: fixed; font-size: .78rem; }
  .lv-table thead th { letter-spacing: 0; font-size: .62rem; white-space: nowrap; }
  .lv-table th:nth-child(2), .lv-table td:nth-child(2) { width: 64px; }
  .lv-table th:nth-child(3), .lv-table td:nth-child(3) { width: 48px; }
  .lv-table th:nth-child(4), .lv-table td:nth-child(4) { width: 42px; }
  .lv-table th:nth-child(5), .lv-table td:nth-child(5) { width: 32px; }
  .lv-table th, .lv-table td { padding: 6px 4px; }
  .lv-group th { white-space: normal; font-size: .82rem; }
  .lv-player { gap: 6px; --shirt: 26px; min-width: 0; }
  .lv-player button.p-name { font-size: .82rem; overflow-wrap: anywhere; }
  .p-name { overflow-wrap: anywhere; }

  .tabs { min-width: 0; }
  .tabs [role="tab"] { font-size: .72rem; padding: 6px 2px; min-width: 0; }
  .rail-body { min-width: 0; }

  dialog.stats { width: 100%; max-width: 100%; }
  .stats-head, .stats-titlebar, .stats-filters { min-width: 0; max-width: 100%; }
  .stats-titlebar h2 { font-size: 1.02rem; min-width: 0; }
  .stats-scroll { max-width: 100%; }
  dialog.sheet { width: 100%; max-width: 100%; left: 0; right: 0; }
  .sheet-head, .sheet-titlebar { min-width: 0; }
  .sheet-titlebar h2 { font-size: 1.02rem; }
  .sheet-sub { overflow-wrap: anywhere; }
  .sheet-controls { grid-template-columns: minmax(0, 1fr) 5.6rem; }
  .sheet-list .prow { grid-template-columns: 26px minmax(0, 1fr) auto auto auto auto; gap: 4px; padding: 6px 8px; }
  .sheet-pick { padding: 4px 7px; font-size: .72rem; }
  dialog.dialog { width: calc(100% - 16px); max-width: calc(100% - 16px); }
  .footer { padding-left: 10px; padding-right: 10px; overflow-wrap: break-word; }
}

.boot { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #0a0e27; color: #fff; font-family: "DM Sans", system-ui, sans-serif; text-align: center; padding: 24px; }
.boot[hidden] { display: none; }
.boot strong { font-family: Syne, system-ui, sans-serif; font-size: 1.35rem; }
.boot p { margin: 0; max-width: 36rem; color: #cbd5e1; }
.boot-error { background: #0a0e27; }
