* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 620px at 50% -10%, #1b2242 0%, #0c0f1e 62%);
  color: #e8ecff;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  display: flex; justify-content: center; align-items: flex-start;
  min-height: 100vh;
  user-select: none; -webkit-user-select: none;
}
#app { width: 100%; max-width: 700px; padding: 10px; }
.hidden { display: none !important; }

/* ===== HUD ===== */
#hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 2px; flex-wrap: wrap; }
#hud-timer { font-size: 24px; font-weight: 800; color: #ffd740; font-variant-numeric: tabular-nums; min-width: 66px; }
#hud-timer.urgent { color: #ff5252; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
#hud-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: center; }
.chip {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px; border: 1px solid; border-radius: 20px;
  font-size: 12px; background: rgba(255,255,255,.05); white-space: nowrap;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip .nm { font-weight: 700; }
.chip .st { opacity: .85; }
.chip.dead { opacity: .35; filter: grayscale(1); }
.hud-btn, .link-btn {
  background: #232a45; color: #e8ecff; border: 1px solid #3a4670;
  border-radius: 6px; padding: 5px 10px; font-size: 13px; cursor: pointer;
}
.hud-btn:hover, .link-btn:hover { background: #2e3860; }
.hud-right { display: flex; gap: 6px; }

/* ===== 舞台 ===== */
#stage { position: relative; width: 100%; max-width: 660px; margin: 0 auto; }
canvas {
  display: block; width: 100%; height: auto;
  border-radius: 10px; background: #161a2b;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}

/* ===== 覆盖层 ===== */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(9, 11, 24, .93);
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 18px; text-align: center;
  overflow-y: auto;
}
.overlay h1 { font-size: 40px; letter-spacing: 6px; color: #ffd740; text-shadow: 0 0 24px rgba(255,160,0,.55); }
.overlay h2 { font-size: 30px; color: #ffd740; }
.subtitle { opacity: .75; margin-top: -8px; }
.menu-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.menu-label { font-size: 14px; opacity: .8; min-width: 56px; text-align: right; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.seg button {
  background: #1c2340; color: #cdd6ff; border: 1px solid #39436e;
  padding: 7px 12px; border-radius: 7px; font-size: 14px; cursor: pointer;
}
.seg button.on { background: #ffd740; color: #20243a; border-color: #ffd740; font-weight: 700; }
#btn-start {
  margin-top: 4px; background: linear-gradient(180deg, #ff8f00, #ff6d00);
  color: #fff; border: none; font-size: 20px; font-weight: 800; letter-spacing: 4px;
  padding: 12px 46px; border-radius: 10px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(255,111,0,.35);
}
#btn-start:hover { filter: brightness(1.1); }
#pause button, #gameover button {
  background: #2a3358; color: #e8ecff; border: 1px solid #46528a;
  font-size: 16px; padding: 10px 30px; border-radius: 8px; cursor: pointer; min-width: 180px;
}
#pause button:hover, #gameover button:hover { background: #36427a; }
#over-sub { opacity: .85; }
.menu-row.small { font-size: 13px; }
.menu-row.small label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
#help {
  font-size: 13px; line-height: 1.8; text-align: left;
  background: rgba(255,255,255,.05); border-radius: 8px; padding: 10px 16px;
}
#help .dim { opacity: .6; }
#stats-line { font-size: 13px; color: #9fb0e8; }

/* ===== 触控 ===== */
#touch-ui { display: flex; justify-content: space-between; align-items: center; padding: 14px 6px 6px; touch-action: none; }
#dpad { display: grid; grid-template-areas: ". u ." "l . r" ". d ."; gap: 6px; }
#t-up { grid-area: u; } #t-down { grid-area: d; } #t-left { grid-area: l; } #t-right { grid-area: r; }
.tbtn {
  width: 58px; height: 58px; border-radius: 14px;
  border: 1px solid #46528a; background: rgba(52,64,110,.8);
  color: #fff; font-size: 20px; touch-action: none; cursor: pointer;
}
.tbtn:active { background: #ffd740; color: #20243a; }
.tbtn.big { width: 74px; height: 74px; border-radius: 50%; font-size: 16px; font-weight: 700; }
#t-actions { display: flex; gap: 14px; }
#t-bomb { background: rgba(198,40,40,.85); border-color: #ff5252; }
#t-det { background: rgba(40,90,200,.85); border-color: #448aff; }

@media (max-width: 480px) {
  .overlay h1 { font-size: 30px; }
  .overlay { gap: 10px; }
  #hud-timer { font-size: 20px; }
}
