/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:   #2d7a3a;
  --green-lt:#4a9b58;
  --pitch:   #3d8b4f;
  --dark:    #111827;
  --surface: #1f2937;
  --card:    #263342;
  --border:  #374151;
  --text:    #f3f4f6;
  --muted:   #9ca3af;
  --accent:  #facc15;
  --red:     #ef4444;
  --blue:    #3b82f6;
}

html { font-size: 16px; }
body {
  background: var(--dark);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  transition: background .2s ease, color .2s ease;
}

body.theme-light {
  --dark: #f3f6fb;
  --surface: #ffffff;
  --card: #eef3f8;
  --border: #cfd8e3;
  --text: #0f172a;
  --muted: #475569;
  --green: #2d7a3a;
  --green-lt: #3e9a4d;
  --accent: #d97706;
  --red: #dc2626;
  --blue: #2563eb;
}
body.theme-light .logo { color: #1d4f7d; }
body.theme-light .picker-hero {
  background: linear-gradient(135deg, #fff9ec 0%, #eef6ff 55%, #e8f7ef 100%);
  border-color: #d7e2ee;
}
body.theme-light .picker-hero::before {
  background-image:
    repeating-linear-gradient(90deg, rgba(15,23,42,.045) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg,  rgba(15,23,42,.045) 0 1px, transparent 1px 64px);
}
body.theme-light .picker-title {
  background: linear-gradient(120deg, #0f766e 0%, #0369a1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
body.theme-light .picker-stat {
  background: rgba(15,23,42,.045);
  border-color: rgba(15,23,42,.15);
}

/* ── Header ──────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 2px solid var(--green);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: .8rem 1.5rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.logo { font-size: 1.3rem; font-weight: 700; color: #7cc4d6; white-space: nowrap; }
#breadcrumb { display: flex; flex: 1; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
#breadcrumb .crumb { cursor: pointer; color: var(--green-lt); }
#breadcrumb .crumb:hover { text-decoration: underline; }
#breadcrumb .sep { color: var(--border); }
.btn-random-global {
  background: var(--accent); border: none; border-radius: 8px;
  padding: .45rem 1rem; color: var(--dark); font-size: .85rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: opacity .15s;
  margin-left: auto; flex-shrink: 0;
}
.btn-random-global:hover { opacity: .85; }
.btn-random-global:disabled { opacity: .5; cursor: not-allowed; }
.btn-help {
  background: transparent; border: 1.5px solid var(--muted); border-radius: 50%;
  width: 2rem; height: 2rem; color: var(--muted); font-size: 1rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0; transition: border-color .15s, color .15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-help:hover { border-color: var(--accent); color: var(--accent); }

/* ── Help modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  max-width: 640px; width: 92%; max-height: 85vh; overflow-y: auto;
  padding: 2rem; position: relative;
}
.modal-title { font-size: 1.3rem; margin-bottom: 1.2rem; color: var(--accent); }
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.btn-theme-toggle {
  position: absolute;
  top: 1rem;
  right: 3.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .75rem;
  font-weight: 700;
  padding: .34rem .55rem;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-theme-toggle:hover {
  border-color: var(--green-lt);
}
.modal-section { margin-bottom: 1.3rem; }
.modal-section h3 { font-size: 1rem; margin-bottom: .35rem; color: var(--green-lt); }
.modal-section p { font-size: .88rem; color: var(--muted); line-height: 1.65; }
.modal-section p strong { color: var(--text); }
.modal-section p em { color: var(--text); font-style: normal; }
.modal-footer {
  border-top: 1px solid var(--border); margin-top: 1.2rem; padding-top: 1rem;
}
.modal-footer p { font-size: .78rem; color: var(--muted); line-height: 1.6; }
.modal-footer a { color: var(--green-lt); text-decoration: none; }
.modal-footer a:hover { text-decoration: underline; }

/* ── Main / views ────────────────────────────────────────────────── */
main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.view { display: none; }
.view.active { display: block; }

h2 { font-size: 1.6rem; margin-bottom: .3rem; }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: .95rem; }

/* ── Loading spinner ─────────────────────────────────────────────── */
.loading-spinner {
  width: 48px; height: 48px;
  border: 5px solid var(--border);
  border-top-color: var(--green-lt);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 4rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Picker hero ─────────────────────────────────────────────────── */
.picker-hero {
  text-align: center;
  padding: 2.8rem 1.5rem 2.2rem;
  margin-bottom: 1.8rem;
  background: linear-gradient(135deg, #172817 0%, #1f2937 55%, #1a1f2e 100%);
  border-radius: 16px;
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.picker-hero::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg,  rgba(255,255,255,.025) 0 1px, transparent 1px 64px);
}
.picker-title {
  font-size: 2rem; font-weight: 800; margin-bottom: .6rem;
  background: linear-gradient(120deg, var(--accent) 0%, var(--green-lt) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.picker-sub {
  color: var(--muted); font-size: .93rem;
  max-width: 540px; margin: 0 auto 1.3rem; line-height: 1.65;
}
.picker-stats {
  display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;
}
.picker-stat {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: .28rem .9rem;
  font-size: .8rem; color: var(--text);
}
.picker-stat strong { color: var(--accent); }

/* ── Picker filter ───────────────────────────────────────────────── */
.picker-filter { margin-bottom: 1.4rem; }
#comp-search {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem 1.1rem;
  color: var(--text); font-size: .95rem; outline: none;
}
#comp-search:focus { border-color: var(--green-lt); }
.comp-search-status {
  margin-top: .45rem;
  font-size: .8rem;
  color: var(--muted);
  min-height: 1.1rem;
}

/* ── Competition grid ────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.comp-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  transition: transform .18s, border-color .18s, box-shadow .18s;
  animation: cardIn .4s ease both;
}
.comp-card:hover {
  transform: translateY(-4px);
  border-left-color: var(--accent);
  border-color: var(--green-lt);
  box-shadow: 0 6px 22px rgba(74,155,88,.28);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.comp-card-header {
  display: flex; align-items: flex-start; gap: .55rem; margin-bottom: .65rem;
}
.comp-flag { font-size: 1.15rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.comp-card h3 { font-size: .95rem; flex: 1; color: var(--text); line-height: 1.3; }
.comp-seasons-badge {
  background: rgba(74,155,88,.18); color: var(--green-lt);
  border-radius: 20px; padding: .12rem .6rem;
  font-size: .7rem; white-space: nowrap; flex-shrink: 0; margin-top: 2px;
}
.comp-card .season-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.season-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .2rem .7rem;
  font-size: .78rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.season-pill:hover { background: var(--green); border-color: var(--green-lt); color: #fff; }

/* ── Match list ──────────────────────────────────────────────────── */
.toolbar {
  display: flex; gap: .8rem; margin-top: 1.6rem; margin-bottom: 1.2rem; flex-wrap: wrap;
}
#match-search {
  flex: 1; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .55rem 1rem; color: var(--text); font-size: .95rem;
  outline: none;
}
#match-search:focus { border-color: var(--green-lt); }
.btn-random {
  background: var(--green); border: none; border-radius: 8px;
  padding: .55rem 1.1rem; color: #fff; font-size: .9rem; cursor: pointer;
  transition: background .15s;
}
.btn-random:hover { background: var(--green-lt); }

.match-list { display: flex; flex-direction: column; gap: .7rem; }
.match-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.3rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center; gap: .8rem;
  transition: border-color .15s, box-shadow .15s;
}
.match-card:hover { border-color: var(--green-lt); box-shadow: 0 3px 12px rgba(74,155,88,.25); }
.match-team { font-weight: 600; font-size: 1rem; }
.match-team.away { text-align: right; }
.match-score {
  font-size: 1.4rem; font-weight: 700; color: var(--accent);
  min-width: 3.5rem; text-align: center;
}
.match-meta { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* ── Match header ────────────────────────────────────────────────── */
.match-header {
  background: var(--card);
  border-radius: 12px;
  padding: 1.4rem 2rem;
  margin-bottom: 1.5rem;
  text-align: center;
}
.match-header .teams { font-size: 1.6rem; font-weight: 700; margin-bottom: .3rem; }
.match-header .score-big { font-size: 3rem; font-weight: 800; color: var(--accent); line-height: 1; }
.match-header .info { color: var(--muted); font-size: .9rem; margin-top: .5rem; }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .4rem; margin-bottom: 1.2rem; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; border-bottom: 3px solid transparent;
  color: var(--muted); padding: .6rem 1.2rem; font-size: 1rem; cursor: pointer;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tab-hidden { display: none; }
.tab.active, .tab:hover { color: var(--text); border-bottom-color: var(--green-lt); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Formation pitch ─────────────────────────────────────────────── */
.pitch-row { display: flex; gap: 2rem; flex-wrap: wrap; justify-content: center; }
.pitch-wrap { display: flex; flex-direction: column; align-items: center; }
.pitch-wrap h3 { margin-bottom: .5rem; font-size: 1.05rem; }
canvas { display: block; border-radius: 8px; }

/* ── Bench ───────────────────────────────────────────────────────── */
.bench-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.bench-panel { background: var(--card); border-radius: 10px; padding: 1rem 1.2rem; }
.bench-panel h4 { margin-bottom: .8rem; font-size: .95rem; color: var(--muted); }
.bench-player {
  display: flex; align-items: center; gap: .7rem;
  padding: .35rem 0; border-bottom: 1px solid var(--border); font-size: .87rem;
}
.bench-player:last-child { border-bottom: none; }
.jersey-num {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.sub-on     { color: #4ade80; font-size: .8rem; margin-left: auto; }
.sub-off    { color: #f87171; font-size: .8rem; margin-left: auto; }
.sub-on-off { color: #fb923c; font-size: .8rem; margin-left: auto; }

/* ── Shot map ────────────────────────────────────────────────────── */
.shotmap-row { display: flex; gap: 2rem; flex-wrap: wrap; justify-content: center; }
.shotmap-col { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.shotmap-label { font-weight: 600; font-size: .95rem; color: var(--text); text-align: center; }
.team-toggle {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); border-radius: 8px; padding: .45rem 1.1rem;
  font-size: .9rem; cursor: pointer; transition: all .15s;
}
.team-toggle.active { background: var(--green); border-color: var(--green-lt); color: #fff; }
.shotmap-wrap { overflow-x: auto; }
.shotmap-col canvas { display: block; }
.shot-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .8rem; font-size: .85rem; }
.legend-item { display: flex; align-items: center; gap: .4rem; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }

/* ── Pass map ────────────────────────────────────────────────────── */
.passmap-row { display: flex; gap: 2rem; flex-wrap: wrap; justify-content: center; }
.passmap-col { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.passmap-label { font-weight: 600; font-size: .95rem; color: var(--text); text-align: center; }
.passmap-select-wrap { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.passmap-select-wrap select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .35rem .5rem; font-size: .82rem;
  min-width: 200px; max-width: 480px; width: 100%;
  scrollbar-width: thin;
}
.passmap-select-wrap select option { padding: .2rem .4rem; }
.passmap-select-wrap select option:checked { background: var(--green); color: #fff; }
.passmap-hint { font-size: .72rem; color: var(--muted); margin: 0; text-align: center; }
.passmap-col canvas { display: block; }
.passmap-stats {
  font-size: .85rem; color: var(--text);
  text-align: center; padding: .35rem .5rem;
  background: var(--surface); border-radius: 8px;
  border: 1px solid var(--border); min-width: 200px;
}
.passmap-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .8rem; font-size: .85rem; }

/* ── Pass network ────────────────────────────────────────────────── */
.passnet-note {
  font-size: .78rem; color: var(--muted); text-align: center;
  margin: 0 0 .8rem; padding: 0;
}

/* ── Player card ─────────────────────────────────────────────────── */
.playercard-row {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}
.playercard-col {
  flex: 1 1 520px;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.perf-card-wrap { width: 100%; }
.btn-save-card {
  align-self: flex-end;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .75rem;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, color .15s, opacity .15s;
}
.btn-save-card:hover {
  border-color: var(--green-lt);
  color: #fff;
}
.btn-save-card:disabled {
  opacity: .65;
  cursor: wait;
}
.perf-card-empty {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.perf-card {
  background: #e8ebef;
  color: #111827;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.perf-card-header {
  background: #a8c7e8;
  padding: .85rem 1rem 1rem;
}
.perf-card-match {
  font-size: .72rem;
  text-align: center;
  color: #1f2937;
  margin-bottom: .65rem;
}
.perf-card-head-row {
  display: flex;
  justify-content: space-between;
  gap: .8rem;
  align-items: flex-start;
}
.perf-card-name {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.08;
}
.perf-card-role {
  margin-top: .35rem;
  font-size: .95rem;
  color: #334155;
}
.perf-rating {
  border: 1.5px solid #facc15;
  border-radius: 12px;
  min-width: 86px;
  padding: .35rem .5rem;
  text-align: center;
}
.perf-rating-label { font-size: .8rem; }
.perf-rating-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.perf-rating-grade { font-size: .9rem; }

.perf-box {
  border: 2px solid #64748b;
  border-radius: 12px;
  padding: .62rem .82rem;
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.52;
  background: rgba(255,255,255,0.2);
}
.perf-box-shots {
  margin: .62rem .75rem .35rem;
  border-color: #f97316;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}
.perf-metric-grid {
  margin: 0 .75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .58rem;
}
.perf-box-pass { border-color: #7c3aed; }
.perf-box-foul { border-color: #65a30d; }
.perf-box-dribble { border-color: #2563eb; }
.perf-box-turnover { border-color: #ef4444; }
.perf-box-defense { border-color: #c6c614; }
.perf-box-full { grid-column: 1 / -1; }
.perf-box-foul-strip {
  text-align: center;
  font-size: .95rem;
  font-weight: 700;
  white-space: nowrap;
}

.perf-map-grid {
  margin: .7rem .75rem .75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .58rem;
}
.perf-map-panel {
  background: rgba(255,255,255,0.28);
  border-radius: 10px;
  padding: .45rem;
}
.perf-map-title {
  text-align: center;
  font-weight: 700;
  font-size: .88rem;
  margin-bottom: .35rem;
}
.perf-map-canvas {
  width: 100%;
  height: 330px;
  background: #f8fafc;
  border: 1px solid rgba(15,23,42,0.18);
  border-radius: 8px;
}
.perf-map-legend {
  display: flex;
  justify-content: center;
  gap: .8rem;
  margin-top: .35rem;
  font-size: .75rem;
  color: #1f2937;
  flex-wrap: wrap;
}
.perf-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}
.perf-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.perf-red { background: #dc2626; }
.perf-blue { background: #1d4ed8; }
.perf-blue-soft { background: rgba(37,99,235,0.35); border: 1px solid rgba(37,99,235,0.7); }
.perf-legend-line {
  width: 14px;
  height: 0;
  border-top: 2px solid #2563eb;
  display: inline-block;
}

/* ── xG Plot ─────────────────────────────────────────────────────── */
#tab-xgplot.tab-content.active { display: flex; flex-direction: column; gap: 1.2rem; align-items: center; }
#canvas-xgplot { display: block; border-radius: 8px; background: #1a1a1a; max-width: 100%; }
body.theme-light #canvas-xgplot { background: #f8fafc; border: 1px solid #d6e2ef; }
.xgplot-summary {
  width: 100%; max-width: 960px;
  background: var(--surface); border-radius: 8px;
  border: 1px solid var(--border); padding: 1.2rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.xg-summary { display: flex; flex-direction: column; gap: 1.2rem; }
.xg-score {
  display: flex; justify-content: space-between; gap: 2rem;
  align-items: flex-start;
}
.xg-team {
  flex: 1; text-align: center;
  padding: .8rem; background: rgba(255,255,255,0.03); border-radius: 8px;
  border: 1px solid var(--border);
}
body.theme-light .xg-team { background: rgba(15,23,42,0.035); }
.xg-team-name {
  font-size: .86rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: .25rem;
  line-height: 1.25;
}
.xg-home { border-left: 4px solid #60a5fa; }
.xg-away { border-left: 4px solid #ef4444; }
.xg-goals {
  font-size: 2rem; font-weight: 700; margin-bottom: .2rem;
  color: var(--text);
}
.xg-stat { font-size: .85rem; color: var(--muted); }
.xg-divider {
  align-self: center; color: var(--muted); font-weight: 600;
  font-size: 1.2rem;
}
.xg-probs {
  display: flex; justify-content: space-around; gap: 1rem;
  padding: .8rem; background: rgba(255,255,255,0.03); border-radius: 8px;
  border: 1px solid var(--border);
}
body.theme-light .xg-probs { background: rgba(15,23,42,0.035); }
.xg-prob {
  flex: 1; text-align: center;
  padding: .5rem; border-radius: 6px;
  font-size: .85rem; color: var(--muted);
}
.xg-home-prob { background: rgba(96,165,250,0.1); }
.xg-draw-prob { background: rgba(156,163,175,0.1); }
.xg-away-prob { background: rgba(239,68,68,0.1); }
.xg-prob strong { font-size: 1.1rem; color: var(--text); display: block; margin-bottom: .2rem; }

/* ── Penalty shootout ───────────────────────────────────────────── */
.shootout-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.2rem;
}
.shootout-headline {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: .7rem;
}
.shootout-summary {
  color: var(--muted);
  font-size: .86rem;
  margin-bottom: .9rem;
}
.shootout-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.shootout-table th,
.shootout-table td {
  padding: .52rem .55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.shootout-table th {
  color: var(--muted);
  font-weight: 600;
}
.shootout-team-home { color: var(--red); font-weight: 700; }
.shootout-team-away { color: var(--blue); font-weight: 700; }
.shootout-made { color: #4ade80; font-weight: 700; }
.shootout-missed { color: #f87171; font-weight: 700; }

/* ── Stats ───────────────────────────────────────────────────────── */
.stats-table { background: var(--card); border-radius: 12px; overflow: hidden; }
.stat-row {
  display: grid; grid-template-columns: 1fr 160px 1fr;
  align-items: center; gap: .5rem;
  padding: .75rem 1.2rem; border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { text-align: center; font-size: .82rem; color: var(--muted); }
.stat-val-home { text-align: right; font-weight: 700; }
.stat-val-away { text-align: left; font-weight: 700; }
.stat-bar-wrap { position: relative; height: 6px; background: var(--border); border-radius: 3px; }
.stat-bar-home {
  position: absolute; right: 50%; top: 0; height: 100%;
  background: var(--red); border-radius: 3px 0 0 3px;
}
.stat-bar-away {
  position: absolute; left: 50%; top: 0; height: 100%;
  background: var(--blue); border-radius: 0 3px 3px 0;
}

/* ── Shot tooltip ────────────────────────────────────────────────── */
.shot-tooltip {
  position: absolute; pointer-events: none;
  background: rgba(15,20,15,0.92); color: #f3f4f6;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
  padding: .45rem .85rem; font-size: .82rem; white-space: nowrap;
  opacity: 0; transition: opacity .15s; z-index: 300;
}
.shot-tooltip.visible { opacity: 1; }

/* ── Pass network node tooltip ────────────────────────────── */
.passnet-tooltip {
  position: absolute; pointer-events: none;
  background: rgba(15,20,15,0.93); color: #f3f4f6;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
  padding: .5rem .9rem; font-size: .82rem; min-width: 170px;
  line-height: 1.6; opacity: 0; transition: opacity .15s; z-index: 300;
}
.passnet-tooltip.visible { opacity: 1; }
.passnet-tooltip-sub {
  margin-top: 4px; color: var(--muted); font-size: .74rem;
}

/* ── xG goal tooltip ─────────────────────────────────────────── */
.xg-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15,20,15,0.95);
  color: #f3f4f6;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: .55rem .85rem;
  font-size: .8rem;
  line-height: 1.55;
  min-width: 220px;
  max-width: 320px;
  opacity: 0;
  transition: opacity .15s;
  z-index: 300;
}
.xg-tooltip.visible { opacity: 1; }
.xg-tooltip-sub { color: var(--muted); font-size: .74rem; }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(4rem);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem 1.4rem; font-size: .9rem;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .modal-box {
    padding: 1.2rem;
  }
  .modal-title {
    font-size: 1.1rem;
    margin-bottom: .9rem;
  }
  .modal-section {
    margin-bottom: 1rem;
  }
  .modal-section h3 {
    font-size: .9rem;
  }
  .modal-section p {
    font-size: .8rem;
    line-height: 1.5;
  }
  .modal-footer p {
    font-size: .72rem;
    line-height: 1.45;
  }

  .btn-theme-toggle {
    position: static;
    display: block;
    width: 100%;
    margin: 0 0 .85rem 0;
    font-size: .74rem;
    padding: .34rem .45rem;
  }

  .header-inner {
    padding: .65rem .85rem;
    gap: .55rem;
    flex-wrap: wrap;
    align-items: center;
  }
  .logo {
    font-size: 1rem;
    white-space: normal;
    line-height: 1.2;
    flex: 1 1 auto;
    min-width: 180px;
  }
  #breadcrumb {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    font-size: .78rem;
  }
  .btn-random-global {
    margin-left: 0;
    padding: .4rem .7rem;
    font-size: .76rem;
  }
  .btn-help {
    width: 1.85rem;
    height: 1.85rem;
    font-size: .95rem;
  }

  .tabs { gap: .28rem; }
  .tab {
    padding: .5rem .75rem;
    font-size: .9rem;
  }

  .match-header {
    padding: 1rem 1rem;
  }
  .match-header .teams {
    font-size: 1.22rem;
  }
  .match-header .score-big {
    font-size: 2.2rem;
  }
  .match-header .info {
    font-size: .82rem;
  }

  .pitch-row { flex-direction: column; }
  .shotmap-row,
  .passmap-row {
    gap: 1rem;
  }
  .playercard-col {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
  }
  .perf-card-wrap {
    display: flex;
    justify-content: center;
  }
  .perf-card {
    width: min(92vw, 360px);
  }
  .perf-box {
    font-size: .74rem;
    line-height: 1.35;
    padding: .5rem .6rem;
  }
  .perf-box-shots {
    font-size: .82rem;
  }
  .perf-box-foul-strip {
    font-size: .78rem;
  }
  .perf-metric-grid {
    gap: .44rem;
  }
  .perf-map-grid {
    gap: .44rem;
  }
  .perf-map-canvas {
    height: auto;
    aspect-ratio: 240 / 330;
  }
  .perf-map-title {
    font-size: .78rem;
  }
  .perf-map-legend {
    font-size: .68rem;
    gap: .45rem;
  }
  .shotmap-col,
  .passmap-col {
    width: 100%;
    max-width: 100%;
  }
  .shotmap-col canvas {
    width: min(100%, 400px);
    height: auto;
    margin-inline: auto;
  }
  .passmap-col canvas {
    width: min(100%, 480px);
    height: auto;
    margin-inline: auto;
  }
  .passmap-select-wrap,
  .passmap-stats {
    width: 100%;
    max-width: 480px;
  }
  .passmap-select-wrap select {
    min-width: 0;
  }
  .bench-row { grid-template-columns: 1fr; }
  .match-card { grid-template-columns: 1fr auto 1fr; }
  .match-meta { display: none; }
}
