/* ============================================
   ALIEN INVASION - STYLES
   Retro arcade aesthetic with CRT effects
   ============================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Courier New', monospace;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Game Container ---- */

#gameContainer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---- CRT Overlay ---- */

#crtOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.08) 0px,
      rgba(0, 0, 0, 0.08) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: multiply;
}

#crtOverlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.35) 100%
  );
}

/* ---- UI Overlay ---- */

#gameUI {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

/* ---- HUD ---- */

#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 16px;
  z-index: 15;
}

#hudLeft, #hudCenter, #hudRight {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 10px;
  color: #888;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hud-value {
  font-size: 18px;
  color: #fff;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
  letter-spacing: 2px;
}

#livesDisplay {
  font-size: 16px;
  letter-spacing: 4px;
}

/* ---- Wave Indicator ---- */

#waveIndicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  pointer-events: none;
}

#waveText {
  font-size: 48px;
  font-weight: bold;
  color: #0f0;
  text-shadow:
    0 0 10px #0f0,
    0 0 20px #0f0,
    0 0 40px #0a0;
  letter-spacing: 8px;
  animation: waveFlash 0.5s ease-in-out infinite alternate;
}

@keyframes waveFlash {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

/* ---- Overlay Screens ---- */

.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.85);
}

.overlay-screen.hidden {
  display: none;
}

.screen-content {
  text-align: center;
  max-width: 400px;
  padding: 20px;
}

.game-title {
  font-size: 42px;
  color: #0f0;
  text-shadow:
    0 0 10px #0f0,
    0 0 20px #0f0,
    0 0 40px #0a0,
    0 0 80px #060;
  letter-spacing: 4px;
  margin-bottom: 16px;
  animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 40px #0a0; }
  50% { text-shadow: 0 0 15px #0f0, 0 0 30px #0f0, 0 0 60px #0a0, 0 0 100px #060; }
}

.title-aliens {
  margin: 16px auto;
}

#titleAlienCanvas {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.game-description {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 24px;
  line-height: 1.5;
}

.game-over-title {
  font-size: 48px;
  color: #f00;
  text-shadow:
    0 0 10px #f00,
    0 0 20px #f00,
    0 0 40px #a00;
  letter-spacing: 6px;
  margin-bottom: 24px;
  animation: gameOverFlash 1s ease-in-out infinite alternate;
}

@keyframes gameOverFlash {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* ---- Stats ---- */

.final-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat-label {
  font-size: 10px;
  color: #888;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 28px;
  color: #0f0;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
}

/* ---- Buttons ---- */

.btn-action {
  background: transparent;
  color: #0f0;
  border: 2px solid #0f0;
  padding: 14px 48px;
  font-size: 18px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  pointer-events: auto;
  box-shadow:
    0 0 10px rgba(0, 255, 0, 0.3),
    inset 0 0 10px rgba(0, 255, 0, 0.1);
}

.btn-action:hover {
  background: rgba(0, 255, 0, 0.1);
  box-shadow:
    0 0 20px rgba(0, 255, 0, 0.5),
    inset 0 0 20px rgba(0, 255, 0, 0.2);
  transform: scale(1.05);
}

.btn-action:active {
  transform: scale(0.98);
}

.leaderboard-msg {
  font-size: 11px;
  color: #555;
  margin-top: 16px;
}

/* ---- Controls Info ---- */

.controls-info {
  margin-top: 24px;
}

.controls-info h3 {
  font-size: 12px;
  color: #888;
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.controls-desktop,
.controls-mobile {
  font-size: 13px;
  color: #aaa;
}

.controls-mobile {
  display: none;
}

.key {
  display: inline-block;
  background: rgba(0, 255, 0, 0.15);
  border: 1px solid rgba(0, 255, 0, 0.4);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  color: #0f0;
  margin: 0 2px;
}

/* ---- Touch Controls ---- */

#touchControls {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 12px 16px;
  z-index: 25;
  pointer-events: auto;
}

.touch-btn {
  background: rgba(0, 255, 0, 0.12);
  border: 2px solid rgba(0, 255, 0, 0.4);
  color: #0f0;
  font-size: 24px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.1s;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-btn:active {
  background: rgba(0, 255, 0, 0.3);
}

.touch-fire {
  font-size: 16px;
  letter-spacing: 4px;
  background: rgba(255, 50, 50, 0.15);
  border-color: rgba(255, 50, 50, 0.5);
  color: #f55;
}

.touch-fire:active {
  background: rgba(255, 50, 50, 0.35);
}

#touchLeft {
  position: absolute;
  bottom: 12px;
  left: 16px;
  width: 72px;
  height: 72px;
}

#touchRight {
  position: absolute;
  bottom: 12px;
  left: 104px;
  width: 72px;
  height: 72px;
}

#touchFire {
  position: absolute;
  bottom: 12px;
  right: 16px;
  width: 100px;
  height: 72px;
}

/* ---- Responsive ---- */

@media (pointer: coarse) {
  #touchControls {
    display: block;
  }
  .controls-desktop {
    display: none;
  }
  .controls-mobile {
    display: block;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 28px;
    letter-spacing: 2px;
  }

  .game-over-title {
    font-size: 32px;
  }

  #waveText {
    font-size: 32px;
  }

  .hud-value {
    font-size: 14px;
  }

  .hud-label {
    font-size: 8px;
  }

  .stat-value {
    font-size: 22px;
  }

  .btn-action {
    padding: 12px 32px;
    font-size: 14px;
  }

  .final-stats {
    gap: 16px;
  }

  #touchLeft,
  #touchRight {
    width: 60px;
    height: 60px;
  }

  #touchRight {
    left: 88px;
  }

  #touchFire {
    width: 80px;
    height: 60px;
  }

  .touch-btn {
    font-size: 20px;
  }

  .touch-fire {
    font-size: 13px;
  }
}
