:root {
  --bg: #0a0a0f;
  --card-bg: #141420;
  --green: #22c55e;
  --green-dark: #16a34a;
  --green-glow: rgba(34, 197, 94, 0.35);
  --orange: #f59e0b;
  --orange-glow: rgba(245, 158, 11, 0.35);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.35);
  --gray: #6b7280;
  --text: #ffffff;
  --text-dim: #9ca3af;
  --text-muted: #6b7280;
  --ring: #52525b;
  --ring-light: #71717a;
  --border: rgba(255,255,255,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

h1, h2, h3, h4, .score-text, .stat-value {
  font-family: 'Space Grotesk', sans-serif;
}

#app {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* ===== GAME SCREEN ===== */
.game-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  padding: 8px 10px;
  position: relative;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  z-index: 10;
  flex-shrink: 0;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  font-family: 'Space Grotesk', sans-serif;
}

.stat-pill .icon { font-size: 14px; }

.stat-pill.score-pill .value { color: var(--text); }
.stat-pill.timer-pill .value { color: var(--text); }
.stat-pill.timer-pill.urgent .value { color: var(--red); }
.stat-pill.best-pill .value { color: var(--text); }

.ad-indicator {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

/* Billboard */
.billboard {
  flex: 1;
  border-radius: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 6px 0;
  min-height: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.05);
  transition: background 0.6s ease;
}

.billboard-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: opacity 0.6s ease;
}

.billboard-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 24px 20px;
}

.ad-info {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  text-align: center;
}

.ad-icon { font-size: 36px; margin-bottom: 4px; }

.ad-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  letter-spacing: -0.5px;
}

.ad-tagline {
  font-size: 18px;
  font-weight: 600;
  opacity: 0.9;
  margin-top: 2px;
}

.ad-subtitle {
  font-size: 14px;
  opacity: 0.7;
  margin-top: 4px;
}

.ad-category {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  margin-top: 8px;
  letter-spacing: 0.5px;
}

/* Zone indicators on billboard */
.zone-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 10px;
  z-index: 5;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 1px;
  animation: zone-pulse 0.8s ease-in-out infinite;
}

.zone-banner.warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--orange);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.zone-banner.danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

@keyframes zone-pulse {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.05); }
}

/* Game Button */
.game-button-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.button-ring {
  position: absolute;
  width: 196px;
  height: 196px;
  border-radius: 50%;
  border: 7px solid var(--ring);
  pointer-events: none;
  transition: border-color 0.3s;
}

.button-ring.warning { border-color: var(--orange); }
.button-ring.danger { border-color: var(--red); }
.button-ring.lockout { border-color: var(--gray); }

.game-button {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  color: white;
  position: relative;
  transition: transform 0.08s, box-shadow 0.3s, background 0.3s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 2;
}

.game-button.idle {
  background: radial-gradient(circle at 40% 35%, #4ade80, var(--green), var(--green-dark));
  box-shadow: 0 0 40px var(--green-glow), 0 6px 20px rgba(0,0,0,0.3), inset 0 -4px 8px rgba(0,0,0,0.2);
}

.game-button.playing {
  background: radial-gradient(circle at 40% 35%, #4ade80, var(--green), var(--green-dark));
  box-shadow: 0 0 30px var(--green-glow), 0 4px 16px rgba(0,0,0,0.3), inset 0 -4px 8px rgba(0,0,0,0.2);
}

.game-button.warning {
  background: radial-gradient(circle at 40% 35%, #fbbf24, var(--orange), #d97706);
  box-shadow: 0 0 40px var(--orange-glow), 0 4px 16px rgba(0,0,0,0.3), inset 0 -4px 8px rgba(0,0,0,0.2);
}

.game-button.danger {
  background: radial-gradient(circle at 40% 35%, #f87171, var(--red), #dc2626);
  box-shadow: 0 0 40px var(--red-glow), 0 4px 16px rgba(0,0,0,0.3), inset 0 -4px 8px rgba(0,0,0,0.2);
}

.game-button.lockout {
  background: radial-gradient(circle at 40% 35%, #9ca3af, var(--gray), #4b5563);
  box-shadow: 0 0 10px rgba(107,114,128,0.2), inset 0 -4px 8px rgba(0,0,0,0.2);
  cursor: not-allowed;
}

.game-button:active:not(.lockout) {
  transform: scale(0.93);
}

.btn-icon {
  font-size: 28px;
  margin-bottom: 2px;
}

.btn-label {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.btn-score {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
}

.btn-sublabel {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Tap feedback */
.tap-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple 0.4s ease-out;
  pointer-events: none;
}

@keyframes ripple {
  to { transform: scale(2.5); opacity: 0; }
}

/* Float score */
.float-score {
  position: absolute;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: 24px;
  pointer-events: none;
  animation: float-up 0.6s ease-out forwards;
  z-index: 10;
}

.float-score.bonus { color: var(--orange); font-size: 28px; }
.float-score.normal { color: rgba(255,255,255,0.9); }

@keyframes float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* Visit Link */
.visit-link {
  position: absolute;
  bottom: 14px;
  left: 14px;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 12px;
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  transition: color 0.2s, background 0.2s;
  z-index: 2;
}

.visit-link:hover { color: white; background: rgba(0,0,0,0.5); }

/* Ad Dots */
.ad-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 6px 0;
  flex-shrink: 0;
}

.ad-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: background 0.3s, transform 0.3s;
}

.ad-dot.active {
  background: var(--green);
  transform: scale(1.2);
}

/* Leaderboard Ticker */
.ticker-wrap {
  overflow: hidden;
  padding: 6px 0;
  flex-shrink: 0;
}

.ticker {
  display: flex;
  gap: 20px;
  animation: ticker-scroll 25s linear infinite;
  white-space: nowrap;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.ticker-item .medal { font-size: 15px; }
.ticker-item .t-score {
  color: var(--green);
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ===== SCORE POPUP ===== */
.score-popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.popup-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 36px 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  border: 1px solid var(--border);
  animation: pop-in 0.3s ease;
  position: relative;
}

.popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 16px;
  transition: background 0.2s;
}

.popup-close:hover { background: rgba(255,255,255,0.15); }

@keyframes pop-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.popup-card h2 {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}

.popup-score {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 68px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}

.popup-high {
  color: var(--green);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.popup-rank {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.popup-btn {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: transform 0.1s;
}

.popup-btn:active { transform: scale(0.97); }

.popup-btn.primary {
  background: var(--green);
  color: white;
  margin-bottom: 8px;
}

.popup-btn.secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

/* ===== HAMBURGER MENU ===== */
.hamburger {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 200;
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  transition: background 0.2s;
}

.hamburger:hover { background: rgba(255,255,255,0.12); }

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.nav-overlay.open { opacity: 1; pointer-events: auto; }

.nav-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 280px;
  background: var(--card-bg);
  z-index: 190;
  padding: 70px 24px 24px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.nav-menu.open { transform: translateX(0); }

.nav-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--green);
}

.nav-brand span { color: var(--text); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: color 0.2s;
  cursor: pointer;
}

.nav-link:hover { color: var(--green); }
.nav-link .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.nav-user {
  margin-top: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
}

.nav-user-email {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.nav-user-stats {
  display: flex;
  gap: 16px;
}

.nav-user-stat {
  font-size: 12px;
  color: var(--text-dim);
}

.nav-user-stat strong {
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
}

.nav-logout {
  margin-top: 12px;
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--red);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.nav-logout:hover { background: rgba(239, 68, 68, 0.2); }

/* ===== AUTH MODAL ===== */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  animation: fade-in 0.3s ease;
}

.auth-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 32px 28px;
  max-width: 380px;
  width: 92%;
  border: 1px solid var(--border);
  animation: pop-in 0.3s ease;
}

.auth-card h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.auth-card .auth-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--green); }

.form-input::placeholder { color: var(--text-muted); }

.form-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
  min-height: 18px;
}

.btn {
  padding: 13px 24px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: transform 0.1s, opacity 0.2s;
  text-align: center;
  display: inline-block;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-green { background: var(--green); color: white; width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 8px;
}

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-dim);
}

.auth-toggle a {
  color: var(--green);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}

.auth-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 18px;
  border: none;
  transition: background 0.2s;
}

.auth-close:hover { background: rgba(255,255,255,0.15); }

/* ===== PAGE LAYOUTS ===== */
.page {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  padding: 56px 16px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-header {
  margin-bottom: 24px;
}

.back-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.back-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  margin-top: 2px;
  transition: background 0.2s;
}

.back-btn:hover { background: rgba(255,255,255,0.14); }

.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.page-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
}

/* Leaderboard */
.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.lb-tab {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  border: none;
  font-family: 'Inter', sans-serif;
  transition: background 0.2s, color 0.2s;
}

.lb-tab.active { background: var(--green); color: white; }

.lb-list { display: flex; flex-direction: column; gap: 6px; }

.lb-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  gap: 12px;
  transition: background 0.2s;
}

.lb-row:hover { background: rgba(255,255,255,0.06); }

.lb-rank {
  width: 36px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
}

.lb-rank.gold { color: #fbbf24; }
.lb-rank.silver { color: #d1d5db; }
.lb-rank.bronze { color: #d97706; }

.lb-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
  font-family: 'Space Grotesk', sans-serif;
}

.lb-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.lb-alltime-banner {
  background: linear-gradient(135deg, rgba(34,197,94,0.1), rgba(34,197,94,0.05));
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.lb-alltime-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--green);
  font-weight: 700;
  margin-bottom: 4px;
}

.lb-alltime-score {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 36px;
  font-weight: 800;
  color: var(--green);
}

/* About, Advertise, Race, Admin pages */
.content-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 16px;
}

.content-card h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.content-card p {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--green);
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Race mode */
.room-code-display {
  font-family: 'Space Grotesk', monospace;
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 8px;
  text-align: center;
  color: var(--green);
  padding: 24px;
  background: rgba(34,197,94,0.08);
  border: 2px dashed rgba(34,197,94,0.3);
  border-radius: 16px;
  margin-bottom: 16px;
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== VIEWPORT LOCK ===== */
body.game-active {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-height: 600px) {
  .game-button { width: 140px; height: 140px; }
  .button-ring { width: 156px; height: 156px; }
  .btn-score { font-size: 40px; }
  .ad-info { top: 12px; }
  .ad-brand { font-size: 20px; }
  .ad-tagline { font-size: 15px; }
}

@media (min-width: 481px) {
  .game-screen, .page {
    padding-left: 24px;
    padding-right: 24px;
  }
}
