/* =============================================================
   GAME: Snake
   ============================================================= */
.board-snake { display: flex; flex-direction: column; align-items: center; gap: 12px; outline: none; }
.sn-stage { position: relative; touch-action: none; }
.sn-canvas {
  display: block; width: min(calc(100vw - 60px), 460px, calc(100vh - 230px)); min-width: 240px; aspect-ratio: 1; border-radius: 14px; background: #06140c;
  box-shadow: 0 0 0 2px #4dff6a, 0 0 26px rgba(77, 255, 106, .35);
}
.board-snake.sn-wrap .sn-canvas { box-shadow: 0 0 0 2px rgba(77, 255, 106, .35), 0 0 0 5px rgba(77, 255, 106, .08), 0 0 26px rgba(77, 255, 106, .2); }
.board-snake:focus-visible .sn-canvas { box-shadow: 0 0 0 3px #fff, 0 0 26px rgba(77, 255, 106, .5); }
.sn-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 80%;
  padding: 10px 16px; border-radius: 12px; background: rgba(4, 14, 8, .82); color: #d8ffd8; font-weight: 700; text-align: center;
  box-shadow: 0 0 0 1px rgba(77, 255, 106, .5); pointer-events: none;
}
.sn-msg[hidden] { display: none; }
.sn-num { color: #8dff7a; font-variant-numeric: tabular-nums; }

/* on-screen pad: phones and tablets only */
.sn-pad { display: none; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 46px); gap: 4px 8px; touch-action: none; }
.sn-key {
  display: grid; place-items: center; border: 0; border-radius: 14px; cursor: pointer; color: #8dff7a;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px rgba(77, 255, 106, .45), 0 4px 0 rgba(0, 0, 0, .35);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.sn-key svg { width: 26px; height: 26px; fill: currentColor; }
.sn-key:active { background: #173d22; transform: translateY(2px); box-shadow: inset 0 0 0 1px #4dff6a, 0 2px 0 rgba(0, 0, 0, .35); }
.sn-key-up { grid-area: 1 / 2; }
.sn-key-left { grid-area: 2 / 1; }
.sn-key-pause { grid-area: 2 / 2; color: var(--ink); border-radius: 50%; width: 42px; height: 42px; justify-self: center; align-self: center; }
.sn-key-pause svg { width: 20px; height: 20px; }
.sn-key-right { grid-area: 2 / 3; }
.sn-key-down { grid-area: 3 / 2; }
@media (pointer: coarse) {
  .sn-pad { display: grid; }
  .board-snake { gap: 8px; }
  .sn-canvas { width: min(calc(100vw - 60px), 460px, calc(100vh - 400px)); }
}

/* crash: a short shake + red flash of the frame (off when motion is reduced) */
.sn-crash { animation: snShake .42s cubic-bezier(.36, .07, .19, .97); }
.sn-crash .sn-canvas { box-shadow: 0 0 0 2px #ff3d5e, 0 0 30px rgba(255, 61, 94, .55); transition: box-shadow .3s; }
@keyframes snShake { 15%, 55% { translate: -5px 0; } 35%, 75% { translate: 5px 0; } 90% { translate: -2px 0; } }
