:root {
  color-scheme: dark;
  --bg: #11141a;
  --panel: #202832;
  --panel-2: #2b3541;
  --text: #fff6e7;
  --muted: #c2d0dc;
  --gold: #f3c760;
  --red: #f15d4e;
  --blue: #5dc8ff;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(93, 200, 255, 0.22), transparent 30%),
    radial-gradient(circle at 82% 12%, rgba(243, 199, 96, 0.2), transparent 32%),
    linear-gradient(150deg, #1a2029, #0b0e12);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.game-shell {
  width: min(940px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
}

.topbar,
.hud,
.stage {
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(32, 40, 50, 0.94);
  box-shadow: 0 18px 50px rgba(0,0,0,0.3);
}

.topbar {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 82px;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.topbar a,
.topbar button,
.mobile-controls button,
.result-dialog button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #171717;
  text-decoration: none;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.topbar div { text-align: center; min-width: 0; }
.topbar span,
.hud span,
.result-dialog span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.topbar strong {
  display: block;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1;
}

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

.hud div {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--panel-2);
}

.hud strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(19px, 3vw, 28px);
  line-height: 1.1;
  white-space: nowrap;
}

.stage {
  overflow: hidden;
  min-height: 0;
  background: #25313d;
}

#game {
  width: 100%;
  height: min(72dvh, 720px);
  min-height: 440px;
  display: block;
  touch-action: none;
}

.mobile-controls {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mobile-controls button:nth-child(3) {
  background: var(--blue);
}

.result-dialog {
  width: min(92vw, 440px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: #18202a;
}

.result-dialog::backdrop { background: rgba(0,0,0,0.62); }
.result-dialog form { padding: 22px; }
.result-dialog h2 { margin: 6px 0 8px; font-size: 34px; }
.result-dialog p { margin: 0; color: var(--muted); line-height: 1.6; }
.result-dialog button { width: 100%; margin-top: 18px; }

@media (max-width: 680px) {
  body { overflow: auto; }
  .game-shell { min-height: 100dvh; padding: 8px; }
  .topbar { grid-template-columns: 64px minmax(0, 1fr) 64px; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #game { height: 58dvh; min-height: 360px; }
  .mobile-controls { display: grid; }
}
