.snake-page {
  max-width: 760px;
  margin-inline: auto;
  padding-block: 10px 48px;
}

.snake-intro {
  margin-bottom: 10px;
}

.snake-intro h1 {
  margin-bottom: 3px;
  font-size: clamp(32px, 8vw, 42px);
  letter-spacing: -2px;
  line-height: 1.1;
}

.snake-intro p,
.snake-how-to-play p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.snake-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: white;
  box-shadow: 0 12px 30px #29234a0a;
}

.snake-score {
  width: min(100%, 340px);
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.snake-score strong {
  color: var(--purple);
  font-variant-numeric: tabular-nums;
}

.snake-board {
  display: block;
  width: min(100%, 32svh, 340px);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid #e8e3f7;
  border-radius: 12px;
  background: #f7f5ff;
}

.snake-status {
  width: min(100%, 340px);
  min-height: 21px;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.snake-controls {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.direction-pad {
  display: grid;
  grid-column: 1;
  grid-row: 1;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  justify-self: center;
  gap: 4px;
}

.direction-button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #e6e1f4;
  border-radius: 12px;
  background: #f7f5ff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.direction-up {
  grid-area: 1 / 2;
}

.direction-left {
  grid-area: 2 / 1;
}

.direction-right {
  grid-area: 2 / 3;
}

.direction-down {
  grid-area: 3 / 2;
}

.direction-button.is-active {
  border-color: var(--purple);
  background: #e9e3ff;
  color: var(--purple-dark);
  transform: scale(0.94);
}

.direction-button:focus-visible,
.restart-button:focus-visible {
  outline: 3px solid #a391ff;
  outline-offset: 3px;
}

.direction-button:disabled {
  cursor: default;
}

.restart-button {
  min-width: 160px;
  min-height: 44px;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.snake-how-to-play {
  margin-top: 24px;
}

.snake-how-to-play h2 {
  margin-bottom: 8px;
}

.related-games {
  margin-top: 12px;
}

.related-games a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--purple-dark);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 520px) {
  .snake-page {
    padding-block: 8px 36px;
  }

  .snake-panel {
    gap: 6px;
    padding: 8px;
    border-radius: 16px;
  }

  .snake-board {
    width: min(100%, 32svh, 340px);
  }

  .direction-pad {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 48px);
  }
}

@media (max-height: 700px) {
  .snake-board {
    width: min(100%, 28svh, 300px);
  }

  .snake-panel {
    gap: 4px;
    padding: 6px;
  }

  .direction-pad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 3px;
  }

  .direction-button {
    border-radius: 10px;
  }

  .snake-page {
    padding-top: 5px;
  }

  .snake-intro {
    margin-bottom: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .direction-button.is-active {
    transform: none;
  }
}
