:root {
  --paper: #F4F2EC;
  --ink: #141414;
  --gray: #8A8A8A;
  --accent: #FF3B1F;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

.mono { font-family: 'Space Mono', ui-monospace, monospace; }
.hidden { display: none !important; }

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  pointer-events: none;
  z-index: 5;
}
.hud-cell { display: flex; flex-direction: column; gap: 2px; }
.hud-right { align-items: flex-end; }
.hud-label { font-size: 11px; letter-spacing: 2px; color: var(--gray); font-weight: 700; }
.hud-val { font-size: 28px; font-weight: 700; line-height: 1; }
.hud-weapon { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.hud-combo { font-size: 26px; font-weight: 700; line-height: 1; color: var(--gray); transition: color .12s; }
.hud-combo.hot { color: var(--accent); }

/* ---------- Toast ---------- */
#toast {
  position: absolute;
  top: 22%; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 24px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  z-index: 8;
  pointer-events: none;
  white-space: nowrap;
}
#toast.toast-anim { animation: toastPop .35s ease-out; }
@keyframes toastPop {
  0% { transform: translateX(-50%) scale(.7); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.08); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ---------- Countdown ---------- */
#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(90px, 28vw, 220px);
  color: var(--ink);
  z-index: 7;
  pointer-events: none;
  animation: cd .5s ease-out;
}
@keyframes cd { from { transform: scale(1.6); opacity: .2; } to { transform: scale(1); opacity: 1; } }

/* ---------- Screens (title / result) ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(244, 242, 236, 0.0);
}
/* 标题页透明，露出画布里漂移的靶子——一眼看出是射击游戏 */
#title { background: transparent; align-items: flex-start; }
.title-inner {
  text-align: center;
  margin-top: 12vh;
  padding: 0 16px;
}
.logo {
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(54px, 16vw, 120px);
  letter-spacing: -2px;
  line-height: .95;
  /* 纸白光晕：靶子飘到字后面时仍清晰 */
  text-shadow: 0 0 26px var(--paper), 0 0 12px var(--paper), 0 0 4px var(--paper);
}
.tagline {
  margin-top: 14px;
  font-size: clamp(15px, 4.5vw, 22px);
  color: var(--ink);
  font-weight: 600;
  text-shadow: 0 0 16px var(--paper), 0 0 6px var(--paper);
}
.tap {
  margin-top: 40px;
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 16px var(--paper), 0 0 6px var(--paper);
  animation: blink 1.1s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: .25; } }

.best {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--gray);
  font-weight: 700;
}
.mute {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  background: none;
  border: 2px solid var(--ink);
  border-radius: 8px;
  width: 44px; height: 44px;
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 12;
}
/* 语言切换：静音按钮左侧 */
.lang {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 70px;
  background: none;
  border: 2px solid var(--ink);
  border-radius: 8px;
  height: 44px;
  min-width: 44px;
  padding: 0 10px;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 12;
}

/* ---------- 中文排版微调（logo/record 需要粗体中文回退） ---------- */
body.lang-zh .logo {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  font-weight: 800;
  letter-spacing: 2px;
}
body.lang-zh .record {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  font-weight: 800;
}
body.lang-zh .tap,
body.lang-zh .times-up,
body.lang-zh .result-label { letter-spacing: 3px; }

/* ---------- Result ---------- */
#result { background: rgba(244, 242, 236, 0.92); backdrop-filter: blur(2px); }
.result-inner { text-align: center; padding: 24px; width: 100%; max-width: 460px; }
.times-up { font-size: 16px; letter-spacing: 6px; color: var(--gray); font-weight: 700; }
.record {
  margin-top: 6px;
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(26px, 8vw, 40px);
  color: var(--accent);
  animation: recordPulse 1s ease-in-out infinite;
}
@keyframes recordPulse { 50% { transform: scale(1.06); } }
.result-label { margin-top: 18px; font-size: 14px; letter-spacing: 5px; color: var(--gray); font-weight: 700; }
.result-score {
  font-size: clamp(80px, 26vw, 150px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
}
.result-stats {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.result-stats > div { display: flex; flex-direction: column; gap: 4px; }
.rs-label { font-size: 11px; letter-spacing: 2px; color: var(--gray); font-weight: 700; }
.result-stats > div > span:last-child { font-size: 24px; font-weight: 700; }

.result-btns { margin-top: 34px; display: flex; gap: 14px; justify-content: center; }
.btn {
  font-family: 'Space Mono', monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 16px 26px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  cursor: pointer;
  min-width: 150px;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:active { background: var(--accent); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:active { background: var(--ink); color: var(--paper); }

@media (max-width: 380px) {
  .result-btns { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .tap, .record, #toast.toast-anim, #countdown { animation: none !important; }
}
