/* ==========================================================================
   BALLOON FUNRIDE - 3D Endless Runner Stylesheet
   Modern Glassmorphism, Retro Arcade Aesthetics, Accessible & Responsive
   ========================================================================== */

:root {
  --primary-accent: #ff8e3c;
  --primary-glow: rgba(255, 142, 60, 0.45);
  --secondary-accent: #00e5ff;
  --gold-coin: #ffd700;
  --gold-glow: rgba(255, 215, 0, 0.4);
  --danger-color: #ff3366;
  --danger-glow: rgba(255, 51, 102, 0.5);
  --bg-dark: #0d0f18;
  --surface-glass: rgba(22, 26, 42, 0.78);
  --surface-glass-border: rgba(255, 255, 255, 0.12);
  --text-main: #f0f4f8;
  --text-muted: #9ba5b7;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Impact", "Arial Black", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-stack);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ==========================================================================
   Canvas & World Container
   ========================================================================== */
#game-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ==========================================================================
   HUD Overlay (Top Layer)
   ========================================================================== */
.hud-layer {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.glass-pill {
  pointer-events: auto;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-glass-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

/* Player Badge */
.player-badge {
  padding: 5px 14px 5px 6px;
}

.player-badge img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #394263;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.player-info {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  line-height: 1.2;
}

.player-account {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-pill-action {
  background: #d8fd71;
  color: #12141d;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 9999px;
  transition: transform 0.1s ease, background-color 0.1s ease;
}

.btn-pill-action:hover {
  background: #e5ff8a;
  transform: scale(1.04);
}

/* HUD Stats */
.hud-stats-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-badge {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.5px;
}

.coin-icon {
  font-size: 18px;
  filter: drop-shadow(0 0 6px var(--gold-glow));
}

.dist-icon {
  font-size: 18px;
}

.stat-coins .stat-value {
  color: #ffe066;
}

.stat-distance .stat-value {
  color: #69db7c;
}

.stat-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: -4px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--surface-glass-border);
  background: var(--surface-glass);
  color: var(--text-main);
  font-size: 18px;
}

.icon-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* ==========================================================================
   Burner Flight Gauge
   ========================================================================== */
.flight-gauge-container {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
  opacity: 0.85;
}

.burner-indicator {
  width: 140px;
  height: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.burner-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff922b, #ff4d4d, #ffea79);
  box-shadow: 0 0 12px rgba(255, 110, 30, 0.8);
  transition: width 0.08s ease-out;
}

.burner-status-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ==========================================================================
   Hazard Warning Indicators
   ========================================================================== */
.hazard-warnings-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 60px;
  pointer-events: none;
  z-index: 9;
}

.hazard-warning-pill {
  position: absolute;
  right: 12px;
  width: 36px;
  height: 36px;
  background: var(--danger-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 0 16px var(--danger-glow);
  animation: pulseWarning 0.35s infinite alternate ease-in-out;
}

@keyframes pulseWarning {
  from { transform: scale(0.9); opacity: 0.8; }
  to { transform: scale(1.15); opacity: 1; }
}

/* ==========================================================================
   Modals & Overlay Screens
   ========================================================================== */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 18, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: rgba(18, 22, 36, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(255, 142, 60, 0.1);
  padding: 32px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Title & Logo */
.game-logo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.balloon-badge-icon {
  font-size: 48px;
  filter: drop-shadow(0 6px 16px rgba(255, 142, 60, 0.5));
  animation: gentleFloat 3s ease-in-out infinite alternate;
}

@keyframes gentleFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.game-title {
  font-family: var(--font-display);
  font-size: 42px;
  line-height: 0.95;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
}

.title-highlight {
  color: var(--primary-accent);
  background: linear-gradient(135deg, #ffc078, #ff8e3c, #ff4d4d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-tagline {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* How to Play Grid */
.how-to-play-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
}

.tip-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tip-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.tip-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tip-text strong {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
}

.tip-text span {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.25;
}

/* Style Preview Box */
.style-preview-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 9999px;
  font-size: 12px;
  color: #adb5bd;
}

.style-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #20c997;
  box-shadow: 0 0 8px #20c997;
}

/* Primary Glow Button */
.btn-primary-glow {
  background: linear-gradient(135deg, #ff922b, #ff6b6b);
  border: none;
  border-radius: 16px;
  padding: 16px 32px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 10px 24px rgba(255, 107, 107, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  width: 100%;
}

.btn-primary-glow:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 14px 30px rgba(255, 107, 107, 0.55);
}

.btn-primary-glow:active {
  transform: translateY(1px);
}

.btn-primary-glow .btn-text {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 1.5px;
}

.btn-primary-glow .btn-subtext {
  font-size: 11px;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Game Over Dialog (Modern Top-Layer Pattern)
   ========================================================================== */
.game-over-dialog {
  border: none;
  background: transparent;
  padding: 16px;
  max-width: 560px;
  width: 100%;
  margin: auto;
  overflow: visible;
  transition: opacity 0.3s ease, transform 0.3s ease, overlay 0.3s ease allow-discrete, display 0.3s ease allow-discrete;
}

.game-over-dialog::backdrop {
  background: rgba(8, 10, 18, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color 0.3s ease, overlay 0.3s ease allow-discrete, display 0.3s ease allow-discrete;
}

.game-over-dialog[open] {
  opacity: 1;
  transform: scale(1);
}

@starting-style {
  .game-over-dialog[open] {
    opacity: 0;
    transform: scale(0.92);
  }
  .game-over-dialog[open]::backdrop {
    background-color: transparent;
  }
}

.game-over-card {
  max-width: 100%;
  gap: 16px;
}

.defeat-badge {
  font-size: 38px;
}

.game-over-title {
  font-family: var(--font-display);
  font-size: 34px;
  letter-spacing: 1.5px;
  color: var(--danger-color);
  text-shadow: 0 0 20px var(--danger-glow);
}

.defeat-cause-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* Score Summary */
.score-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.summary-stat-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.summary-value {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
}

.summary-unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.summary-coin-icon {
  font-size: 22px;
}

/* Status Banner */
.status-banner {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.status-banner.improved {
  background: rgba(32, 201, 151, 0.15);
  border-color: #20c997;
  color: #38d9a9;
}

/* Leaderboard Section */
.leaderboard-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lb-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.lb-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 9999px;
  color: #ced4da;
}

.leaderboard-table-container {
  max-height: 160px;
  overflow-y: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.leaderboard-table th {
  position: sticky;
  top: 0;
  background: rgba(20, 24, 38, 0.95);
  color: var(--text-muted);
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.leaderboard-table tr.current-player {
  background: rgba(255, 142, 60, 0.18);
  font-weight: 700;
}

.leaderboard-table tr.current-player td {
  color: #ffa94d;
}

.col-rank { width: 32px; text-align: center; }
.col-dist { text-align: right; }
.col-coins { text-align: right; width: 60px; }

.lb-loading {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
}

.game-over-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-secondary-link {
  font-size: 12px;
  color: #ffc078;
  text-decoration: underline;
  padding: 4px;
}

/* ==========================================================================
   Reduced Motion Preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .game-over-dialog {
    transform: none !important;
  }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 600px) {
  .hud-layer {
    top: 10px;
    left: 10px;
    right: 10px;
  }
  .player-account {
    display: none;
  }
  .stat-badge {
    font-size: 15px;
    padding: 4px 10px;
  }
  .modal-card {
    padding: 20px 16px;
    gap: 14px;
  }
  .game-title {
    font-size: 32px;
  }
  .how-to-play-grid {
    grid-template-columns: 1fr;
  }
  .score-summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

