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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f0f1a;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#game-container {
  position: relative;
  max-width: 800px;
  box-shadow: 0 0 40px rgba(0, 217, 255, 0.15);
  background: #1a1a2e;
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 800px;
  height: auto;
  max-height: 90vh;
  aspect-ratio: 800 / 600;
}

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#ui-overlay > * {
  pointer-events: auto;
}

#menu-screen,
#game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

#menu-screen {
  background: linear-gradient(
    135deg,
    rgba(15, 15, 26, 0.85) 0%,
    rgba(26, 26, 46, 0.9) 50%,
    rgba(15, 15, 26, 0.85) 100%
  );
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0, 217, 255, 0.12);
  box-shadow: inset 0 0 60px rgba(0, 217, 255, 0.03);
}

#menu-screen h1 {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 0 12px rgba(0, 217, 255, 0.2);
  margin-bottom: 0.5rem;
}

#menu-screen .menu-tagline {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.25em;
}

#menu-screen .menu-best {
  font-size: 1rem;
  font-weight: 600;
  color: #00D9FF;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  opacity: 0.95;
}

#menu-screen p,
#game-over-screen p {
  color: #EEEEEE;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

#game-over-screen h2 {
  color: #00D9FF;
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
}

.hint {
  margin-top: 1.5rem !important;
  color: #00D9FF !important;
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

.controller-hint {
  margin-top: 2rem !important;
  font-size: 0.9rem !important;
  color: #888 !important;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem 1rem;
}

#hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

#level-display {
  color: #FFD700;
  font-size: 1.1rem;
  font-weight: 600;
}

#lives-display {
  color: #E91E63;
  font-size: 1.25rem;
  font-weight: 600;
}

#near-miss-display {
  color: #FF6600;
  font-size: 1rem;
  font-weight: 600;
}

#shield-display {
  color: #2196F3;
  font-size: 1.1rem;
  font-weight: 600;
}

#score-display,
#high-score-display {
  color: #EEEEEE;
  font-size: 1.25rem;
  font-weight: 600;
}

#high-score-display,
#high-level-display {
  color: #00D9FF;
}

#pause-hint {
  color: #888;
  font-size: 0.85rem;
  order: 10;
  flex-basis: 100%;
  text-align: center;
  margin-top: 0.25rem;
}

#powerup-hud-legend {
  order: 11;
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 0.25rem;
}

#powerup-hud-legend span {
  white-space: nowrap;
}

#powerup-hud-legend .pu-shield { color: #2196F3; }
#powerup-hud-legend .pu-slowmo { color: #9C27B0; }
#powerup-hud-legend .pu-magnet { color: #00BCD4; }
#powerup-hud-legend .pu-life { color: #E91E63; }
#powerup-hud-legend .pu-clear { color: #FFEB3B; }

#powerup-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  font-size: 0.95rem;
  margin: 1rem 0 0.5rem;
}

#powerup-legend span {
  white-space: nowrap;
  cursor: help;
}

#powerup-legend .pu-shield { color: #2196F3; }
#powerup-legend .pu-slowmo { color: #9C27B0; }
#powerup-legend .pu-magnet { color: #00BCD4; }
#powerup-legend .pu-life { color: #E91E63; }
#powerup-legend .pu-clear { color: #FFEB3B; }

#paused-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}

#paused-overlay h2 {
  color: #00D9FF;
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

#paused-overlay .hint {
  margin-top: 0.5rem;
}

#countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  pointer-events: none; /* don't block game input */
}

#countdown-text {
  font-size: 6rem;
  font-weight: 700;
  color: #00D9FF;
  text-shadow: 0 0 20px rgba(0, 217, 255, 0.25);
  animation: countdown-pop 0.3s ease-out;
}

@keyframes countdown-pop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

#level-up-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  pointer-events: none;
}

#level-up-text {
  font-size: 4rem;
  font-weight: 700;
  color: #FFD700;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.25);
  animation: level-up-pop 0.4s ease-out;
}

.level-up-visible #level-up-text {
  animation: level-up-pop 0.4s ease-out;
}

#points-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  font-weight: 700;
  color: #FFD700;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
  pointer-events: none;
}

#points-popup.points-popup-visible {
  animation: points-popup 0.8s ease-out forwards;
}

#near-miss-bonus {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 700;
  color: #FF6600;
  text-shadow: 0 0 16px rgba(255, 102, 0, 0.6);
  pointer-events: none;
}

#near-miss-bonus.near-miss-bonus-visible {
  animation: near-miss-bonus-pop 1.5s ease-out forwards;
}

@keyframes near-miss-bonus-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -70%) scale(1.1);
  }
}

@keyframes points-popup {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.8);
  }
  30% {
    transform: translate(-50%, -60%) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80%) scale(1);
  }
}

@keyframes level-up-pop {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

#sound-hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 217, 255, 0.4);
  color: #00D9FF;
  font-size: 0.9rem;
  border-radius: 4px;
  pointer-events: none;
  animation: pulse 1.5s ease-in-out infinite;
}

.hidden {
  display: none !important;
}
