@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&display=swap');

/*
 * style.css – Rocket to the Moon
 * Sections: reset & variables | layout (#game-container, #sky, #stars, #moon)
 *           | rocket, collectibles, obstacles | level-2 (lasers, ships)
 *           | level-3 (duel) | UI (top-row, level, footer) | start screen (#instructions)
 *           | overlays (pause, game-over, level-complete) | utilities | media queries
 */

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

:root {
  --sky-dark: #1a0a2e;
  --sky-pink: rgba(255, 182, 218, 0.35);
  --moon-glow: #fff5e6;
  --accent: #ffd93d;
  --kid-pink: #ff9ecd;
  --kid-blue: #6bcbff;
  /* Responsive scaling */
  --ui-pad: clamp(8px, 2.5vw, 16px);
  --font-score: clamp(0.9rem, 2.5vw, 1.25rem);
  --font-level: clamp(0.75rem, 2vw, 0.85rem);
  --font-instruction: clamp(0.8rem, 2.2vw, 0.95rem);
  --font-instruction-h2: clamp(1.2rem, 4vw, 1.5rem);
  --rocket-size: clamp(36px, 12vw, 52px);
  --moon-size: clamp(50px, 18vw, 90px);
  --collectible-size: clamp(32px, 10vw, 44px);
  --btn-min-height: clamp(44px, 12vw, 52px);
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-left: env(safe-area-inset-left, 0);
  --safe-right: env(safe-area-inset-right, 0);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--safe-top) var(--safe-left) var(--safe-bottom) var(--safe-right);
  background: var(--sky-dark);
  font-family: 'Fredoka', sans-serif;
  overflow: hidden;
}

#game-container {
  position: relative;
  width: 100%;
  max-width: min(100vw, 560px);
  height: 100vh;
  height: 100dvh;
  max-height: min(100dvh, 900px);
  border-radius: clamp(0px, 3vw, 16px);
  overflow: hidden;
  box-shadow: 0 0 50px rgba(255, 158, 205, 0.25);
}

/* Night sky – soft and magical */
#sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    #2d1b4e 0%,
    #1a0a2e 40%,
    #0f0820 100%
  );
  background-image:
    radial-gradient(ellipse 140% 90% at 50% 0%, var(--sky-pink) 0%, transparent 55%),
    radial-gradient(ellipse 100% 100% at 85% 15%, rgba(255, 217, 61, 0.12) 0%, transparent 45%);
}

#stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(3px 3px at 25px 35px, #fff, transparent),
    radial-gradient(2px 2px at 55px 75px, rgba(255,255,255,0.95), transparent),
    radial-gradient(2px 2px at 95px 45px, #fff, transparent),
    radial-gradient(3px 3px at 140px 90px, rgba(255,255,255,0.9), transparent),
    radial-gradient(2px 2px at 180px 130px, #fff, transparent);
  background-size: 220px 220px;
  animation: twinkle 3s ease-in-out infinite;
  opacity: 0.95;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.7; }
}

/* Moon – scales with viewport */
#moon {
  position: absolute;
  top: 6%;
  right: 10%;
  width: var(--moon-size);
  height: var(--moon-size);
  background: radial-gradient(
    circle at 38% 38%,
    #fffef5,
    #f5e6c8 35%,
    #e8d4a8 65%,
    #c9b87a
  );
  border-radius: 50%;
  box-shadow:
    0 0 50px var(--moon-glow),
    0 0 90px rgba(255, 245, 230, 0.5),
    inset -8px -8px 18px rgba(0,0,0,0.1);
  opacity: 0;
  transition: opacity 0.5s ease;
}

#moon.visible {
  opacity: 1;
}

/* Rocket – scales with viewport */
#rocket {
  position: absolute;
  left: 14%;
  top: 50%;
  font-size: var(--rocket-size);
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.3));
  transition: top 0.15s ease-out, opacity 0.2s;
  z-index: 10;
}

#rocket.hit {
  opacity: 0.5;
  animation: rocket-hit 0.3s ease-out;
}

#rocket.bubble {
  box-shadow: 0 0 0 8px rgba(174, 230, 255, 0.5), 0 0 20px rgba(135, 206, 250, 0.4), 0 6px 12px rgba(0,0,0,0.3);
  border-radius: 50%;
  animation: bubble-pulse 1.2s ease-in-out infinite;
}

@keyframes bubble-pulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(174, 230, 255, 0.5), 0 0 20px rgba(135, 206, 250, 0.4), 0 6px 12px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 0 12px rgba(174, 230, 255, 0.35), 0 0 28px rgba(135, 206, 250, 0.5), 0 6px 12px rgba(0,0,0,0.3); }
}

@keyframes rocket-hit {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Collectible stars – scale with viewport */
.collectible.star {
  position: absolute;
  width: var(--collectible-size);
  height: var(--collectible-size);
  font-size: calc(var(--collectible-size) * 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  animation: star-spin 2s linear infinite;
}

/* Floating obstacles – scale with viewport */
.obstacle.floating {
  position: absolute;
  width: var(--collectible-size);
  height: var(--collectible-size);
  font-size: calc(var(--collectible-size) * 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

@keyframes star-spin {
  from { transform: translate(0, -50%) rotate(0deg); }
  to { transform: translate(0, -50%) rotate(360deg); }
}

/* UI – responsive padding and font */
#ui {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--ui-pad);
  padding-top: max(var(--ui-pad), var(--safe-top));
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  z-index: 20;
  pointer-events: none;
}

#score {
  font-size: var(--font-score);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s;
}

#score-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

#pilot-name {
  font-size: clamp(0.7rem, 2vw, 0.8rem);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.3s;
}

#score-wrap.visible #pilot-name {
  opacity: 1;
}

#top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(4px, 1.5vw, 8px);
}

#level-row {
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s;
  width: 100%;
}
#level-row.visible {
  opacity: 1;
}
#level-row #level-label {
  font-size: var(--font-level);
  color: rgba(255,255,255,0.95);
  display: block;
  margin-bottom: 4px;
}
#level-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
#level-progress-wrap #level-progress-bar {
  flex: 1;
  min-width: 0;
}
#level-progress-icon {
  font-size: clamp(14px, 3.5vw, 20px);
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255, 217, 61, 0.4));
}

#lives-row {
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s;
}
#lives-row.visible {
  opacity: 1;
}

#lives {
  font-size: clamp(1rem, 3vw, 1.2rem);
  letter-spacing: 2px;
  opacity: 0;
  transition: opacity 0.3s;
}

#score.visible,
#lives.visible,
#score-wrap.visible #score {
  opacity: 1;
}

#pause-btn-wrap {
  opacity: 0;
  pointer-events: none;
}

#pause-btn-wrap.visible {
  opacity: 1;
  pointer-events: auto;
}

#exit-btn-wrap {
  opacity: 0;
  pointer-events: none;
  margin-left: auto;
}

#exit-btn-wrap.visible {
  opacity: 1;
  pointer-events: auto;
}

#top-right-lives {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}
#top-right-lives #pilot-lives-label,
#top-right-lives #alien-lives-label {
  font-size: clamp(0.75rem, 2vw, 0.85rem);
  color: rgba(255,255,255,0.95);
  font-weight: 600;
}
#top-right-lives #lives {
  margin: 0;
}
#top-right-lives .alien-lives-only {
  display: flex;
  align-items: center;
  opacity: 1;
}
#top-right-lives .alien-lives-only.visible {
  display: flex;
}
/* Always show Alien hearts in top-right when game UI is visible */
#top-right-lives #alien-lives-wrap {
  display: flex !important;
  opacity: 1 !important;
}
#top-right-lives #alien-lives-label {
  display: inline !important;
}
#top-right-lives #alien-lives {
  letter-spacing: 2px;
}

.alien-lives-only {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  opacity: 0;
  transition: opacity 0.3s;
}
.alien-lives-only.visible {
  display: flex;
  opacity: 1;
}
#alien-lives-label {
  color: rgba(255,255,255,0.9);
}
#alien-lives {
  letter-spacing: 2px;
}

/* Level 3 hard mode: second alien lives (hidden until level 3 hard) */
.alien2-only {
  display: none !important;
}
#top-right-lives .alien2-only.visible {
  display: inline-block !important;
}
#top-right-lives #alien-lives-wrap-2.visible {
  display: flex !important;
  opacity: 1 !important;
}

#exit-btn {
  font-size: clamp(0.75rem, 2vw, 0.85rem);
  padding: clamp(4px, 1.5vw, 6px) clamp(8px, 2vw, 12px);
  min-height: clamp(32px, 8vw, 36px);
  background: rgba(255, 107, 107, 0.9);
}

#exit-btn:hover {
  background: #ff6b6b;
}

#pause-btn {
  font-size: clamp(0.8rem, 2.2vw, 0.9rem);
  padding: clamp(6px, 1.5vw, 8px) clamp(12px, 2.5vw, 16px);
  margin-top: 0;
  min-height: clamp(34px, 8vw, 36px);
}

#turbo-indicator.turbo-badge {
  display: none;
  font-size: var(--font-level);
  color: var(--accent);
  font-weight: 700;
  margin-left: 8px;
}
#turbo-indicator.turbo-badge.active {
  display: inline-block;
  animation: turbo-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes turbo-pulse {
  from { opacity: 0.9; }
  to { opacity: 1; text-shadow: 0 0 8px var(--accent); }
}

#level-progress-bar {
  height: clamp(6px, 1.8vw, 8px);
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  overflow: hidden;
}

#level-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--kid-blue), var(--accent));
  border-radius: 8px;
  transition: width 0.2s ease;
}

#controls-hint {
  font-size: clamp(0.65rem, 1.8vw, 0.75rem);
  opacity: 0;
  margin-top: 4px;
  color: rgba(255,255,255,0.92);
}

#controls-hint.visible {
  opacity: 1;
}

/* Touch controls: fixed at bottom (footer) on touch devices */
#touch-controls.touch-only {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 12px var(--ui-pad);
  padding-bottom: max(12px, var(--safe-bottom));
  background: rgba(10, 5, 25, 0.9);
  border-top: 2px solid rgba(255, 182, 218, 0.25);
  z-index: 25;
  pointer-events: none;
  margin-top: 0;
  margin-bottom: 0;
}
#touch-controls.touch-only.visible {
  display: flex;
  pointer-events: auto;
}
.touch-only .touch-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(26,10,46,0.85);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  pointer-events: auto;
}
.touch-only .touch-btn:active {
  background: rgba(255,217,61,0.4);
  border-color: var(--accent);
}
.touch-only .touch-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Exit confirmation modal */
.modal-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(26, 10, 46, 0.92);
  z-index: 40;
  padding: var(--ui-pad);
}
.modal-overlay.visible {
  display: flex;
}
.modal-content {
  background: rgba(45, 27, 78, 0.98);
  border: 3px solid rgba(255, 158, 205, 0.4);
  border-radius: clamp(12px, 4vw, 20px);
  padding: clamp(20px, 5vw, 28px);
  text-align: center;
  max-width: min(320px, 90%);
}
.modal-content h2 {
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  color: var(--accent);
  margin-bottom: 10px;
}
.modal-content p {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  color: rgba(255,255,255,0.95);
  margin-bottom: 20px;
  line-height: 1.4;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.modal-actions button {
  min-width: 100px;
}
#exit-confirm-no {
  background: linear-gradient(135deg, var(--kid-blue), #5ab8e8);
}
#exit-confirm-yes {
  background: linear-gradient(135deg, #ff6b6b, #e85555);
}

#game-footer {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: clamp(8px, 2vw, 12px) var(--ui-pad);
  padding-bottom: max(16px, var(--safe-bottom));
  background: rgba(10, 5, 25, 0.85);
  border-top: 2px solid rgba(255, 182, 218, 0.25);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 20;
}
#game-footer.hidden {
  display: none !important;
}

#game-footer.visible {
  opacity: 1;
}

/* Start screen – responsive, centered, no cropping */
#instructions {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(calc(100% - 24px), 420px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  pointer-events: auto;
  text-align: center;
  padding: clamp(16px, 4vw, 24px) clamp(14px, 4vw, 20px);
  background: rgba(45, 27, 78, 0.95);
  border: 3px solid rgba(255, 158, 205, 0.4);
  border-radius: clamp(12px, 4vw, 20px);
  z-index: 25;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

#instructions h2 {
  font-size: var(--font-instruction-h2);
  color: var(--accent);
  margin-bottom: clamp(8px, 2vw, 14px);
  line-height: 1.3;
  text-shadow: 0 0 20px rgba(255, 217, 61, 0.4);
}

.level-choose-label {
  font-size: var(--font-instruction);
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: clamp(10px, 2.5vw, 14px);
}

#level-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(10px, 3vw, 14px);
  margin-bottom: clamp(14px, 3vw, 18px);
}

.level-btn {
  min-width: clamp(100px, 28vw, 120px);
  padding: clamp(12px, 3vw, 14px) clamp(16px, 4vw, 20px);
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 600;
  border-radius: 12px;
  border: 2px solid rgba(255, 158, 205, 0.5);
  background: linear-gradient(180deg, rgba(255, 182, 218, 0.35), rgba(157, 78, 180, 0.4));
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.level-btn:hover,
.level-btn:focus {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(255, 158, 205, 0.5);
  outline: none;
}

#instructions p {
  margin-bottom: clamp(6px, 1.5vw, 10px);
  font-size: var(--font-instruction);
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#rocket-name-label {
  display: block;
  margin-top: clamp(10px, 2.5vw, 14px);
  margin-bottom: 8px;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  color: var(--accent);
  font-weight: 600;
}

#rocket-name-input {
  display: block;
  width: 100%;
  max-width: min(240px, 85%);
  margin: 0 auto 16px;
  padding: clamp(10px, 2.5vw, 12px) clamp(12px, 3vw, 16px);
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  border: 2px solid rgba(255, 158, 205, 0.5);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: #1a0a2e;
  text-align: center;
  box-sizing: border-box;
}

#rocket-name-input::placeholder {
  color: rgba(26, 10, 46, 0.5);
}

#rocket-name-input:focus {
  outline: none;
  border-color: var(--kid-pink);
  box-shadow: 0 0 12px rgba(255, 158, 205, 0.4);
}

#difficulty-label {
  display: block;
  margin-top: 12px;
  margin-bottom: 8px;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 600;
}

#difficulty-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.mode-btn {
  padding: 12px 20px;
  font-size: 1rem;
  margin-top: 0;
  min-height: 48px;
}

.mode-btn.chosen {
  box-shadow: 0 0 0 3px var(--accent);
}

#timer-wrap {
  display: none;
  align-items: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

#timer-wrap.visible {
  display: flex;
}

#timer-wrap.warning #game-timer {
  color: #ff6b6b;
  animation: timer-pulse 0.5s ease-in-out infinite;
}

@keyframes timer-pulse {
  50% { opacity: 0.8; }
}

#instructions.hidden {
  display: none;
}

/* Buttons – touch-friendly min size, scale with viewport */
button {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 700;
  padding: clamp(12px, 3vw, 16px) clamp(24px, 5vw, 32px);
  margin-top: clamp(12px, 3vw, 16px);
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--kid-pink), #ff6b9d);
  color: white;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: var(--btn-min-height);
}

button:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 24px rgba(255, 107, 157, 0.5);
}

button:active {
  transform: scale(0.98);
}

/* Game Over – encouraging, responsive */
#game-over,
#level-complete,
#pause-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(26, 10, 46, 0.94);
  z-index: 30;
  padding: clamp(16px, 4vw, 28px) clamp(16px, 4vw, 24px);
  padding-top: max(clamp(16px, 4vw, 28px), var(--safe-top));
  padding-bottom: max(clamp(16px, 4vw, 28px), var(--safe-bottom));
  box-sizing: border-box;
}

#pause-overlay.visible {
  display: flex;
}

#pause-overlay h2 {
  font-size: clamp(1.4rem, 4.5vw, 1.75rem);
  color: var(--accent);
  margin-bottom: 12px;
  text-align: center;
}

#pause-overlay p.pause-hint,
#pause-overlay .pause-hint {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  color: rgba(255,255,255,0.9);
  margin-bottom: clamp(16px, 4vw, 24px);
  text-align: center;
  max-width: min(280px, 85vw);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding: 0 12px;
}

#game-over h1 {
  color: #ff6b6b;
  font-size: clamp(1.5rem, 5vw, 2rem);
  text-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
}

#game-over h1,
#level-complete h1 {
  font-size: clamp(1.4rem, 4.5vw, 1.8rem);
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.3;
}

#level-complete h1 {
  color: var(--kid-blue);
}

#final-score,
#level-complete p {
  font-size: clamp(0.95rem, 2.8vw, 1.1rem);
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: clamp(16px, 4vw, 24px);
  text-align: center;
}

#balloons {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

#level-complete h1,
#level-complete p,
#level-complete button {
  position: relative;
  z-index: 1;
}

.balloon {
  position: absolute;
  bottom: -60px;
  width: 44px;
  height: 56px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: inset -6px -6px 12px rgba(0,0,0,0.15);
  animation: balloon-float 4s ease-in infinite;
}

.balloon::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 14px;
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}

@keyframes balloon-float {
  0% {
    bottom: -60px;
    transform: translateX(0) rotate(-5deg);
    opacity: 1;
  }
  100% {
    bottom: 110%;
    transform: translateX(20px) rotate(5deg);
    opacity: 0.7;
  }
}

#game-over.visible,
#level-complete.visible {
  display: flex;
}

/* Level 2: hidden until active */
#player-lasers,
#enemy-ships {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
}

.laser {
  position: absolute;
  width: clamp(18px, 5vw, 24px);
  height: 6px;
  background: linear-gradient(90deg, #ff4444, #ff8844);
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(255, 68, 68, 0.8);
  z-index: 8;
}

.enemy-ship {
  position: absolute;
  width: var(--collectible-size);
  height: var(--collectible-size);
  font-size: calc(var(--collectible-size) * 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
}

/* Level 3: duel on moon */
#duel-scene {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 15;
}

#duel-scene.visible {
  display: block;
}

#duel-moon-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #1a0a2e 0%, #2d1b4e 50%, #3d2a5c 100%);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 100%, #4a3d5c 0%, #2d2040 40%, transparent 70%),
    radial-gradient(3px 3px at 20px 30px, #fff, transparent),
    radial-gradient(2px 2px at 60px 80px, rgba(255,255,255,0.9), transparent);
  background-size: 120px 120px;
}

/* Level 3: Jupiter shelter in center – blocks alien lasers */
#duel-jupiter {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(56px, 20vw, 100px);
  z-index: 10;
  filter: drop-shadow(0 0 20px rgba(210, 180, 140, 0.5));
  pointer-events: none;
}

#duel-scene.level-4 #duel-jupiter {
  display: none;
}

#duel-shelters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#duel-shelters .duel-shelter {
  position: absolute;
  font-size: clamp(32px, 10vw, 48px);
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 12px rgba(210, 180, 140, 0.4));
  pointer-events: none;
}

#duel-player {
  position: absolute;
  left: 18%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(40px, 14vw, 56px);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
  z-index: 12;
  transition: top 0.1s ease-out;
}

#duel-player.bubble {
  box-shadow: 0 0 0 12px rgba(174, 230, 255, 0.5), 0 0 24px rgba(135, 206, 250, 0.45);
  border-radius: 50%;
  animation: bubble-pulse 1.2s ease-in-out infinite;
}

#duel-alien {
  position: absolute;
  right: 18%;
  top: 50%;
  transform: translate(50%, -50%);
  font-size: clamp(40px, 14vw, 56px);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
  z-index: 12;
  transition: top 0.15s ease-out;
}

#duel-alien2.duel-alien-extra {
  position: absolute;
  right: 18%;
  top: 30%;
  transform: translate(50%, -50%);
  font-size: clamp(40px, 14vw, 56px);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
  z-index: 12;
  transition: top 0.15s ease-out;
  display: none;
}

#duel-scene.hard-mode #duel-alien2.duel-alien-extra {
  display: block;
}

#duel-player-lasers,
#duel-alien-lasers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 11;
}

.duel-laser-player,
.duel-laser-alien {
  position: absolute;
  width: clamp(20px, 6vw, 28px);
  height: 6px;
  border-radius: 4px;
}

.duel-laser-player {
  background: linear-gradient(90deg, #ff4444, #ff8844);
  box-shadow: 0 0 14px rgba(255, 68, 68, 0.9);
}

.duel-laser-alien {
  background: linear-gradient(90deg, #00ff88, #00ccff);
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.8);
}

.duel-laser-player.ice {
  background: linear-gradient(90deg, #66ccff, #cceeff);
  box-shadow: 0 0 14px rgba(100, 200, 255, 0.95);
}

#duel-alien.frozen,
#duel-alien2.duel-alien-extra.frozen {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4)) hue-rotate(180deg) saturate(0.7);
  opacity: 0.9;
}

/* Responsive: tablet and desktop */
@media (min-width: 768px) {
  #game-container {
    max-width: 520px;
    border-radius: 16px;
  }
}

@media (min-width: 1024px) {
  #game-container {
    max-width: 560px;
    max-height: 900px;
  }
}

/* Very short viewports (e.g. landscape phone): keep instructions scrollable */
@media (max-height: 400px) {
  #instructions {
    max-height: calc(100% - 16px);
    padding-top: 12px;
    padding-bottom: 12px;
  }
  #instructions h2 {
    margin-bottom: 6px;
  }
  #instructions p {
    margin-bottom: 6px;
  }
}
