:root {
  --bg: #0b1220;
  --panel: rgba(22, 32, 56, 0.86);
  --line: rgba(120, 255, 190, 0.18);
  --green: #37f5a3;
  --green-dim: #1fb87a;
  --accent: #ff5f7e;
  --text: #e8f4ff;
  --muted: #8ba0c4;
  --board: #070b14;
  --grid: rgba(120, 200, 255, 0.06);
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.5);
}

html[data-theme="light"] {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.92);
  --line: rgba(31, 184, 122, 0.28);
  --green: #12a86a;
  --green-dim: #0d8455;
  --text: #10202e;
  --muted: #5d7288;
  --board: #eef3f9;
  --grid: rgba(16, 42, 68, 0.08);
  --shadow: 0 18px 44px rgba(16, 42, 68, 0.16);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18px 14px 24px;
  background:
    radial-gradient(900px 560px at 8% -12%, rgba(55, 245, 163, 0.16), transparent 62%),
    radial-gradient(860px 520px at 96% 4%, rgba(96, 140, 255, 0.18), transparent 64%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="light"] body {
  background:
    radial-gradient(900px 560px at 8% -12%, rgba(18, 168, 106, 0.14), transparent 62%),
    radial-gradient(860px 520px at 96% 4%, rgba(96, 140, 255, 0.12), transparent 64%),
    var(--bg);
}

.shell {
  width: min(94vw, 520px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.brand { display: flex; align-items: baseline; gap: 8px; }

.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  transform: translateY(-2px);
}

.brand h1 { margin: 0; font-size: 19px; letter-spacing: 2px; }

.brand-sub { font-size: 10px; letter-spacing: 3px; color: var(--muted); }

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

.score-card {
  min-width: 62px; padding: 5px 10px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); text-align: center;
}

.score-card .label { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.score-card strong { font-size: 19px; font-variant-numeric: tabular-nums; color: var(--green); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 11px; color: var(--muted); max-width: 100%;
}

.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }

.pill[data-state="ok"] { color: var(--green); border-color: rgba(55, 245, 163, 0.45); }
.pill[data-state="ok"] .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill[data-state="warn"] .dot { background: #f4b942; }
.pill[data-state="preview"] .dot { background: #6ba8ff; }

.stage {
  position: relative; border-radius: 18px; padding: 9px;
  background: linear-gradient(160deg, rgba(30, 44, 78, 0.62), rgba(10, 15, 28, 0.86));
  border: 1px solid var(--line); box-shadow: var(--shadow);
}

html[data-theme="light"] .stage {
  background: linear-gradient(160deg, #ffffff, #eef3f9);
}

canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 1 / 1;
  border-radius: 12px; background: var(--board); touch-action: none;
}

.overlay {
  position: absolute; inset: 9px; display: flex; align-items: center; justify-content: center;
  padding: 16px; border-radius: 12px; background: rgba(6, 10, 20, 0.74);
  backdrop-filter: blur(6px); transition: opacity 0.18s ease;
}

html[data-theme="light"] .overlay { background: rgba(244, 247, 251, 0.82); }

.overlay[data-state="playing"] { opacity: 0; pointer-events: none; }

.panel {
  width: 100%; max-width: 320px; padding: 20px 18px; text-align: center;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px; font-size: 11px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--green-dim);
}

.panel h2 { margin: 0 0 10px; font-size: 23px; letter-spacing: 1px; }

.ov-text { margin: 0 0 16px; font-size: 13px; line-height: 1.7; color: var(--muted); }

.btn {
  font: inherit; cursor: pointer; border-radius: 12px;
  border: 1px solid transparent; padding: 10px 18px;
  transition: transform 0.12s ease, background 0.18s ease;
}

.btn:active { transform: scale(0.97); }

.btn.primary {
  background: linear-gradient(180deg, var(--green), var(--green-dim));
  color: #04231a; font-weight: 700; letter-spacing: 1px;
  box-shadow: 0 10px 22px rgba(55, 245, 163, 0.26);
}

.btn.ghost {
  background: rgba(127, 160, 200, 0.14);
  border-color: var(--line); color: var(--text); padding: 9px 15px;
}

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

.dpad {
  display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 38px); gap: 6px;
}

.dpad-btn {
  font: inherit; color: var(--text); cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(127, 160, 200, 0.14); font-size: 12px;
}

.dpad-btn:active { background: rgba(55, 245, 163, 0.28); transform: scale(0.95); }

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

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn.icon { min-width: 44px; }

.hint { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--muted); }

kbd {
  display: inline-block; margin: 0 1px; padding: 1px 5px; border-radius: 5px;
  background: rgba(127, 160, 200, 0.16); border: 1px solid var(--line);
  font-family: inherit; font-size: 10px;
}

@media (max-width: 430px) {
  body { padding: 12px 10px 18px; }
  .brand h1 { font-size: 16px; }
  .score-card { min-width: 54px; padding: 4px 8px; }
  .score-card strong { font-size: 16px; }
  .hint { display: none; }
  .dpad { grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(3, 36px); }
  .btn.ghost { padding: 8px 12px; font-size: 13px; }
}
