:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #eef1f7;
  --text: #1b2030;
  --muted: #606a80;
  --accent: #1f9d63;
  --accent-strong: #14804e;
  --accent-soft: #d8f2e4;
  --wire: #d5dae6;
  --food: #e8563f;
  --shadow: 0 10px 30px rgba(25, 35, 60, 0.08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12151d;
  --surface: #1a1f2a;
  --surface-soft: #222937;
  --text: #eef1f7;
  --muted: #9aa4b8;
  --accent: #3ecf8e;
  --accent-strong: #2fb87c;
  --accent-soft: #1d3a2d;
  --wire: #2c3444;
  --food: #ff6a52;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 26px;
}
.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.title h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.subtitle { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.platform {
  margin: 0; padding: 4px 10px; border-radius: 999px; font-size: 11px;
  background: var(--surface-soft); color: var(--muted); white-space: nowrap;
}
.platform[data-state="ready"] { background: var(--accent-soft); color: var(--accent-strong); }
.platform[data-state="preview"] { background: var(--surface-soft); color: var(--accent-strong); }
.platform[data-state="error"] { background: #fde8e4; color: #b23b26; }
.scoreboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.score {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--wire); border-radius: 12px;
  box-shadow: var(--shadow);
}
.score-label { font-size: 11px; color: var(--muted); }
.score strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.board-wrap { position: relative; }
canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 1 / 1;
  background: var(--surface); border: 1px solid var(--wire); border-radius: 16px;
  box-shadow: var(--shadow); touch-action: none;
}
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 24px; border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
.overlay-title { margin: 0; font-size: 20px; font-weight: 600; }
.overlay-text { margin: 0; font-size: 13px; color: var(--muted); max-width: 280px; }
.controls { display: flex; gap: 10px; }
button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent;
  padding: 10px 16px; transition: transform 0.06s ease, background 0.15s ease;
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #ffffff; font-weight: 600; }
.primary:hover { background: var(--accent-strong); }
.ghost { background: var(--surface); border-color: var(--wire); color: var(--text); }
.ghost:hover { background: var(--surface-soft); }
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 46px); justify-content: center; gap: 8px; }
.dpad-button { background: var(--surface); border-color: var(--wire); color: var(--text); font-size: 14px; }
.dpad-button.up { grid-column: 2; grid-row: 1; }
.dpad-button.left { grid-column: 1; grid-row: 2; }
.dpad-button.down { grid-column: 2; grid-row: 2; }
.dpad-button.right { grid-column: 3; grid-row: 2; }
.app-footer p { margin: 0; font-size: 11px; color: var(--muted); text-align: center; }
@media (max-width: 380px) {
  .dpad { grid-template-columns: repeat(3, 48px); }
  .title h1 { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
