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

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

body {
  background: radial-gradient(ellipse at 50% 30%, #0f0c29, #0a0a1a 60%, #000);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  overflow: hidden;
}

/* Animated starfield background */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 30% 50%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 55% 15%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 85% 40%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 15% 90%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 45% 65%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 90% 10%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 25% 75%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 60% 35%, rgba(255,255,255,0.5), transparent);
  animation: bgDrift 60s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes bgDrift {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-100px); }
}

#game-container {
  position: relative;
  border: 1px solid rgba(100, 140, 255, 0.25);
  border-radius: 10px;
  box-shadow:
    0 0 30px rgba(80, 120, 255, 0.15),
    0 0 60px rgba(80, 120, 255, 0.08),
    0 0 120px rgba(80, 120, 255, 0.04),
    inset 0 0 30px rgba(80, 120, 255, 0.03);
  animation: containerPulse 4s ease-in-out infinite;
}

@keyframes containerPulse {
  0%, 100% {
    box-shadow:
      0 0 30px rgba(80, 120, 255, 0.15),
      0 0 60px rgba(80, 120, 255, 0.08),
      0 0 120px rgba(80, 120, 255, 0.04),
      inset 0 0 30px rgba(80, 120, 255, 0.03);
  }
  50% {
    box-shadow:
      0 0 40px rgba(100, 140, 255, 0.2),
      0 0 80px rgba(100, 140, 255, 0.1),
      0 0 140px rgba(100, 140, 255, 0.05),
      inset 0 0 40px rgba(100, 140, 255, 0.04);
  }
}

canvas {
  display: block;
  border-radius: 9px;
}

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

#start-screen,
#game-over-screen,
#pause-screen {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(3, 3, 18, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 9px;
  color: #fff;
  pointer-events: auto;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

#start-screen h1,
#game-over-screen h1,
#pause-screen h1 {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 2.4rem;
  margin-bottom: 0.6rem;
  letter-spacing: 3px;
  text-shadow:
    0 0 10px rgba(100, 160, 255, 0.8),
    0 0 30px rgba(100, 160, 255, 0.4),
    0 0 60px rgba(100, 160, 255, 0.2);
  animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
  0%, 100% {
    text-shadow:
      0 0 10px rgba(100, 160, 255, 0.8),
      0 0 30px rgba(100, 160, 255, 0.4),
      0 0 60px rgba(100, 160, 255, 0.2);
  }
  50% {
    text-shadow:
      0 0 15px rgba(140, 190, 255, 1),
      0 0 40px rgba(140, 190, 255, 0.6),
      0 0 80px rgba(140, 190, 255, 0.3);
  }
}

#game-over-screen h1 {
  text-shadow:
    0 0 10px rgba(255, 80, 80, 0.8),
    0 0 30px rgba(255, 80, 80, 0.4),
    0 0 60px rgba(255, 80, 80, 0.2);
  animation: gameOverGlow 2s ease-in-out infinite;
}

@keyframes gameOverGlow {
  0%, 100% {
    text-shadow:
      0 0 10px rgba(255, 80, 80, 0.8),
      0 0 30px rgba(255, 80, 80, 0.4),
      0 0 60px rgba(255, 80, 80, 0.2);
  }
  50% {
    text-shadow:
      0 0 15px rgba(255, 100, 100, 1),
      0 0 40px rgba(255, 100, 100, 0.6),
      0 0 80px rgba(255, 100, 100, 0.3);
  }
}

#start-screen p,
#game-over-screen p,
#pause-screen p {
  font-size: 1.15rem;
  color: #8899bb;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

#final-score,
#final-level {
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem !important;
  color: #ffdd55 !important;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 220, 80, 0.4);
}

.controls {
  display: flex;
  gap: 1rem;
  margin: 1.2rem 0 1.8rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #99aacc;
  letter-spacing: 0.5px;
}

.controls span {
  background: rgba(100, 140, 255, 0.08);
  padding: 0.35rem 0.9rem;
  border-radius: 5px;
  border: 1px solid rgba(100, 140, 255, 0.18);
  transition: background 0.2s;
}

.controls span:hover {
  background: rgba(100, 140, 255, 0.15);
}

button {
  margin-top: 1.2rem;
  padding: 0.85rem 3rem;
  font-family: 'Orbitron', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #4a6cf7, #7b3cf7);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 2px;
  box-shadow:
    0 4px 20px rgba(100, 80, 255, 0.4),
    0 0 40px rgba(100, 80, 255, 0.15);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 50%, transparent 60%);
  transition: left 0.6s ease;
}

button:hover::before {
  left: 110%;
}

button:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 25px rgba(100, 80, 255, 0.6),
    0 0 50px rgba(100, 80, 255, 0.2);
}

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

#restart-btn {
  background: linear-gradient(135deg, #e74c6f, #f77b3c);
  box-shadow:
    0 4px 20px rgba(231, 76, 111, 0.35),
    0 0 40px rgba(231, 76, 111, 0.12);
}

#restart-btn:hover {
  box-shadow:
    0 6px 25px rgba(231, 76, 111, 0.55),
    0 0 50px rgba(231, 76, 111, 0.18);
}
