:root {
  --bg: #080a18;
  --panel: rgba(14, 17, 40, 0.88);
  --edge: rgba(120, 135, 255, 0.35);
  --text: #eef0ff;
  --muted: #9aa2d6;
  --accent: #6c7cff;
  --go: #3ddc97;
  --wait: #ff5266;
  --gold: #ffd166;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; }

/* ---------- 舞台：颜色即信号，不做颜色过渡（过渡会改变测量时刻） ---------- */
.stage {
  position: fixed;
  inset: 0;
  touch-action: manipulation;
  transition: none;
  overflow: hidden;
}
.stage[data-state="idle"] { background: #0b0e20; }
.stage[data-state="wait"] { background: #3a0c1c; }
.stage[data-state="feint"] { background: #b35c00; }
.stage[data-state="go"] { background: #14965a; }
.stage[data-state="early"] { background: #7a4b00; }
.stage[data-state="result"] { background: #14183a; }
.stage[data-state="win"] { background: #0c3b33; }
.stage[data-state="lose"] { background: #3d0a12; }
.stage[data-state="replay"] { background: #1b1f3d; }
.stage.shake { animation: shake 0.45s; }

.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
.chip-hud {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(10, 12, 30, 0.7);
  border: 1px solid var(--edge);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
#hud-left { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#hud-right { color: var(--muted); }
.icon-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: rgba(10, 12, 30, 0.75);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.bot-lane {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 58px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  font-weight: 800;
  font-size: 14px;
}
.bot-tag {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--wait);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.1em;
}
#bot-status {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 12, 30, 0.6);
  color: var(--muted);
}
.bot-lane[data-tone="pressed"] #bot-status { color: var(--gold); }
.bot-lane[data-tone="jumped"] #bot-status { color: #ffb4bd; }
.bot-lane[data-tone="timeout"] #bot-status { color: var(--muted); }

.center {
  position: absolute;
  left: 0;
  right: 0;
  top: 38%;
  padding: 0 16px;
  text-align: center;
  pointer-events: none;
}
.center-main {
  margin: 0;
  font-weight: 900;
  font-size: clamp(34px, 9vw, 84px);
  letter-spacing: 0.02em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
  word-break: break-word;
}
.center-sub {
  margin: 10px auto 0;
  max-width: 560px;
  font-size: clamp(15px, 3.8vw, 20px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}
.center.pop .center-main { animation: pop 0.45s ease-out; }
.stage[data-state="go"] .center-main { animation: none; }

.stage-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fx .p {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--c);
  animation: burst var(--d, 1s) ease-out forwards;
}

@keyframes pop {
  0% { transform: scale(1.25); opacity: 0.2; }
  100% { transform: none; opacity: 1; }
}
@keyframes burst {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(360deg) scale(0.4); opacity: 0; }
}
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
  40%, 60% { transform: translate3d(8px, 0, 0); }
}

/* ---------- 屏幕（首页、结算、暂停） ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 24px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at center, rgba(8, 10, 24, 0.35), rgba(8, 10, 24, 0.85));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel {
  width: min(440px, 100%);
  margin: auto 0;
  padding: 26px 22px 18px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--edge);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  animation: rise 0.35s ease-out;
}
#home .panel { margin-top: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.logo {
  margin: 0;
  font-size: clamp(34px, 9vw, 50px);
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--go), #b9a8ff 50%, var(--wait));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 24px rgba(108, 124, 255, 0.4));
}
.hook { margin: 8px 0 18px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.intro { margin: 14px 0 14px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.spec { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); text-align: left; }
.howto { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
kbd {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}
.record { margin: 14px 0 8px; color: var(--muted); font-size: 13px; line-height: 1.5; white-space: pre-line; }

.settings { display: grid; gap: 12px; margin-bottom: 4px; }
.setting { display: grid; gap: 6px; text-align: left; }
.setting-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.seg button:active { transform: scale(0.97); }
.seg button.on { background: rgba(108, 124, 255, 0.28); border-color: var(--accent); }

.primary-btn, .secondary-btn {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.06em;
  transition: transform 0.1s, filter 0.15s;
}
.primary-btn:active, .secondary-btn:active { transform: scale(0.98); }
.primary-btn {
  border: 0;
  color: #061016;
  background: linear-gradient(90deg, #3ddc97, #38d6ff);
  box-shadow: 0 10px 30px rgba(61, 220, 151, 0.3);
}
.secondary-btn {
  border: 1px solid var(--edge);
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  font-size: 14px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row .secondary-btn { margin-top: 10px; }
.text-btn {
  min-height: 44px;
  margin-top: 6px;
  padding: 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}
.back-link { display: inline-block; margin-bottom: 8px; padding: 10px 4px; color: var(--muted); font-size: 14px; text-decoration: none; }
.back-link.center { display: block; text-align: center; margin: 10px 0 0; }

/* ---------- 结算 ---------- */
.result-title {
  margin: 0;
  font-size: clamp(30px, 8vw, 40px);
  font-weight: 950;
  letter-spacing: 0.04em;
  color: var(--text);
}
.result-title.win { color: var(--gold); }
.result-title.lose { color: #ff8a97; }
.big-label { margin: 6px 0 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.big-ms { margin: 0; font-size: clamp(48px, 14vw, 72px); font-weight: 900; line-height: 1.1; }
.big-score { margin: 6px 0 0; font-size: 34px; font-weight: 900; letter-spacing: 0.04em; }
.rating {
  display: inline-block;
  margin: 4px 0 14px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(61, 220, 151, 0.18);
  border: 1px solid rgba(61, 220, 151, 0.5);
  color: var(--go);
  font-weight: 800;
  font-size: 14px;
}
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div {
  padding: 10px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.stats b { display: block; font-size: 16px; font-weight: 900; }
.stats span { font-size: 11px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(108, 124, 255, 0.15);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.rows { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.rows li {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 14px;
  font-weight: 600;
}
.rows li.row-win { border-left: 3px solid var(--go); }
.rows li.row-lose { border-left: 3px solid var(--wait); }
.rows li.row-replay { border-left: 3px solid var(--muted); color: var(--muted); }
.challenge { margin: 14px 0 0; color: var(--muted); font-size: 15px; font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(10, 12, 30, 0.95);
  border: 1px solid var(--edge);
  font-size: 14px;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* ---------- 说明文章 ---------- */
.about {
  width: min(680px, 100%);
  padding: 8px 4px 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}
.about h2 { margin: 16px 0 10px; font-size: 24px; color: var(--text); }
.about h3 { margin: 26px 0 8px; font-size: 18px; color: var(--text); }
.about p { margin: 0 0 12px; }
.about ul { margin: 0 0 12px; padding-left: 20px; }
.about li { margin-bottom: 8px; }
.about strong { color: var(--text); }
.about details {
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.about summary { cursor: pointer; font-weight: 700; color: var(--text); min-height: 28px; }
.about details p { margin: 8px 0 0; }
.about .more { margin-top: 18px; }
.about a { color: var(--accent); }

@media (max-width: 480px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chip-hud { font-size: 12px; padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .center.pop .center-main, .fx .p, .stage.shake { animation: none !important; }
}

/* 首页（含可滚动的说明文章）打开时隐藏舞台底部提示，避免叠在文章上 */
body:has(#home:not([hidden])) .stage-hint { visibility: hidden; }
