/* =====================================================
   BASE
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a0a1a;
  color: #e8e8f0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* =====================================================
   NAV
   ===================================================== */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-logo {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.nav-logo span { color: #FFD700; }

.btn-podium {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: #fff;
  border: none;
  padding: 0.55rem 1.4rem;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(240, 93, 251, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-podium:hover  { transform: translateY(-2px); box-shadow: 0 7px 22px rgba(240,93,251,0.65); }
.btn-podium:active { transform: translateY(0); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

/* Daily Podium — cooler blue/teal to distinguish from the final reveal */
.btn-daily {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  box-shadow: 0 4px 18px rgba(79, 172, 254, 0.45);
}
.btn-daily:hover { box-shadow: 0 7px 22px rgba(79, 172, 254, 0.65); }

.btn-podium:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
.btn-podium:disabled:hover { transform: none; box-shadow: 0 4px 18px rgba(240, 93, 251, 0.25); }

/* =====================================================
   STANDINGS
   ===================================================== */
.standings-wrapper {
  max-width: 1600px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  transition: filter 0.45s ease;
}

.standings-header {
  text-align: center;
  margin-bottom: 2rem;
}
.standings-title {
  font-size: 2.53rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.grail-icon {
  width: 1.1em;
  height: 1.1em;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(255,215,0,0.4));
}
.standings-subtitle {
  margin-top: 0.35rem;
  font-size: 1.33rem;
  color: rgba(255,255,255,0.45);
}

/* =====================================================
   TABLE SCROLL WRAPPER (enables horizontal scroll on small screens)
   ===================================================== */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* shared grid layout — rank | emoji | name | 6 days | total | change */
.table-header,
.team-row {
  display: grid;
  grid-template-columns: 3.5rem 3.5rem 1fr repeat(6, 7.5rem) 8rem 6.5rem;
  align-items: center;
  gap: 0.6rem;
  min-width: 900px;
}

/* ── Header row (same box as a data row, neutral accent) ── */
.table-header {
  padding: 1.3rem 1.5rem;
  margin-bottom: 0.75rem;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  box-shadow: inset 5px 0 0 rgba(255,255,255,0.18);
}

/* ── Day image cells ── */
.col-day-img {
  position: relative;
  height: 3.5rem;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,0.07);
  border: 1.5px dashed rgba(255,255,255,0.18);
}

/* placeholder shown until real image covers it */
.col-day-img::before {
  content: '🖼️';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  opacity: 0.3;
}

.col-day-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

/* ── Data rows ── */
.team-row {
  padding: 1.3rem 1.5rem;
  margin-bottom: 0.75rem;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  /* inset shadow: border-left shrinks content width (box-sizing), misaligning all grid columns vs the header */
  box-shadow: inset 5px 0 0 var(--tc);
  animation: slideInRow 0.45s ease both;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.team-row:hover             { background: rgba(255,255,255,0.09); transform: translateX(5px); }
.team-row[data-rank="1"]    { background: rgba(255,215,0,0.07); box-shadow: inset 7px 0 0 var(--tc); }

.col-rank   { font-size: 2rem; }
.col-emoji  { font-size: 2rem; }
.col-name   { font-size: 1.35rem; font-weight: 700; }
.col-day    { font-size: 1.5rem; font-weight: 600; text-align: center; color: rgba(255,255,255,0.85); }
.col-day--empty { color: rgba(255,255,255,0.2); font-weight: 400; }
.col-total  { font-size: 1.4rem; font-weight: 800; color: #FFD700; text-align: right; }
.col-change { font-size: 1.1rem; font-weight: 700; text-align: right; }
.col-change.up   { color: #6BCB77; }
.col-change.down { color: #FF6B6B; }
.col-change.same { color: rgba(255,255,255,0.35); }

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* Medium — tighten columns and fonts */
@media (max-width: 1280px) {
  .table-header,
  .team-row {
    grid-template-columns: 3rem 3rem 1fr repeat(6, 6.5rem) 7rem 6rem;
    gap: 0.45rem;
  }
  .col-rank, .col-emoji { font-size: 1.7rem; }
  .col-name   { font-size: 1.15rem; }
  .col-day    { font-size: 1.05rem; }
  .col-total  { font-size: 1.2rem; }
  .col-change { font-size: 0.95rem; }
  .col-day-img { height: 3rem; }
}

/* Tablet — smaller padding, rely on scroll */
@media (max-width: 960px) {
  .standings-wrapper { margin: 1.5rem auto; padding: 0 1rem; }
  .table-header,
  .team-row {
    grid-template-columns: 2.6rem 2.6rem 1fr repeat(6, 5.8rem) 6.2rem 5.4rem;
    gap: 0.35rem;
    min-width: 820px;
  }
  .team-row   { padding: 1rem 1rem; border-radius: 12px; }
  .table-header { padding: 1rem 1rem; border-radius: 12px; }
  .col-rank, .col-emoji { font-size: 1.5rem; }
  .col-name   { font-size: 1.05rem; }
  .col-day    { font-size: 0.95rem; }
  .col-total  { font-size: 1.1rem; }
  .col-change { font-size: 0.85rem; }
  .col-day-img { height: 2.6rem; border-radius: 8px; }
}

/* Mobile — compact, still scrollable */
@media (max-width: 600px) {
  .standings-wrapper { padding: 0 0.5rem; }
  .standings-title   { font-size: 1.4rem; }
  .standings-subtitle { font-size: 0.85rem; }
  .btn-podium { font-size: 0.8rem; padding: 0.45rem 1rem; }
  .nav { padding: 0.75rem 1rem; }
  .table-header,
  .team-row {
    grid-template-columns: 2.2rem 2.2rem 1fr repeat(6, 5rem) 5.5rem 4.8rem;
    gap: 0.25rem;
    min-width: 720px;
  }
  .team-row   { padding: 0.85rem 0.75rem; margin-bottom: 0.5rem; }
  .table-header { padding: 0.85rem 0.75rem; margin-bottom: 0.5rem; border-radius: 10px; }
  .col-rank, .col-emoji { font-size: 1.25rem; }
  .col-name   { font-size: 0.95rem; }
  .col-day    { font-size: 0.88rem; }
  .col-total  { font-size: 1rem; }
  .col-change { font-size: 0.78rem; }
  .col-day-img { height: 2.2rem; border-radius: 6px; }
}

/* Empty / loading */
.loading, .empty-msg {
  text-align: center;
  padding: 4rem 2rem;
  color: rgba(255,255,255,0.45);
}
.empty-msg h3  { font-size: 1.3rem; margin-bottom: 1rem; }
.empty-msg pre {
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  text-align: left;
  font-size: 0.78rem;
  color: #6BCB77;
  line-height: 1.8;
  overflow-x: auto;
  margin-top: 0.75rem;
}

/* =====================================================
   CONFETTI CANVAS
   ===================================================== */
#confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3000;
  display: none;
}

/* =====================================================
   PODIUM OVERLAY
   ===================================================== */
/* Applied to nav + main while podium is open */
.podium-active .nav,
.podium-active .standings-wrapper {
  filter: brightness(0.2) blur(3px);
  pointer-events: none;
}

#podiumOverlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(5, 5, 16, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: background 0.6s ease;
}
#podiumOverlay.hidden { display: none; }

/* ── MLG fly-through images ── */
.mlg-popup {
  position: absolute;
  left: 0;
  z-index: 12;
  pointer-events: none;
  animation: mlgFly var(--dur, 1.3s) linear both;
}
.mlg-popup img {
  display: block;
  height: var(--sz, 320px);
  width: auto;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.9));
}

@keyframes mlgFly {
  0%   { transform: translateX(-300px) rotate(var(--rot-start, -6deg)); opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { transform: translateX(calc(100vw + 300px)) rotate(var(--rot-end, 6deg)); opacity: 0; }
}

/* ── Next button ── */
.btn-next {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f093fb, #f5576c);
  color: #fff;
  border: none;
  padding: 0.85rem 3.2rem;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  animation: nextGlow 1.5s ease infinite;
  transition: transform 0.1s;
  white-space: nowrap;
}
.btn-next:hover  { transform: translateX(-50%) translateY(-3px); }
.btn-next:active { transform: translateX(-50%) scale(0.95); }
.btn-next.hidden { display: none; }

@keyframes nextGlow {
  0%, 100% { box-shadow: 0 4px 18px rgba(240,93,251,0.45); }
  50%       { box-shadow: 0 4px 38px rgba(240,93,251,0.85); }
}

/* ── Wow popup ── */
.wow-popup {
  position: absolute;
  top: 40%;
  left: 0;
  width: 230px;
  z-index: 10;
  pointer-events: none;
}
.wow-popup img {
  width: 100%;
  border-radius: 14px;
  border: 3px solid #FFD700;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
  display: block;
}
.wow-popup.hidden { display: none; }
.wow-popup:not(.hidden) { animation: wowFlyThrough 3.2s ease-in-out forwards; }

@keyframes wowFlyThrough {
  0%   { transform: translate(-280px,  140px) rotate(-22deg) scale(0.45); opacity: 0; }
  7%   { opacity: 1; }
  45%  { transform: translate(calc(50vw - 115px), -160px) rotate(8deg)  scale(1.25); opacity: 1; }
  93%  { opacity: 1; }
  100% { transform: translate(calc(100vw + 280px), -80px)  rotate(28deg) scale(0.6);  opacity: 0; }
}

#podiumStage {
  width: 100%;
  max-width: 1400px;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* ── Intro title ── */
.intro-title {
  font-size: clamp(3.6rem, 10vw, 7rem);
  font-weight: 900;
  text-align: center;
  color: #fff;
  animation: pulseScale 1.4s ease infinite;
}

/* ── Start gate button ── */
.btn-start {
  display: block;
  margin: 2.5rem auto 0;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  color: #fff;
  border: none;
  padding: 1rem 4rem;
  border-radius: 50px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  animation: nextGlow 1.5s ease infinite;
}
.btn-start:hover  { transform: translateY(-3px); }
.btn-start:active { transform: scale(0.95); }

/* ── Countdown ── */
.countdown-num {
  font-size: clamp(12rem, 44vw, 28rem);
  font-weight: 900;
  color: #FFD700;
  text-shadow: 0 0 60px rgba(255,215,0,0.55);
  animation: popIn 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  line-height: 1;
  user-select: none;
}

/* ── Reveal screen (one team, full stage) ── */
.reveal-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  text-align: center;
  width: 100%;
}

.rv-day-banner {
  width: 100%;
  max-width: 490px;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  animation: slideUp 0.5s ease both;
}

.rv-rank {
  font-size: clamp(5.5rem, 21vw, 12rem);
  line-height: 1;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.rv-headline {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
}

.rv-mascot {
  font-size: clamp(3rem, 10vw, 5rem);
  animation: bounceIn 0.6s 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.rv-name {
  font-size: clamp(3.6rem, 12vw, 6.4rem);
  font-weight: 900;
  color: var(--tc);
  text-shadow: 0 0 28px var(--tc);
  animation: slideUp 0.45s 0.15s ease both;
}

.rv-pts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  animation: slideUp 0.45s 0.3s ease both;
}
.rv-today { font-size: clamp(2.2rem, 8vw, 3.8rem); font-weight: 800; color: #6BCB77; }
.rv-total { font-size: clamp(1.7rem, 6vw, 2.4rem); color: rgba(255,255,255,0.55); }

.rv-change {
  font-size: clamp(1.9rem, 6vw, 2.8rem);
  font-weight: 700;
  animation: slideUp 0.45s 0.45s ease both;
}
.rv-change.up   { color: #6BCB77; }
.rv-change.down { color: #FF6B6B; }
.rv-change.same { color: rgba(255,255,255,0.4); }

.rv-reaction {
  font-size: clamp(1.7rem, 5.6vw, 2.3rem);
  color: rgba(255,255,255,0.65);
  animation: slideUp 0.45s 0.6s ease both;
}

.rv-winner-badge {
  font-size: clamp(3rem, 10vw, 5rem);
  animation: bounceIn 0.7s 0.85s ease both;
}

/* ── Final standings board ── */
.final-board { width: 100%; }

.final-title {
  font-size: 1.7rem;
  font-weight: 900;
  text-align: center;
  color: #FFD700;
  margin-bottom: 1rem;
  animation: slideUp 0.4s ease both;
}

.final-card {
  display: grid;
  grid-template-columns: 3rem 3rem 1fr auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1.2rem;
  margin-bottom: 0.5rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border-left: 5px solid var(--tc);
  animation: slideInRow 0.4s ease both;
}
.final-card[data-rank="1"] {
  background: rgba(255,215,0,0.09);
  border-left-width: 7px;
  box-shadow: 0 0 22px rgba(255,215,0,0.15);
}

.fc-rank, .fc-emoji { font-size: 1.4rem; }
.fc-name { font-size: 1.05rem; font-weight: 700; }
.fc-pts  { font-size: 1.1rem; font-weight: 800; color: #FFD700; }

.btn-close {
  display: block;
  margin: 1.4rem auto 0;
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  padding: 0.55rem 2.2rem;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  animation: slideUp 0.4s 0.5s ease both;
}
.btn-close:hover { background: rgba(255,255,255,0.16); }

/* =====================================================
   KEYFRAMES
   ===================================================== */
@keyframes slideInRow {
  from { transform: translateX(-50px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(28px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes popIn {
  0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.18) rotate(4deg); }
  80%  { transform: scale(0.95) rotate(-1deg); }
  100% { transform: scale(1) rotate(0);        opacity: 1; }
}

@keyframes bounceIn {
  0%   { transform: scale(0); opacity: 0; }
  55%  { transform: scale(1.25); }
  80%  { transform: scale(0.92); }
  100% { transform: scale(1);    opacity: 1; }
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.04); opacity: 0.88; }
}

@keyframes shakeWild {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  15%     { transform: translate(-12px, 4px) rotate(-3deg); }
  30%     { transform: translate(14px, -5px) rotate(3deg); }
  45%     { transform: translate(-10px, 6px) rotate(-2deg); }
  60%     { transform: translate(10px, -4px) rotate(2deg); }
  75%     { transform: translate(-6px, 3px) rotate(-1deg); }
  90%     { transform: translate(6px, -2px) rotate(1deg); }
}

@keyframes flashColor {
  0%, 100% { opacity: 0; }
  10%, 90% { opacity: 1; }
}

.shake { animation: shakeWild 0.65s ease; }
