/* ─── Design tokens: broadcast / tactical analyst aesthetic ─── */
:root {
  --pitch-dark: #1a4d2e;
  --pitch-mid: #236b3e;
  --pitch-light: #2d8a4e;
  --pitch-line: rgba(255, 255, 255, 0.72);
  --ink: #0c1210;
  --ink-soft: #1a2420;
  --paper: #e8ebe4;
  --paper-dim: #c5cbc0;
  --muted: #6b756e;
  --arg: #74acdf;
  --arg-deep: #3380c2;
  --arg-ink: #0a2a4a;
  --aut: #ed2939;
  --aut-deep: #b81d2a;
  --aut-ink: #3a080c;
  --gold: #d4a84b;
  --surface: #121916;
  --surface-2: #1a2420;
  --surface-3: #24302b;
  --border: rgba(232, 235, 228, 0.1);
  --text: #e8ebe4;
  --text-dim: #8a948c;
  --radius: 6px;
  --font-display: "Barlow Condensed", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --header-h: 88px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--ink);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(45, 138, 78, 0.12), transparent),
    var(--ink);
}

/* ─── Header / scoreboard ─── */
.match-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.header-right { justify-content: flex-end; }

.sim-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.28rem 0.5rem;
  background: #c41e3a;
  color: #fff;
  border-radius: 3px;
  animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

.comp-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.team-block {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 140px;
}

.team-block.away { flex-direction: row; justify-content: flex-end; text-align: right; }

.team-block.away .team-meta { align-items: flex-end; }

.flag { font-size: 1.6rem; line-height: 1; }

.team-meta { display: flex; flex-direction: column; gap: 0.1rem; }

.team-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.team-form {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.score-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 120px;
}

.score-digits {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

#score-home { color: var(--arg); }
#score-away { color: var(--aut); }
.score-sep { color: var(--text-dim); font-weight: 500; font-size: 2rem; }

.clock-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
}

.clock-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold);
  background: rgba(212, 168, 75, 0.15);
  padding: 0.15rem 0.35rem;
  border-radius: 2px;
}

.clock {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

.match-status {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.speed-control {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
}

.speed-control label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.speed-control select {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}

/* ─── Main layout ─── */
.main-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: 0;
  min-height: 0;
}

.pitch-section {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem 1rem;
  min-width: 0;
}

.pitch-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--pitch-light);
  color: #fff;
  border-color: var(--pitch-mid);
}

.btn-primary:hover:not(:disabled) { background: var(--pitch-mid); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }

.toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--pitch-light); cursor: pointer; }

.pitch-frame {
  position: relative;
  flex: 1;
  min-height: 360px;
  background: #0a100c;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

#pitch {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - var(--header-h) - 160px);
  object-fit: contain;
}

.pitch-overlay-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 0.4rem;
  pointer-events: none;
}

.hud-item {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.5rem;
  background: rgba(12, 18, 16, 0.72);
  border: 1px solid var(--border);
  border-radius: 4px;
  backdrop-filter: blur(6px);
  color: var(--paper);
}

/* xG bar */
.xG-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.65rem;
  padding: 0.5rem 0.25rem;
}

.xg-side {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.xg-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.xg-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
}

.xg-side.home .xg-val { color: var(--arg); }
.xg-side.away .xg-val { color: var(--aut); }

.xg-track {
  position: relative;
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.xg-fill {
  height: 100%;
  transition: width 0.4s ease;
}

.xg-fill.home { background: var(--arg); margin-left: auto; }
.xg-fill.away { background: var(--aut); }

/* ─── Side panels ─── */
.side-panels {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
}

.panel {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.65rem;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
}

.stat-val.home { color: var(--arg); text-align: left; }
.stat-val.away { color: var(--aut); text-align: right; }

.stat-name {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-align: center;
}

.poss-bar {
  height: 5px;
  background: var(--aut);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.poss-fill {
  height: 100%;
  background: var(--arg);
  transition: width 0.35s ease;
}

.stat-grid { display: flex; flex-direction: column; gap: 0.4rem; }

.mini-stat {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.ms-val:first-child { color: var(--arg); text-align: left; }
.ms-val:last-child { color: var(--aut); text-align: right; }
.ms-lab {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-align: center;
  font-family: var(--font-body);
}

/* Events */
.events-panel { flex: 1; min-height: 160px; display: flex; flex-direction: column; }

.event-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  max-height: 220px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.event-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 0.45rem;
  font-size: 0.72rem;
  padding: 0.35rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  animation: event-in 0.3s ease;
}

@keyframes event-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.event-item.goal {
  background: rgba(212, 168, 75, 0.12);
  border-left: 2px solid var(--gold);
}

.event-item.shot { border-left: 2px solid var(--paper-dim); }
.event-item.foul { border-left: 2px solid #888; }

.event-min {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.68rem;
}

.event-text { color: var(--text); line-height: 1.35; }

.event-text .team-arg { color: var(--arg); font-weight: 600; }
.event-text .team-aut { color: var(--aut); font-weight: 600; }

/* Influence */
.influence-list { display: flex; flex-direction: column; gap: 0.4rem; }

.inf-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
}

.inf-name { display: flex; align-items: center; gap: 0.4rem; }

.inf-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.inf-dot.arg { background: var(--arg); }
.inf-dot.aut { background: var(--aut); }

.inf-bar-wrap {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.15rem;
}

.inf-bar { height: 100%; border-radius: 2px; transition: width 0.3s; }
.inf-bar.arg { background: var(--arg); }
.inf-bar.aut { background: var(--aut); }

.inf-touches {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: right;
}

.note-text {
  font-size: 0.68rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.app-footer {
  padding: 0.5rem 1.25rem;
  font-size: 0.62rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-sep { opacity: 0.4; }

/* ─── Responsive ─── */
@media (max-width: 960px) {
  .match-header {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .header-left, .header-right { justify-content: center; }

  .scoreboard { justify-content: center; }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .side-panels {
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .team-block { min-width: auto; }

  .comp-label { display: none; }
}

@media (max-width: 520px) {
  .score-digits { font-size: 2rem; }
  .team-name { font-size: 1rem; }
  .team-form { display: none; }
  .flag { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sim-badge { animation: none; }
  .event-item { animation: none; }
  .xg-fill, .poss-fill, .inf-bar { transition: none; }
}
