/* ============================================================
   World Cup 2026 Predictor — Styles
   ============================================================ */
:root {
  --bg: #070b16;
  --bg2: #0b1024;
  --card: rgba(255, 255, 255, 0.045);
  --card-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.16);
  --text: #eaf0fb;
  --muted: #8b99b8;
  --muted-2: #687596;
  --green: #22e0a1;
  --green-deep: #0fae7a;
  --gold: #ffd35c;
  --amber: #ffae45;
  --blue: #5b8cff;
  --out: #56607d;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 11px;
  --brand-grad: linear-gradient(120deg, #22e0a1 0%, #5b8cff 48%, #ffd35c 100%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Kanit", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ---------- Background decoration ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60% 50% at 12% 0%, rgba(34, 224, 161, 0.16), transparent 60%),
    radial-gradient(55% 50% at 92% 6%, rgba(91, 140, 255, 0.18), transparent 62%),
    radial-gradient(70% 60% at 50% 110%, rgba(255, 211, 92, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg) 60%);
}
.bg-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Hero ---------- */
.hero { padding: clamp(20px, 4vw, 40px) 16px 8px; }
.hero-inner { max-width: 1180px; margin: 0 auto; }
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand-badge {
  font-size: 40px;
  width: 66px; height: 66px;
  display: grid; place-items: center;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.08);
  filter: drop-shadow(0 4px 12px rgba(255, 211, 92, 0.35));
}
.brand-text h1 {
  margin: 0;
  font-size: clamp(26px, 4.6vw, 42px);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.05;
}
.grad {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { margin: 4px 0 0; color: var(--muted); font-size: clamp(13px, 2.2vw, 15px); font-weight: 300; }

.hosts {
  display: flex; align-items: center; gap: 6px;
  font-size: 26px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
}
.hosts small { font-size: 12px; color: var(--muted); margin-left: 4px; font-weight: 400; }

/* ---------- Champion bar ---------- */
.champ-bar {
  margin: 22px 0 4px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: linear-gradient(100deg, rgba(255, 211, 92, 0.12), rgba(91, 140, 255, 0.08));
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.champ-bar-label { color: var(--muted); font-size: 13px; font-weight: 400; }
.champ-bar-team {
  font-size: clamp(17px, 3vw, 21px);
  font-weight: 700;
  display: inline-flex; align-items: center; gap: 9px;
}
.champ-bar-team .flag { font-size: 1.25em; }

/* ---------- Toolbar ---------- */
.toolbar {
  margin-top: 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.btn {
  appearance: none; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--border-2);
  padding: 10px 16px;
  border-radius: 12px;
  transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease;
}
.btn:hover { transform: translateY(-2px); background: rgba(255,255,255,0.11); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--brand-grad);
  color: #05210f;
  font-weight: 700;
  border: none;
  box-shadow: 0 10px 26px -10px rgba(34, 224, 161, 0.6);
}
.btn-primary:hover { background: var(--brand-grad); filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.progress { margin-left: auto; color: var(--muted); font-size: 13px; }
.progress b { color: var(--green); font-weight: 600; }

/* ---------- Stepper ---------- */
.stepper {
  position: sticky; top: 0; z-index: 30;
  margin: 18px auto 0;
  max-width: 1180px;
  display: flex; gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(7, 11, 22, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.stepper::-webkit-scrollbar { display: none; }
.step {
  flex: 0 0 auto;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 1px;
  padding: 8px 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  transition: all 0.16s ease;
  min-width: 96px;
}
.step:hover { color: var(--text); border-color: var(--border-2); }
.step.active {
  background: var(--brand-grad);
  color: #061b10;
  border-color: transparent;
  box-shadow: 0 8px 22px -10px rgba(91, 140, 255, 0.7);
}
.step.active .step-sub { color: rgba(6, 27, 16, 0.7); }
.step-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.step-sub { font-size: 11px; color: var(--muted-2); font-weight: 300; }
.step .done-dot { display: none; }

/* ---------- Main ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}
.view-head { margin: 6px 2px 18px; }
.view-head h2 { margin: 0; font-size: clamp(20px, 3.4vw, 27px); font-weight: 700; }
.view-head p { margin: 5px 0 0; color: var(--muted); font-weight: 300; font-size: 14px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.q { background: var(--green); }
.dot.t { background: var(--amber); }
.dot.o { background: var(--out); }

/* ---------- Group cards ---------- */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.group-card .gc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.gc-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.gc-letter {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-grad); color: #05210f; font-weight: 800; font-size: 14px;
}
.gc-hint { font-size: 11.5px; color: var(--muted-2); font-weight: 300; }

.team-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  position: relative;
  transition: background 0.15s ease;
}
.team-row:last-child { border-bottom: none; }
.team-row.q { background: linear-gradient(90deg, rgba(34,224,161,0.10), transparent 70%); }
.team-row.t { background: linear-gradient(90deg, rgba(255,174,69,0.10), transparent 70%); }
.team-row.o { opacity: 0.62; }
.pos {
  width: 24px; height: 24px; flex: 0 0 auto;
  border-radius: 7px; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
  background: rgba(255,255,255,0.07); color: var(--muted);
}
.team-row.q .pos { background: rgba(34,224,161,0.2); color: var(--green); }
.team-row.t .pos { background: rgba(255,174,69,0.2); color: var(--amber); }
.flag { font-size: 22px; line-height: 1; flex: 0 0 auto; }
img.flag {
  height: 1em; width: auto; border-radius: 3px;
  object-fit: cover; vertical-align: middle; display: inline-block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.4);
  background: rgba(255, 255, 255, 0.06);
}
.flag-none {
  display: inline-grid; place-items: center;
  height: 1em; min-width: 1.3em; padding: 0 3px;
  font-size: 0.5em; font-weight: 700; color: var(--muted);
  border-radius: 3px; background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
/* per-context flag sizing (img.flag carries base .flag font-size, override where needed) */
.team-row > .flag { font-size: 25px; }
.third-chip .flag { font-size: 19px; }
.path-row .flag { font-size: 21px; }
.hosts .flag { font-size: 26px; }
.champ-bar-team .flag { font-size: 23px; border-radius: 4px; }
.tinfo { min-width: 0; flex: 1; }
.tname { font-weight: 500; font-size: 14.5px; display: flex; align-items: center; gap: 7px; }
.tname .tag {
  font-size: 9.5px; font-weight: 500; color: var(--muted);
  background: rgba(255,255,255,0.07); padding: 1px 6px; border-radius: 5px; white-space: nowrap;
}
.tmeta { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.ptsbar { flex: 1; height: 4px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; max-width: 110px; }
.ptsbar > i { display: block; height: 100%; background: var(--green-deep); border-radius: 3px; }
.team-row.o .ptsbar > i { background: var(--out); }
.pts { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.status-pill { font-size: 10.5px; font-weight: 500; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status-pill.q { color: var(--green); background: rgba(34,224,161,0.13); }
.status-pill.t { color: var(--amber); background: rgba(255,174,69,0.13); }
.status-pill.o { color: var(--muted-2); background: rgba(255,255,255,0.05); }

.arrows { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.arrows button {
  width: 24px; height: 17px; cursor: pointer;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.06); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 9px; line-height: 1; transition: all 0.13s;
}
.arrows button:hover:not(:disabled) { background: var(--card-2); color: var(--text); border-color: var(--border-2); }
.arrows button:disabled { opacity: 0.25; cursor: default; }

/* ---------- Third place panel ---------- */
.thirds {
  margin-top: 22px;
}
.thirds .card { padding: 16px 18px; }
.thirds h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.thirds .sub { margin: 0 0 14px; font-size: 13px; color: var(--muted); font-weight: 300; }
.third-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px;
}
.third-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: 10px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  font-size: 13px;
}
.third-chip.adv { border-color: rgba(34,224,161,0.4); background: rgba(34,224,161,0.08); }
.third-chip .rank { font-size: 11px; color: var(--muted-2); width: 18px; }
.third-chip.adv .rank { color: var(--green); }
.third-chip .grp { margin-left: auto; font-size: 10.5px; color: var(--muted-2); }

/* ---------- Knockout ---------- */
.match-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px;
}
.match {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow);
}
.match-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 13px; font-size: 11px; color: var(--muted-2);
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.02);
}
.match-head .picked-tag { color: var(--blue); font-weight: 500; }
.match-head .ai-tag { color: var(--green); font-weight: 500; }
.slot {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.14s ease;
  position: relative;
}
.slot:last-child { border-bottom: none; }
.slot:hover { background: rgba(255,255,255,0.045); }
.slot.win { background: linear-gradient(90deg, rgba(34,224,161,0.14), transparent 75%); }
.slot.lose { opacity: 0.5; }
.slot .flag { font-size: 24px; }
.slot .sname { font-weight: 500; font-size: 15px; flex: 1; min-width: 0; }
.slot .sname .ref { font-size: 10px; color: var(--muted-2); font-weight: 300; display:block; }
.winprob {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto;
  min-width: 60px;
}
.winprob .pct { font-size: 13px; font-weight: 600; color: var(--muted); }
.slot.win .winprob .pct { color: var(--green); }
.probbar { width: 56px; height: 4px; border-radius: 3px; background: rgba(255,255,255,0.09); overflow: hidden; }
.probbar > i { display: block; height: 100%; background: var(--green-deep); }
.check {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 12px;
  border: 1.5px solid var(--border-2); color: transparent;
}
.slot.win .check { background: var(--green); border-color: var(--green); color: #052114; font-weight: 800; }
.ai-badge {
  font-size: 9px; font-weight: 600; color: var(--green);
  background: rgba(34,224,161,0.14); padding: 1px 5px; border-radius: 5px;
}

/* ---------- Final / champion ---------- */
.final-stage { display: grid; gap: 22px; }
.bracket-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.bracket-mini .col h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 500; text-align: center; }
.champion-card {
  text-align: center;
  padding: 34px 22px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(80% 120% at 50% -10%, rgba(255,211,92,0.22), transparent 60%),
    var(--card);
  border: 1px solid rgba(255,211,92,0.35);
  position: relative; overflow: hidden;
}
.champion-card .crown { font-size: 52px; filter: drop-shadow(0 6px 16px rgba(255,211,92,0.5)); }
.champion-card .c-label { color: var(--gold); font-size: 14px; letter-spacing: 2px; margin-top: 6px; font-weight: 500; }
.champion-card .c-flag { font-size: 76px; line-height: 0; margin: 10px 0 4px; }
.champion-card .c-flag .flag { font-size: 88px; border-radius: 9px; }
.champion-card .c-name { font-size: clamp(28px, 6vw, 44px); font-weight: 800; }
.champion-card .c-name.placeholder { color: var(--muted-2); font-weight: 500; font-size: 22px; }
.podium { display: flex; justify-content: center; gap: 26px; margin-top: 18px; flex-wrap: wrap; }
.podium .p { text-align: center; }
.podium .p .pf { font-size: 32px; line-height: 0; }
.podium .p .pf .flag { font-size: 36px; border-radius: 5px; }
.podium .p .pl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.podium .p .pn { font-size: 14px; font-weight: 600; }

.final-match { max-width: 460px; margin: 0 auto; width: 100%; }
.final-match .match-head { font-size: 13px; color: var(--gold); }

.path-card { padding: 16px 18px; }
.path-card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.path-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.path-row:last-child { border-bottom: none; }
.path-row .pr-round { width: 86px; color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.path-row .pr-beat { color: var(--muted-2); font-size: 12px; }

/* ---------- Toast & confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,26,44,0.96); border: 1px solid var(--border-2);
  color: var(--text); padding: 11px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: all 0.3s ease; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.confetti-wrap { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti-piece { position: absolute; width: 9px; height: 14px; top: -20px; will-change: transform; }

/* ---------- Footer ---------- */
.foot { max-width: 1180px; margin: 0 auto; padding: 22px 16px 40px; text-align: center; color: var(--muted-2); font-size: 12.5px; font-weight: 300; }
.foot p { margin: 3px 0; }
.foot-dim { opacity: 0.65; }

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.enter > .view-head { animation: fadeUp 0.4s ease both; }
.enter .group-grid > *, .enter .match-grid > *, .enter .final-stage > * { animation: fadeUp 0.4s ease both; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .brand-badge { width: 54px; height: 54px; font-size: 32px; }
  .hosts { font-size: 22px; padding: 6px 11px; }
  .group-grid, .match-grid { grid-template-columns: 1fr; }
  .toolbar .btn { flex: 1; justify-content: center; }
  .progress { width: 100%; margin: 4px 0 0; text-align: center; }
  .bracket-mini { grid-template-columns: 1fr; }
}
