:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --accent: #38bdf8;
  --accent-2: #34d399;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --grid-a: #111c33;
  --grid-b: #0d182b;
  --snake: #34d399;
  --snake-head: #6ee7b7;
  --food: #f87171;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #1e293b, #0f172a 70%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 16px;
}

.topbar {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.title {
  font-size: 26px;
  letter-spacing: 4px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.score-box {
  background: var(--panel);
  border-radius: 12px;
  padding: 8px 14px;
  text-align: center;
  min-width: 64px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

.score-label { display: block; font-size: 12px; color: var(--muted); }
.score-value { display: block; font-size: 22px; font-weight: 700; color: var(--accent); }

.stage {
  position: relative;
  width: 480px;
  max-width: 92vw;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  background: var(--grid-a);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .82);
  backdrop-filter: blur(4px);
  transition: opacity .2s ease;
}

.overlay.hidden { display: none; }

.panel {
  text-align: center;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.panel h2 { font-size: 24px; }
.hint { color: var(--muted); font-size: 14px; }

.btn {
  border: none;
  cursor: pointer;
  font-size: 16px;
  border-radius: 999px;
  padding: 12px 28px;
  font-weight: 600;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.96); }

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #06283b;
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(148,163,184,.3);
}

.controls { display: flex; gap: 12px; }
.controls .btn { padding: 10px 22px; font-size: 14px; }

.icp {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.icp a {
  color: var(--muted);
  text-decoration: none;
}
.icp a:hover { color: var(--accent); }
