.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.75rem;
  max-width: 640px;
  margin: 0 auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: rgba(3, 35, 5, 0.9);
  color: #b7ffb7;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  margin-bottom: 0.75rem;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.game-area {
  flex: 2;
  min-height: 260px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.controls {
  flex: 1;
  min-height: 170px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Quicksand', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #e0ffe0 0, #b3e6b3 35%, #6b8f6b 100%);
  color: #0b2b0b;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.stats {
  display: flex;
  gap: 0.75rem;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat .label {
  opacity: 0.7;
}

.stat .value {
  margin-top: 0.1rem;
}

.game-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #001b00;
  border-radius: 18px;
  padding: 0.5rem;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}

#snake-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #001b00;
}

.overlay {
  position: absolute;
  inset: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #b7ffb7;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.overlay--visible {
  pointer-events: auto;
  opacity: 1;
}

.overlay-content h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.overlay-content .hint {
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.85;
}

.top-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.btn {
  flex: 1;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  background: #c4e6c4;
  color: #052405;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn.primary {
  background: linear-gradient(135deg, #73ff73, #25b325);
  color: #002100;
}

.btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.btn:hover {
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
}

.dpad {
  display: grid;
  grid-template-rows: auto auto auto;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
}

.dpad-btn {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #b7ffb7;
  font-size: 1.3rem;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.dpad-btn:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.dpad .up {
  justify-self: center;
}

.dpad .down {
  justify-self: center;
}

.dpad-middle {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}

@media (min-width: 720px) {
  .page {
    padding-top: 1.5rem;
  }

  .main {
    flex-direction: row;
    align-items: stretch;
  }

  .controls {
    max-width: 260px;
    align-self: stretch;
    justify-content: center;
  }
}

