:root {
  --bg: #0b0f14;
  --bg-2: #111821;
  --panel: #151e29;
  --line: #223041;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #3ddc84;
  --accent-2: #7cf5b0;
  --food: #ff5c7a;
  --bonus: #ffc53d;
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(61, 220, 132, 0.12), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 16px rgba(61, 220, 132, 0.6);
}

.nav { display: flex; gap: 20px; font-size: 14px; color: var(--muted); }
.nav a:hover { color: var(--text); }

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.hud {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.value { font-family: var(--mono); font-size: 22px; font-weight: 700; }

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(61, 220, 132, 0.08) inset;
}

#board { display: block; width: 100%; height: 100%; background: var(--bg-2); touch-action: none; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(8, 12, 16, 0.78);
  backdrop-filter: blur(3px);
  transition: opacity 0.2s ease;
}

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

.overlay-title {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(26px, 6vw, 38px);
  color: var(--accent-2);
  text-shadow: 0 0 24px rgba(61, 220, 132, 0.5);
}

.overlay-text { margin: 0; color: var(--muted); max-width: 320px; }

.hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); font-family: var(--mono); }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 12px 26px;
  border-radius: 999px;
  font: 700 15px var(--sans);
  color: #06210f;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 24px rgba(61, 220, 132, 0.35);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.btn:hover { box-shadow: 0 10px 30px rgba(61, 220, 132, 0.5); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.pad {
  display: none;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 8px;
  margin-top: 4px;
}

.pad-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.pad-btn:active { background: #1d2a38; }

.pad-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border: 10px solid transparent;
}

.pad-btn.up { grid-area: 1 / 2; }
.pad-btn.left { grid-area: 2 / 1; }
.pad-btn.pause { grid-area: 2 / 2; }
.pad-btn.right { grid-area: 2 / 3; }
.pad-btn.down { grid-area: 3 / 2; }

.pad-btn.up::after { border-bottom-color: var(--accent); margin-top: 14px; }
.pad-btn.down::after { border-top-color: var(--accent); margin-bottom: 14px; }
.pad-btn.left::after { border-right-color: var(--accent); margin-left: 14px; }
.pad-btn.right::after { border-left-color: var(--accent); margin-right: 14px; }
.pad-btn.pause::after { width: 14px; height: 16px; border: 0; border-left: 4px solid var(--muted); border-right: 4px solid var(--muted); }

.panel {
  margin-top: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.panel h2 { margin: 0 0 12px; font-size: 18px; font-family: var(--mono); }
.panel p { margin: 0; color: var(--muted); line-height: 1.6; }

.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; color: var(--muted); }
.rules li { display: flex; align-items: center; gap: 12px; line-height: 1.5; }
.rules b { color: var(--text); }

.dot { flex: 0 0 12px; width: 12px; height: 12px; border-radius: 3px; }
.dot.food { background: var(--food); }
.dot.bonus { background: var(--bonus); }
.dot.wall { background: var(--line); outline: 1px solid var(--muted); }
.dot.speed { background: var(--accent); }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 20px clamp(16px, 4vw, 40px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (hover: none) and (pointer: coarse) {
  .pad { display: grid; }
  .hint { display: none; }
}

@media (max-width: 480px) {
  .nav { gap: 12px; font-size: 13px; }
  .value { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .overlay, .btn { transition: none; }
}
