:root {
  --bg: #070b14;
  --panel: rgba(19, 27, 44, 0.88);
  --panel-strong: rgba(11, 17, 30, 0.97);
  --line: rgba(122, 162, 247, 0.18);
  --text: #e8eeff;
  --muted: #93a5cb;
  --accent: #4ade80;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --amber: #fbbf24;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1100px 560px at 12% -12%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(139, 92, 246, 0.18), transparent 58%),
    var(--bg);
  -webkit-text-size-adjust: 100%;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px clamp(12px, 3vw, 30px) 30px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 68% 28%, #86efac 0 18%, transparent 19%),
    linear-gradient(135deg, #22c55e, #0ea5e9);
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.28);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.brand-text h1 { margin: 0; font-size: 22px; letter-spacing: 0.04em; }
.brand-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.16em; }

.status {
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  max-width: 100%;
}

.status[data-state="ok"] { color: #bbf7d0; border-color: rgba(74, 222, 128, 0.4); }
.status[data-state="warn"] { color: #fde68a; border-color: rgba(251, 191, 36, 0.4); }
.status[data-state="err"] { color: #fecaca; border-color: rgba(248, 113, 113, 0.45); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(3, 8, 20, 0.55);
  backdrop-filter: blur(8px);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 26, 0.72);
}

.hud-label { font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.hud-item strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.board-shell {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(122, 162, 247, 0.24);
  background: #060a12;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 22px;
  text-align: center;
  background: linear-gradient(180deg, rgba(6, 10, 18, 0.82), rgba(6, 10, 18, 0.94));
  backdrop-filter: blur(3px);
}

.overlay[hidden] { display: none; }
.overlay h2 { margin: 0; font-size: clamp(20px, 3.4vw, 27px); }
.overlay p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; max-width: 34ch; }
.overlay .overlay-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.overlay .tip { font-size: 12px; color: #7f90b5; }
.overlay .cause { color: var(--danger); font-weight: 600; }

.pad { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(2, 48px);
  gap: 8px;
}

.pad-btn {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(30, 41, 63, 0.95), rgba(17, 24, 39, 0.95));
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.pad-btn:hover { border-color: rgba(74, 222, 128, 0.5); }
.pad-btn:active { transform: translateY(1px) scale(0.98); }
.pad-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }

.pad-btn.action {
  min-width: 96px;
  height: 48px;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #06210f;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  font-weight: 700;
}

.pad-btn.action[data-off="true"] {
  color: var(--text);
  background: linear-gradient(180deg, rgba(30, 41, 63, 0.95), rgba(17, 24, 39, 0.95));
  border-color: var(--line);
}

.side { display: flex; flex-direction: column; gap: 14px; }

.card {
  padding: 14px 16px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(8px);
}

.card h2 { margin: 0 0 6px; font-size: 15px; letter-spacing: 0.06em; }
.hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); }

.maps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.map-btn {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 26, 0.66);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.map-btn:hover { border-color: rgba(34, 211, 238, 0.5); }
.map-btn[aria-pressed="true"] {
  border-color: rgba(74, 222, 128, 0.75);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 211, 238, 0.12));
}
.map-name { font-size: 14px; font-weight: 600; }
.map-desc { font-size: 12px; color: var(--muted); }

.keys { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.85; }
.keys kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 5px;
  margin: 0 1px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  text-align: center;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 26, 0.9);
}

.runs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }

.runs li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(9, 14, 26, 0.66);
  color: var(--muted);
}

.runs li.empty { justify-content: center; color: #6f7fa4; font-size: 12px; }
.runs .run-score { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

.foot { margin-top: 22px; text-align: center; font-size: 12px; color: #6f7fa4; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side { order: 2; }
  .board-shell { max-width: 100%; }
}

@media (max-width: 420px) {
  .app { padding: 14px 10px 22px; }
  .stage { padding: 12px; border-radius: 18px; }
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 44px); }
  .brand-text h1 { font-size: 19px; }
}
