/* Missile Tap - iPhone-optimized (430×719 viewport) */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0a0a1a;
  color: #eee;
  /* Prevent pull-to-refresh and overscroll on iOS */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  /* Prevent text selection on taps */
  -webkit-user-select: none;
  user-select: none;
}

body {
  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);
}

/* HUD - top bar */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 430px;
  padding: 8px 16px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  z-index: 10;
}

#hud-left, #hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-icon {
  font-size: 1.2rem;
}

/* Game area */
#game {
  position: relative;
  width: 430px;
  height: 600px; /* Fits 719 - safe areas */
  background: linear-gradient(180deg, #0f1a3a 0%, #1a2a5a 40%, #2a4a7a 100%);
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 100, 255, 0.15);
  touch-action: none; /* prevent gesture interference */
}

/* Starfield */
.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: 0.5;
}

/* Ground glow */
#ground-glow {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background: linear-gradient(0deg, rgba(255, 100, 0, 0.08) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* Danger zone indicator */
#danger-line {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 50, 50, 0.4);
  z-index: 1;
  pointer-events: none;
}

/* Missile styling */
.missile {
  position: absolute;
  width: 28px;
  height: 52px;
  background: linear-gradient(180deg, #c0c0c0 0%, #888 40%, #555 100%);
  border-radius: 4px 4px 2px 2px;
  z-index: 5;
  touch-action: none;
}

/* Missile nose cone */
.missile::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid #ff3333;
}

/* Missile fins */
.missile::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 8px;
  background: #333;
  border-radius: 0 0 2px 2px;
  box-shadow: -10px -4px 0 -2px #444, 10px -4px 0 -2px #444;
}

/* Missile flame trail */
.missile-trail {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 0;
  background: linear-gradient(0deg, transparent, #ff6600, #ffcc00);
  border-radius: 3px;
  pointer-events: none;
  animation: trailBurn 0.3s ease-out;
}

@keyframes trailBurn {
  0% { height: 24px; opacity: 0.8; }
  100% { height: 8px; opacity: 0; }
}

/* Explosion effect */
.explosion {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff, #ffcc00, #ff6600, transparent);
  z-index: 10;
  pointer-events: none;
  animation: explode 0.4s ease-out forwards;
}

@keyframes explode {
  0% { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* Tap flash on game area */
.tap-flash {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.8), transparent);
  pointer-events: none;
  animation: tapRipple 0.3s ease-out forwards;
  z-index: 20;
}

@keyframes tapRipple {
  0% { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(3); opacity: 0; }
}

/* Game over overlay */
#game-over {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#game-over.show {
  display: flex;
}

#game-over h2 {
  font-size: 2rem;
  margin: 0 0 8px;
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255, 50, 50, 0.5);
}

#game-over p {
  font-size: 1.2rem;
  margin: 0 0 24px;
  color: #ddd;
}

#game-over .final-score {
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  margin: 8px 0;
}

#restart-btn {
  font-size: 1.2rem;
  padding: 14px 48px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #4a9eff, #2a7aff);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(42, 122, 255, 0.4);
  touch-action: manipulation;
  cursor: pointer;
}

#restart-btn:active {
  opacity: 0.8;
  transform: scale(0.96);
}

/* Lives display */
#lives {
  color: #ff6666;
}

/* HUD score */
#score {
  color: #ffcc00;
}

/* High score */
#high-score {
  color: #8af;
}
