/* Boot loader — full-screen v2 splash background with a subtle pulsing
   label at the bottom. Replaces Capacitor's letterboxed static splash
   (the square 1254×1254 splash gets letterboxed on portrait screens; CSS
   background-size:cover fills the viewport instead). Hidden by JS once
   the WebView + Firebase are warmed up. */
.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background-color: #05030f;
  background-image: url('assets/apogee-splash-vertical.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: max(env(safe-area-inset-bottom), 48px);
  transition: opacity 0.55s ease;
}
.boot-loader.hide { opacity: 0; pointer-events: none; }
.boot-label {
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5em;
  color: #ffd86b;
  text-shadow: 0 0 18px rgba(255, 216, 107, 0.55);
  animation: boot-blink 1.4s ease-in-out infinite;
}
@keyframes boot-blink {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* Ad-loading overlay — shown while AdMob prepares + presents an ad.
   Same animation language as the boot loader but smaller + in a card. */
.ad-loading {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(5, 3, 15, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
}
.ad-loading[hidden] { display: none; }
.ad-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 32px 38px;
  background: linear-gradient(160deg, #1a0a30 0%, #0e0a28 100%);
  border: 1px solid rgba(255, 216, 107, 0.25);
  border-radius: 18px;
}
.ad-loading-orbit {
  position: relative;
  width: 100px;
  height: 100px;
  animation: boot-spin 2.2s linear infinite;
}
.ad-loading-planet {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff9bd0 0%, #c4378e 45%, #4a1040 100%);
  box-shadow: 0 0 18px rgba(196, 55, 142, 0.55);
  animation: boot-pulse 1.6s ease-in-out infinite;
}
.ad-loading-ufo {
  position: absolute;
  top: 3px; left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(180deg, #dee4f0 0%, #76e8ff 35%, #1a8bb0 100%);
  box-shadow: 0 0 12px rgba(118, 232, 255, 0.65);
  animation: boot-ufo-counterspin 2.2s linear infinite reverse;
}
.ad-loading-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4em;
  color: #ffd86b;
  text-shadow: 0 0 12px rgba(255, 216, 107, 0.45);
  animation: boot-blink 1.4s ease-in-out infinite;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: #05030f;
  color: #e8eaf2;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0e0a28 0%, #05030f 70%);
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0) 24px env(safe-area-inset-bottom, 24px);
  text-align: center;
  pointer-events: none;
}
.screen.visible { display: flex; }
.screen > * { pointer-events: auto; }

/* Title screen sits over the live demo loop — dim the canvas behind so
   the heading/buttons stay readable without fully hiding the gameplay. */
#title {
  background:
    radial-gradient(ellipse at center 35%, rgba(5, 3, 15, 0.55) 0%, rgba(5, 3, 15, 0) 65%),
    linear-gradient(180deg, rgba(5, 3, 15, 0.35) 0%, rgba(5, 3, 15, 0.85) 100%);
}

h1 {
  font-size: clamp(56px, 16vw, 112px);
  font-weight: 900;
  letter-spacing: 0.12em;
  margin: 0 0 8px;
  background: linear-gradient(180deg, #ffd86b 0%, #ff5e7a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(255, 200, 80, 0.25);
}
h2 {
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 900;
  letter-spacing: 0.1em;
  margin: 0 0 12px;
  color: #ff5e7a;
}
.tag {
  font-size: 16px;
  opacity: 0.7;
  margin: 0 0 40px;
  letter-spacing: 0.04em;
  max-width: 320px;
  line-height: 1.5;
}
.hint {
  font-size: 12px;
  opacity: 0.5;
  margin-top: 24px;
  letter-spacing: 0.04em;
  line-height: 1.7;
}
.hint-desktop { opacity: 0.65; }

.cta {
  appearance: none;
  border: none;
  background: linear-gradient(135deg, #ffd86b 0%, #ff5e7a 100%);
  color: #1a0a14;
  font-family: inherit;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.12em;
  padding: 18px 40px;
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(255, 134, 90, 0.30);
  cursor: pointer;
  margin: 8px 0;
  min-width: 240px;
}
.cta:active { transform: scale(0.97); }

.cta-rewarded {
  background: linear-gradient(135deg, #00d9ff 0%, #6a5cff 100%);
  color: #fff;
  box-shadow: 0 8px 28px rgba(0, 217, 255, 0.30);
}
.cta-rewarded .icon { display: inline-block; transform: rotate(-90deg); margin-right: 8px; }

.cta-secondary {
  background: transparent;
  border: 2px solid rgba(255, 216, 107, 0.55);
  color: #ffd86b;
  box-shadow: none;
  font-size: 14px;
  padding: 14px 28px;
  min-width: 200px;
}
.cta-small {
  font-size: 15px;
  padding: 14px 32px;
  min-width: 140px;
}

.mode-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.title-links,
.death-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: center;
  margin-top: 12px;
}
.title-links .link-btn,
.death-link-row .link-btn {
  margin: 0;
  padding: 8px 12px;
}

.link-btn {
  appearance: none;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 12px 16px;
  margin-top: 8px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.link-btn:hover { color: rgba(255, 255, 255, 0.85); }

/* Onboarding overlay */
.onboarding {
  background: rgba(5, 3, 15, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.onb-card {
  max-width: 360px;
  background: linear-gradient(160deg, #1a0a30 0%, #0e0a28 100%);
  border: 1px solid rgba(255, 216, 107, 0.25);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  pointer-events: auto;
}
.onb-step {
  font-size: 11px;
  letter-spacing: 0.4em;
  opacity: 0.5;
  margin-bottom: 16px;
}
.onb-card h3 {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 16px;
  letter-spacing: 0.02em;
  color: #ffd86b;
}
.onb-card p {
  font-size: 15px;
  line-height: 1.55;
  opacity: 0.85;
  margin: 0 0 28px;
}
.onb-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Leaderboard overlay */
.leaderboard-screen,
.achievements-screen {
  background: rgba(5, 3, 15, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Achievements grid — viewer modal opened from the title screen.
   Shows all 10 with locked items grayed out and unlocked items
   in gold. Each tile shows icon + name + description + status. */
.achievements-card {
  max-width: 420px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: linear-gradient(160deg, #1a0a30 0%, #0e0a28 100%);
  border: 1px solid rgba(255, 216, 107, 0.25);
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
  pointer-events: auto;
}
.achievements-header {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0.16em;
  font-weight: 900;
  color: #ffd86b;
}
.achievements-progress {
  font-size: 12px;
  letter-spacing: 0.2em;
  opacity: 0.6;
  margin-bottom: 18px;
}
.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.achievement-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
}
.achievement-row.unlocked {
  background: rgba(255, 216, 107, 0.10);
  border-color: rgba(255, 216, 107, 0.40);
}
.achievement-row .ach-icon {
  font-size: 28px;
  width: 44px;
  text-align: center;
  flex-shrink: 0;
  filter: grayscale(1);
  opacity: 0.5;
}
.achievement-row.unlocked .ach-icon {
  filter: none;
  opacity: 1;
}
.achievement-row .ach-body {
  flex: 1;
  min-width: 0;
}
.achievement-row .ach-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 2px;
}
.achievement-row.unlocked .ach-name {
  color: #ffd86b;
}
.achievement-row .ach-desc {
  font-size: 11px;
  opacity: 0.6;
  line-height: 1.4;
}
.achievement-row .ach-status {
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
.achievement-row.unlocked .ach-status {
  color: #ffd86b;
}
.leaderboard-card {
  max-width: 380px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: linear-gradient(160deg, #1a0a30 0%, #0e0a28 100%);
  border: 1px solid rgba(255, 216, 107, 0.25);
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
  pointer-events: auto;
}
.leaderboard-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 4px;
  margin: -8px -10px 12px;
  padding: 0 10px 4px;
  scrollbar-width: none;
}
.leaderboard-tabs::-webkit-scrollbar { display: none; }
.lb-tab {
  appearance: none;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.lb-tab.active {
  background: rgba(255, 216, 107, 0.15);
  border-color: rgba(255, 216, 107, 0.6);
  color: #ffd86b;
}

.leaderboard-header h3 {
  font-size: 14px;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.14em;
  color: #ffd86b;
}
.leaderboard-date {
  font-size: 11px;
  opacity: 0.55;
  letter-spacing: 0.3em;
  margin-top: 6px;
  margin-bottom: 18px;
}
.leaderboard-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 14px;
  align-items: center;
}
.leaderboard-row.me {
  background: rgba(255, 216, 107, 0.15);
  border: 1px solid rgba(255, 216, 107, 0.4);
  font-weight: 700;
}
.leaderboard-row .rank { opacity: 0.5; font-weight: 700; }
.leaderboard-row .name {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leaderboard-row .score { font-weight: 800; color: #ffd86b; }
.leaderboard-empty {
  font-size: 13px;
  opacity: 0.6;
  padding: 24px 0;
}
.leaderboard-me {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 16px;
}
.leaderboard-name-row {
  margin: 14px 0;
  text-align: left;
}
.leaderboard-name-row label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.3em;
  opacity: 0.5;
  margin-bottom: 6px;
}
.leaderboard-name-row input {
  width: 100%;
  appearance: none;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}
.leaderboard-name-row input:focus {
  border-color: rgba(255, 216, 107, 0.6);
}
.player-name-error {
  margin-top: 6px;
  font-size: 11px;
  color: #ff7e9a;
  letter-spacing: 0.04em;
}

/* Ship picker overlay */
.ship-picker-screen {
  background: rgba(5, 3, 15, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ship-picker-card {
  max-width: 380px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: linear-gradient(160deg, #1a0a30 0%, #0e0a28 100%);
  border: 1px solid rgba(255, 216, 107, 0.25);
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
  pointer-events: auto;
}
.ship-picker-header {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: #ffd86b;
  margin: 0 0 18px;
}
.ship-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.ship-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.ship-card:hover {
  border-color: rgba(255, 216, 107, 0.4);
}
.ship-card.equipped {
  border-color: rgba(255, 216, 107, 0.8);
  background: rgba(255, 216, 107, 0.10);
}
.ship-card.locked {
  opacity: 0.55;
  cursor: default;
}
.ship-preview {
  width: 64px;
  height: 36px;
  margin: 4px auto 8px;
  position: relative;
}
.ship-preview-saucer {
  position: absolute;
  left: 0; right: 0;
  bottom: 8px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.4);
}
.ship-preview-dome {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 22px;
  height: 18px;
  border-radius: 50% 50% 50% 50% / 70% 70% 50% 50%;
}
.ship-card-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  margin-bottom: 4px;
}
.ship-card-tag {
  font-size: 10px;
  opacity: 0.55;
  letter-spacing: 0.05em;
}
.ship-card.equipped .ship-card-tag::after {
  content: ' · EQUIPPED';
  color: #ffd86b;
}
.ship-card-action {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: rgba(0, 217, 255, 0.85);
}
.ship-card-action.rewarded { color: #ffd86b; }

/* Achievement chime */
.achievement-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 70px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, #ffd86b 0%, #ff5e7a 100%);
  color: #1a0a14;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.06em;
  z-index: 50;
  box-shadow: 0 8px 28px rgba(255, 134, 90, 0.35);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  text-align: center;
}
.achievement-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.achievement-toast-label {
  font-size: 9px;
  letter-spacing: 0.3em;
  opacity: 0.8;
}
.achievement-toast-name {
  font-size: 15px;
}

.score {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 18px);
  left: 0; right: 0;
  text-align: center;
  font-size: 72px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  line-height: 1;
}
.sublabel {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 96px);
  left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  opacity: 0.55;
  letter-spacing: 0.3em;
  pointer-events: none;
}

/* Intro narrative overlay — 3-screen cinematic, tap to advance.
   Full-screen, sits ABOVE everything else so it covers the title.
   All art is CSS-drawn (no external image assets needed). */
/* Boss Wave button — distinct danger color so it reads as a hard mode. */
.cta-boss {
  background: linear-gradient(180deg, rgba(255, 100, 60, 0.18) 0%, rgba(180, 40, 20, 0.18) 100%);
  border-color: rgba(255, 100, 60, 0.55);
  color: #ff9a3d;
}
.cta-boss:hover, .cta-boss:active {
  background: linear-gradient(180deg, rgba(255, 100, 60, 0.32) 0%, rgba(180, 40, 20, 0.32) 100%);
}

.intro-story {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: radial-gradient(ellipse at center, #1a0b3a 0%, #08051a 60%, #02010a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
  overflow: hidden;
}
.intro-story[hidden] { display: none; }
.intro-skip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 16px);
  right: calc(env(safe-area-inset-right, 0) + 18px);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  letter-spacing: 0.2em;
  font-weight: 700;
  padding: 8px 12px;
  z-index: 10;
}
.intro-scene {
  width: 100%;
  max-width: 460px;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  animation: intro-fade-in 0.7s ease-out;
}
.intro-scene[hidden] { display: none; }
@keyframes intro-fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.intro-art {
  position: relative;
  width: 240px;
  height: 240px;
}

/* Scene 1: burning planet + alien */
.intro-planet-burning {
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #ffea6b 0%, #ff6b35 35%, #b22020 65%, #4a0805 100%);
  box-shadow:
    0 0 80px rgba(255, 150, 60, 0.65),
    inset -20px -20px 60px rgba(0, 0, 0, 0.4);
  animation: intro-planet-pulse 1.6s ease-in-out infinite;
}
.intro-flames {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 50% at 50% 100%, rgba(255, 150, 50, 0.4) 0%, transparent 60%);
  animation: intro-flames-flicker 0.6s ease-in-out infinite alternate;
}
.intro-alien {
  position: absolute;
  left: 50%;
  top: 18%;
  font-size: 28px;
  transform: translateX(-50%);
  animation: intro-alien-bob 1.5s ease-in-out infinite;
}
@keyframes intro-planet-pulse {
  0%, 100% { box-shadow: 0 0 80px rgba(255, 150, 60, 0.65), inset -20px -20px 60px rgba(0, 0, 0, 0.4); }
  50%      { box-shadow: 0 0 120px rgba(255, 200, 90, 0.85), inset -20px -20px 60px rgba(0, 0, 0, 0.4); }
}
@keyframes intro-flames-flicker {
  from { opacity: 0.65; }
  to   { opacity: 1; }
}
@keyframes intro-alien-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-6px); }
}

/* Scene 2: UFO launching from planet */
.intro-ufo-launch {
  position: absolute;
  left: 50%;
  top: 30%;
  font-size: 56px;
  transform: translateX(-50%);
  animation: intro-ufo-rise 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(118, 232, 255, 0.6));
}
.intro-launch-trail {
  position: absolute;
  left: 50%;
  top: 55%;
  width: 6px;
  height: 100px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255, 200, 90, 0.85) 0%, rgba(255, 100, 40, 0.5) 50%, transparent 100%);
  border-radius: 3px;
  filter: blur(2px);
  animation: intro-trail-pulse 0.6s ease-in-out infinite alternate;
}
.intro-planet-small {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 140px;
  height: 60px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center top, #ff6b35 0%, #b22020 60%, #4a0805 100%);
  box-shadow: 0 0 40px rgba(255, 100, 40, 0.5);
  opacity: 0.8;
}
@keyframes intro-ufo-rise {
  0%   { transform: translateX(-50%) translateY(20px); }
  50%  { transform: translateX(-50%) translateY(-20px); }
  100% { transform: translateX(-50%) translateY(20px); }
}
@keyframes intro-trail-pulse {
  from { opacity: 0.65; height: 80px; }
  to   { opacity: 1;    height: 120px; }
}

/* Scene 3: UFO with the destruction wave behind */
.intro-ufo-escape {
  position: absolute;
  left: 50%;
  top: 25%;
  font-size: 56px;
  transform: translateX(-50%);
  filter: drop-shadow(0 0 16px rgba(118, 232, 255, 0.6));
  animation: intro-ufo-bob 1.5s ease-in-out infinite;
}
.intro-wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60%;
  background:
    linear-gradient(0deg,
      rgba(110, 18, 12, 0.95) 0%,
      rgba(230, 70, 35, 0.85) 35%,
      rgba(255, 160, 60, 0.55) 70%,
      rgba(255, 230, 120, 0) 100%);
  border-radius: 100% 100% 0 0 / 30% 30% 0 0;
  animation: intro-wave-rise 1.8s ease-in-out infinite alternate;
}
@keyframes intro-ufo-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-8px); }
}
@keyframes intro-wave-rise {
  from { transform: translateY(8%); }
  to   { transform: translateY(-4%); }
}

.intro-text {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.intro-line-1 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #ffd86b;
  text-shadow: 0 0 24px rgba(255, 216, 107, 0.4);
}
.intro-line-2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.5;
  color: #d8cfe8;
  opacity: 0.92;
}
.intro-begin-btn {
  margin-top: 10px;
  animation: intro-begin-glow 1.4s ease-in-out infinite;
}
@keyframes intro-begin-glow {
  0%, 100% { box-shadow: 0 0 24px rgba(255, 216, 107, 0.4); }
  50%      { box-shadow: 0 0 48px rgba(255, 216, 107, 0.75); }
}

.intro-progress {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0) + 28px);
  left: 0; right: 0;
  display: flex;
  gap: 10px;
  justify-content: center;
}
.intro-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.3s, transform 0.3s;
}
.intro-dot-active {
  background: #ffd86b;
  transform: scale(1.3);
}

/* Power-up active-effect chips. Shown in a row under the score when an
   effect is live. Each chip pulses subtly when activated. */
.powerup-hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 118px);
  left: 0; right: 0;
  display: flex;
  gap: 10px;
  justify-content: center;
  pointer-events: none;
}
.powerup-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 12, 35, 0.78);
  border: 1.5px solid currentColor;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  animation: powerup-chip-pulse 1.6s ease-in-out infinite;
}
.powerup-chip-slowmo  { color: #76e8ff; }
.powerup-chip-shield  { color: #76ffa0; }
.powerup-chip-score2x { color: #ff8af0; }
.powerup-chip-icon  { font-size: 13px; }
.powerup-chip-timer { font-variant-numeric: tabular-nums; opacity: 0.85; }
@keyframes powerup-chip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
  50%      { box-shadow: 0 0 12px 0 currentColor; }
}
.death-quip {
  font-size: 14px;
  font-style: italic;
  opacity: 0.78;
  letter-spacing: 0.02em;
  max-width: 300px;
  margin: 0 auto 24px;
  line-height: 1.5;
}

.run-stat {
  font-size: clamp(28px, 8vw, 48px);
  font-weight: 800;
  letter-spacing: 0.04em;
  margin: 0 0 32px;
  color: #ffd86b;
}
.best-stat {
  margin-top: 12px;
  font-size: 14px;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

.ad-slot {
  margin-top: 24px;
  min-height: 0;
  width: min(320px, 90vw);
}

.ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.ad-overlay[hidden] { display: none; }
.ad-overlay-inner {
  background: #1a1a2e;
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  text-align: center;
}

.house-ad {
  display: block;
  background: linear-gradient(135deg, #0e0a28 0%, #1a0a30 100%);
  border: 1px solid rgba(255, 215, 100, 0.25);
  border-radius: 12px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.house-ad strong { display: block; font-size: 16px; margin-bottom: 4px; color: #ffd86b; }
.house-ad em { font-style: normal; opacity: 0.7; }

.mute-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 12px);
  right: calc(env(safe-area-inset-right, 0) + 12px);
  z-index: 100;
  appearance: none;
  background: rgba(10, 6, 24, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 216, 107, 0.35);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.mute-toggle:active { transform: scale(0.92); }
.mute-toggle.muted { opacity: 0.55; border-color: rgba(255, 255, 255, 0.2); }

.abort-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 12px);
  left: calc(env(safe-area-inset-left, 0) + 12px);
  z-index: 100;
  appearance: none;
  background: rgba(40, 6, 12, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 94, 122, 0.45);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.abort-toggle:active { transform: scale(0.92); }
