:root {
  --bg: #080a18;
  --panel: rgba(14, 17, 40, 0.86);
  --edge: rgba(120, 135, 255, 0.35);
  --text: #eef0ff;
  --muted: #9aa2d6;
  --you: #38d6ff;
  --bot: #ff5266;
  --gold: #ffd166;
  --accent: #6c7cff;
}

* { 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;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
}

[hidden] { display: none !important; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 0 calc(60px + env(safe-area-inset-right)) 0 calc(60px + env(safe-area-inset-left));
  pointer-events: none;
}
.scoreboard {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(10, 12, 30, 0.75);
  border: 1px solid var(--edge);
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 15px;
}
.scoreboard b { font-size: 20px; }
.side.you { color: var(--you); }
.side.bot { color: var(--bot); }
.round { color: var(--muted); font-size: 12px; }
@media (max-width: 480px) {
  .scoreboard { gap: 10px; padding: 7px 12px; font-size: 13px; }
  .scoreboard b { font-size: 18px; }
  .round { font-size: 10px; }
}
.icon-btn {
  pointer-events: auto;
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: rgba(10, 12, 30, 0.75);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.dash-btn {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: radial-gradient(circle at 35% 30%, #5f6dff, #3a2fb8);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.06em;
  touch-action: none;
  box-shadow: 0 8px 30px rgba(80, 90, 255, 0.45);
}
.dash-btn.cooling { opacity: 0.45; }
.dash-cd {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.center-msg {
  position: fixed;
  left: 0;
  right: 0;
  top: 42%;
  text-align: center;
  font-weight: 900;
  font-size: clamp(34px, 9vw, 76px);
  letter-spacing: 0.03em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0;
}
.center-msg small { display: block; font-size: 0.32em; color: var(--muted); font-weight: 700; margin-top: 6px; }
.center-msg.show { animation: pop 0.9s ease-out forwards; }
.center-msg.hold { animation: popHold 1.6s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: scale(1.6); }
  20% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(0.95); }
}
@keyframes popHold {
  0% { opacity: 0; transform: scale(1.5); }
  12% { opacity: 1; transform: scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 24px;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(8, 10, 24, 0.35), rgba(8, 10, 24, 0.8));
  overflow-y: auto;
}
.panel {
  width: min(440px, 100%);
  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);
  backdrop-filter: blur(6px);
  text-align: center;
  animation: rise 0.35s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.logo {
  margin: 0;
  font-size: clamp(40px, 11vw, 58px);
  font-weight: 950;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--you), #b9a8ff 50%, var(--bot));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 24px rgba(108, 124, 255, 0.45));
}
.hook { margin: 6px 0 18px; color: var(--muted); font-size: 15px; line-height: 1.4; }

.settings { display: grid; gap: 10px; margin-bottom: 18px; }
.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; }
.seg button {
  flex: 1;
  padding: 10px 4px;
  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 {
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 950;
  letter-spacing: 0.1em;
  color: #fff;
  background: linear-gradient(90deg, #ff5266, #ff8a3d);
  box-shadow: 0 10px 30px rgba(255, 82, 102, 0.4);
  cursor: pointer;
  animation: breathe 1.8s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.025); box-shadow: 0 12px 40px rgba(255, 82, 102, 0.6); } }
.secondary-btn {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.row { display: flex; gap: 10px; }
.text-btn {
  margin-top: 12px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.howto { margin: 14px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
kbd {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-only { display: inline; }
  .kbd-only { display: none; }
}
.record { margin: 10px 0 0; font-size: 13px; color: var(--gold); min-height: 1em; }

.result-title { margin: 0; font-size: clamp(40px, 11vw, 56px); font-weight: 950; letter-spacing: 0.05em; }
.result-title.win { color: var(--gold); text-shadow: 0 0 30px rgba(255, 209, 102, 0.45); }
.result-title.lose { color: var(--bot); text-shadow: 0 0 30px rgba(255, 82, 102, 0.45); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 14px; }
.stats div { padding: 10px 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.stats b { display: block; font-size: 20px; }
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.challenge { margin: 0 0 14px; color: var(--gold); font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(20, 24, 52, 0.95);
  border: 1px solid var(--edge);
  font-size: 14px;
}

/* 首页面板下方有说明文章，可向下滚动 */
#home { align-content: start; padding-top: max(24px, 6vh); }

/* ---------- Back link + about article ---------- */
.back-link {
  display: inline-block;
  margin: -8px 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.panel > .back-link { display: block; text-align: left; }
.back-link.center { display: block; text-align: center; margin: 10px 0 0; }
.back-link:hover { color: var(--text); }
.about {
  width: min(640px, 100%);
  padding: 22px;
  border-radius: 18px;
  background: rgba(12, 14, 34, 0.95);
  border: 1px solid rgba(120, 135, 255, 0.18);
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
  user-select: text;
  -webkit-user-select: text;
  margin-bottom: 24px;
}
.about h2, .about h3 { color: var(--text); margin: 18px 0 8px; }
.about h2 { margin-top: 0; font-size: 22px; }
.about h3 { font-size: 17px; }
.about ul { padding-left: 20px; margin: 0; }
.about strong { color: var(--text); }
.about details { padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.about summary { color: var(--text); cursor: pointer; font-weight: 600; }
.about details p { margin: 8px 0 0; }
.about a { color: var(--you); }
.about .more { margin: 16px 0 0; }
