@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@500;600;700&family=Nunito:wght@400;600;700&display=swap');

:root {
  --bg: #f0f7e8;
  --surface: #e8f0e0;
  --snake-head: #2e7d32;
  --snake-body: #43a047;
  --snake-tail: #1b5e20;
  --apple: #c62828;
  --apple-shine: #e57373;
  --hud-text: #5d4037;
  --hud-value: #3e2723;
  --accent: #388e3c;
  --danger: #c62828;
  --wall: #7cb342;
  --floor: #c8e6c9;
  --floor-alt: #a5d6a7;
  --banner-bg: rgba(129, 199, 132, 0.4);
  --overlay-bg: rgba(232, 245, 233, 0.95);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Nunito', sans-serif;
  color: var(--hud-text);
  -webkit-font-smoothing: antialiased;
}

#game-wrapper {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(129, 199, 132, 0.15) 0%, transparent 55%),
    linear-gradient(180deg, #e8f5e9 0%, #f1f8e9 50%, #fff8e1 100%);
}

/* HUD */
#hud {
  width: 100%;
  max-width: 720px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  gap: 12px;
  flex-shrink: 0;
}

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

.hud-label {
  font-family: 'Quicksand', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--hud-text);
  opacity: 0.8;
}

.hud-value {
  font-family: 'Quicksand', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--hud-value);
}

.game-title {
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-shadow: 0 1px 2px rgba(46, 125, 50, 0.2);
}

.title-item {
  flex: 1;
}

/* Arena */
#arena-container {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  min-height: 0;
}

#game-canvas {
  display: block;
  border: 4px solid var(--wall);
  border-radius: 12px;
  box-shadow:
    0 4px 20px rgba(46, 125, 50, 0.2),
    inset 0 0 0 2px rgba(255, 255, 255, 0.3);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Level Banner */
#level-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: var(--banner-bg);
  border: 2px solid rgba(56, 142, 60, 0.4);
  border-radius: 12px;
  padding: 20px 40px;
  text-align: center;
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(46, 125, 50, 0.15);
}

#level-banner.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

#level-banner.hidden {
  display: none;
}

/* Countdown */
#countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 230, 201, 0.6);
  pointer-events: none;
  z-index: 15;
  border-radius: 12px;
}

#countdown-overlay.hidden {
  display: none;
}

#countdown-text {
  font-family: 'Quicksand', sans-serif;
  font-size: 72px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 2px 8px rgba(46, 125, 50, 0.3);
  animation: countdown-pulse 1s ease-out;
}

@keyframes countdown-pulse {
  0% { transform: scale(0.5); opacity: 0.5; }
  20% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.banner-text {
  font-family: 'Quicksand', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 1px 4px rgba(46, 125, 50, 0.2);
  margin-bottom: 6px;
}

.banner-sub {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  color: #558b2f;
}

/* Overlays */
#overlay, #game-over-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  z-index: 50;
  transition: opacity 0.4s;
}

#overlay.hidden, #game-over-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

#overlay.visible, #game-over-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-content {
  text-align: center;
  max-width: 380px;
  padding: 20px;
}

.overlay-content h1 {
  font-family: 'Quicksand', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 1px 4px rgba(46, 125, 50, 0.2);
  margin-bottom: 16px;
  line-height: 1.3;
}

.tagline {
  font-size: 14px;
  color: var(--hud-text);
  margin-bottom: 28px;
  line-height: 1.5;
}

.controls-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
}

.key-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.key-row span {
  font-size: 12px;
  color: rgba(93, 64, 55, 0.5);
}

kbd {
  font-family: 'Quicksand', sans-serif;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(129, 199, 132, 0.5);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--hud-value);
  min-width: 32px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

button {
  font-family: 'Quicksand', sans-serif;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 40px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  letter-spacing: 1px;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(46, 125, 50, 0.35);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(46, 125, 50, 0.4);
}

button:active {
  transform: translateY(0);
}

.go-stat {
  font-size: 13px;
  color: var(--hud-text);
  margin-bottom: 8px;
  line-height: 1.6;
}

.go-stat strong {
  color: var(--accent);
}

.go-stat:last-of-type {
  margin-bottom: 28px;
}

.go-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.go-buttons .hidden {
  display: none;
}

button.btn-secondary {
  background: rgba(255, 255, 255, 0.6);
  color: var(--hud-text);
  border: 2px solid rgba(129, 199, 132, 0.5);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 28px;
  letter-spacing: 1px;
}

button.btn-secondary:hover {
  border-color: rgba(56, 142, 60, 0.6);
  color: var(--hud-value);
  background: rgba(255, 255, 255, 0.8);
}

a.menu-btn {
  display: inline-block;
  font-family: 'Quicksand', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 20px;
  letter-spacing: 1px;
  text-decoration: none;
  color: var(--hud-text);
  border: 2px solid rgba(129, 199, 132, 0.4);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

a.menu-btn:hover {
  color: var(--hud-value);
  border-color: rgba(56, 142, 60, 0.5);
  background: rgba(255, 255, 255, 0.7);
}

.mobile-hint {
  margin-top: 16px;
  font-size: 11px;
  color: rgba(93, 64, 55, 0.5);
}

/* Responsive */
@media (max-width: 500px) {
  #countdown-text {
    font-size: 48px;
  }
  .game-title {
    font-size: 12px;
  }
  .hud-value {
    font-size: 16px;
  }
  .overlay-content h1 {
    font-size: 24px;
  }
  .banner-text {
    font-size: 18px;
  }
  button {
    font-size: 13px;
    padding: 12px 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
