/* ============================================
   NEON SNAKE GAME - STYLESHEET
   Modern dark theme with neon glow effects
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(18, 18, 30, 0.85);
  --neon-green: #00ff88;
  --neon-cyan: #00e5ff;
  --neon-pink: #ff2d75;
  --neon-purple: #b14dff;
  --neon-yellow: #ffe156;
  --text-primary: #e0e0e0;
  --text-muted: #888;
  --glow-green: 0 0 10px #00ff8855, 0 0 30px #00ff8833;
  --glow-pink: 0 0 10px #ff2d7555, 0 0 30px #ff2d7533;
  --glow-cyan: 0 0 10px #00e5ff55, 0 0 30px #00e5ff33;
  --radius: 12px;
  --transition: 0.3s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* ---------- Animated Background Particles ---------- */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#particles::before,
#particles::after {
  content: '';
  position: absolute;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  animation: floatBlob 12s ease-in-out infinite alternate;
}

#particles::before {
  background: var(--neon-green);
  top: 10%;
  left: 15%;
}

#particles::after {
  background: var(--neon-purple);
  bottom: 10%;
  right: 15%;
  animation-delay: -6s;
}

@keyframes floatBlob {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(40px, -30px) scale(1.15); }
  100% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ---------- Container ---------- */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ---------- Header ---------- */
.header {
  text-align: center;
}

.title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 2.6rem;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: var(--glow-green);
}

.title .highlight {
  color: var(--neon-green);
  text-shadow: 0 0 12px #00ff8888, 0 0 40px #00ff8844;
}

.subtitle {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ---------- Score Panel ---------- */
.score-panel {
  display: flex;
  gap: 12px;
  width: 100%;
}

.score-box {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  backdrop-filter: blur(10px);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.score-box:hover {
  border-color: rgba(0, 255, 136, 0.4);
  box-shadow: var(--glow-green);
}

.score-box.high {
  border-color: rgba(255, 45, 117, 0.3);
}

.score-box.high:hover {
  border-color: rgba(255, 45, 117, 0.6);
  box-shadow: var(--glow-pink);
}

.score-label {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.score-value {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--neon-green);
}

.score-box.high .score-value {
  color: var(--neon-pink);
}

/* ---------- Canvas Wrapper ---------- */
.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 500px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid rgba(0, 255, 136, 0.2);
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.08), inset 0 0 60px rgba(0, 0, 0, 0.4);
  background: var(--bg-secondary);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* ---------- Overlay Screens ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(5, 5, 12, 0.88);
  backdrop-filter: blur(6px);
  z-index: 10;
  animation: fadeIn 0.4s ease;
}

.overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-content {
  text-align: center;
  padding: 32px;
}

.overlay-content h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  margin-bottom: 12px;
  color: #fff;
  text-shadow: var(--glow-green);
}

.overlay-content.game-over h2 {
  text-shadow: var(--glow-pink);
}

.overlay-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 8px;
}

.final-score {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.4rem !important;
  color: var(--neon-green) !important;
  margin-top: 8px !important;
}

.final-high {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem !important;
  color: var(--neon-pink) !important;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  padding: 14px 36px;
  transition: all var(--transition);
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50px;
  opacity: 0;
  transition: opacity var(--transition);
}

.btn:hover::after {
  opacity: 1;
}

.btn-start, .btn-restart {
  background: linear-gradient(135deg, var(--neon-green), #00cc6a);
  color: #000;
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
  margin-top: 16px;
}

.btn-start:hover, .btn-restart:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 30px rgba(0, 255, 136, 0.5);
}

.btn-start:active, .btn-restart:active {
  transform: translateY(0) scale(0.98);
}

/* Control buttons */
.controls {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-ctrl {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  font-size: 0.7rem;
  backdrop-filter: blur(10px);
}

.btn-ctrl:hover:not(:disabled) {
  border-color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
  color: var(--neon-cyan);
  transform: translateY(-1px);
}

.btn-ctrl:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- Mobile D-Pad ---------- */
.dpad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}

.dpad-middle {
  display: flex;
  gap: 4px;
  align-items: center;
}

.dpad-center {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.dpad-btn {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(0, 255, 136, 0.25);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--neon-green);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.dpad-btn:active {
  background: rgba(0, 255, 136, 0.2);
  box-shadow: var(--glow-green);
  transform: scale(0.92);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .title {
    font-size: 1.8rem;
    letter-spacing: 2px;
  }

  .subtitle {
    font-size: 0.75rem;
  }

  .score-value {
    font-size: 1.2rem;
  }

  .canvas-wrapper {
    max-width: 95vw;
  }

  .dpad {
    display: flex;
  }
}

@media (max-width: 380px) {
  .container {
    padding: 12px 8px;
    gap: 14px;
  }

  .title {
    font-size: 1.5rem;
  }

  .score-box {
    padding: 8px 4px;
  }

  .score-label {
    font-size: 0.5rem;
  }

  .score-value {
    font-size: 1rem;
  }
}

/* ---------- Utility ---------- */
.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
