:root {
  --bg: #0e0f12;
  --panel: #141519;
  --line: #3a3d44;
  --line-soft: #2a2c31;
  --disc: #1c1e24;
  --disc-stroke: #4a4e57;
  --code: #c9ccd3;
  --accent: #2dd4a7;
  --text: #e7e9ee;
  --muted: #9aa0ac;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.badge.ok { color: var(--accent); border-color: rgba(45, 212, 167, 0.4); }
.badge.bad { color: #ff6b6b; border-color: rgba(255, 107, 107, 0.5); }
.badge.soft { color: var(--muted); }

.stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

/* Title-odds panel */
#odds-panel {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 188px;
  background: rgba(20, 21, 25, 0.82);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 11px 12px;
  backdrop-filter: blur(4px);
  z-index: 5;
}
#odds-panel h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 0;
  text-transform: uppercase;
  color: var(--text);
}
.odds-note { font-size: 10px; color: var(--muted); margin: 2px 0 9px; }
#odds-list { list-style: none; margin: 0; padding: 0; }
#odds-list li {
  display: grid;
  grid-template-columns: 16px 30px 1fr 34px;
  align-items: center;
  gap: 6px;
  margin: 5px 0;
}
.odds-flag { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.odds-code { font-size: 11px; font-weight: 700; color: var(--code); }
.odds-bar { height: 5px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.odds-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.odds-val { font-size: 11px; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  #odds-panel { position: static; width: auto; margin-bottom: 10px; backdrop-filter: none; }
  .stage { flex-direction: column; }
}

#bracket {
  width: min(94vw, 86vh, 900px);
  height: auto;
  aspect-ratio: 1 / 1;
}

/* Connectors */
.connector {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.connector.win { stroke: var(--accent); stroke-width: 2.2; }
.matchpt { fill: var(--line); }
.matchpt.done { fill: var(--accent); }
.matchpt:hover { fill: #fff; cursor: help; }

/* Always-visible per-match Elo head-to-head pill */
.mlabel { cursor: help; }
.mlabel-bg {
  fill: #0e0f12;
  fill-opacity: 0.82;
  stroke: var(--line-soft);
  stroke-width: 0.6;
}
.mlabel-txt {
  fill: var(--text);
  font-size: 8.5px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.mlabel:hover .mlabel-bg { stroke: var(--accent); }

/* Team nodes */
.flag-disc {
  fill: var(--disc);
  stroke: none;
}
.flag-img { pointer-events: none; }
.flag-ring {
  fill: none;
  stroke: var(--disc-stroke);
  stroke-width: 1.5;
}
.flag-fallback {
  fill: var(--code);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.flag-missing .flag-disc { fill: #23262e; }
.flag-ring.champ { stroke: var(--accent); stroke-width: 2.5; }
.team.ghost { opacity: 0.3; }
.team.ghost:hover, .team.ghost:focus { opacity: 0.85; }
.code {
  fill: var(--code);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.team { cursor: default; outline: none; }
.team:hover .flag-ring,
.team:focus .flag-ring { stroke: var(--accent); stroke-width: 2.4; }
.team:hover .code,
.team:focus .code { fill: #fff; }

/* Centre trophy */
.trophy-bg { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.trophy { font-size: 30px; text-anchor: middle; dominant-baseline: middle; }

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 10;
  background: #000;
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  pointer-events: none;
  transform: translateY(-2px);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .topbar h1 { font-size: 14px; }
  .badge { font-size: 11px; }
  #bracket { width: 96vw; }
}
