:root {
  color-scheme: light;
  --ink: #17231e;
  --muted: #64736c;
  --surface: #ffffff;
  --surface-2: #f2f6f3;
  --line: #d6dfda;
  --brand: #123c2d;
  --brand-2: #1d6248;
  --accent: #e7b64b;
  --blue: #2467c7;
  --red: #c53d3d;
  --shadow: 0 14px 36px rgba(18, 60, 45, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eaf0ec;
}
button, select, input { font: inherit; }
button, select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
}
button { padding: 0.7rem 0.9rem; cursor: pointer; font-weight: 700; }
button:hover { border-color: var(--brand-2); }
button:focus-visible, select:focus-visible, input:focus-visible, .pitch:focus-visible { outline: 3px solid rgba(231, 182, 75, 0.7); outline-offset: 2px; }
button.primary { background: var(--brand); color: white; border-color: var(--brand); }
button.active { background: var(--brand); color: white; border-color: var(--brand); }
select { width: 100%; padding: 0.7rem; }
label { display: block; margin: 0.75rem 0 0.35rem; font-size: 0.86rem; font-weight: 700; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding: 1.1rem clamp(1rem, 3vw, 2.5rem);
  background: var(--brand);
  color: white;
}
h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.15rem); }
.subtitle { margin: 0.25rem 0 0; color: #cae0d5; }
.eyebrow { margin: 0 0 0.3rem; font-size: 0.72rem; letter-spacing: 0.14em; font-weight: 800; color: var(--accent); }
.mode-switch { display: flex; background: rgba(255,255,255,0.12); padding: 0.3rem; border-radius: 12px; }
.mode-btn { background: transparent; border-color: transparent; color: white; white-space: nowrap; }
.mode-btn.active { background: white; color: var(--brand); }

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr) minmax(250px, 320px);
  gap: 1rem;
  padding: 1rem;
  max-width: 1700px;
  margin: 0 auto;
}
.panel, .stage-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.panel { padding: 1rem; }
.panel section + section { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
h2, h3 { margin: 0 0 0.55rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { line-height: 1.5; }
.muted { color: var(--muted); font-size: 0.87rem; }
.hidden { display: none !important; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.button-grid.single { grid-template-columns: 1fr; }
.toggle-row { display: flex; align-items: center; gap: 0.55rem; font-weight: 600; }
.toggle-row input { width: 1rem; height: 1rem; accent-color: var(--brand); }

.stage-panel { padding: 0.8rem; min-width: 0; }
.stage-toolbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 0.25rem 0.2rem 0.8rem; }
.stage-toolbar strong { display: block; }
#stageStatus { color: var(--muted); font-size: 0.82rem; }
.time-readout { font-variant-numeric: tabular-nums; font-weight: 800; }
.pitch {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  max-height: 72vh;
  margin: auto;
  overflow: hidden;
  border: 5px solid #f8fff9;
  border-radius: 12px;
  background-color: #3c9257;
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 12.5%, rgba(0,0,0,0.025) 12.5% 25%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
  touch-action: none;
}
.pitch-markings > * { position: absolute; pointer-events: none; border-color: rgba(255,255,255,.78); }
.halfway-line { top: 50%; left: 0; width: 100%; border-top: 2px solid rgba(255,255,255,.78); }
.centre-circle { left: 35%; top: 40%; width: 30%; aspect-ratio: 1; border: 2px solid rgba(255,255,255,.78); border-radius: 50%; }
.penalty { left: 22%; width: 56%; height: 17%; border: 2px solid rgba(255,255,255,.78); }
.penalty.top { top: -2px; }
.penalty.bottom { bottom: -2px; }
.goal { left: 39%; width: 22%; height: 3%; border: 2px solid rgba(255,255,255,.78); }
.goal.top { top: -1px; transform: translateY(-55%); }
.goal.bottom { bottom: -1px; transform: translateY(55%); }
.overlay, .entities { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.entities { z-index: 2; }
.player, .ball {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0,0,0,.32);
  transition: opacity .2s, filter .2s;
  user-select: none;
}
.player {
  width: clamp(32px, 5.5vw, 48px);
  height: clamp(32px, 5.5vw, 48px);
  border: 3px solid white;
  color: white;
  font-size: clamp(0.68rem, 1.3vw, 0.85rem);
  font-weight: 900;
  pointer-events: auto;
  cursor: grab;
}
.player:active { cursor: grabbing; }
.player.blue { background: var(--blue); }
.player.red { background: var(--red); }
.player.goalkeeper { outline: 3px solid var(--accent); outline-offset: 1px; }
.player.selected { box-shadow: 0 0 0 6px rgba(231,182,75,.8), 0 3px 8px rgba(0,0,0,.32); z-index: 4; }
.player.dimmed { opacity: .26; filter: grayscale(.7); }
.ball { width: 18px; height: 18px; background: radial-gradient(circle at 35% 30%, #fff 0 25%, #222 26% 40%, #fff 41% 68%, #222 69%); border: 2px solid white; z-index: 5; }
.player-label { position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%); background: rgba(17,35,27,.86); color: white; border-radius: 5px; padding: 2px 5px; font-size: 0.62rem; white-space: nowrap; }
.timeline { width: 100%; margin-top: 0.85rem; accent-color: var(--brand); }
.path { fill: none; stroke-width: .55; stroke-dasharray: 2 1.2; opacity: .8; }
.path.blue { stroke: #d8e7ff; }
.path.red { stroke: #ffd8d8; }
.lane { stroke: #ffe28a; stroke-width: .8; stroke-dasharray: 1.3 1.3; opacity: .85; }
.danger { fill: rgba(218, 48, 48, .28); stroke: rgba(255, 220, 220, .9); stroke-width: .45; }

.why-card, .outcome-card { padding: 0.9rem; border-radius: 12px; }
.why-card { background: #edf5f1; }
.outcome-card { background: #fff7e6; }
ol { margin: 0; padding-left: 1.3rem; }
li { margin: 0.5rem 0; line-height: 1.4; }
footer { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 1.2rem 1rem; color: var(--muted); font-size: 0.8rem; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 220px 1fr; }
  .teaching-panel { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .app-header { align-items: flex-start; flex-direction: column; gap: 0.8rem; }
  .workspace { display: flex; flex-direction: column; }
  .stage-panel { order: -1; }
  .pitch { max-height: none; }
  footer { flex-direction: column; }
}
