:root {
  --bg: #0f172a;
  --card: #111c33;
  --line: #24324f;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --blue: #3b82f6;
  --red: #ef4444;
  --gold: #facc15;
  --green: #22c55e;
  --amber: #f59e0b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; }
.brand span { color: var(--muted); font-size: 14px; margin-left: 6px; }
.stats { display: flex; gap: 22px; }
.stats div { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: center; }
.stats span { display: block; color: var(--text); font-size: 20px; font-weight: 700; letter-spacing: 0; }

main {
  display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px;
  padding: 18px 20px; max-width: 1600px; margin: 0 auto;
}
@media (max-width: 1050px) { main { grid-template-columns: 1fr; } }

.pitch-wrap { position: relative; width: 100%; border-radius: 10px; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
canvas { display: block; width: 100%; margin: 0 auto; touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, .82); color: #fff; padding: 6px 14px; border-radius: 999px;
  font-weight: 600; font-size: 14px; pointer-events: none; white-space: nowrap;
}
.banner.ok { background: rgba(22, 101, 52, .92); }
.banner.bad { background: rgba(153, 27, 27, .92); }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.controls label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.controls .spacer { flex: 1; }

button, select {
  font: inherit; color: var(--text); background: #1e293b; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: #3b4d72; background: #243250; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
button.primary:hover { background: #2563eb; }
button.big { font-size: 17px; padding: 11px 22px; margin: 6px 0 10px; }
button.ghost { background: transparent; color: var(--muted); }
select { padding: 5px 8px; }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto;
}
.panel h2 { font-size: 20px; line-height: 1.3; margin: 6px 0 8px; }
.panel h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; text-transform: none; letter-spacing: 0; }
.blue { color: #60a5fa; }
kbd { background: #1e293b; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; }
.how { padding-left: 20px; }
.how li { margin: 6px 0; }

.phase { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #93c5fd; background: rgba(59,130,246,.15); padding: 3px 9px; border-radius: 999px; }
.phase.q { color: #fde68a; background: rgba(250,204,21,.15); }
.teams { line-height: 1.9; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.home { background: #2563eb; } .dot.away { background: #dc2626; }

.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.chip { display: flex; flex-direction: column; align-items: center; padding: 6px 4px; font-size: 11px; color: var(--muted); }
.chip b { font-size: 17px; color: #fff; }
.chip:hover { border-color: var(--gold) !important; }
.chip.gk b { color: #fbbf24; }
.actions { display: flex; gap: 8px; }
.action { flex: 1; padding: 10px; font-weight: 600; }
.action:hover, .move:hover { border-color: var(--gold) !important; }
.moves { display: flex; flex-direction: column; gap: 8px; }
.move { text-align: left; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.letter { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; color: #111; font-weight: 800; font-size: 13px; flex: none; }

.verdict { font-size: 22px; font-weight: 800; padding: 10px 14px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; }
.verdict span { font-size: 16px; opacity: .9; }
.v-best { background: rgba(34,197,94,.18); color: #86efac; }
.v-good { background: rgba(59,130,246,.18); color: #93c5fd; }
.v-ok { background: rgba(245,158,11,.18); color: #fcd34d; }
.v-poor { background: rgba(239,68,68,.18); color: #fca5a5; }
.you { margin: 12px 0 2px; color: var(--muted); }
.you b { color: var(--text); }
.headline { font-size: 17px; font-weight: 600; margin: 4px 0; }
.why { padding-left: 18px; margin: 0; }
.why li { margin: 5px 0; }
.why li.trade::marker { content: '⚖  '; }
.principle { margin-top: 14px; padding: 10px 12px; border-left: 3px solid var(--gold); background: rgba(250,204,21,.08); border-radius: 0 8px 8px 0; }
.principle b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); margin-bottom: 2px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

table.options { width: 100%; border-collapse: collapse; font-size: 13px; }
.options th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 4px; }
.options td { padding: 6px 4px; border-top: 1px solid var(--line); }
.options tbody tr { cursor: pointer; }
.options tbody tr:hover { background: rgba(255,255,255,.04); }
.options tr.chosen td { background: rgba(255,255,255,.05); }
.options tr.focused td { box-shadow: inset 0 0 0 9999px rgba(250,204,21,.07); }
.options em { color: var(--muted); font-style: normal; }
.rank { font-weight: 800; width: 22px; text-align: center; }
.rank.gold { color: var(--gold); }
.succ { white-space: nowrap; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.bar { width: 70px; }
.bar div { height: 7px; border-radius: 4px; background: linear-gradient(90deg, #3b82f6, #22c55e); }

.detail { margin-top: 6px; }
.notes { list-style: none; padding: 0; margin: 0; }
.notes li { display: flex; gap: 8px; margin: 5px 0; }
.notes i { font-style: normal; font-weight: 800; width: 14px; flex: none; }
.notes .good i { color: var(--green); } .notes .bad i { color: var(--red); } .notes .neutral i { color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.legend i.circle { width: 11px; height: 11px; border-radius: 50%; border: 1px dashed #fff; background: rgba(255,255,255,.1); }
.legend i.x { width: auto; height: auto; background: none; color: var(--red); font-style: normal; font-weight: 800; }

.phase.def { color: #fca5a5; background: rgba(239,68,68,.15); }
.tag { display: inline-block; margin: 6px 0 0 6px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.record { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rec { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px;
  background: #16223d; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; }
.rec span { color: var(--text); }
.rec b { font-size: 16px; grid-row: span 2; }
.rec i { font-style: normal; color: var(--muted); font-size: 11px; }
.rec.empty { opacity: .55; }

/* Side-by-side "what happens next" */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 10px; }
.compare.single { grid-template-columns: 1fr; }
.mini { margin: 0; background: #0b1324; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mini.best { border-color: rgba(250,204,21,.55); }
.mini figcaption { padding: 6px 9px 5px; font-size: 12px; font-weight: 600; line-height: 1.3; min-height: 44px; }
.mini figcaption span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini.best figcaption span { color: var(--gold); }
.mini-wrap { width: 100%; }
.mini canvas { display: block; width: 100%; margin: 0 auto; touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.outcome { font-size: 12px; font-weight: 600; padding: 6px 9px; }
.outcome.ok { color: #86efac; } .outcome.bad { color: #fca5a5; }

.breakdown { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.breakdown summary { cursor: pointer; font-weight: 600; color: #cbd5e1; list-style: none; }
.breakdown summary::before { content: '▸ '; color: var(--muted); }
.breakdown[open] summary::before { content: '▾ '; }
.toggle { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.legend i.dash { height: 0; background: none !important; border-top: 3px dashed; }
.legend i.dots { height: 0; background: none !important; border-top: 3px dotted; }

/* Possession: coloured frame around the pitch + an opening cue */
.pitch-wrap { transition: box-shadow .3s; }
.pitch-wrap.poss-home { box-shadow: 0 0 0 3px #2563eb, 0 8px 30px rgba(0,0,0,.35); }
.pitch-wrap.poss-away { box-shadow: 0 0 0 3px #dc2626, 0 8px 30px rgba(0,0,0,.35); }
.cue { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none;
  opacity: 0; padding: 14px 28px; border-radius: 14px; text-align: center; color: #fff;
  box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.cue b { display: block; font-size: 30px; line-height: 1.1; letter-spacing: .01em; }
.cue span { display: block; font-size: 15px; font-weight: 600; opacity: .9; margin-top: 4px; }
.cue.home { background: rgba(37,99,235,.92); }
.cue.away { background: rgba(220,38,38,.92); }
.cue.show { animation: cue 1.7s ease forwards; }
@keyframes cue {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.85); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.04); }
}

/* ── Phones ───────────────────────────────────────────────────────────────── */
.dock { display: none; }
.pitch-wrap { background: #2d6a37; }

@media (max-width: 699px) {
  body { font-size: 15px; }
  header { padding: 8px 12px; gap: 10px; }
  .brand { font-size: 17px; white-space: nowrap; }
  .brand span { display: none; }
  .stats { gap: 12px; }
  .stats div { font-size: 9px; }
  .stats span { font-size: 16px; }
  main { padding: 8px; gap: 10px; }
  .pitch-wrap { border-radius: 8px; }
  .banner { top: 8px; font-size: 12px; padding: 4px 11px; }
  .cue { padding: 10px 20px; }
  .cue b { font-size: 22px; }
  .cue span { font-size: 13px; }

  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .controls label { justify-content: space-between; }
  .controls label.check { grid-column: span 2; justify-content: flex-start; }
  .controls .spacer { display: none; }
  .controls select { flex: 1; min-height: 38px; }
  .controls button { min-height: 40px; }

  .panel { padding: 14px; max-height: none; border-radius: 10px; }
  .panel h2 { font-size: 17px; }
  .chips { gap: 5px; }
  .chip { padding: 8px 2px; }
  .action, .move { min-height: 46px; }
  .compare { gap: 8px; }
  .mini figcaption { min-height: 0; }
  .buttons button { flex: 1 1 auto; min-height: 44px; }
  kbd { display: none; }
}

/* Portrait phones: vertical pitch + bottom action bar */
body.portrait { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
body.portrait .dock {
  display: flex; align-items: center; gap: 8px;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11, 19, 36, .97); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0,0,0,.35);
}
.dock button { min-height: 46px; padding: 0 14px; font-weight: 600; flex: none; }
.dock button.wide { flex: 1; }
.dock-text { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dock-text small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dock-text.dv-best { color: #86efac; } .dock-text.dv-good { color: #93c5fd; }
.dock-text.dv-ok { color: #fcd34d; } .dock-text.dv-poor { color: #fca5a5; }
.letters { display: flex; gap: 6px; flex: 1; justify-content: flex-end; min-width: 0; }
.letters button { flex: 1 1 0; max-width: 48px; min-width: 34px; padding: 0; font-size: 17px; }
.dock-text.short { flex: 0 0 auto; max-width: 78px; }
body.portrait .stage { scroll-margin-top: 4px; }
body.portrait .panel { scroll-margin-top: 8px; }

/* Landscape phones / short screens: pitch and panel side by side, pitch fitted to the height */
@media (max-height: 520px) and (orientation: landscape) {
  header { padding: 6px 12px; }
  main { grid-template-columns: minmax(0, 1fr) minmax(260px, 38%); padding: 8px; gap: 10px; }
  .panel { max-height: calc(100vh - 60px); }
  .controls { display: flex; }
}
body.portrait .compare.single .mini { max-width: 240px; width: 100%; margin: 0 auto; }

/* Follow the play */
.context { margin: 10px 0 2px; padding: 8px 11px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.context.bad { background: rgba(239,68,68,.15); color: #fca5a5; }
.context.good { background: rgba(34,197,94,.14); color: #86efac; }
.trail { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; }
.dot-v { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-v.v-best { background: #22c55e; } .dot-v.v-good { background: #3b82f6; }
.dot-v.v-ok { background: #f59e0b; } .dot-v.v-poor { background: #ef4444; }
.sum-score { display: flex; align-items: baseline; gap: 10px; margin: 12px 0; }
.sum-score b { font-size: 40px; line-height: 1; }
.sum-score span { color: var(--muted); }
.sum-list { list-style: none; padding: 0; margin: 0 0 14px; }
.sum-list li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; margin-bottom: 6px; border-radius: 8px; background: #16223d; border-left: 4px solid var(--line); }
.sum-list li.s-best { border-left-color: #22c55e; } .sum-list li.s-good { border-left-color: #3b82f6; }
.sum-list li.s-ok { border-left-color: #f59e0b; } .sum-list li.s-poor { border-left-color: #ef4444; }
.sum-list .n { font-weight: 800; color: var(--muted); text-align: center; }
.sum-list small { display: block; color: var(--muted); font-size: 11px; }
.sum-list b { display: block; font-size: 14px; }
.sum-list em { display: block; font-style: normal; font-size: 12px; color: #fcd34d; }
.sum-list .pts { font-weight: 700; }

.legend i.arrowi { width: auto; height: auto; background: none; font-style: normal; color: #bfdbfe; font-weight: 800; }

.zoom-btn { position: absolute; right: 8px; bottom: 8px; z-index: 5; min-height: 34px; padding: 4px 11px;
  font-size: 13px; font-weight: 600; background: rgba(15,23,42,.85); border-color: rgba(255,255,255,.25); }
.zoom-btn[hidden] { display: none; }

.header-right { display: flex; align-items: center; gap: 14px; }
.icon-btn { font-size: 18px; line-height: 1; padding: 7px 9px; min-width: 40px; }
@media (max-width: 699px) { .header-right { gap: 8px; } .icon-btn { font-size: 16px; padding: 6px 7px; min-width: 34px; } }
