/* CSS Reset and Variable Definitions */
:root {
  --bg-color: #09070f;
  --panel-bg: rgba(20, 16, 35, 0.7);
  --panel-border: rgba(147, 51, 234, 0.3);
  --neon-purple: #a855f7;
  --neon-pink: #ec4899;
  --neon-yellow: #eab308;
  --neon-cyan: #06b6d4;
  --neon-red: #ef4444;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --font-retro: 'Press Start 2P', monospace;
  --font-modern: 'Outfit', sans-serif;
  --glow-shadow: 0 0 15px rgba(168, 85, 247, 0.5);
}

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

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 20% 20%, rgba(76, 29, 149, 0.15) 0px, transparent 50%),
    radial-gradient(at 80% 80%, rgba(219, 39, 119, 0.1) 0px, transparent 50%);
  color: var(--text-primary);
  font-family: var(--font-modern);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* Game Container Layout */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  width: 100%;
  max-width: 820px;
  padding: 10px;
}

/* HUD Styling */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 24px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  box-shadow: var(--glow-shadow);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud .label {
  font-family: var(--font-retro);
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.hud .value {
  font-family: var(--font-retro);
  font-size: 18px;
  font-weight: bold;
  color: var(--text-primary);
  text-shadow: 0 0 8px var(--neon-purple);
}

#score-val {
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan);
}

#highscore-val {
  color: var(--neon-yellow);
  text-shadow: 0 0 8px var(--neon-yellow);
}

.lives-hearts {
  display: flex;
  gap: 6px;
  font-size: 18px;
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
  min-height: 22px;
}

/* Canvas & Screen Overlay Wrapper */
.canvas-wrapper {
  position: relative;
  width: 800px;
  height: 600px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 10px var(--panel-border);
  border: 2px solid var(--panel-border);
}

/* Canvas styling */
#gameCanvas {
  display: block;
  background: #0f0b21;
}

/* Overlay Base Stylings (Glassmorphism) */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 8, 20, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: scale(1.05);
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* Titles and Typography inside Overlays */
.game-title {
  font-family: var(--font-retro);
  font-size: 42px;
  line-height: 1.3;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(236, 72, 153, 0.4);
}

.neon-text {
  color: var(--neon-pink);
  text-shadow: 0 0 15px var(--neon-pink), 0 0 30px var(--neon-pink);
  animation: glowPulse 2s infinite ease-in-out;
}

.subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-weight: 500;
}

/* Character Preview for Start Menu */
.character-preview {
  display: flex;
  gap: 30px;
  margin-bottom: 40px;
}

.preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.3s ease;
}

.preview-item:hover {
  transform: translateY(-5px);
}

.preview-item .emoji {
  font-size: 32px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.preview-item .desc {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: bold;
}

/* Buttons */
.btn {
  font-family: var(--font-modern);
  font-weight: 800;
  font-size: 18px;
  padding: 14px 36px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
  color: white;
  box-shadow: 0 0 15px rgba(236, 72, 153, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  transform: scale(1.08);
  box-shadow: 0 0 25px rgba(236, 72, 153, 0.7);
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--neon-purple);
  box-shadow: var(--glow-shadow);
}

.btn-secondary:hover {
  background: var(--neon-purple);
  transform: scale(1.05);
  box-shadow: 0 0 25px var(--neon-purple);
}

/* Controls Guide */
.controls-guide {
  margin-top: 35px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.8;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 20px;
  border-radius: 8px;
  border-left: 3px solid var(--neon-cyan);
}

/* Game Over Overlay Specific */
.game-over-box {
  background: rgba(15, 10, 25, 0.8);
  border: 2px solid var(--neon-red);
  border-radius: 24px;
  padding: 40px 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
  text-align: center;
  max-width: 450px;
  width: 90%;
}

.game-over-title {
  font-family: var(--font-retro);
  font-size: 32px;
  color: var(--neon-red);
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.8);
  margin-bottom: 24px;
  letter-spacing: 2px;
  animation: shake 0.5s ease-in-out;
}

.final-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
}

.stat-row {
  font-size: 20px;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
}

.neon-highlight {
  font-family: var(--font-retro);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan);
  font-weight: bold;
}

.new-record {
  display: none; /* Shown dynamically via game.js */
  font-family: var(--font-retro);
  font-size: 14px;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px var(--neon-yellow);
  animation: pulse 1s infinite alternate;
  background: rgba(234, 179, 8, 0.1);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--neon-yellow);
  margin-top: 10px;
}

/* Pause Overlay Specific */
.pause-title {
  font-family: var(--font-retro);
  font-size: 36px;
  color: var(--neon-cyan);
  text-shadow: 0 0 15px var(--neon-cyan);
  margin-bottom: 12px;
}

.pause-sub {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Screen Shake Effect for Damage/Game Over */
.shake-screen {
  animation: screenShake 0.15s 2;
}

/* Animations */
@keyframes glowPulse {
  0%, 100% {
    text-shadow: 0 0 15px var(--neon-pink), 0 0 30px var(--neon-pink);
  }
  50% {
    text-shadow: 0 0 25px var(--neon-pink), 0 0 45px var(--neon-pink);
  }
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.05); opacity: 1; }
}

@keyframes screenShake {
  0% { transform: translate(2px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(0px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(2px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(2px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Responsive adjustment */
@media (max-width: 820px) {
  .game-container {
    width: 100%;
    padding: 5px;
  }
  .canvas-wrapper {
    width: 100%;
    height: auto;
    aspect-ratio: 4/3;
  }
  #gameCanvas {
    width: 100%;
    height: auto;
  }
  .hud {
    padding: 10px 15px;
  }
  .game-title {
    font-size: 28px;
  }
  .character-preview {
    gap: 15px;
    margin-bottom: 20px;
  }
  .preview-item {
    padding: 8px 12px;
  }
  .preview-item .emoji {
    font-size: 24px;
  }
  .btn {
    padding: 10px 24px;
    font-size: 16px;
  }
}
