:root {
  color-scheme: dark;
  --bg: #09130f;
  --panel: #12231b;
  --line: #345443;
  --text: #f5fbf7;
  --muted: #b7cabf;
  --focus: #ffe66d;
  --blue: #4da3ff;
  --red: #ff6b6b;
  --grass-1: #184d2f;
  --grass-2: #1c5936;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at top, #173526, var(--bg) 55%); color: var(--text); font: 17px/1.5 system-ui, sans-serif; }
button, summary { font: inherit; }
.skip-link { position: absolute; left: 1rem; top: -5rem; background: var(--focus); color: #111; padding: .75rem 1rem; z-index: 10; }
.skip-link:focus { top: 1rem; }
header { display: flex; justify-content: space-between; gap: 2rem; align-items: center; padding: 1.4rem clamp(1rem, 4vw, 4rem); border-bottom: 1px solid var(--line); }
.visual-heading, p { margin-top: 0; }
.visual-heading { font-weight: 700; }
.visual-heading-1 { margin-bottom: 0; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1; }
.visual-heading-2 { margin-bottom: .83em; font-size: 1.15rem; }
.eyebrow { margin-bottom: .35rem; color: #87d4a5; text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 800; }
.scoreboard { display: grid; grid-template-columns: auto auto auto; gap: .6rem; font-size: 1.35rem; font-weight: 800; text-align: center; }
.turn-label { grid-column: 1 / -1; color: var(--focus); font-size: .85rem; }
main { max-width: 1280px; margin: auto; padding: 1.25rem; }
.panel { background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.instructions { margin-bottom: 1rem; }
.instructions p { margin-bottom: .5rem; color: var(--muted); }
summary { cursor: pointer; color: var(--focus); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; }
.status-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; }
.status-row p { margin-bottom: .65rem; }
.pitch-wrap { overflow-x: auto; padding: 0 4px 8px; }
.pitch { display: grid; grid-template-columns: repeat(14, minmax(42px, 1fr)); min-width: 660px; border: 3px solid #e8fff0; border-radius: 7px; overflow: hidden; position: relative; }
.pitch-row { display: contents; }
.cell { aspect-ratio: 1; min-width: 0; border: 1px solid rgba(255,255,255,.16); background: var(--grass-1); color: white; display: flex; align-items: center; justify-content: center; position: relative; font-weight: 900; cursor: default; }
.cell.stripe { background: var(--grass-2); }
.cell.penalty-area { background-image: linear-gradient(rgba(255,255,255,.055), rgba(255,255,255,.055)); }
.cell.goal-area { background-image: linear-gradient(rgba(255,255,255,.11), rgba(255,255,255,.11)); }
.cell.penalty-left:is([data-col="2"]), .cell.penalty-right:is([data-col="11"]) { border-inline-color: rgba(255,255,255,.82); }
.cell.penalty-area:is([data-row="2"]), .cell.penalty-area:is([data-row="7"]) { border-block-color: rgba(255,255,255,.82); }
.cell.goal-left:is([data-col="1"]), .cell.goal-right:is([data-col="12"]) { border-inline-color: white; }
.cell.goal-area:is([data-row="3"]), .cell.goal-area:is([data-row="6"]) { border-block-color: white; }
.cell.goal-mouth { box-shadow: inset 0 0 0 2px rgba(255,255,255,.9); }
.cell:focus { outline: 4px solid var(--focus); outline-offset: -5px; z-index: 2; }
.cell.valid-target::after { content: ""; position: absolute; inset: 9%; border: 3px dashed var(--focus); border-radius: 8px; }
.cell.selected { box-shadow: inset 0 0 0 5px white; }
.player { width: 72%; height: 72%; border-radius: 50%; display: grid; place-items: center; border: 3px solid white; text-shadow: 0 1px 2px #000; }
.player.blue { background: #0869c9; }
.player.red { background: #c82c3b; }
.has-ball .player::after { content: "⚽"; position: absolute; right: 2%; bottom: 0; font-size: clamp(.8rem, 2.4vw, 1.4rem); }
.legend { display: flex; gap: 1rem; margin-top: .65rem; color: var(--muted); font-size: .9rem; }
.dot { display: inline-block; width: .8rem; height: .8rem; margin-right: .3rem; border-radius: 50%; }
.dot.blue { background: var(--blue); } .dot.red { background: var(--red); } .dot.ball { background: white; }
aside { display: grid; align-content: start; gap: 1rem; }
.actions { display: grid; gap: .55rem; }
.actions h2 { margin-bottom: .25rem; }
button { border: 1px solid #71907e; background: #1a3327; color: white; border-radius: 7px; padding: .65rem .8rem; text-align: left; }
button:hover:not(:disabled) { background: #254b38; }
button:focus-visible, summary:focus-visible, .match-log:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button:disabled { opacity: .42; }
button.primary { background: #f2cf3a; color: #101b14; border-color: #fff0a3; font-weight: 900; }
input { width: 100%; box-sizing: border-box; border: 1px solid #71907e; background: #10251b; color: white; border-radius: 7px; padding: .65rem .8rem; font: inherit; }
input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
kbd { border: 1px solid currentColor; border-radius: 4px; padding: .05rem .3rem; font-size: .8em; }
.match-log { max-height: 280px; overflow: auto; padding-left: 1.6rem; margin-bottom: 0; color: var(--muted); }
.match-log li:first-child { color: white; font-weight: 700; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 1rem; background: rgba(0, 0, 0, .78); }
.dialog-backdrop[hidden] { display: none; }
.dialog-panel { width: min(620px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 2px solid var(--focus); border-radius: 12px; padding: 1.25rem; }
.home-screen { align-items: start; overflow-y: auto; }
.home-panel { width: min(560px, 100%); margin-block: clamp(1rem, 7vh, 5rem); text-align: center; }
.home-team-summary { margin: 1.25rem 0; color: var(--muted); }
.home-team-summary strong { display: block; color: var(--text); font-size: 1.3rem; }
.home-team-summary span { display: block; }
.welcome-panel { width: min(850px, 100%); }
.welcome-panel { margin-block: clamp(1rem, 5vh, 4rem); }
.welcome-panel form { display: grid; gap: .75rem; margin-bottom: 1.5rem; }
.welcome-panel input { width: 100%; max-width: 32rem; padding: .8rem; font: inherit; }
.welcome-panel form button { justify-self: start; }
.welcome-guide { border-top: 1px solid var(--border); padding-top: 1rem; }
.welcome-guide details { margin-top: .75rem; border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
.welcome-guide summary { cursor: pointer; font-size: 1.2rem; font-weight: 800; }
.welcome-guide details > div { padding-top: .5rem; }
.welcome-guide h1 { font-size: 1.6rem; }
.welcome-guide h2 { font-size: 1.35rem; }
.welcome-guide h3 { font-size: 1.15rem; }
body.welcome-active > header,
body.welcome-active > main,
body.welcome-active > .skip-link { display: none; }
body.quick-simulation-active > header,
body.quick-simulation-active > main,
body.quick-simulation-active > .skip-link,
body.quick-simulation-active > #setup-dialog { display: none; }
body.online-lobby-active > header,
body.online-lobby-active > main,
body.online-lobby-active > .skip-link { display: none; }
.home-menu { width: min(420px, 100%); margin-inline: auto; text-align: center; }
.club-menu a.primary-link { background: #f2cf3a; color: #101b14; border-color: #fff0a3; font-weight: 900; }
.club-panel { width: min(760px, 100%); }
.club-menu { display: grid; gap: .55rem; margin: 1rem 0; }
.club-menu a { display: block; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 8px; color: inherit; background: var(--panel); text-decoration: underline; }
.club-menu a:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.kicker-list { display: grid; gap: .45rem; margin: 1rem 0; }
.kicker-list button { width: 100%; }
.finance-summary { padding: .8rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; }
.finance-summary p { margin-bottom: .25rem; }
.finance-week { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.finance-transaction { display: grid; grid-template-columns: 1fr auto; gap: .75rem; margin-bottom: .45rem; }
.finance-income { color: #87d4a5; }
.finance-expense { color: #ff9b9b; }
.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; }

@media (max-width: 820px) {
  header { align-items: flex-start; }
  .game-layout { grid-template-columns: 1fr; }
  .pitch { grid-template-columns: repeat(14, minmax(38px, 1fr)); }
}
@media (max-width: 520px) {
  header { flex-direction: column; gap: 1rem; }
  .pitch { grid-template-columns: repeat(14, minmax(34px, 1fr)); }
  .player { font-size: .75rem; border-width: 2px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media (forced-colors: active) { .cell { border: 1px solid CanvasText; } .player { forced-color-adjust: none; } }
