/* ============================================
   Snake - AstroTech Mission to Mars
   ============================================ */

:root {
  --bg-dark: #0a0f1a;
  --bg-card: #111827;
  --primary: #33afff;
  --secondary: #6b4cff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #f2f2f2;
  --text-dim: #9ca3af;
  --border: rgba(51, 175, 255, 0.25);
  --glow: rgba(51, 175, 255, 0.4);
}

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

body {
  font-family: "Roboto", sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scanlines */
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 2px,
    transparent 4px
  );
  opacity: 0.15;
  z-index: 1000;
}

/* Animated background */
.bg-animation {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse at 20% 80%,
      rgba(107, 76, 255, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 20%,
      rgba(51, 175, 255, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 50% 50%,
      rgba(51, 175, 255, 0.05) 0%,
      transparent 60%
    );
  animation: bgPulse 8s ease-in-out infinite;
  z-index: -1;
}

@keyframes bgPulse {
  0%,
  100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
}

/* Stars */
.stars {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, white, transparent),
    radial-gradient(
      2px 2px at 40px 70px,
      rgba(255, 255, 255, 0.8),
      transparent
    ),
    radial-gradient(1px 1px at 90px 40px, white, transparent),
    radial-gradient(
      2px 2px at 130px 80px,
      rgba(255, 255, 255, 0.6),
      transparent
    ),
    radial-gradient(1px 1px at 160px 120px, white, transparent);
  background-size: 200px 200px;
  animation: twinkle 4s ease-in-out infinite;
  z-index: -1;
}

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

/* ============================================
   Screens System
   ============================================ */

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* ============================================
   Menu Screen
   ============================================ */

.menu-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.game-title {
  font-family: "Orbitron", sans-serif;
  font-size: 4rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 40px var(--glow);
  margin-bottom: 0.5rem;
  letter-spacing: 8px;
}

.game-title .accent {
  color: var(--success);
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 3rem;
  letter-spacing: 2px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 280px;
  margin-bottom: 3rem;
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  font-family: "Orbitron", sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-icon {
  width: 20px;
  height: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg-dark);
  box-shadow: 0 4px 20px rgba(51, 175, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(51, 175, 255, 0.5);
}

.btn-secondary {
  background: rgba(51, 175, 255, 0.1);
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(51, 175, 255, 0.2);
  border-color: var(--primary);
}

/* Best Score Display */
.best-score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 2rem;
  background: rgba(51, 175, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.best-score-display .label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.best-score-display .value {
  font-family: "Orbitron", sans-serif;
  font-size: 2rem;
  color: var(--primary);
  text-shadow: 0 0 20px var(--glow);
}

/* ============================================
   How to Play Screen
   ============================================ */

.panel-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.panel-title {
  font-family: "Orbitron", sans-serif;
  font-size: 2rem;
  color: var(--primary);
  text-shadow: 0 0 20px var(--glow);
  margin-bottom: 2rem;
  letter-spacing: 3px;
}

.howto-content {
  width: 100%;
  margin-bottom: 2rem;
}

.howto-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.howto-section h3 {
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.howto-section p,
.howto-section li {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.howto-section ul {
  list-style: none;
  padding: 0;
}

.howto-section li {
  padding-left: 1.5rem;
  position: relative;
  margin-bottom: 0.5rem;
}

.howto-section li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--primary);
}

.howto-section strong {
  color: var(--text);
}

/* ============================================
   Game Screen
   ============================================ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.logo {
  font-family: "Orbitron", sans-serif;
  font-size: 1.5rem;
  color: var(--primary);
  text-shadow: 0 0 12px var(--glow);
  letter-spacing: 3px;
}

.boot-button {
  padding: 0.6rem 1.5rem;
  font-family: "Orbitron", sans-serif;
  font-size: 0.85rem;
  border: 2px solid var(--primary);
  background: rgba(10, 15, 25, 0.7);
  color: var(--primary);
  border-radius: 6px;
  cursor: pointer;
  transition: 0.25s;
  box-shadow:
    0 0 8px var(--primary) inset,
    0 0 12px var(--primary);
  backdrop-filter: blur(5px);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.boot-button:hover {
  background: var(--primary);
  color: var(--bg-dark);
  transform: translateY(-2px);
}

.content-wrapper {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 1rem 2rem;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 25px rgba(51, 175, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.stat-label {
  font-family: "Orbitron", sans-serif;
  font-size: 0.7rem;
  color: var(--primary);
  opacity: 0.8;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: "Orbitron", sans-serif;
  font-size: 1.75rem;
  color: var(--text);
  text-shadow: 0 0 10px rgba(51, 175, 255, 0.5);
}

.game-wrapper {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  backdrop-filter: blur(8px);
  box-shadow:
    0 0 40px rgba(51, 175, 255, 0.2),
    0 0 80px rgba(51, 175, 255, 0.1);
}

#game {
  display: block;
  background: linear-gradient(180deg, #0a0f1a 0%, #111827 50%, #1a1a2e 100%);
  border-radius: 8px;
}

.game-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ============================================
   Overlays
   ============================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 26, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(10px);
}

.overlay.active {
  display: flex;
}

.overlay-content {
  text-align: center;
  padding: 2rem;
}

.overlay-title {
  font-family: "Orbitron", sans-serif;
  font-size: 2.5rem;
  color: var(--primary);
  text-shadow: 0 0 30px var(--glow);
  margin-bottom: 2rem;
  letter-spacing: 4px;
}

.overlay-title.gameover {
  color: var(--danger);
  text-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
}

.overlay-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.overlay-buttons .btn {
  min-width: 200px;
}

/* Final Score Display */
.final-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.final-score .label {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.final-score .value {
  font-family: "Orbitron", sans-serif;
  font-size: 3.5rem;
  color: var(--primary);
  text-shadow: 0 0 30px var(--glow);
}

.new-highscore {
  font-family: "Orbitron", sans-serif;
  font-size: 1.25rem;
  color: var(--warning);
  text-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
  margin-bottom: 2rem;
  animation: pulse 1.5s ease-in-out infinite;
}

.new-highscore.hidden {
  display: none;
}

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

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 600px) {
  .game-title {
    font-size: 2.5rem;
    letter-spacing: 4px;
  }

  #game {
    width: 320px !important;
    height: 320px !important;
  }

  .header {
    padding: 1rem;
  }

  .logo {
    font-size: 1.1rem;
  }

  .content-wrapper {
    padding: 1rem;
  }

  #stats {
    gap: 1rem;
  }

  .stat-box {
    padding: 0.75rem 1rem;
    min-width: 80px;
  }

  .stat-value {
    font-size: 1.25rem;
  }
}
