/* ─── Reset & Base ─── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #fff;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ─── Game Container ─── */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#gameCanvas {
  display: block;
  background: #111122;
  border: 2px solid #333366;
  border-radius: 4px;
  box-shadow: 0 0 30px rgba(80, 80, 200, 0.3);
  max-width: 100vw;
  max-height: 100vh;
}

/* ─── HUD (Score, Lives, Level) — LARGER ─── */
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  pointer-events: none;
  z-index: 10;
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(100, 100, 255, 0.8);
}

#score-display {
  color: #88ccff;
}

#lives-display {
  color: #ff8888;
}

#level-display {
  color: #88ff88;
}

/* ─── Overlays (Title, Pause, Game Over, Win) ─── */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(5, 5, 20, 0.85);
  z-index: 20;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay h1 {
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 800;
  letter-spacing: 8px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bff8b, #6bb5ff, #b56bff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px rgba(150, 150, 255, 0.5));
  margin-bottom: 16px;
}

.overlay h2 {
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #ff6b6b;
  text-shadow: 0 0 12px rgba(255, 100, 100, 0.5);
  margin-bottom: 16px;
}

.prompt {
  font-size: clamp(14px, 2.5vw, 22px);
  color: #aaaadd;
  animation: pulse 1.5s ease-in-out infinite;
  margin-bottom: 12px;
}

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

#high-score-display {
  font-size: clamp(12px, 2vw, 16px);
  color: #ffcc44;
  margin-top: 8px;
}

#final-score, #win-score {
  font-size: clamp(18px, 3vw, 28px);
  color: #ccccff;
  margin-bottom: 16px;
}

.hint {
  font-size: clamp(11px, 1.5vw, 14px);
  color: #7777aa;
  margin-top: 8px;
}

/* ─── Buttons ─── */
button {
  padding: 12px 32px;
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #4444aa, #6644cc);
  border: 2px solid #7766dd;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 0 15px rgba(100, 80, 200, 0.4);
  min-height: 44px;
  min-width: 120px;
}

button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 25px rgba(120, 100, 220, 0.6);
}

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

/* ─── Level Select Overlay ─── */
#level-select-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(5, 5, 20, 0.75);
  z-index: 30;
  transition: opacity 0.3s ease;
}

#level-select-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#level-select-overlay h2 {
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #ffcc44;
  text-shadow: 0 0 10px rgba(255, 200, 50, 0.5);
  margin-bottom: 24px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 20px;
  max-width: 600px;
  width: 90%;
}

.level-btn {
  padding: 16px 12px;
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #334488, #5544aa);
  border: 2px solid #6666cc;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 0 12px rgba(80, 60, 180, 0.4);
  min-height: 56px;
  text-align: center;
  pointer-events: auto;
}

.level-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 22px rgba(100, 80, 220, 0.7);
  background: linear-gradient(135deg, #4455aa, #6655cc);
}

.level-btn:active {
  transform: scale(0.96);
}

.level-hint {
  font-size: clamp(11px, 1.5vw, 14px);
  color: #7777aa;
  margin-top: 16px;
}

/* ─── Mobile Adjustments ─── */
@media (max-width: 600px) {
  #ui-overlay {
    padding: 6px 12px;
  }

  .overlay h1 {
    letter-spacing: 4px;
  }

  .overlay h2 {
    letter-spacing: 2px;
  }

  .level-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .level-btn {
    padding: 12px 8px;
    min-height: 48px;
  }
}