:root {
  --bg-dark: #0a0e1a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-gold: #fbbf24;
  --accent-pink: #f472b6;
  --accent-purple: #a855f7;
  --accent-green: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

/* Full Viewport Canvas */
#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

/* Ambient Start Screen (Full Screen View) */
.start-screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background-image: url('../assets/start_screen_ambient.jpg');
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 20px) 24px env(safe-area-inset-bottom, 28px);
  transition: opacity 0.4s ease, visibility 0.4s;
}

.start-screen-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-screen-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 40%, rgba(0, 0, 0, 0.8) 100%);
  pointer-events: none;
}

.start-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge-pill {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-pill.gold {
  color: var(--accent-gold);
  border-color: rgba(251, 191, 36, 0.35);
}

.badge-pill.status-pill {
  font-size: 0.78rem;
  transition: all 0.3s ease;
}

.badge-pill.status-pill.online {
  color: var(--accent-green);
  border-color: rgba(16, 185, 129, 0.4);
}

.badge-pill.status-pill.offline {
  color: var(--accent-gold);
  border-color: rgba(245, 158, 11, 0.5);
}

.start-title-container {
  position: relative;
  z-index: 2;
  text-align: center;
  margin-top: auto;
  margin-bottom: 30px;
}

.start-title {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 20px rgba(168, 85, 247, 0.7);
  background: linear-gradient(135deg, #ffffff, #f472b6, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.start-subtitle {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--accent-cyan);
  text-transform: uppercase;
  margin-top: 4px;
}

.start-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-launch {
  background: linear-gradient(135deg, #0284c7, #9333ea);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 18px 24px;
  border-radius: 20px;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 30px -5px rgba(147, 51, 234, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: pulse-launch 1.8s infinite ease-in-out;
}

@keyframes pulse-launch {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* In-Game HUD */
.in-game-hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 16px) 18px env(safe-area-inset-bottom, 20px);
}

.in-game-hud * {
  pointer-events: auto;
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.altitude-display {
  display: flex;
  flex-direction: column;
}

.altitude-val {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: white;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
}

.altitude-best {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.hud-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
}

.combo-banner {
  align-self: center;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  padding: 6px 16px;
  border-radius: 9999px;
  font-weight: 900;
  font-size: 0.95rem;
  animation: bounce-combo 0.3s ease;
}

@keyframes bounce-combo {
  0% { transform: scale(0.6); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-pill {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.3);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

/* Sync Toast Notification */
.sync-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 16px) + 65px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.95);
  color: white;
  padding: 10px 18px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sync-toast.hidden {
  opacity: 0;
  transform: translate(-50%, -15px);
  pointer-events: none;
}

/* Modals & Dialogs */
dialog {
  margin: auto;
  padding: 24px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  max-width: 90vw;
  width: 380px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
  z-index: 100;
}

dialog::backdrop {
  background-color: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
}

.modal-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 900;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  margin: 10px 0;
}

.lb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.88rem;
}

.lb-row.highlight {
  background: rgba(2, 132, 199, 0.25);
  border-color: var(--accent-cyan);
}

.lb-rank {
  font-weight: 800;
  color: var(--text-muted);
  width: 24px;
}
.lb-rank.gold { color: #f59e0b; }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #d97706; }

.lb-player {
  flex: 1;
  text-align: left;
  font-weight: 700;
  margin-left: 8px;
}

.lb-score {
  font-weight: 900;
  color: var(--accent-cyan);
}

/* PWA Install Banner */
.install-banner {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 65px);
  max-width: 380px;
  width: calc(100% - 32px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  left: 50%;
  transform: translateX(-50%);
}

.install-banner.hidden {
  display: none;
}
