/* GAME CONTAINER MODAL & HUD STYLES
   Canvas must fully cover the modal; HUD is transparent overlay only. */
#gameContainerModal {
  display: none !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 99999 !important;
  background: #5a9ad4; /* matches default sky while WebGL boots */
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  /* Never use flex here — it can leave uncovered strips beside the canvas */
  flex-direction: unset;
}

#gameContainerModal.active {
  display: block !important;
}

#gameContainerModal canvas,
#gameContainerModal canvas.game-canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  z-index: 1 !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  /* avoid layout filter creating compositor gaps */
  filter: none;
}

#hud {
  position: absolute !important; /* bound to game modal, not document */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  background: transparent !important;
  overflow: hidden;
}

  #topbar {
    position:absolute; top:24px; left:0; width:100%;
    display:flex; justify-content:space-between; align-items:flex-start;
    padding:0 32px; color:#fff;
  }
  #logo {
    font-size:22px; font-weight:900; letter-spacing:4px;
    text-shadow:0 4px 12px rgba(0,0,0,0.15);
    opacity:0.95;
  }
  #score {
    text-align:right;
    text-shadow:0 4px 12px rgba(0,0,0,0.15);
  }
  #distance { font-size:36px; font-weight:800; line-height:1; }
  #distance span { font-size:16px; font-weight:500; opacity:0.8; margin-left:4px; }
  #zone { font-size:11px; font-weight:600; letter-spacing:3px; text-transform:uppercase; opacity:0.8; margin-top:6px; }

  #status {
    position:absolute; bottom:40px; left:50%; transform:translateX(-50%);
    color:#fff; font-size:15px; font-weight:600; letter-spacing:2px; opacity:0;
    transition:opacity 0.2s ease;
    text-shadow:0 2px 10px rgba(0,0,0,0.2);
    background:rgba(255,255,255,0.15); padding:10px 24px; border-radius:30px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  }
  #status.show { opacity:1; }
  #status.warning { color: #ff5555; background:rgba(255,50,50,0.25); border: 1px solid rgba(255,50,50,0.5); }

  /* WIND UI ELEMENT */
  #windBox {
    position: absolute; bottom: 40px; right: 32px;
    background: rgba(20, 30, 40, 0.4);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: 16px;
    color: #fff;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    opacity: 0;
  }
  #windBox.show { opacity: 1; }
  #windBox.danger { border-color: rgba(255, 100, 100, 0.6); background: rgba(80, 20, 20, 0.5); }
  #windTitle { font-size: 11px; font-weight: 800; letter-spacing: 3px; opacity: 0.7; margin-bottom: 4px; }
  #windArrow { font-size: 32px; font-weight: 900; margin: 8px 0; display: inline-block; transform-origin: center center; text-shadow: 0 2px 8px rgba(0,0,0,0.5); transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
  #windSpeed { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

  /* LOADING SCREEN */
  #loadingScreen {
    position:fixed; inset:0; z-index:50; display:flex; align-items:center; justify-content:center;
    background: radial-gradient(circle at 50% 30%, #1a2b3c 0%, #0d1520 100%);
    color:#fff; text-align:center; backdrop-filter: blur(10px);
  }
  #loadingScreen .panel { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: #fff; width: 400px;}
  #loadingScreen h2 { font-size: 20px; letter-spacing: 4px; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.5); margin-bottom: 20px;}

  #overlay {
    position:fixed; inset:0; z-index:30;
    display:flex; align-items:center; justify-content:center;
    background: radial-gradient(circle at 50% 30%, rgba(127,189,246,0.85) 0%, rgba(70,120,160,0.95) 100%);
    color:#1a2b3c;
    text-align:center;
    backdrop-filter: blur(10px);
    overflow-y: auto;
    padding: 20px;
  }
  #overlay.hide { display:none; }
  .panel { max-width:680px; width: 100%; padding:36px; background: rgba(255,255,255,0.7); border-radius: 24px; box-shadow: 0 24px 64px rgba(0,0,0,0.15); border: 1px solid rgba(255,255,255,0.8); text-align: left; }
  .panel h1 {
    font-size:46px; letter-spacing:6px; font-weight:900;
    color: #1a2b3c; text-align: center;
    margin-bottom:4px;
  }
  .panel .tag { opacity:0.8; font-weight: 700; font-size:13px; letter-spacing:3px; text-transform:uppercase; margin-bottom:24px; color:#2c4359; text-align: center;}
  
  .section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; color: #2a5a3a; margin-top: 16px; margin-bottom: 8px; }
  .panel p { font-size:14px; font-weight: 600; line-height:1.6; opacity:0.85; margin-bottom:10px; }

  /* CUSTOMIZATION & DASHBOARD */
  .custom-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
  .color-btn {
    padding: 10px 12px; border-radius: 12px; border: 2px solid transparent; background: #fff;
    font-weight: 800; font-size: 11px; cursor: pointer; text-align: center; color: #333;
    transition: all 0.2s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.08); position: relative;
    letter-spacing: 0.5px;
  }
  .color-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
  .color-btn.selected { border-color: #2a5a3a; box-shadow: 0 0 0 3px rgba(42,90,58,0.3); }
  .color-btn.selected::after { content: '✓'; position: absolute; top: 2px; right: 6px; font-size: 11px; font-weight: 900; }
  .color-btn.locked { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.6); }
  .color-btn.locked:hover { transform: none; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

  .color-btn[data-color="white"] { background: #ffffff; color: #1a2b3c; border-color: #cbd5e1; }
  .color-btn[data-color="kraft"] { background: #c8a774; color: #3d2b15; text-shadow: 0 1px 2px rgba(255,255,255,0.4); }
  .color-btn[data-color="blueprint"] { background: #1e3a8a; color: #ffffff; text-shadow: 0 1px 2px rgba(0,0,0,0.4); border-color: #60a5fa; }
  .color-btn[data-color="sunset"] { background: linear-gradient(135deg, #e8380d, #ff9a1f); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
  .color-btn[data-color="sakura"] { background: linear-gradient(135deg, #fce4ec, #f48fb1); color: #880e4f; text-shadow: 0 1px 2px rgba(255,255,255,0.6); }
  .color-btn[data-color="aurora"] { background: linear-gradient(135deg, #0d3b2e, #12575c 50%, #2e1065); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.4); }
  .color-btn[data-color="gold"] {
    background: linear-gradient(135deg, #b8860b 0%, #ffd700 50%, #fff8dc 100%);
    color: #3e2723; text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    box-shadow: 0 4px 16px rgba(212,175,55,0.4);
    animation: goldShimmer 3s infinite linear;
  }

  @keyframes goldShimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
  }

  #lockMsg { text-align: center; font-size: 12px; font-weight: 700; color: #b23b3b; height: 16px; margin: -6px 0 12px; opacity: 0; transition: opacity 0.2s ease; }
  #lockMsg.show { opacity: 1; }

  /* UNLOCK CELEBRATION TOAST MODAL */
  .unlock-toast-wrap {
    position: fixed; top: 32px; left: 50%; transform: translateX(-50%) translateY(-120%);
    z-index: 99999; pointer-events: none; opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .unlock-toast-wrap.show { transform: translateX(-50%) translateY(0); opacity: 1; }

  .unlock-toast-card {
    background: rgba(255, 252, 245, 0.95);
    backdrop-filter: blur(16px);
    border: 2px solid var(--sun-gold, #ffb834);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35), 0 0 30px rgba(255, 184, 52, 0.4);
    border-radius: 20px;
    padding: 20px 32px;
    text-align: center;
    color: #1b2820;
    min-width: 320px;
  }
  .unlock-badge {
    font-size: 11px; font-weight: 900; letter-spacing: 2px; text-transform: uppercase;
    color: #d97706; margin-bottom: 6px;
  }
  .unlock-toast-card h3 {
    font-family: 'Outfit', sans-serif; font-size: 22px; font-weight: 900; margin-bottom: 4px;
    color: #1b2820;
  }
  .unlock-toast-card p {
    font-size: 13px; font-weight: 600; opacity: 0.8; margin: 0;
  }

  .dashboard-stats {
    background: rgba(0,0,0,0.04); padding: 12px 16px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 8px;
  }
  .stat-item { text-align: center; flex: 1; }
  .stat-val { font-size: 18px; font-weight: 900; color: #1a2b3c; }
  .stat-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; opacity: 0.6; }

  #greeting { font-size: 15px; font-weight: 700; color: #1a2b3c; text-align: center; margin-bottom: 16px; opacity: 0.85; }

  #unlockProgressWrap { margin-bottom: 20px; }
  #unlockProgressLabel { font-size: 11px; font-weight: 700; opacity: 0.7; margin-bottom: 6px; text-align: center; }
  .progress-track { width: 100%; height: 8px; border-radius: 4px; background: rgba(0,0,0,0.08); overflow: hidden; }
  .progress-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2a5a3a, #4caf7d); transition: width 0.4s ease; }

  /* Audio Controls UI (Guide & Music Toggles) */
  #audioControls { pointer-events: auto; background: rgba(20, 30, 40, 0.85); backdrop-filter: blur(12px); border-radius: 12px; padding: 12px; margin-top: 12px; display: none; border: 1px solid rgba(255,255,255,0.2); box-shadow: 0 8px 24px rgba(0,0,0,0.25); width: 150px; }
  #audioControls.show { display: block; }
  .audio-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #fff;}
  .audio-btn-toggle { background: #ff5555; border: none; color: white; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 10px; transition: background 0.2s; }
  .audio-btn-toggle.active { background: #4caf7d; }

  #audioBtn {
    pointer-events: auto; cursor: pointer; background: rgba(255,255,255,0.15); border: none;
    color: #fff; font-size: 14px; font-weight:bold; padding: 8px 12px; border-radius: 20px;
    backdrop-filter: blur(8px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); transition: all 0.2s ease;
  }
  #audioBtn:hover { background: rgba(255,255,255,0.3); transform: scale(1.05); }

  .btn-secondary {
    width: 100%; margin-top:12px; padding:14px 0; font-size:14px; letter-spacing:3px;
    text-transform:uppercase; font-weight:800; color:#1b2820;
    background: rgba(27, 40, 32, 0.08); border:1px solid rgba(27, 40, 32, 0.2); border-radius:40px;
    cursor:pointer; transition:all 0.2s ease; text-align: center;
  }
  .btn-secondary:hover { background: rgba(27, 40, 32, 0.14); transform: translateY(-2px); }

  .keys { display:flex; justify-content:center; gap:8px; margin:16px 0; flex-wrap: wrap; }
  .key {
    min-width:36px; height:36px; padding: 0 8px; border-radius:8px;
    background:#fff; border:1px solid rgba(0,0,0,0.1); display:flex; align-items:center; justify-content:center;
    font-weight:800; font-size:14px; color:#1a2b3c; box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }
  
  #startBtn, #retryBtn {
    width: 100%; margin-top:20px; padding:16px 0; font-size:15px; letter-spacing:3px;
    text-transform:uppercase; font-weight:800; color:#fff;
    background: #2a5a3a; border:none; border-radius:40px;
    cursor:pointer; box-shadow:0 8px 24px rgba(42,90,58,0.4); transition:all 0.2s ease; text-align: center;
  }
  #startBtn:hover, #retryBtn:hover { transform:translateY(-3px); box-shadow:0 12px 32px rgba(42,90,58,0.6); background: #357348; }

  /* Crash screen styles live in the modern block below — avoid white-on-white overrides here */

/* MODERN ELEVATED GAME UI DESIGN SYSTEM */
#topbar {
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 28px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 12;
  background: transparent !important;
  pointer-events: none;
}

#logo {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #ffffff;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  /* Keep clear of top-right exit button; map sits below */
  max-width: calc(100vw - 200px);
  pointer-events: none;
}

#score {
  text-align: right;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

#distance {
  font-family: 'Outfit', sans-serif;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  color: #ffb834;
}

#distance span {
  font-size: 18px;
  font-weight: 600;
  opacity: 0.85;
  margin-left: 4px;
  color: #ffffff;
}

#zone {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 12px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  margin-top: 6px;
  display: inline-block;
}

#status {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(18, 28, 39, 0.85);
  padding: 12px 28px;
  border-radius: 30px;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

#status.show { opacity: 1; }
#status.warning {
  color: #ff6b6b;
  background: rgba(60, 15, 15, 0.9);
  border-color: rgba(255, 107, 107, 0.6);
}

#windBox {
  position: absolute;
  bottom: 40px;
  right: 36px;
  background: rgba(18, 28, 39, 0.85);
  backdrop-filter: blur(16px);
  padding: 18px 24px;
  border-radius: 20px;
  color: #ffffff;
  text-align: center;
  border: 1px solid rgba(212, 175, 55, 0.4);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  transition: all 0.3s ease;
  opacity: 0;
}
#windBox.show { opacity: 1; }

#windTitle {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #d4af37;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#windArrow {
  font-size: 36px;
  font-weight: 900;
  margin: 6px 0;
  display: inline-block;
  color: #ffb834;
  text-shadow: 0 4px 12px rgba(255, 184, 52, 0.4);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#windSpeed {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(18, 28, 39, 0.92) 0%, rgba(10, 15, 22, 0.96) 100%);
  color: #1b2820;
  backdrop-filter: blur(24px);
  overflow-y: auto;
  padding: 24px;
}
#overlay.hide { display: none; }

.panel {
  max-width: 660px;
  width: 100%;
  padding: 40px;
  background: #faf5ea;
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(212, 175, 55, 0.3);
  border: 2px solid #d4af37;
  text-align: left;
  clip-path: none !important;
}

.panel h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 40px;
  letter-spacing: 4px;
  font-weight: 900;
  color: #1b2820;
  text-align: center;
  margin-bottom: 4px;
}

#greeting {
  font-size: 14px;
  font-weight: 700;
  color: #5a462a;
  text-align: center;
  margin-bottom: 20px;
}

.dashboard-stats {
  background: rgba(90, 70, 42, 0.08);
  padding: 16px 20px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  border: 1px solid rgba(90, 70, 42, 0.15);
}

.stat-item {
  text-align: center;
  background: #ffffff;
  padding: 12px 8px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(90, 70, 42, 0.1);
  transform: none !important;
}

.stat-val {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 900;
  color: #2a5a3a;
}

.stat-lbl {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7a664d;
  margin-top: 2px;
}

.section-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #b85a3c;
  margin-top: 20px;
  margin-bottom: 10px;
}

.custom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.color-btn {
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  position: relative;
  letter-spacing: 0.5px;
}

.color-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.color-btn.selected {
  border-color: #d4af37 !important;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.4), 0 8px 24px rgba(0, 0, 0, 0.15);
}

.color-btn.selected::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 8px;
  font-size: 12px;
  font-weight: 900;
}

.color-btn.locked {
  opacity: 0.6;
  filter: grayscale(0.5);
  cursor: not-allowed;
}
.color-btn.locked:hover {
  transform: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.keys {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.key {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(90, 70, 42, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #1b2820;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

#startBtn, #retryBtn {
  width: 100%;
  margin-top: 24px;
  padding: 18px 0;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #ffb834 0%, #e85d04 100%);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(232, 93, 4, 0.45);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
}

#startBtn:hover, #retryBtn:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 16px 40px rgba(232, 93, 4, 0.6);
  filter: brightness(1.08);
}

#crashScreen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(40, 70, 50, 0.45) 0%, transparent 55%),
    rgba(10, 16, 24, 0.88);
  color: #fff8e8;
  text-align: center;
  backdrop-filter: blur(18px);
  padding: 24px;
}
#crashScreen.show { display: flex; }

/* Dark glass card — light text only on dark surfaces (no white-on-cream) */
.crash-panel,
#crashScreen .crash-panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(28, 40, 52, 0.96) 0%, rgba(16, 24, 34, 0.98) 100%);
  border: 1px solid rgba(212, 175, 55, 0.55);
  color: #fff8e8;
  text-align: center;
  max-width: 460px;
  width: 100%;
  padding: 36px 32px 28px;
  border-radius: 24px;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 40px rgba(255, 184, 52, 0.12);
  animation: crashPanelIn 0.55s cubic-bezier(0.34, 1.35, 0.64, 1) both;
}

.crash-panel-glow {
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 184, 52, 0.28) 0%, transparent 70%);
  pointer-events: none;
}

@keyframes crashPanelIn {
  from { opacity: 0; transform: translateY(22px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.crash-panel-icon {
  position: relative;
  font-size: 48px;
  line-height: 1;
  margin-bottom: 10px;
  filter: drop-shadow(0 8px 16px rgba(255, 184, 52, 0.5));
  animation: crashIconPop 0.7s ease both;
}

@keyframes crashIconPop {
  0% { transform: scale(0.4) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.crash-kicker {
  position: relative;
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: 2.5px !important;
  text-transform: uppercase;
  color: #d4af37 !important;
  margin: 0 0 8px !important;
  opacity: 1 !important;
}

#crashScreen h2,
.crash-panel h2 {
  position: relative;
  font-family: 'Outfit', sans-serif;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 0 0 14px;
  color: #fff8e8 !important;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

#crashScreen p.crash-distance,
.crash-distance,
#finalDistance {
  position: relative;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 1.55;
  color: rgba(255, 248, 232, 0.82) !important;
  margin: 0 0 26px !important;
  opacity: 1 !important;
}

.crash-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crash-btn-primary,
#crashScreen #retryBtn {
  width: 100%;
  margin: 0 !important;
  padding: 16px 0;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 800;
  color: #1a1408 !important;
  background: linear-gradient(135deg, #ffb834 0%, #e85d04 100%) !important;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(232, 93, 4, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.crash-btn-primary:hover,
#crashScreen #retryBtn:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 14px 34px rgba(232, 93, 4, 0.55);
}

.crash-btn-secondary,
#crashScreen #dashboardBtn {
  width: 100%;
  margin: 0 !important;
  padding: 14px 0;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 800;
  color: #fff8e8 !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.crash-btn-secondary:hover,
#crashScreen #dashboardBtn:hover {
  background: rgba(255, 255, 255, 0.14) !important;
  border-color: rgba(212, 175, 55, 0.5) !important;
  transform: translateY(-1px);
}

/* Live crash-story captions over the 3D scene */
.crash-caption {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 14;
  pointer-events: none;
  opacity: 0;
  color: #fff8e8;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-align: center;
  padding: 12px 22px;
  border-radius: 999px;
  background: rgba(18, 28, 39, 0.55);
  border: 1px solid rgba(255, 184, 52, 0.35);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  transition: opacity 0.35s ease, transform 0.35s ease;
  max-width: min(520px, 86vw);
  white-space: normal;
}

.crash-caption.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* (crash title/body contrast handled in .crash-panel block above) */

/* ── Premium cinematic HUD layer (glass chips only — no solid blue walls) ── */
.hud-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(8, 14, 22, 0.22) 100%);
  z-index: 2;
}

.hud-right-cluster {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: min(280px, 42vw);
  background: transparent !important;
  /* Room for top-right Landing Page exit button */
  margin-top: 48px;
  margin-right: 0;
}

.hud-right-cluster #audioBtn,
.hud-right-cluster #audioControls {
  pointer-events: auto;
}

.hud-center-cluster {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent !important;
}

.flight-mode-pill,
.trick-hint-pill {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff8e8;
  background: rgba(18, 28, 39, 0.55);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 7px 14px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  text-transform: uppercase;
  white-space: nowrap;
}

.trick-hint-pill {
  font-size: 9px;
  letter-spacing: 0.8px;
  opacity: 0.9;
  color: rgba(255, 248, 232, 0.92);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(18, 28, 39, 0.42);
}

/* ── Time of day clock ── */
.tod-clock {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 8px 12px;
  min-width: 168px;
  background: rgba(12, 20, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.tod-clock.show {
  display: flex;
}

.tod-icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.tod-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 52px;
}

.tod-time {
  font-family: 'Outfit', ui-monospace, monospace;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff8e8;
  line-height: 1.1;
}

.tod-phase {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 248, 232, 0.65);
}

.tod-bar {
  position: relative;
  flex: 1;
  height: 6px;
  min-width: 64px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    #0a1020 0%,
    #ff7a4a 22%,
    #5a9ad4 40%,
    #4aa0e0 50%,
    #ff5a3a 72%,
    #0a1020 100%);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

.tod-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 30%;
  background: rgba(255, 255, 255, 0.35);
  border-right: 2px solid #fff8e8;
  box-shadow: 0 0 10px rgba(255, 248, 232, 0.55);
  transition: width 0.2s linear;
}

.tod-bar-marks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 22%;
  pointer-events: none;
}

.tod-bar-marks i {
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.35);
}

.tod-clock.is-night {
  border-color: rgba(140, 160, 255, 0.35);
  box-shadow: 0 8px 22px rgba(20, 30, 80, 0.4), 0 0 16px rgba(100, 120, 255, 0.12);
}

.tod-clock.is-night .tod-phase {
  color: rgba(180, 200, 255, 0.8);
}

.tod-clock.is-sunset {
  border-color: rgba(255, 140, 80, 0.45);
}

#gameContainerModal.filter-cyberpunk .tod-clock {
  border-color: rgba(255, 43, 214, 0.4);
}

.score-glass {
  background: rgba(18, 28, 39, 0.5) !important;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  text-align: right;
}

.flight-instruments {
  position: absolute;
  left: 28px;
  bottom: 40px;
  display: flex;
  gap: 12px;
  pointer-events: none;
  z-index: 12;
  align-items: flex-end;
}

/* BOOST METER */
.boost-instrument {
  min-width: 96px;
  border-color: rgba(102, 240, 255, 0.35) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(102, 240, 255, 0.12);
  transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.boost-instrument.ready {
  border-color: rgba(255, 224, 102, 0.75) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3), 0 0 24px rgba(255, 200, 80, 0.35);
}

.boost-instrument.boosting {
  border-color: rgba(255, 102, 217, 0.85) !important;
  box-shadow: 0 12px 36px rgba(255, 80, 200, 0.35), 0 0 28px rgba(102, 240, 255, 0.4);
  transform: translateY(-2px) scale(1.03);
}

.boost-bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: 2px;
}

.boost-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3db8ff 0%, #66f0ff 45%, #c8f7ff 100%);
  box-shadow: 0 0 12px rgba(102, 240, 255, 0.55);
  transition: width 0.12s linear, background 0.25s ease, box-shadow 0.25s ease;
}

.boost-bar-fill.ready {
  background: linear-gradient(90deg, #ffb834 0%, #ffe066 50%, #fff6c2 100%);
  box-shadow: 0 0 16px rgba(255, 200, 80, 0.7);
  animation: boostReadyPulse 1.1s ease-in-out infinite;
}

.boost-bar-fill.active {
  background: linear-gradient(90deg, #66f0ff 0%, #ff66d9 50%, #ffe066 100%);
  background-size: 200% 100%;
  animation: boostFlow 0.55s linear infinite;
  box-shadow: 0 0 18px rgba(255, 102, 217, 0.65);
}

@keyframes boostReadyPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

@keyframes boostFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.boost-key-hint {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 4px;
}

.boost-instrument.boosting .boost-key-hint {
  color: #ffe066;
}

/* ── GPS flight map ── */
.flight-map {
  position: absolute;
  top: 78px;
  left: 28px;
  z-index: 20; /* above vignette (2) and below crash UI */
  width: 210px;
  pointer-events: none;
  background: linear-gradient(165deg, rgba(10, 18, 28, 0.92) 0%, rgba(8, 14, 22, 0.94) 100%);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(80, 180, 230, 0.28);
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(80, 180, 230, 0.08);
  padding: 10px 10px 8px;
  color: #e8f6ff;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.flight-map.show {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0);
}

.flight-map.gps-map .flight-map-title {
  color: #5ec8ff;
  letter-spacing: 2.5px;
}

.gps-canvas-wrap {
  border-color: rgba(70, 170, 230, 0.35) !important;
  background: #0c1520 !important;
  box-shadow: inset 0 0 20px rgba(0, 40, 80, 0.45) !important;
}

.aerial-map .flight-map-title {
  color: #8fd98a;
}

.aerial-canvas-wrap {
  border-color: rgba(120, 180, 90, 0.4) !important;
  background: #4a7a3a !important;
  box-shadow: inset 0 0 18px rgba(20, 40, 10, 0.35) !important;
}

.gps-track-label {
  color: rgba(120, 200, 255, 0.45) !important;
  letter-spacing: 1.5px !important;
}

.gps-sat-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #5dff9a;
  text-shadow: 0 0 8px rgba(93, 255, 154, 0.6);
}

/* Visual filter strip */
.viz-filters {
  position: absolute;
  /* Above wind panel, clear of score/exit */
  top: auto;
  bottom: 150px;
  right: 28px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  background: rgba(12, 20, 30, 0.78);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

.viz-filters-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #d4af37;
  margin-right: 2px;
}

.viz-filter-btn {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: rgba(255, 248, 232, 0.75);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.viz-filter-btn:hover {
  color: #fff8e8;
  border-color: rgba(212, 175, 55, 0.45);
  background: rgba(255, 255, 255, 0.1);
}

.viz-filter-btn.active {
  color: #0a1218;
  background: linear-gradient(135deg, #ffb834, #e89a20);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(255, 184, 52, 0.35);
}

/* Fullscreen CSS overlays for filter modes */
#gameContainerModal.filter-wireframe canvas.game-canvas {
  filter: contrast(1.15) saturate(0.35) brightness(1.05);
}
#gameContainerModal.filter-wireframe::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 200, 255, 0.03) 2px, rgba(0, 200, 255, 0.03) 3px);
  mix-blend-mode: screen;
}

#gameContainerModal.filter-cyberpunk canvas.game-canvas {
  filter: contrast(1.2) saturate(1.45) hue-rotate(-8deg);
}
#gameContainerModal.filter-cyberpunk::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 0, 180, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 240, 255, 0.1) 0%, transparent 45%),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0, 0, 0, 0.08) 3px, rgba(0, 0, 0, 0.08) 4px);
  mix-blend-mode: soft-light;
}
#gameContainerModal.filter-cyberpunk .flight-map {
  border-color: rgba(255, 43, 214, 0.4);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.15);
}
#gameContainerModal.filter-cyberpunk .viz-filters {
  border-color: rgba(0, 240, 255, 0.35);
}

.flight-map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding: 0 2px;
}

.flight-map-title {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #d4af37;
}

.flight-map-range {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
}

.flight-map-canvas-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: radial-gradient(circle at 50% 55%, rgba(40, 70, 90, 0.55) 0%, rgba(10, 18, 28, 0.95) 72%);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
}

#flightMapCanvas {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

.flight-map-n {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.flight-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 7px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.62);
}

.flight-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.leg-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.leg-you { background: #66f0ff; box-shadow: 0 0 6px #66f0ff; }
.leg-sun { background: #ffb834; box-shadow: 0 0 5px rgba(255, 184, 52, 0.7); }
.leg-goal { background: #7dffa0; box-shadow: 0 0 5px rgba(125, 255, 160, 0.6); }
.leg-best { background: #ff6b9d; box-shadow: 0 0 5px rgba(255, 107, 157, 0.55); }
.leg-haz { background: #ff5555; opacity: 0.85; }

.flight-map-goal {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #e8f6ff;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 5px 8px;
  border: 1px solid rgba(125, 255, 160, 0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flight-map-goal.complete {
  border-color: rgba(255, 184, 52, 0.45);
  color: #ffe8a8;
}

.flight-map-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
}

@media (max-width: 768px) {
  .flight-map {
    top: auto;
    bottom: 120px;
    left: 12px;
    width: 148px;
    padding: 8px;
  }
  .flight-map-legend {
    display: none;
  }
  .flight-instruments {
    left: 12px;
    bottom: 16px;
    transform: scale(0.88);
    transform-origin: bottom left;
  }
  .viz-filters {
    right: 12px;
    bottom: 100px;
    transform: scale(0.9);
    transform-origin: bottom right;
  }
}

.instrument-card {
  background: rgba(18, 28, 39, 0.82);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: 12px 14px;
  color: #fff;
  min-width: 72px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.instrument-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #d4af37;
  margin-bottom: 8px;
}

.instrument-value {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.92);
}

.instrument-value.big {
  font-size: 22px;
  margin-top: 4px;
  line-height: 1.1;
}

.instrument-value.big small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-top: 2px;
}

.alt-bar-track {
  position: relative;
  width: 18px;
  height: 96px;
  margin: 0 auto;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.alt-bar-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%;
  background: linear-gradient(180deg, #ffb834 0%, #4caf7d 55%, #2a5a3a 100%);
  border-radius: 10px 10px 0 0;
  transition: height 0.12s linear, background 0.25s ease;
  box-shadow: 0 0 12px rgba(255, 184, 52, 0.35);
}

.alt-bar-fill.danger {
  background: linear-gradient(180deg, #ff6b6b 0%, #e85d04 60%, #9a3412 100%);
  box-shadow: 0 0 14px rgba(255, 107, 107, 0.45);
}

.alt-cap-mark {
  position: absolute;
  top: 4px;
  left: 2px;
  right: 2px;
  height: 2px;
  background: rgba(255, 107, 107, 0.85);
  border-radius: 2px;
  z-index: 2;
}

#windBox .wind-hint {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  opacity: 0.55;
  margin-top: 6px;
  max-width: 110px;
  line-height: 1.3;
}

#windBox.danger {
  border-color: rgba(255, 107, 107, 0.65);
  box-shadow: 0 12px 36px rgba(120, 20, 20, 0.4), 0 0 20px rgba(255, 80, 80, 0.2);
}

/* Canvas impact feedback — translate only, never scale (avoids edge gaps) */
#gameContainerModal canvas.impact-shake {
  animation: impactShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes impactShake {
  10%, 90% { transform: translate3d(-2px, 1px, 0); }
  20%, 80% { transform: translate3d(3px, -2px, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 2px, 0); }
  40%, 60% { transform: translate3d(4px, -1px, 0); }
}

@media (max-width: 768px) {
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .panel {
    padding: 24px;
  }
  #topbar {
    padding: 16px 20px;
  }
  .flight-instruments {
    left: 14px;
    bottom: 24px;
    transform: scale(0.9);
    transform-origin: bottom left;
  }
  .hud-center-cluster {
    top: 18px;
  }
  #windBox {
    right: 14px;
    bottom: 24px;
    padding: 12px 14px;
  }
  #windBox .wind-hint {
    display: none;
  }
}