/* World Cup 2026 Sweepstake */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #0b1426;
  --card: #14213d;
  --card-hi: #1b2c4f;
  --ink: #f1f5fb;
  --muted: #8fa3c4;
  --gold: #ffd166;
  --green: #2dd4a0;
  --red: #ff6b6b;
  --accent: #4cc9f0;
  --radius: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 500px at 20% -10%, #1d3461 0%, transparent 60%),
    radial-gradient(900px 400px at 90% 0%, #143d33 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------- Hero ---------------- */
.hero { padding: 36px 20px 0; text-align: center; }
.hero h1 {
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  letter-spacing: -0.5px;
}
.hero h1 span {
  background: linear-gradient(90deg, var(--gold), #ff9f1c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline { color: var(--muted); margin-top: 8px; font-size: 1.05rem; }
.join-btn {
  margin-top: 18px;
  font-size: 1.1rem;
  padding: 14px 30px;
  border-radius: 999px;
  box-shadow: 0 8px 26px rgba(255, 159, 28, 0.35);
  animation: glow 2.2s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 8px 26px rgba(255, 159, 28, 0.35); }
  50% { box-shadow: 0 8px 36px rgba(255, 209, 102, 0.6); }
}
.join-form { margin-top: 16px; }
.modal .join-form + .err { margin-bottom: 4px; }

/* ---------------- Ticker ---------------- */
.ticker {
  margin: 24px auto 0;
  max-width: 1100px;
  display: flex;
  align-items: stretch;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
}
.ticker-label {
  background: var(--gold);
  color: #1a1a1a;
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  display: flex; align-items: center;
  padding: 0 14px;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.ticker-track {
  flex: 1;
  padding: 10px 16px;
  overflow: hidden;
}
.ticker-move { display: flex; gap: 22px; width: max-content; }
.tick-group { display: flex; gap: 22px; }
.ticker-move.scrolling { animation: ticker-scroll var(--ticker-dur, 30s) linear infinite; }
/* -50% is half of (2 copies + 22px gap); the extra 11px makes the loop seamless */
@keyframes ticker-scroll { to { transform: translateX(calc(-50% - 11px)); } }
.ticker-track:hover .ticker-move.scrolling { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .ticker-move.scrolling { animation: none; }
  .ticker-track { overflow-x: auto; }
}
.tick-match {
  display: flex; align-items: center; gap: 7px;
  white-space: nowrap;
  font-size: 0.9rem;
  color: var(--ink);
}
.tick-match img { width: 18px; height: 18px; object-fit: contain; }
.tick-match .vs { color: var(--muted); font-size: 0.75rem; }
.tick-match .score { font-weight: 800; color: var(--gold); }
.tick-match .live {
  background: var(--red); color: #fff;
  font-size: 0.65rem; font-weight: 800;
  padding: 2px 6px; border-radius: 6px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------------- Board ---------------- */
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 28px 20px 40px; }
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.player-card {
  background: linear-gradient(160deg, var(--card-hi), var(--card));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.player-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
.player-card.out { opacity: 0.55; filter: saturate(0.4); }
.player-card.champion {
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(255, 209, 102, 0.35);
}
.rank-badge {
  position: absolute; top: 14px; right: 14px;
  font-size: 0.75rem; font-weight: 800;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  padding: 3px 9px; border-radius: 999px;
}
.player-card.r1 .rank-badge { background: var(--gold); color: #1a1a1a; }
.player-card.r2 .rank-badge { background: #c0c8d8; color: #1a1a1a; }
.player-card.r3 .rank-badge { background: #c98a5e; color: #1a1a1a; }

.card-top { display: flex; align-items: center; gap: 14px; }
.crest {
  width: 56px; height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}
.who .pname { font-size: 1.15rem; font-weight: 800; }
.who .tname { color: var(--accent); font-weight: 600; margin-top: 2px; }
.who .tname .flag { margin-right: 4px; }

.odds-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 10px 14px;
}
.odds-block { text-align: center; }
.odds-block .lbl { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.odds-block .val { font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.odds-block .val.now { color: var(--gold); }
.trend { font-size: 1.3rem; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }
.trend.flat { color: var(--muted); }

.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; font-size: 0.85rem; color: var(--muted);
  gap: 8px; flex-wrap: wrap;
}
.record b { color: var(--ink); }
.status-pill {
  font-size: 0.7rem; font-weight: 800;
  padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.status-pill.alive { background: rgba(45,212,160,0.15); color: var(--green); }
.status-pill.out { background: rgba(255,107,107,0.15); color: var(--red); }
.status-pill.champion { background: var(--gold); color: #1a1a1a; }

.next-match {
  margin-top: 10px; font-size: 0.82rem; color: var(--muted);
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px;
}
/* Keep "date v", crest+opponent, and stage as unbreakable units so long
   names (e.g. United States) wrap cleanly between them, never mid-unit. */
.next-match .when, .next-match em { white-space: nowrap; }
.next-match .opp {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.next-match img { width: 16px; height: 16px; object-fit: contain; }

/* ---------------- Empty state ---------------- */
.empty { text-align: center; padding: 80px 20px; }
.empty-ball { font-size: 4rem; animation: bounce 1.6s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
.empty h2 { margin: 18px 0 8px; }
.empty a { color: var(--accent); }

/* ---------------- Footer ---------------- */
footer {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1100px; width: 100%;
  margin: 0 auto; padding: 16px 20px 28px;
  color: var(--muted); font-size: 0.8rem;
}
.admin-link { color: var(--muted); text-decoration: none; }
.admin-link:hover { color: var(--ink); }

/* ================= Admin page ================= */
.admin-wrap { max-width: 900px; margin: 0 auto; padding: 30px 20px 60px; width: 100%; }
.panel {
  background: linear-gradient(160deg, var(--card-hi), var(--card));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
}
.panel h2 { font-size: 1.1rem; margin-bottom: 14px; }
.pin-form, .add-form { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"], input[type="password"] {
  flex: 1; min-width: 200px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: var(--ink);
  padding: 12px 14px;
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn {
  background: linear-gradient(90deg, var(--gold), #ff9f1c);
  color: #1a1a1a; font-weight: 800;
  border: none; border-radius: 10px;
  padding: 12px 22px; font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.btn:hover { transform: scale(1.04); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.ghost { background: rgba(255,255,255,0.1); color: var(--ink); }
.btn.danger { background: rgba(255,107,107,0.18); color: var(--red); padding: 8px 14px; font-size: 0.8rem; }
.btn.small { padding: 8px 14px; font-size: 0.8rem; }
.admin-bar { display: flex; justify-content: flex-end; margin-top: 20px; }
.join-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.join-status { font-size: 1rem; }
.join-status b { color: var(--gold); }
.err { color: var(--red); margin-top: 10px; font-size: 0.9rem; min-height: 1.2em; }

.admin-list { list-style: none; margin-top: 6px; }
.admin-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.admin-list li:last-child { border-bottom: none; }
.admin-list img { width: 30px; height: 30px; object-fit: contain; }
.admin-list .nm { font-weight: 700; flex: 1; }
.admin-list .joined-at {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.admin-list .tm { color: var(--accent); }
.free-count { color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
.free-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.free-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 5px 12px 5px 7px;
  font-size: 0.82rem;
}
.free-chip img { width: 18px; height: 18px; object-fit: contain; }

/* ---------------- Reveal modal ---------------- */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(5, 10, 22, 0.85);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: linear-gradient(160deg, var(--card-hi), var(--card));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  padding: 40px 50px;
  text-align: center;
  max-width: 420px; width: 92%;
  position: relative; overflow: hidden;
}
.modal .spin-crest { width: 110px; height: 110px; object-fit: contain; margin: 14px auto; display: block; }
.modal.spinning .spin-crest { animation: wobble 0.18s infinite; }
@keyframes wobble {
  0% { transform: rotate(-6deg) scale(0.95); }
  50% { transform: rotate(6deg) scale(1.05); }
  100% { transform: rotate(-6deg) scale(0.95); }
}
.modal h3 { font-size: 1.3rem; }
.modal .reveal-team { font-size: 1.6rem; font-weight: 900; color: var(--gold); margin-top: 4px; min-height: 2rem; }
.modal .reveal-odds { color: var(--muted); margin-top: 8px; min-height: 1.3em; }
.modal .btn { margin-top: 22px; }

/* ---------------- Confetti ---------------- */
.confetti {
  position: fixed;
  top: -12px;
  z-index: 60;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0.8; }
}

@media (max-width: 480px) {
  .modal { padding: 28px 22px; }
}

/* ---------------- Mobile ---------------- */
@media (max-width: 600px) {
  .hero { padding-top: 26px; }
  .tagline { font-size: 0.92rem; }
  .ticker { margin-top: 18px; }
  main { padding: 20px 14px 32px; }
  .tabs { width: 100%; margin-bottom: 20px; }
  .tab-btn { flex: 1; padding: 8px 4px; font-size: 0.8rem; }
  .board { grid-template-columns: 1fr; gap: 14px; }
  .player-card { padding: 15px; }
  .h2h-bar { grid-template-columns: 1fr; }
  .grave-grid { grid-template-columns: repeat(2, 1fr); }
  .groups-grid { gap: 12px; }
  footer { flex-direction: column; gap: 6px; text-align: center; }
}

/* ---------------- Head-to-head ⚔️ ---------------- */
.h2h-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.h2h {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, rgba(247,37,133,0.10), var(--card));
  border: 1px solid rgba(247,37,133,0.3);
  border-radius: 14px;
  padding: 12px 16px;
}
.h2h-icon { font-size: 1.3rem; flex-shrink: 0; }
.h2h-mid { flex: 1; min-width: 0; }
.h2h-names {
  font-size: 1.02rem; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.h2h-names span { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.h2h-sub {
  color: var(--muted); font-size: 0.76rem; margin-top: 2px;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap; overflow: hidden;
}
.h2h-sub img { width: 14px; height: 14px; object-fit: contain; }
.h2h-when { font-weight: 800; font-size: 0.88rem; white-space: nowrap; flex-shrink: 0; }
.h2h-when.is-live { color: var(--red); }
/* Collision course 💥 — future derby, gold instead of red */
.h2h.collision {
  background: linear-gradient(135deg, rgba(255,209,102,0.08), var(--card));
  border-color: rgba(255,209,102,0.35);
}
.h2h-when.collision-when { color: var(--gold); font-size: 0.8rem; }

/* ---------------- Honours ticker 🏅 ---------------- */
.awards-ticker { margin: 26px 0 0; max-width: none; }
.award-item { font-size: 0.84rem; }
.award-item b { color: var(--gold); font-weight: 700; }
.award-item .award-holder { color: var(--muted); }
.badge { font-size: 0.85rem; margin-left: 4px; cursor: default; }

/* ---------------- Live pulse 🔴 ---------------- */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255,107,107,0.3); }
  50% { box-shadow: 0 0 24px rgba(255,107,107,0.7); }
}
.player-card.live-now, .h2h.live-now {
  border-color: var(--red);
  animation: glowPulse 1.6s ease-in-out infinite;
}
.next-match.next-live { color: var(--red); font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .player-card.live-now, .h2h.live-now { animation: none; }
}

/* ---------------- Graveyard 🪦 ---------------- */
.graveyard { margin-top: 46px; }
.graveyard h2 {
  text-align: center; color: var(--muted);
  letter-spacing: 3px; font-size: 0.95rem;
  text-transform: uppercase; margin-bottom: 18px;
}
.grave-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.grave {
  background: linear-gradient(180deg, #232834, #1a1e27);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 70px 70px 10px 10px;
  text-align: center;
  padding: 16px 12px 14px;
  filter: saturate(0.3);
}
.grave-top {
  font-size: 0.62rem;
  letter-spacing: 3px;
  color: var(--muted);
  font-weight: 700;
}
.grave-crest { width: 28px; height: 28px; object-fit: contain; opacity: 0.5; margin-top: 8px; }
.grave-name { font-weight: 800; font-size: 0.92rem; margin-top: 5px; }
.grave-team { color: var(--muted); font-size: 0.78rem; margin-top: 1px; }
.grave-dates { color: var(--muted); font-size: 0.7rem; margin-top: 5px; letter-spacing: 1px; }
.grave-epitaph { color: var(--muted); font-style: italic; font-size: 0.74rem; margin-top: 7px; line-height: 1.35; }

/* ---------------- Tabs (segmented control) ---------------- */
.tabs {
  display: flex;
  gap: 4px;
  width: max-content;
  margin: 0 auto 26px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 4px;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  background: linear-gradient(90deg, var(--gold), #ff9f1c);
  color: #1a1a1a;
}

/* ---------------- Groups ---------------- */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.group-card {
  background: linear-gradient(160deg, var(--card-hi), var(--card));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.group-card h3 {
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.group-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.group-table th {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 700;
  padding: 4px 5px;
  text-align: center;
}
.group-table td { padding: 6px 5px; text-align: center; border-top: 1px solid rgba(255,255,255,0.05); }
.group-table .gt-team { text-align: left; }
.group-table td.gt-team { display: flex; align-items: center; gap: 7px; }
.group-table td.gt-team img { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }
.gt-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.gt-name.owned { color: var(--gold); }
.gt-pts { font-weight: 800; }
.group-table tr.qualify td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.group-table tr.maybe td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.groups-note { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 16px; }

/* ---------------- Bracket ---------------- */
.champ-banner {
  text-align: center;
  font-size: 1.15rem;
  background: linear-gradient(90deg, rgba(255,209,102,0.18), rgba(255,159,28,0.18));
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 18px;
}
.bracket-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  align-items: stretch;
  padding-bottom: 24px;
}
.round { min-width: 225px; flex: 1; display: flex; flex-direction: column; }
.round h3 {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.round-matches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.b-match {
  background: linear-gradient(160deg, var(--card-hi), var(--card));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px;
  font-size: 0.85rem;
}
.b-match.live-match { border-color: var(--red); }
.b-side { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 8px; }
.b-side.won { background: rgba(45,212,160,0.12); }
.b-side.won .b-name { color: var(--green); }
.b-side.lost { opacity: 0.45; }
.b-crest { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; text-align: center; }
.b-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-name.owned { color: var(--gold); }
.b-side.tbd .b-name { color: var(--muted); font-weight: 400; }
.b-tla { color: var(--muted); font-size: 0.68rem; }
.b-score { font-weight: 800; min-width: 14px; text-align: right; }
.b-date { text-align: center; color: var(--muted); font-size: 0.68rem; margin-top: 4px; }
.b-third { margin-top: 28px; }
.b-third h4 {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
