: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; }
[hidden] { display: none !important; }
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; }
select { width: 100%; box-sizing: border-box; border: 1px solid #71907e; background: #10251b; color: white; border-radius: 7px; padding: .65rem .8rem; font: inherit; }
select: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; }
.match-choice-actions { display: grid; grid-template-columns: 1fr; gap: .75rem; margin: 1rem 0; }
.match-choice-actions button { width: 100%; }
.sound-guide-panel { width: min(880px, 100%); }
.sound-guide-panel h3 { margin: 1.35rem 0 .45rem; color: var(--focus); }
.sound-guide-panel section > p { color: var(--muted); }
.sound-guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin: .75rem 0; }
.sound-guide-grid button { width: 100%; }
.sound-guide-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1rem; }
#match-sound-guide-status { min-height: 1.5em; margin: 1rem 0 0; color: var(--muted); }
.realtime-match { position: fixed; inset: 0; z-index: 50; overflow: auto; padding: clamp(.75rem, 2vw, 1.5rem); background: #06100b; }
.realtime-match[hidden] { display: none; }
.realtime-match.live-modal-open { overflow: hidden; }
.realtime-match > .dialog-backdrop { z-index: 100; }
.realtime-hud { display: flex; justify-content: space-between; align-items: start; gap: 1rem; max-width: 1180px; margin: 0 auto .6rem; }
.realtime-hud h2, .realtime-hud p { margin-bottom: .25rem; }
#realtime-match-status, .realtime-help { max-width: 1180px; margin: .5rem auto; color: var(--muted); }
.realtime-viewport { position: relative; width: min(1180px, 100%); height: min(64vh, 620px); margin: auto; overflow: hidden; border: 3px solid #eafff1; border-radius: 14px; background: #123e27; outline: none; }
.realtime-viewport:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.realtime-pitch { position: absolute; inset-block: 0; left: 0; width: 2800px; background: linear-gradient(180deg, #1b613a, #174d31); transform-origin: left center; will-change: transform; }
.realtime-pitch::after { content: ""; position: absolute; inset: 12px; border: 3px solid rgba(255,255,255,.88); pointer-events: none; }
.realtime-halfway { position: absolute; left: 50%; top: 12px; bottom: 12px; width: 3px; background: rgba(255,255,255,.85); }
.realtime-center-circle { position: absolute; left: 50%; top: 50%; width: 150px; height: 150px; border: 3px solid rgba(255,255,255,.85); border-radius: 50%; transform: translate(-50%,-50%); }
.realtime-box { position: absolute; top: 25%; width: 260px; height: 50%; border: 3px solid rgba(255,255,255,.85); }
.realtime-box.own { left: 12px; border-left: 0; } .realtime-box.rival { right: 12px; border-right: 0; }
.realtime-goal { position: absolute; top: 39%; width: 44px; height: 22%; display: grid; place-items: center; overflow: hidden; border: 4px double #dce8e2; color: transparent; }
.realtime-goal.own { left: -32px; } .realtime-goal.rival { right: -32px; }
.realtime-match[data-orientation="vertical"] .realtime-pitch { inset-block: auto; top: 0; left: 0; width: 100%; height: 2800px; transform-origin: center top; }
.realtime-match[data-orientation="vertical"] .realtime-halfway { left: 12px; right: 12px; top: 50%; bottom: auto; width: auto; height: 3px; }
.realtime-match[data-orientation="vertical"] .realtime-box { left: 25%; width: 50%; height: 260px; }
.realtime-match[data-orientation="vertical"] .realtime-box.own { top: auto; bottom: 12px; border: 3px solid rgba(255,255,255,.85); border-bottom: 0; }
.realtime-match[data-orientation="vertical"] .realtime-box.rival { top: 12px; right: auto; border: 3px solid rgba(255,255,255,.85); border-top: 0; }
.realtime-match[data-orientation="vertical"] .realtime-goal { left: 39%; top: auto; width: 22%; height: 44px; }
.realtime-match[data-orientation="vertical"] .realtime-goal.own { bottom: -32px; }
.realtime-match[data-orientation="vertical"] .realtime-goal.rival { top: -32px; right: auto; }
.live-player, .live-ball { position: absolute; translate: -50% -50%; border-radius: 50%; will-change: left, top; }
.live-player { width: 38px; height: 38px; display: grid; place-items: center; border: 3px solid white; font-size: 12px; font-weight: 900; box-shadow: 0 4px 12px #0008; }
.live-player.user { width: 44px; height: 44px; background: #ffe66d; color: #102016; border-color: #fff; }
.live-player.ally { background: #0878d2; } .live-player.enemy { background: #c82c3b; }
.live-ball { width: 28px; height: 28px; display: grid; place-items: center; background: white; border: 3px solid #111; color: #111; z-index: 4; box-shadow: 0 3px 9px #000b; font-size: 19px; }
body.realtime-active > header, body.realtime-active > main { visibility: hidden; }
.realtime-controls { width: min(1180px, 100%); margin: .75rem auto; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.realtime-controls button { text-align: center; touch-action: manipulation; }
@media (max-width: 760px) { .realtime-controls { grid-template-columns: repeat(2, 1fr); } .realtime-hud { align-items: stretch; flex-direction: column; } .realtime-viewport { height: 52vh; } }
@media (max-width: 620px) { .sound-guide-grid { grid-template-columns: 1fr; } }
.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; }
.welcome-statistics { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.welcome-statistics h2 { margin: 0 0 .75rem; font-size: 1.35rem; }
.welcome-statistics p { margin-bottom: .35rem; }
.home-player-statistics { margin-bottom: 2rem; }
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%; }
.lineup-slot-list { display: grid; gap: .75rem; margin: 1rem 0; }
.lineup-slot-field { display: grid; gap: .3rem; }
.lineup-slot-field label { color: var(--focus); font-weight: 800; }
.position-filter-list { display: flex; flex-wrap: wrap; gap: .45rem; margin: .65rem 0; }
.position-filter-list button { flex: 1 1 130px; }
.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; } }
