/* Match Radar console. One stylesheet for index.html; editor/scraper pages keep styles.css. */

:root {
  color-scheme: dark;
  --bg: #0b0f0e;
  --surface: #121816;
  --surface-2: #19211e;
  --surface-3: #212b27;
  --line: #26312c;
  --line-strong: #34433c;
  --text: #e7eeea;
  --muted: #8d9c94;
  --faint: #5e6c65;
  --accent: #b7f34b;
  --accent-ink: #0b0f0e;
  --accent-soft: #b7f34b1f;
  --live: #ff5a4f;
  --warn: #f2b84b;
  --ok: #5fd68f;
  --home: #c91c28;
  --away: #522b6d;
  --shadow: 0 12px 32px #0008;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --r: 8px;
  --r-sm: 5px;
  --topbar-h: 48px;
  --statusbar-h: 28px;
  /* Height the stage keeps for everything except the pitch (score bar, transport, inspector slot). The
     inspector slot is fixed so hovering a player never changes the layout height (no scrollbar flicker). */
  --inspector-h: 158px;
  --stage-reserve: 360px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-2: #f3f6f4;
  --surface-3: #e6ebe8;
  --line: #dce3df;
  --line-strong: #c4cec8;
  --text: #121a16;
  --muted: #56655d;
  --faint: #8a978f;
  --accent: #4f7d0f;
  --accent-ink: #ffffff;
  --accent-soft: #4f7d0f1a;
  --live: #d63a2f;
  --warn: #a86b00;
  --ok: #1d8a4c;
  --shadow: 0 12px 32px #0002;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.num, time { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ── Primitives ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.btn:not(:disabled):hover { border-color: var(--muted); }
.btn-primary { border-color: transparent; background: var(--accent); color: var(--accent-ink); }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); border-color: transparent; }
.btn-live .dot { background: var(--live); }
.btn-live.is-on { border-color: var(--live); color: var(--live); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
}
.icon-btn:not(:disabled):hover { background: var(--surface-3); color: var(--text); }
.icon-btn.is-on { color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }

.field {
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  outline: none;
}
.field:focus { border-color: var(--accent); }

.dot {
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--live); }
.dot.live { background: var(--live); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--muted);
  font: 600 10px/1 var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.live { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; white-space: nowrap; }
.check input { margin: 0; accent-color: var(--accent); }

.seg { display: inline-flex; padding: 2px; border-radius: var(--r-sm); background: var(--surface-2); }
.seg button {
  height: 22px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.seg button.is-on { background: var(--surface-3); color: var(--text); }

/* Popover built on <details> */
.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  right: 0;
  width: 300px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pop-panel.up { top: auto; bottom: calc(100% + 6px); }
.pop-title { margin: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* ── Passcode gate ── */

.gate {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}
.gate-card {
  display: grid;
  gap: 10px;
  width: min(340px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.gate-card .brand { margin-bottom: 8px; }
.gate-card label { color: var(--muted); font-size: 12px; }
.gate-card .field { height: 38px; font-family: var(--mono); }
.gate-card .btn { justify-content: center; height: 38px; }
.gate-error { min-height: 1.2em; margin: 0; color: var(--live); font-size: 12px; }
.gate-card .field.shake { border-color: var(--live); animation: shake .3s; }
@keyframes shake { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }

/* ── Top bar ── */

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px 6px 6px 2px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 800 11px/1 var(--sans);
}
.match-form { display: flex; gap: 6px; }
.match-form .field { width: 170px; font-family: var(--mono); }
.stream-controls { display: flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--line); }
.topbar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 5px 8px; border-radius: var(--r-sm); color: var(--muted); font-size: 12px; text-decoration: none; }
.nav a:hover { background: var(--surface-3); color: var(--text); }

.token-pop .pop-panel { display: grid; gap: 8px; }
.token-pop p { margin: 0; color: var(--muted); font-size: 12px; }
.token-pop .field { width: 100%; font-family: var(--mono); font-size: 11px; }
.token-pop .hint { color: var(--faint); font-size: 11px; }

/* ── Console grid ── */

.console {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 360px;
  gap: 1px;
  height: calc(100dvh - var(--topbar-h) - var(--statusbar-h));
  background: var(--line);
}
.pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
}
.pane-head h2 { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pane-head .icon-btn { margin-left: auto; width: 24px; height: 24px; }
.pane-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* ── Match library ── */

.library-tools { display: grid; gap: 6px; padding: 0 12px 8px; border-bottom: 1px solid var(--line); }
.library-tools .field { width: 100%; height: 28px; }
.match-list { margin: 0; padding: 4px 0; list-style: none; }
.match-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 8px;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  border-left: 2px solid transparent;
  background: none;
  text-align: left;
}
.match-item:not(:disabled):hover { background: var(--surface-2); }
.match-item.is-active { border-left-color: var(--accent); background: var(--accent-soft); }
.match-item:disabled { opacity: .5; }
.match-item .teams { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.match-item .score { font: 600 12px var(--mono); text-align: right; }
.match-item .sub { display: flex; gap: 6px; align-items: center; overflow: hidden; color: var(--faint); font-size: 11px; white-space: nowrap; }
.match-item .sub .t { overflow: hidden; text-overflow: ellipsis; }
.match-item .flags { display: flex; gap: 3px; justify-content: flex-end; align-items: center; }
.flag { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.flag.on { background: var(--accent); }
.list-empty { padding: 16px 12px; color: var(--faint); font-size: 12px; }

/* ── Stage: scoreboard, pitch, player ── */

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow-y: auto; background: var(--bg); }

.scorebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.scorebar .team { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 700; }
.scorebar .team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scorebar .team.away { flex-direction: row-reverse; }
.kit { flex: none; width: 10px; height: 22px; border-radius: 2px; }
.kit.home { background: var(--home); }
.kit.away { background: var(--away); }
.scorebar .score { display: grid; justify-items: center; gap: 1px; }
.scorebar .score-digits { font: 700 22px/1 var(--mono); letter-spacing: .04em; }
.scorebar .score-sub { display: flex; gap: 6px; align-items: center; color: var(--muted); font: 11px var(--mono); }

.pitch-frame {
  position: relative;
  padding: 10px 14px 0;
  perspective: 1200px;
}
.pitch-wrap {
  position: relative;
  /* Keep the whole stage on screen: cap width by the height left over for the pitch. */
  width: min(100%, calc((100dvh - var(--topbar-h) - var(--statusbar-h) - var(--stage-reserve)) * 1.78));
  min-width: 280px;
  margin: 0 auto;
  border-radius: var(--r);
  overflow: hidden;
  transform-origin: 50% 90%;
  transition: transform .4s cubic-bezier(.16, 1, .3, 1);
}
.pitch-wrap.stadium-3d-view { overflow: visible; transform: rotateX(25deg) translateY(-12px) scale(.96); }
#pitch { display: block; width: 100%; aspect-ratio: 1.78; background: #101a14; }
.pitch-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  color: #c6d3cb;
  font-size: 13px;
  text-align: center;
  background: #101a14d9;
}

/* Optional WebGL scene (js/view3d). Overlays the 2D canvas, which stays in layout to keep the aspect ratio. */
.v3d { position: absolute; inset: 0; z-index: 2; background: #0c1424; overflow: hidden; }
.v3d[hidden] { display: none; }
.v3d-canvas, .v3d-labels { position: absolute; inset: 0; }
.v3d-canvas canvas { display: block; width: 100%; height: 100%; }
.v3d-labels { pointer-events: none; overflow: hidden; }
.plabel {
  position: absolute; left: 0; top: 0; padding: 1px 6px; border-radius: 9px; white-space: nowrap; will-change: transform;
  font: 600 11px/1.4 var(--mono); color: #fff; background: #0a101acc; border: 1px solid transparent;
}
.plabel.home { border-color: var(--home); }
.plabel.away { border-color: var(--away); }
.plabel.carrier { background: #ffeb3b; color: #111; border-color: #ffeb3b; z-index: 2; }
.v3d-cams { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 4px; }
.v3d-cams button {
  padding: 3px 8px; border-radius: 4px; border: 1px solid #ffffff2e; background: #0b0f0ecc; color: #dfe8e3;
  font: 11px/1.3 var(--mono); cursor: pointer;
}
.v3d-cams button.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pitch-wrap.view-3d-on .hud { z-index: 3; }

.hud { position: absolute; top: 8px; display: flex; gap: 4px; pointer-events: none; }
.hud-left { left: 8px; }
.hud-right { right: 8px; }
.hud span {
  padding: 3px 7px;
  border-radius: 4px;
  background: #0b0f0ecc;
  color: #dfe8e3;
  font: 11px/1.3 var(--mono);
  white-space: nowrap;
}
.hud b { color: #fff; font-weight: 600; }
.hud em { font-style: normal; color: #8fa39a; }
.hud em.tag-air { color: #38bdf8; }
.hud em.tag-high { color: #f59e0b; }
.pitch-wrap.stadium-3d-view .hud { display: none; }

/* Shot 3D window (always on the dark pitch, so fixed dark colours) */
.shot-win {
  position: absolute;
  z-index: 5;
  overflow: hidden;
  border: 1px solid #ffffff1f;
  border-radius: var(--r);
  background: #0b0f0ee8;
  box-shadow: var(--shadow);
  color: #dfe8e3;
  animation: shot-in .22s cubic-bezier(.16, 1, .3, 1);
}
.shot-win[hidden] { display: none; }
.shot-head { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; font: 600 12px/1.2 var(--sans); }
.shot-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-outcome { flex: none; padding: 1px 6px; border-radius: 3px; background: #f59e0b; color: #0b0f0e; font: 700 10px/1.5 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.shot-win .icon-btn { width: 26px; height: 26px; color: #8fa39a; }
.shot-win .icon-btn:hover { background: #ffffff14; color: #fff; }
#shot-canvas { display: block; width: 100%; aspect-ratio: 16 / 10; }
.shot-win.no-scene #shot-canvas { display: none; }
.shot-stats { display: flex; flex-wrap: wrap; gap: 2px 10px; min-height: 14px; padding: 5px 8px 7px; color: #8fa39a; font: 11px/1.3 var(--mono); }
.shot-stats b { color: #fff; font-weight: 600; }
@keyframes shot-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .shot-win { animation: none; } }

/* Player (transport) */
.player { padding: 8px 14px 6px; }
.player-inner { width: min(100%, calc((100dvh - var(--topbar-h) - var(--statusbar-h) - var(--stage-reserve)) * 1.78)); min-width: 280px; margin: 0 auto; }

.timeline { position: relative; height: 26px; touch-action: none; }
.timeline-track {
  position: absolute;
  top: 11px;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  transition: top .1s, height .1s;
}
.timeline:hover .timeline-track, .player.is-scrubbing .timeline-track { top: 10px; height: 6px; }
.timeline-buffered span { position: absolute; top: 0; bottom: 0; background: var(--line-strong); }
.timeline-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 2px; background: var(--accent); }
.timeline-head {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
  pointer-events: none;
}
.timeline-ticks span { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--muted); }
.timeline-pins { position: absolute; inset: 0; pointer-events: none; }
.pin {
  position: absolute;
  top: 8px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  padding: 0;
  border: 2px solid var(--bg);
  border-radius: 50%;
  pointer-events: auto;
}
.pin:hover { transform: scale(1.35); }
.pin-goal { background: var(--accent); }
.pin-yellow { border-radius: 2px; background: #facc15; }
.pin-red { border-radius: 2px; background: #ef4444; }
.pin-sub { top: 9px; width: 8px; height: 8px; margin-left: -4px; background: var(--muted); }
#timeline-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
#timeline-input:disabled { cursor: default; }
.timeline-tip {
  position: absolute;
  bottom: calc(100% + 4px);
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  font: 600 11px var(--mono);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.controls { display: flex; align-items: center; gap: 2px; height: 34px; }
.controls .play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}
.controls .play:not(:disabled):hover { background: var(--accent); filter: brightness(1.08); color: var(--accent-ink); }
.controls .play svg { width: 14px; height: 14px; }
.controls .readout { display: flex; align-items: baseline; gap: 6px; margin-left: 8px; color: var(--muted); font: 12px var(--mono); white-space: nowrap; }
.controls .readout b { color: var(--text); font-size: 14px; font-weight: 600; }
.controls .spacer { flex: 1; }
.controls select.field { height: 26px; padding: 0 4px; font: 12px var(--mono); }
.mode {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  margin-left: 6px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font: 600 10px var(--mono);
  letter-spacing: .06em;
}
.mode.is-live { border-color: var(--live); color: var(--live); }
.mode.is-live .dot { background: var(--live); animation: pulse 1.4s ease-in-out infinite; }
.player.is-buffering .readout::after { content: "buffering…"; color: var(--warn); font-size: 11px; }

.view-pop .pop-panel { display: grid; gap: 8px; width: 260px; }
.view-pop .pop-panel .check { justify-content: space-between; color: var(--text); }
.view-pop .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.view-pop .row input[type="color"] { width: 30px; height: 22px; padding: 0; border: 1px solid var(--line-strong); border-radius: 4px; background: none; }
.view-pop hr { width: 100%; margin: 2px 0; border: 0; border-top: 1px solid var(--line); }

/* Player inspector strip */
.inspector { padding: 0 14px 12px; }
.inspector-inner {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) repeat(2, minmax(0, 1fr)) auto;
  grid-template-rows: auto 1fr;
  height: var(--inspector-h); /* fixed slot: content scrolls inside instead of resizing the stage */
  align-items: center;
  gap: 1px;
  width: min(100%, calc((100dvh - var(--topbar-h) - var(--statusbar-h) - var(--stage-reserve)) * 1.78));
  min-width: 280px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--line);
  overflow-x: hidden;
  overflow-y: auto;
}
.inspector-inner > div { display: grid; gap: 1px; height: 100%; padding: 6px 10px; background: var(--surface); }
.inspector .who { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 8px; }
.inspector .jersey {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font: 700 12px var(--mono);
}
.inspector .name { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.inspector .k { color: var(--faint); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.inspector .v { font: 600 12px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inspector .v small { color: var(--muted); font-weight: 400; }
.inspector .v.text { font-family: var(--sans); }
.inspector .close { display: grid; place-items: center; padding: 0 6px; }
.meter { height: 3px; margin-top: 2px; border-radius: 2px; background: var(--surface-3); }
.meter i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.inspector-hint { grid-column: 1 / -1; grid-row: 1 / -1; place-items: center; color: var(--faint); font-size: 12px; text-align: center; }

/* ── Details pane ── */

.match-meta { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.match-meta h2 { margin: 0 0 2px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.match-meta .line { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 11px; }
.match-meta .line span { white-space: nowrap; }

.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.tab {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.tab.is-on { border-bottom-color: var(--accent); color: var(--text); }
.tab .count { margin-left: 4px; color: var(--faint); font: 11px var(--mono); }
.tab-panel { padding: 10px 12px 16px; }

.section-label { margin: 14px 0 6px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.section-label:first-child { margin-top: 0; }

/* Head-to-head stat rows */
.h2h-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-bottom: 4px; font-size: 11px; font-weight: 700; }
.h2h-head span:last-child { text-align: right; }
.h2h-head i { display: inline-block; width: 8px; height: 8px; margin: 0 5px; border-radius: 2px; vertical-align: 0; }
.stat { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 0 8px; padding: 3px 0; }
.stat .v { font: 600 12px var(--mono); }
.stat .v.away { text-align: right; }
.stat .v.lead { color: var(--text); }
.stat .v:not(.lead) { color: var(--muted); }
.stat .label { color: var(--muted); font-size: 11px; text-align: center; }
.stat .bars { display: grid; grid-column: 1 / -1; grid-template-columns: 1fr 1fr; gap: 2px; height: 4px; margin-top: 2px; }
.stat .bars span { position: relative; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.stat .bars i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.stat .bars span:first-child i { right: 0; background: var(--home); }
.stat .bars span:last-child i { left: 0; background: var(--away); }
.stat.na .bars { opacity: .4; }

.chart { display: block; width: 100%; height: 96px; }
.chart-legend { display: flex; gap: 10px; color: var(--muted); font-size: 11px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; }

.insights { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.insights li { padding: 6px 8px; border-left: 2px solid var(--line-strong); background: var(--surface-2); font-size: 12px; }
.insights li.hot { border-left-color: var(--live); }
.insights li.note { border-left-color: var(--warn); }
.insights li.good { border-left-color: var(--ok); }

/* Events */
.events-tools { display: grid; gap: 6px; margin-bottom: 8px; }
.events-tools .field { width: 100%; height: 28px; }
.event-list { margin: 0; padding: 0; list-style: none; }
.event {
  display: grid;
  grid-template-columns: 38px 16px minmax(0, 1fr) auto;
  align-items: start;
  gap: 0 8px;
  width: 100%;
  padding: 5px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  text-align: left;
}
.event:not(:disabled):hover { background: var(--surface-2); }
.event:disabled { opacity: 1; cursor: default; }
.event:disabled .go { visibility: hidden; }
.event.is-focus { background: var(--accent-soft); }
.event time { color: var(--muted); font: 600 12px var(--mono); }
.event .ico { display: grid; place-items: center; height: 18px; }
.event .ico i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.event .ico i.goal { background: var(--accent); }
.event .ico i.yellow { border-radius: 1px; width: 7px; height: 10px; background: #facc15; }
.event .ico i.red { border-radius: 1px; width: 7px; height: 10px; background: #ef4444; }
.event .ico i.danger { background: var(--live); }
.event .ico i.sub { background: var(--muted); }
.event .ico i.shot { background: none; box-shadow: inset 0 0 0 2px var(--text); }
.event .ico i.noise { width: 4px; height: 4px; }
.event .what { min-width: 0; }
.event .what b { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.event .what small { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.event .side { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; vertical-align: 1px; }
.event .side.home { background: var(--home); }
.event .side.away { background: var(--away); }
.event .go { align-self: center; color: var(--faint); font: 11px var(--mono); }
.event:not(:disabled):hover .go { color: var(--accent); }

/* Lineups */
.lineups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lineup h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.lineup h3 i { flex: none; width: 8px; height: 8px; border-radius: 2px; }
.lineup .group { margin: 8px 0 2px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lineup ul { margin: 0; padding: 0; list-style: none; }
.lineup button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 6px;
  width: 100%;
  padding: 3px 4px;
  border: 0;
  border-radius: 4px;
  background: none;
  font-size: 12px;
  text-align: left;
}
.lineup button:hover { background: var(--surface-2); }
.lineup button.is-on { background: var(--accent-soft); }
.lineup button span:first-child { color: var(--muted); font-family: var(--mono); text-align: right; }
.lineup button span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Status bar + log drawer ── */

.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--statusbar-h);
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font: 11px var(--mono);
  white-space: nowrap;
  overflow: hidden;
}
.statusbar b { color: var(--text); font-weight: 500; }
.statusbar .log-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
}
.statusbar .log-toggle:hover { color: var(--text); }
.statusbar .log-last { overflow: hidden; max-width: 46vw; text-overflow: ellipsis; }
.statusbar .log-last.error { color: var(--live); }

.log-drawer {
  position: fixed;
  z-index: 35;
  right: 0;
  bottom: var(--statusbar-h);
  left: 0;
  max-height: 40vh;
  border-top: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.log-list { margin: 0; padding: 6px 0; list-style: none; font: 11px/1.5 var(--mono); }
.log-list li { display: grid; grid-template-columns: 70px 90px 1fr; gap: 10px; padding: 1px 14px; }
.log-list time { color: var(--faint); }
.log-list .cat { color: var(--accent); overflow: hidden; text-overflow: ellipsis; }
.log-list li.error .msg { color: var(--live); }

.toast {
  position: fixed;
  z-index: 50;
  bottom: calc(var(--statusbar-h) + 12px);
  left: 50%;
  max-width: min(520px, calc(100vw - 32px));
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--live); color: var(--live); }

/* ── Responsive ── */

@media (max-width: 1280px) {
  .console { grid-template-columns: 220px minmax(0, 1fr) 320px; }
  .stream-controls .btn-ghost { display: none; }
}

/* ── Commentary feed ── */

.commentary-list { margin: 0; padding: 0; list-style: none; }

.comm-item { border-bottom: 1px solid var(--line); }
.comm-item:last-child { border-bottom: 0; }

.comm-btn {
  display: grid;
  grid-template-columns: 36px 20px minmax(0, 1fr) auto;
  align-items: start;
  gap: 0 6px;
  width: 100%;
  padding: 7px 4px;
  border: 0;
  border-radius: 0;
  background: none;
  text-align: left;
  line-height: 1.45;
  font-size: 12px;
}
.comm-btn:not(:disabled):hover { background: var(--surface-2); }
.comm-btn.no-seek { cursor: default; }
.comm-btn:disabled { opacity: 1; cursor: default; }

.comm-time { color: var(--muted); font: 600 11px var(--mono); }
.comm-icon { font-size: 13px; }
.comm-body { min-width: 0; }
.comm-body b { font-weight: 700; }
.comm-go { align-self: center; color: var(--faint); font: 11px var(--mono); }
.comm-btn:not(:disabled):hover .comm-go { color: var(--accent); }

/* Kind accents */
.comm-goal .comm-body { color: var(--accent); font-weight: 600; }
.comm-goal .comm-time { color: var(--accent); }
.comm-red .comm-body b { color: #ef4444; }
.comm-yellow .comm-body b { color: #facc15; }
.comm-danger .comm-time { color: var(--live); }
.comm-safe .comm-time { color: var(--ok); }
.comm-shot .comm-body { color: var(--text); }

/* Score chip inside commentary */
.comm-score {
  display: inline-block;
  margin-left: 6px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface-3);
  font: 600 10px var(--mono);
  color: var(--muted);
  vertical-align: 1px;
}

/* Score chip on event items */
.event-score {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface-3);
  font: 600 10px var(--mono);
  color: var(--muted);
  align-self: center;
}

/* ── Situation HUD indicator ── */

.hud-situation {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font: 700 10px var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  color: var(--muted);
  transition: color .3s, border-color .3s;
}
.hud-situation[data-situation="dangerous"] {
  color: var(--live);
  border-color: var(--live);
  animation: danger-pulse 1.6s ease-in-out infinite;
}
.hud-situation[data-situation="dangerous"][data-side="home"] { --danger-glow: var(--home); }
.hud-situation[data-situation="dangerous"][data-side="away"] { --danger-glow: var(--away); }
@keyframes danger-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
@media (prefers-reduced-motion: reduce) { .hud-situation { animation: none; } }

@media (max-width: 1080px) {
  .console { display: flex; flex-direction: column; height: auto; gap: 0; background: none; }
  .pane, .stage { border-bottom: 1px solid var(--line); overflow: visible; }
  .stage { order: 1; }
  .details { order: 2; }
  .library { order: 3; }
  .library .pane-scroll { max-height: 360px; }
  .pitch-wrap, .player-inner, .inspector-inner { width: 100%; }
  .nav { display: none; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .match-form { order: 3; flex: 1; }
  .match-form .field { flex: 1; width: auto; }
  .stream-controls { order: 4; padding-left: 0; border-left: 0; }
  .topbar-end .chip span:last-child { display: none; }
  .pitch-frame, .player, .inspector { padding-right: 8px; padding-left: 8px; }
  .pitch-wrap, .player-inner, .inspector-inner { min-width: 0; }
  .hud { display: none; }
  .controls .step { display: none; }
  .inspector-inner { grid-template-columns: 1fr 1fr; height: auto; overflow: visible; }
  .inspector .who { grid-column: 1 / -1; }
  .inspector .close { display: none; }
  .statusbar .hide-sm { display: none; }
  .lineups { grid-template-columns: 1fr; }
}

/* Physical load block (streaming metrics) */
.inspector-inner > .phys { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; }
.phys-bar { display: flex; height: 6px; overflow: hidden; border-radius: 3px; background: var(--surface-3); }
.phys-bar i { display: block; height: 100%; }
.phys-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font: 11px var(--mono); }
.phys-legend b { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; vertical-align: -1px; }
.phys-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 4px; }
.phys-chip { display: flex; flex-direction: column; gap: 1px; min-width: 0; height: auto; padding: 4px 8px; border-radius: 4px; background: var(--surface-2); }
.phys-chip em { color: var(--faint); font: 10px/1.2 var(--sans); font-style: normal; letter-spacing: .05em; text-transform: uppercase; }
.phys-chip b { overflow: hidden; font: 600 12px/1.3 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.lineup li button .load { margin-left: auto; color: var(--muted); font: 10px var(--mono); }

.tactics-note { margin: 8px 0 0; font-size: 11px; }
.tactic-chart { color: var(--muted); }
.section-label .field { margin-left: 6px; padding: 1px 4px; font-size: 10px; text-transform: none; letter-spacing: 0; }
