:root {
  --bg: #0c0a1f;
  --bg-2: #14112e;
  --ink: #f3f2fb;
  --muted: #9490b8;
  --accent: #8b8ee8;
  --line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(120% 160% at 20% -10%, #201a44 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  min-height: 100%;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 40px 10px;
}

.brand-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand h1 em {
  font-style: normal;
  color: var(--accent);
}

.ghost-btn {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.14); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 40px;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 6px 10px;
  cursor: pointer;
  transition: color 0.15s ease;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }

main { padding: 6px 40px 60px; }
.tab-panel[hidden] { display: none; }

.intro {
  max-width: 640px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 20px 0 28px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 12px;
}
.section-heading h2 { margin: 0; font-size: 18px; }
.section-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

.host-map-section { margin-bottom: 36px; }
.host-map { width: 100%; max-width: 800px; }
.host-map-svg { width: 100%; height: auto; display: block; }
.map-landmass {
  fill: rgba(139, 142, 232, 0.08);
  stroke: rgba(139, 142, 232, 0.35);
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.map-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  fill: var(--muted);
}
.map-node circle { transition: fill-opacity 0.15s ease, stroke-width 0.15s ease; }
.map-node:hover circle:first-child { fill-opacity: 0.5; }
.map-node-empty .map-label, .map-node-empty circle { opacity: 0.25; }
.map-node-active circle:first-child { fill-opacity: 0.65 !important; stroke-width: 2.4; }
.map-node-active .map-label { fill: var(--ink); }

.group-stage-heading {
  font-size: 16px;
  color: var(--muted);
  font-weight: 500;
  margin: 8px 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.round-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.015);
}
.round-section > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 20px;
}
.round-section > summary::-webkit-details-marker { display: none; }
.round-section > summary::after {
  content: "▾";
  color: var(--muted);
  margin-left: 10px;
}
.round-section[open] > summary::after { content: "▴"; }
.round-title { font-weight: 600; font-size: 15px; }
.round-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}
.round-section .match-grid { padding: 0 20px 20px; }

.section-heading-spaced { margin-top: 48px; }

.legends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.legend-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.legend-rank {
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  color: var(--accent);
  width: 26px;
  flex-shrink: 0;
}
.legend-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--line);
  flex-shrink: 0;
}
.legend-info { display: flex; flex-direction: column; min-width: 0; }
.legend-name { font-weight: 600; font-size: 14px; }
.legend-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.legend-goals { color: var(--accent); font-weight: 600; }

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.team-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  font-size: 12.5px;
  transition: border-color 0.15s ease;
}
.team-chip:hover { border-color: var(--accent); }

.bracket-container { max-width: 900px; margin: 0 auto; }
.bracket-scroller { width: 100%; overflow-x: auto; overflow-y: hidden; }
.bracket-svg { width: 100%; height: auto; display: block; min-width: 640px; }
.bracket-group-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  fill: var(--muted);
  text-anchor: middle;
}
.bracket-flag { transition: opacity 0.15s ease; }
.bracket-flag:hover { opacity: 0.85; }
.bracket-flag-dim { opacity: 0.55; }
.bracket-center-emoji { font-size: 46px; }
.bracket-center-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  fill: var(--muted);
  text-anchor: middle;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.match-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.match-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.round-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.mini-preview {
  width: 100%;
  height: auto;
  aspect-ratio: 280 / 170;
  border-radius: 10px;
  margin: 8px 0;
  display: block;
}

.card-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}
.score-nums {
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  color: var(--accent);
}

.site-footer {
  padding: 24px 40px 50px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.site-footer a { color: var(--accent); }

/* About panel */
.about-panel {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 16, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.about-panel.open { display: flex; }
.about-card {
  position: relative;
  max-width: 640px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px;
}
.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
}
.about-card h2 { margin: 6px 0 14px; font-size: 30px; }
.about-card h3 { font-size: 14px; color: var(--accent); margin: 22px 0 10px; }
.about-card p { line-height: 1.65; color: var(--ink); font-size: 14.5px; }
.about-list { padding-left: 18px; line-height: 1.7; font-size: 14.5px; }
.close-btn { position: absolute; top: 20px; right: 20px; padding: 6px 12px; }

/* Viewer overlay */
.viewer {
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--lean-color, #201a44) 35%, #0a0818) 0%, #06050f 70%);
  display: none;
  flex-direction: column;
  z-index: 40;
  transition: background 0.5s ease;
}
.viewer.open { display: flex; }

.viewer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 30px 0;
}

.team-flags {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  letter-spacing: 0.05em;
}
.team-flags .team { display: flex; align-items: center; gap: 8px; }
.team-flags .vs { color: var(--muted); font-size: 11px; }

.flag-img {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--line);
  vertical-align: -2px;
}
.flag-img-lg { width: 28px; height: 21px; border-radius: 4px; }

.match-meta {
  text-align: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  margin: 2px 0 6px;
}

.minute-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.score-big {
  text-align: center;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  margin: 4px 0 0;
}

.goals-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 4px 30px 0;
  margin-top: -4px;
}
.goals-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
  max-height: 190px;
  overflow-y: auto;
}
#goals-away { align-items: flex-end; }
#goals-away .goal-item { flex-direction: row-reverse; }

.goal-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.goal-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1.5px var(--line);
  flex-shrink: 0;
}
.goal-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.goal-text { display: flex; flex-direction: column; line-height: 1.3; }
#goals-away .goal-text { align-items: flex-end; }
.goal-name-row { display: flex; align-items: baseline; gap: 6px; }
.goal-name { white-space: nowrap; color: var(--ink); }
.goal-min { color: var(--accent); }
.goal-club {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.viewer-canvas {
  flex: 1;
  width: 100%;
  min-height: 0;
  cursor: grab;
}
.viewer-canvas:active { cursor: grabbing; }

.fallback-canvas { cursor: default; }
.fallback-note {
  text-align: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  margin: -8px 0 0;
}

.controls {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 30px 26px;
}

.play-btn {
  font-family: "JetBrains Mono", monospace;
  background: var(--accent);
  color: #0c0a1f;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}

#scrubber { width: 140px; accent-color: var(--accent); }

.seismograph {
  width: 100%;
  height: 64px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

@media (max-width: 720px) {
  .site-header, main, .site-footer, .tabs { padding-left: 20px; padding-right: 20px; }
  .goals-row { padding: 0 16px; }
  .controls { grid-template-columns: auto 1fr; }
  #scrubber { grid-column: 1 / -1; width: 100%; }
  .round-section > summary { flex-direction: column; gap: 2px; }
}
