:root {
  --bg: #070b16;
  --bg-2: #0e1528;
  --panel: rgba(14, 21, 40, 0.86);
  --line: rgba(120, 150, 255, 0.14);
  --text: #e6ecff;
  --muted: #8b97b8;
  --snake: #3cf2a5;
  --food: #ff4f8b;
  --accent: #6c8cff;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 16px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(108, 140, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(60, 242, 165, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: min(100%, 520px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--snake), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.scores { display: flex; gap: 10px; }

.stat {
  min-width: 84px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.value.bump { animation: bump 220ms ease-out; }

@keyframes bump {
  40% { transform: scale(1.25); color: var(--snake); }
}

.board-wrap {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 20px 60px -20px rgba(60, 242, 165, 0.25),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(7, 11, 22, 0.55);
  backdrop-filter: blur(3px);
  transition: opacity 180ms ease;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  text-align: center;
  padding: 26px 30px;
  max-width: 82%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.panel h2 { margin: 0 0 6px; font-size: 26px; }
.panel p { margin: 0 0 18px; color: var(--muted); }
.panel .hint { margin: 12px 0 0; font-size: 13px; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 18px;
  cursor: pointer;
  transition: transform 80ms ease, border-color 150ms ease, background 150ms ease;
}

.btn:hover { border-color: rgba(120, 150, 255, 0.4); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.primary {
  color: #04140d;
  background: linear-gradient(180deg, #5dffbd, var(--snake));
  border-color: transparent;
  box-shadow: 0 6px 22px -6px rgba(60, 242, 165, 0.6);
  padding: 11px 28px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.keys { margin: 0; color: var(--muted); font-size: 13px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  margin: 0 1px;
  font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
}
