:root {
  --bg: #0f1620;
  --panel: #172230;
  --panel2: #1d2b3a;
  --line: #2a3a4d;
  --txt: #e6edf3;
  --muted: #8da2b5;
  --accent: #16c784;
  --accent-d: #0f9d63;
  --third: #f5b301;
  --out: #6b7c8d;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #15263a, var(--bg)) fixed;
  color: var(--txt);
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px;
  background: linear-gradient(120deg, #0f9d63, #0b6e84);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo { font-size: 34px; }
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.tagline { margin: 2px 0 0; font-size: 13px; color: rgba(255, 255, 255, .85); }

/* ---------- buttons ---------- */
.btn {
  cursor: pointer; border: 1px solid var(--line); background: var(--panel2); color: var(--txt);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04231a; }
.btn-primary:hover { background: var(--accent-d); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); color: #fff; }

/* ---------- stepper ---------- */
.stepper { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 16px; }
.step {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font-weight: 600; font-size: 13px; cursor: pointer; transition: .15s;
}
.step[aria-current="true"] { background: var(--accent); color: #04231a; border-color: var(--accent); }
.step:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- layout ---------- */
.view { max-width: 1340px; margin: 0 auto; padding: 8px 18px 70px; }
.section-head { margin: 10px 4px 18px; }
.section-head h2 { margin: 0 0 4px; font-size: 22px; }
.section-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 640px; }
.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 14px; margin: 0 4px 14px; }
.counter { color: var(--accent); font-weight: 800; }

/* ---------- shared team chip ---------- */
.chip { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 14px; }
.flag {
  width: 26px; height: 18px; flex: 0 0 26px; border-radius: 3px; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: #26384a; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flag-fallback { font-size: 9px; font-weight: 800; color: #cdd9e5; letter-spacing: .2px; }

/* ---------- group stage ---------- */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.group-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.group-card h3 {
  margin: 0; padding: 12px 14px; font-size: 15px;
  background: var(--panel2); border-bottom: 1px solid var(--line);
}
.team-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.team-row:last-child { border-bottom: none; }
.rank {
  width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border-radius: 6px;
  font-size: 12px; font-weight: 700; background: var(--panel2); color: var(--muted);
}
.team-row .spacer { flex: 1; }
.pill {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px;
  padding: 3px 7px; border-radius: 999px; white-space: nowrap;
}
.pill.advance { background: rgba(22, 199, 132, .16); color: var(--accent); }
.pill.third { background: rgba(245, 179, 1, .16); color: var(--third); }
.pill.out { background: rgba(120, 140, 160, .16); color: var(--out); }
.reorder { display: flex; flex-direction: column; gap: 2px; }
.reorder button {
  width: 24px; height: 18px; line-height: 1; border: 1px solid var(--line);
  background: var(--panel2); color: var(--txt); border-radius: 5px; cursor: pointer; font-size: 10px; padding: 0;
}
.reorder button:disabled { opacity: .3; cursor: not-allowed; }
.reorder button:hover:not(:disabled) { border-color: var(--accent); }

/* ---------- best thirds ---------- */
.third-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.third-card {
  display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; cursor: pointer; transition: .15s; text-align: left; color: var(--txt); font: inherit;
}
.third-card:hover { border-color: var(--accent); }
.third-card.selected { border-color: var(--accent); background: linear-gradient(180deg, rgba(22, 199, 132, .12), transparent); }
.third-card .grp { font-weight: 800; color: var(--muted); font-size: 12px; width: 14px; }
.third-card .tick {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; color: transparent; font-size: 13px; flex: 0 0 22px;
}
.third-card.selected .tick { border-color: var(--accent); background: var(--accent); color: #04231a; }

/* ---------- champion banner ---------- */
.champion {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(120deg, #f5b301, #ff7a00); color: #241500;
  border-radius: 16px; padding: 18px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.champion .trophy { font-size: 42px; }
.champion h2 { margin: 0; font-size: 24px; }
.champion .sub { font-weight: 600; font-size: 13px; }
.champion .flag { width: 46px; height: 32px; flex: 0 0 46px; }

/* ---------- bracket ---------- */
.bracket-scroll { overflow-x: auto; padding-bottom: 14px; }
.bracket { position: relative; display: flex; gap: 30px; min-width: max-content; padding: 6px 8px; }
.bracket-lines { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 2; overflow: visible; }
.bracket-lines path { fill: none; stroke: #3c5063; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round-col { position: relative; z-index: 1; display: flex; flex-direction: column; min-width: 200px; width: 200px; }
.round-title {
  text-align: center; font-size: 12px; font-weight: 800; letter-spacing: .6px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.col-matches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 14px; }
.match { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.match-meta {
  font-size: 10.5px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 8px; background: var(--panel2);
}
.match-meta span:first-child { flex: 0 0 auto; }
.match-meta span:last-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot {
  display: flex; align-items: center; width: 100%; border: none; background: transparent; color: var(--txt);
  padding: 9px 10px; cursor: pointer; text-align: left; gap: 9px; border-bottom: 1px solid var(--line); font: inherit;
}
.slot:last-child { border-bottom: none; }
.slot:hover:not(:disabled):not(.won) { background: var(--panel2); }
.slot.won { background: rgba(22, 199, 132, .18); }
.slot.won .cname { color: #fff; }
.slot.empty { color: var(--muted); cursor: default; font-size: 12px; font-style: italic; }
.slot .check { margin-left: auto; color: var(--accent); font-weight: 900; }

.tp-section { margin-top: 28px; }
.tp-section .round-title { text-align: left; }
.tp-section .match { max-width: 264px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .topbar h1 { font-size: 17px; }
}
