:root {
  --bg: #0f1720;
  --panel: #16212d;
  --grid: #1c2a38;
  --text: #e6edf3;
  --muted: #8ea0b2;
  --snake: #3fd17a;
  --head: #9ef0b9;
  --food: #ff5d73;
  --accent: #3fd17a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { display: grid; place-items: center; padding: 16px; }
.game { width: min(480px, 100%); display: grid; gap: 12px; }
.bar { display: flex; align-items: baseline; justify-content: space-between; }
.bar h1 { margin: 0; font-size: 24px; letter-spacing: 0.02em; }
.scores { margin: 0; display: flex; gap: 16px; color: var(--muted); }
.scores strong { color: var(--text); font-variant-numeric: tabular-nums; }
.board-wrap { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--panel); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; background: rgba(15, 23, 32, 0.78); text-align: center; }
.overlay[hidden] { display: none; }
.overlay .title { margin: 0; font-size: 32px; font-weight: 700; }
.overlay .hint { margin: 0; color: var(--muted); }
.overlay button { margin-top: 8px; padding: 10px 28px; border: 0; border-radius: 999px; background: var(--accent); color: #062312; font: 600 17px/1 inherit; cursor: pointer; }
.overlay button:focus-visible, .pad button:focus-visible { outline: 3px solid var(--head); outline-offset: 2px; }
.pad { display: none; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 56px); justify-content: center; gap: 8px; }
.pad button { border: 0; border-radius: 12px; background: var(--panel); color: var(--text); font-size: 20px; }
.pad [data-dir="up"] { grid-column: 2; grid-row: 1; }
.pad [data-dir="left"] { grid-column: 1; grid-row: 2; }
.pad [data-dir="down"] { grid-column: 2; grid-row: 2; }
.pad [data-dir="right"] { grid-column: 3; grid-row: 2; }
.foot { color: var(--muted); font-size: 13px; text-align: center; }
@media (pointer: coarse) { .pad { display: grid; } }
