/* === RETRO SNAKE - CSS === */
:root {
  --green-neon: #39ff14;
  --green-dark: #0a3d0a;
  --green-mid: #1a6b1a;
  --bg-dark: #0a0a0a;
  --bg-panel: #111;
  --crt-glow: 0 0 10px rgba(57, 255, 20, 0.3);
  --text-glow: 0 0 8px rgba(57, 255, 20, 0.6), 0 0 20px rgba(57, 255, 20, 0.3);
  --pixel-font: 'Press Start 2P', monospace;
}

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

body {
  background: var(--bg-dark);
  color: var(--green-neon);
  font-family: var(--pixel-font);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* CRT Scanlines */
#scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  max-width: 600px;
  width: 100%;
}

/* Header */
header {
  text-align: center;
  width: 100%;
}

header h1 {
  font-size: 28px;
  text-shadow: var(--text-glow);
  letter-spacing: 4px;
  margin-bottom: 12px;
  animation: flicker 3s infinite alternate;
}

@keyframes flicker {
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.8; }
  97% { opacity: 1; }
  98% { opacity: 0.7; }
}

#header-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
}

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

.stat-label {
  font-size: 8px;
  color: #666;
  letter-spacing: 2px;
}

.stat-value {
  font-size: 16px;
  text-shadow: var(--text-glow);
}

/* Canvas */
#canvas-wrapper {
  position: relative;
  border: 3px solid var(--green-neon);
  box-shadow: var(--crt-glow), inset 0 0 30px rgba(57, 255, 20, 0.05);
  border-radius: 4px;
  background: #000;
  line-height: 0;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Overlay */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 10;
}

#overlay.visible {
  display: flex;
}

#overlay-content {
  text-align: center;
  padding: 30px;
}

#overlay-title {
  font-size: 22px;
  text-shadow: var(--text-glow);
  margin-bottom: 24px;
  letter-spacing: 3px;
  line-height: 1.4;
}

#overlay-subtitle {
  font-size: 8px;
  color: #888;
  margin-bottom: 10px;
  line-height: 1.6;
}

#overlay-mobile {
  font-size: 7px;
  color: #555;
  margin-bottom: 28px;
  line-height: 1.6;
}

#start-btn {
  font-family: var(--pixel-font);
  font-size: 12px;
  padding: 14px 32px;
  background: transparent;
  color: var(--green-neon);
  border: 2px solid var(--green-neon);
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
  text-shadow: var(--text-glow);
  box-shadow: var(--crt-glow);
}

#start-btn:hover {
  background: var(--green-neon);
  color: #000;
  text-shadow: none;
}

#final-score {
  margin-top: 16px;
  font-size: 12px;
}

#final-score.hidden {
  display: none;
}

/* Mobile Controls */
#controls-mobile {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}

.ctrl-row {
  display: flex;
  gap: 4px;
}

.ctrl-btn {
  width: 56px;
  height: 56px;
  font-size: 20px;
  background: rgba(57, 255, 20, 0.1);
  color: var(--green-neon);
  border: 2px solid rgba(57, 255, 20, 0.4);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.ctrl-btn:active {
  background: rgba(57, 255, 20, 0.3);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 8px;
}

footer p {
  font-size: 7px;
  color: #444;
}

footer a {
  color: var(--green-neon);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
  header h1 {
    font-size: 18px;
  }

  #header-stats {
    gap: 16px;
  }

  .stat-value {
    font-size: 13px;
  }

  #overlay-title {
    font-size: 16px;
  }

  #controls-mobile {
    display: flex;
  }

  #game-container {
    padding: 10px;
  }
}

@media (max-width: 400px) {
  header h1 {
    font-size: 14px;
    letter-spacing: 2px;
  }

  .stat-value {
    font-size: 11px;
  }

  .stat-label {
    font-size: 6px;
  }

  #start-btn {
    font-size: 10px;
    padding: 10px 24px;
  }
}
