:root {
  --ink: #04100b;
  --ink-2: #071a12;
  --cream: #f4f1e4;
  --mint: #7dffc4;
  --mint-deep: #2bd694;
  --lime: #dcff79;
  --coral: #ff5c67;
  --gold: #ffd166;
  --line: rgba(205, 255, 230, 0.16);
  --line-strong: rgba(205, 255, 230, 0.28);
  --muted: rgba(232, 249, 240, 0.58);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #020604;
  color: var(--cream);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 45%, #0a1d15 0%, #030906 58%, #010302 100%);
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

.app {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0;
}

.stage {
  position: relative;
  width: min(97vw, calc(94vh * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 94vh;
  overflow: hidden;
  isolation: isolate;
  border-radius: clamp(16px, 2vw, 30px);
  border: 1px solid rgba(198, 255, 226, 0.13);
  background: #06110c;
  box-shadow:
    0 50px 130px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(0, 0, 0, 0.5) inset,
    0 0 120px rgba(39, 198, 139, 0.06);
  user-select: none;
  touch-action: none;
}

/* 未开摄像头时的舞台背景 */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 79% 15%, rgba(255, 92, 103, 0.16), transparent 25%),
    radial-gradient(circle at 14% 86%, rgba(83, 255, 190, 0.13), transparent 34%),
    radial-gradient(circle at 52% 45%, rgba(23, 67, 50, 0.85), transparent 65%),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(220, 255, 236, 0.022) 80px),
    repeating-linear-gradient(0deg, transparent 0 79px, rgba(220, 255, 236, 0.018) 80px),
    linear-gradient(150deg, #0a2118 0%, #05120c 55%, #020705 100%);
}

.stage::after {
  content: "果";
  position: absolute;
  z-index: 0;
  right: -0.08em;
  bottom: -0.28em;
  font-family: var(--serif);
  font-size: clamp(300px, 44vw, 780px);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(194, 255, 222, 0.06);
  pointer-events: none;
  transform: rotate(-4deg);
}

.camera {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  filter: saturate(0.86) contrast(1.06) brightness(0.76);
  opacity: 0;
  transition: opacity 0.9s ease;
}

.stage.live .camera { opacity: 1; }

.camera-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(2, 8, 5, 0.64) 0%, rgba(2, 8, 5, 0.1) 26%, rgba(2, 8, 5, 0.04) 55%, rgba(2, 8, 5, 0.62) 100%),
    radial-gradient(ellipse at 50% 45%, transparent 42%, rgba(1, 5, 3, 0.58) 100%);
  opacity: 0;
  transition: opacity 0.9s ease;
}

.stage.live .camera-shade { opacity: 1; }

/* 默认只用主题背景；开启“摄像头画面”后才把实时镜头铺满 */
.stage:not(.show-camera) .camera,
.stage:not(.show-camera) .camera-shade { opacity: 0; }

/* 摄像头小窗：保留默认背景，把镜头放在右上角 */
.stage.camera-preview .camera {
  top: calc(118px * var(--ui, 1));
  right: calc(40px * var(--ui, 1));
  bottom: auto;
  left: auto;
  z-index: 4;
  width: min(24%, calc(240px * var(--ui, 1)));
  height: auto;
  aspect-ratio: 16 / 9;
  border: 2px solid rgba(140, 255, 202, 0.48);
  border-radius: calc(14px * var(--ui, 1));
  background: #010604;
  box-shadow:
    0 16px 42px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.45) inset;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
}

.stage.live.camera-preview .camera { opacity: 1; }
.stage.camera-preview .camera-shade { display: none; }

.camera-preview-tag {
  position: absolute;
  z-index: 5;
  top: calc(126px * var(--ui, 1));
  right: calc(48px * var(--ui, 1));
  display: inline-flex;
  align-items: center;
  gap: calc(5px * var(--ui, 1));
  padding: calc(3px * var(--ui, 1)) calc(7px * var(--ui, 1));
  border: 1px solid rgba(140, 255, 202, 0.24);
  border-radius: 999px;
  background: rgba(2, 10, 6, 0.62);
  color: rgba(225, 255, 239, 0.82);
  font-size: calc(9px * var(--ui, 1));
  font-weight: 600;
  letter-spacing: 0.1em;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease;
}

.camera-preview-tag i {
  width: calc(5px * var(--ui, 1));
  height: calc(5px * var(--ui, 1));
  border-radius: 50%;
  background: #ff7f87;
  box-shadow: 0 0 8px rgba(255, 92, 103, 0.8);
}

.stage.live.camera-preview .camera-preview-tag {
  opacity: 1;
  visibility: visible;
}

.game {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.075;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

.edge {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 0 100px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(224, 255, 240, 0.04);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: clamp(14px, 2.3vw, 30px);
  left: clamp(16px, 2.8vw, 40px);
  right: clamp(16px, 2.8vw, 40px);
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.stage.playing .hud,
.stage.paused .hud,
.stage.over .hud {
  opacity: 1;
  transform: none;
}

.hud-card {
  position: relative;
  min-width: clamp(88px, 9vw, 128px);
  padding: 9px clamp(13px, 1.5vw, 20px) 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(11, 34, 25, 0.72), rgba(4, 14, 10, 0.42));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px) saturate(1.1);
}

.score-card::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  opacity: 0.6;
}

.hud-label {
  display: block;
  margin-bottom: 4px;
  font-size: clamp(8px, 0.68vw, 10px);
  font-weight: 600;
  letter-spacing: 0.24em;
  color: rgba(206, 255, 230, 0.55);
}

.num {
  display: block;
  font-size: clamp(24px, 2.75vw, 42px);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--cream);
  text-shadow: 0 0 24px rgba(125, 255, 196, 0.14);
}

.hud-right {
  display: flex;
  align-items: flex-start;
  gap: clamp(10px, 1.4vw, 18px);
}

.lives {
  display: flex;
  gap: 5px;
  height: 34px;
  padding: 8px 11px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(4, 14, 10, 0.44);
  backdrop-filter: blur(12px);
}

.life {
  width: clamp(14px, 1.25vw, 18px);
  height: clamp(14px, 1.25vw, 18px);
  color: var(--coral);
  filter: drop-shadow(0 0 7px rgba(255, 92, 103, 0.45));
  transition: transform 0.25s ease, opacity 0.25s ease, color 0.25s ease;
}

.life svg { display: block; width: 100%; height: 100%; fill: currentColor; }
.life.lost { color: rgba(255, 255, 255, 0.15); filter: none; transform: scale(0.82); }

.timer-card { text-align: right; }
.timer-card .num { color: var(--lime); }
.timer-card.low .num { color: var(--coral); animation: timerPulse 1s ease-in-out infinite; }

.combo-pill {
  position: absolute;
  top: clamp(8px, 1vw, 16px);
  left: 50%;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 16px 9px;
  border: 1px solid rgba(220, 255, 121, 0.35);
  border-radius: 999px;
  background: rgba(19, 38, 20, 0.64);
  box-shadow: 0 0 28px rgba(220, 255, 121, 0.14);
  backdrop-filter: blur(14px);
  color: var(--lime);
  opacity: 0;
  transform: translate(-50%, -8px) scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.combo-pill.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.combo-pill span {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: rgba(233, 255, 181, 0.7);
}

.combo-pill b {
  font-size: clamp(20px, 1.8vw, 28px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.combo-pill i {
  font-style: normal;
  font-size: 12px;
  opacity: 0.7;
}

/* ---------- 状态与底部 ---------- */
.status-pill {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: clamp(58px, 7.5vh, 82px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid rgba(205, 255, 230, 0.13);
  border-radius: 999px;
  background: rgba(3, 12, 8, 0.48);
  backdrop-filter: blur(12px);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  transform: translateX(-50%);
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.stage.idle .status-pill { opacity: 0; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
  animation: breathe 2.4s ease-in-out infinite;
}

.status-pill.warn { color: var(--gold); border-color: rgba(255, 209, 102, 0.25); }
.status-pill.warn .status-dot { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.status-pill.error { color: #ff9ba2; border-color: rgba(255, 92, 103, 0.3); }
.status-pill.error .status-dot { background: var(--coral); box-shadow: 0 0 10px var(--coral); animation: none; }

.stage-foot {
  position: absolute;
  z-index: 6;
  left: clamp(16px, 2.4vw, 34px);
  right: clamp(16px, 2.4vw, 34px);
  bottom: clamp(14px, 2vh, 24px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.foot-left { display: flex; gap: 8px; pointer-events: auto; }
.foot-right { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(205, 255, 230, 0.14);
  border-radius: 50%;
  background: rgba(4, 14, 10, 0.4);
  color: rgba(232, 249, 240, 0.7);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: color 0.2s, border-color 0.2s, background 0.2s, opacity 0.2s;
}

.icon-btn:hover { color: var(--cream); border-color: var(--line-strong); background: rgba(14, 35, 26, 0.66); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg path:first-child { fill: currentColor; stroke: none; }
.icon-btn.muted .sound-wave { opacity: 0.2; }
#pauseBtn { opacity: 0.35; pointer-events: none; }
.stage.playing #pauseBtn { opacity: 1; pointer-events: auto; }
.stage.paused #pauseBtn { opacity: 1; pointer-events: auto; }

.engine-label,
.fps {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: rgba(220, 255, 235, 0.3);
  font-variant-numeric: tabular-nums;
}

.fps { min-width: 38px; text-align: right; letter-spacing: 0.08em; }

/* ---------- 开始界面 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.72fr);
  align-items: center;
  gap: clamp(24px, 4vw, 72px);
  padding: clamp(28px, 5.2vw, 84px) clamp(26px, 5.4vw, 88px) clamp(46px, 6vh, 70px);
  background:
    linear-gradient(90deg, rgba(2, 9, 6, 0.9) 0%, rgba(2, 9, 6, 0.62) 48%, rgba(2, 9, 6, 0.18) 100%),
    linear-gradient(0deg, rgba(2, 7, 5, 0.62) 0%, transparent 34%);
}

.start-copy {
  position: relative;
  z-index: 1;
  max-width: 650px;
  animation: riseIn 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(9px, 0.78vw, 11px);
  font-weight: 600;
  letter-spacing: 0.28em;
  color: rgba(152, 255, 209, 0.72);
  white-space: nowrap;
}

.eyebrow-line {
  width: clamp(24px, 3vw, 44px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--mint));
  opacity: 0.8;
}

.logo {
  display: flex;
  align-items: flex-start;
  gap: 0.02em;
  margin: clamp(12px, 1.8vw, 22px) 0 clamp(12px, 1.4vw, 18px);
  font-family: var(--serif);
  font-size: clamp(84px, 11.6vw, 184px);
  font-weight: 900;
  line-height: 0.86;
  letter-spacing: -0.09em;
}

.logo > span:first-child {
  color: var(--cream);
  text-shadow: 0 12px 50px rgba(0, 0, 0, 0.4);
}

.logo-accent {
  position: relative;
  color: transparent;
  background: linear-gradient(150deg, #eaffb0 0%, var(--mint) 45%, #1fc98b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 34px rgba(90, 255, 190, 0.25));
}

.logo-accent::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 0;
  bottom: 6%;
  height: 3px;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  opacity: 0.55;
  transform: rotate(-2deg);
}

.tagline {
  margin: 0 0 clamp(22px, 3.2vh, 36px);
  font-size: clamp(14px, 1.25vw, 19px);
  line-height: 1.9;
  letter-spacing: 0.06em;
  color: rgba(235, 250, 241, 0.68);
}

.start-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.setup-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(125, 255, 196, 0.16);
  border-radius: 12px;
  background: rgba(5, 18, 12, 0.42);
  backdrop-filter: blur(10px);
  width: fit-content;
  max-width: 100%;
}

.setup-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(205, 245, 224, 0.66);
  white-space: nowrap;
}

.setup-field select {
  min-height: 30px;
  max-width: min(186px, 34vw);
  border: 1px solid rgba(125, 255, 196, 0.22);
  border-radius: 8px;
  background: rgba(8, 27, 18, 0.86);
  color: #e7fff3;
  padding: 0 7px;
  font: inherit;
  font-size: 11px;
  outline: none;
}

.setup-field select:focus {
  border-color: rgba(125, 255, 196, 0.65);
}

.mini-btn,
.mini-link {
  min-height: 30px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(125, 255, 196, 0.22);
  border-radius: 8px;
  background: rgba(12, 40, 27, 0.62);
  color: rgba(226, 255, 242, 0.82);
  font: inherit;
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
}

.mini-btn:hover,
.mini-link:hover {
  border-color: rgba(125, 255, 196, 0.55);
  color: #effff7;
}

.mini-link {
  border-color: rgba(255, 229, 168, 0.24);
  color: rgba(255, 238, 190, 0.82);
}

@media (max-width: 700px) {
  .setup-row { gap: 6px; }
  .setup-field { font-size: 10px; }
  .setup-field select { max-width: 38vw; font-size: 10px; }
  .mini-btn, .mini-link { padding: 0 8px; font-size: 10px; }
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: clamp(46px, 4.2vw, 56px);
  padding: 0 clamp(20px, 2.1vw, 30px);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: clamp(13px, 1vw, 15px);
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled,
.btn:disabled:hover {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.7);
  transform: none;
  box-shadow: none;
}

.btn.primary {
  color: #042016;
  background: linear-gradient(135deg, #d8ff9d 0%, #7dffc4 48%, #38e3a4 100%);
  box-shadow: 0 12px 40px rgba(56, 227, 164, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 54px rgba(56, 227, 164, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn.ghost {
  color: rgba(238, 252, 244, 0.82);
  border-color: rgba(205, 255, 230, 0.2);
  background: rgba(9, 25, 18, 0.32);
  backdrop-filter: blur(12px);
}

.btn.ghost:hover {
  color: var(--cream);
  border-color: rgba(205, 255, 230, 0.4);
  background: rgba(17, 41, 30, 0.6);
}

.cam-icon {
  position: relative;
  width: 17px;
  height: 12px;
  border: 1.6px solid currentColor;
  border-radius: 3px;
}

.cam-icon::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 5px;
  border: 1.4px solid currentColor;
  border-radius: 50%;
}

.cam-icon::after {
  content: "";
  position: absolute;
  top: 2px;
  right: -4px;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-left: 4px solid currentColor;
}

.privacy {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: clamp(14px, 2vh, 20px) 0 0;
  font-size: clamp(9px, 0.75vw, 11px);
  letter-spacing: 0.04em;
  color: rgba(215, 243, 229, 0.42);
}

.lock-icon {
  position: relative;
  width: 9px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 1.5px;
}

.lock-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border: 1px solid currentColor;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

.how-card {
  position: relative;
  justify-self: end;
  width: min(100%, 360px);
  padding: clamp(22px, 2.3vw, 32px);
  border: 1px solid rgba(205, 255, 230, 0.14);
  border-radius: clamp(18px, 1.8vw, 26px);
  background:
    linear-gradient(160deg, rgba(15, 40, 29, 0.64), rgba(4, 14, 9, 0.46));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(1.1);
  overflow: hidden;
  animation: riseIn 1s 0.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.how-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(125, 255, 196, 0.55), transparent);
}

.how-kicker {
  display: block;
  margin-bottom: 18px;
  font-size: 9px;
  letter-spacing: 0.26em;
  color: rgba(152, 255, 209, 0.5);
}

.how-list {
  display: grid;
  gap: clamp(12px, 1.6vh, 18px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-list li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
}

.how-list b {
  padding-top: 2px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--mint);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.how-list strong {
  display: block;
  margin-bottom: 3px;
  font-size: clamp(12px, 0.9vw, 14px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(245, 252, 247, 0.9);
}

.how-list span {
  display: block;
  font-size: clamp(10px, 0.72vw, 11.5px);
  line-height: 1.55;
  color: rgba(218, 242, 229, 0.42);
}

.how-foot {
  margin-top: clamp(18px, 2.4vh, 26px);
  padding-top: 16px;
  border-top: 1px solid rgba(205, 255, 230, 0.08);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: rgba(215, 243, 229, 0.35);
}

.key {
  display: inline-block;
  min-width: 20px;
  margin: 0 3px 0 8px;
  padding: 2px 5px;
  border: 1px solid rgba(205, 255, 230, 0.14);
  border-radius: 4px;
  text-align: center;
  font-size: 8px;
  color: rgba(235, 250, 241, 0.55);
}

.key:first-child { margin-left: 0; }

.reticle {
  position: absolute;
  top: -40px;
  right: -34px;
  width: 150px;
  height: 150px;
  opacity: 0.5;
  pointer-events: none;
}

.reticle-ring {
  position: absolute;
  border: 1px solid rgba(125, 255, 196, 0.28);
  border-radius: 50%;
}

.ring-a { inset: 20px; border-style: dashed; animation: spin 18s linear infinite; }
.ring-b { inset: 43px; border-color: rgba(125, 255, 196, 0.5); }

.reticle-cross,
.reticle-cross::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 1px;
  background: rgba(125, 255, 196, 0.36);
  transform: translate(-50%, -50%);
}

.reticle-cross::before {
  content: "";
  width: 1px;
  height: 46px;
  transform: translate(-50%, -50%);
}

.reticle-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 16px var(--mint);
  transform: translate(-50%, -50%);
}

/* ---------- 弹层 ---------- */
.modal-screen {
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 8, 5, 0.58);
  backdrop-filter: blur(16px) saturate(0.85);
}

.modal-card {
  position: relative;
  width: min(100%, 470px);
  padding: clamp(28px, 3.6vw, 46px);
  border: 1px solid rgba(205, 255, 230, 0.16);
  border-radius: clamp(20px, 2vw, 28px);
  background:
    radial-gradient(circle at 80% 0%, rgba(125, 255, 196, 0.09), transparent 40%),
    linear-gradient(155deg, rgba(15, 40, 29, 0.95), rgba(4, 13, 9, 0.96));
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  text-align: left;
  animation: modalIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-kicker {
  display: block;
  margin-bottom: 12px;
  font-size: 9px;
  letter-spacing: 0.26em;
  color: rgba(152, 255, 209, 0.55);
}

.modal-card h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: clamp(32px, 3.4vw, 48px);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.modal-card > p {
  margin: 0 0 28px;
  font-size: 12.5px;
  line-height: 1.8;
  color: rgba(224, 245, 233, 0.55);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.modal-actions .btn { min-height: 46px; font-size: 13px; }

.over-card {
  background:
    radial-gradient(circle at 82% 2%, rgba(255, 92, 103, 0.13), transparent 38%),
    linear-gradient(155deg, rgba(31, 20, 20, 0.96), rgba(7, 13, 10, 0.97));
}

.over-card .modal-kicker { color: rgba(255, 146, 153, 0.65); }

.final-score {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 20px 0 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(205, 255, 230, 0.1);
}

.final-score span {
  padding-bottom: 9px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(218, 242, 229, 0.45);
}

.final-score strong {
  font-size: clamp(52px, 6.6vw, 82px);
  line-height: 0.9;
  font-weight: 600;
  color: var(--lime);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(220, 255, 121, 0.18);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats-row div {
  padding: 12px;
  border: 1px solid rgba(205, 255, 230, 0.09);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.stats-row span {
  display: block;
  margin-bottom: 6px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(218, 242, 229, 0.4);
}

.stats-row b {
  font-size: clamp(16px, 1.6vw, 22px);
  font-weight: 600;
  color: rgba(245, 252, 247, 0.9);
  font-variant-numeric: tabular-nums;
}

/* ---------- 倒计时 / 闪光 / toast ---------- */
.countdown {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(3, 14, 9, 0.12) 0%, rgba(3, 9, 6, 0.44) 80%);
}

.countdown.hidden { display: none; }

.countdown span {
  font-family: var(--serif);
  font-size: clamp(120px, 17vw, 260px);
  font-weight: 900;
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 0 80px rgba(125, 255, 196, 0.35);
  animation: countPop 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}

.flash.fire { animation: flash 0.42s ease-out; }
.flash.bomb { background: #ff3b47; animation: flashBomb 0.7s ease-out; }

.toast {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: 16%;
  max-width: min(80%, 520px);
  padding: 11px 18px;
  border: 1px solid rgba(255, 92, 103, 0.3);
  border-radius: 12px;
  background: rgba(23, 9, 11, 0.88);
  color: #ffc4c8;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.rotate-hint {
  display: none;
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(220, 255, 235, 0.35);
  white-space: nowrap;
}

/* ---------- 动画 ---------- */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes countPop {
  0% { opacity: 0; transform: scale(1.5); filter: blur(8px); }
  30% { opacity: 1; transform: scale(1); filter: blur(0); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.92); }
}

@keyframes flash {
  0% { opacity: 0.55; }
  100% { opacity: 0; }
}

@keyframes flashBomb {
  0% { opacity: 0.8; }
  18% { opacity: 0.2; }
  36% { opacity: 0.55; }
  100% { opacity: 0; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.55; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .start-screen {
    grid-template-columns: 1fr;
    padding: 8% 7%;
  }
  .how-card { display: none; }
  .start-copy { max-width: 640px; }
  .logo { font-size: clamp(88px, 17vw, 150px); }
}

@media (max-height: 560px) {
  .logo { font-size: clamp(68px, 10vw, 120px); }
  .tagline { font-size: 13px; margin-bottom: 18px; }
  .start-actions { gap: 8px; }
  .btn { min-height: 42px; }
  .how-card { padding: 18px; }
  .how-list { gap: 9px; }
  .how-foot { display: none; }
  .status-pill { bottom: 46px; }
  .hud-card { padding: 6px 12px 8px; }
}

@media (max-aspect-ratio: 1/1) {
  .stage {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    border: none;
  }
  .rotate-hint { display: block; }
  .start-screen { align-items: start; padding-top: 10vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 右上角快捷操作 / 历史记录 ---------- */
.top-actions {
  position: absolute;
  top: clamp(14px, 2.4vw, 28px);
  right: clamp(16px, 2.8vw, 40px);
  z-index: 8;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.stage.idle .top-actions {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.top-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(205, 255, 230, 0.18);
  border-radius: 999px;
  background: rgba(5, 22, 15, 0.72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px) saturate(1.1);
  color: rgba(225, 255, 238, 0.76);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.top-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top-action:hover {
  border-color: rgba(125, 255, 196, 0.55);
  background: rgba(15, 53, 36, 0.86);
  color: var(--mint);
}

.history-screen {
  z-index: 9;
}

.history-card {
  width: min(100%, 620px);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
}

.history-summary {
  display: flex;
  gap: 28px;
  margin: 18px 0 4px;
  padding: 12px 0 16px;
  border-bottom: 1px solid rgba(205, 255, 230, 0.1);
}

.history-summary div {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.history-summary span {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(224, 245, 233, 0.48);
}

.history-summary b {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  color: var(--mint);
}

.history-list {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 50vh;
  gap: 7px;
  margin: 14px -4px 0 0;
  padding-right: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 255, 196, 0.28) transparent;
}

.history-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid rgba(205, 255, 230, 0.1);
  border-radius: 12px;
  background: rgba(10, 30, 21, 0.48);
}

.history-row.is-best {
  border-color: rgba(125, 255, 196, 0.36);
  background: linear-gradient(100deg, rgba(38, 92, 63, 0.42), rgba(10, 30, 21, 0.42));
}

.history-rank {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  color: rgba(183, 219, 202, 0.48);
  text-align: center;
}

.history-body {
  min-width: 0;
}

.history-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.history-score {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
  color: var(--cream);
}

.history-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
}

.history-tag {
  padding: 2px 6px;
  border: 1px solid rgba(205, 255, 230, 0.13);
  border-radius: 4px;
  color: rgba(183, 219, 202, 0.58);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.history-sub {
  margin-top: 5px;
  overflow: hidden;
  color: rgba(224, 245, 233, 0.42);
  font-size: 10px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-badge {
  padding: 3px 7px;
  border: 1px solid rgba(125, 255, 196, 0.35);
  border-radius: 999px;
  color: var(--mint);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.history-empty {
  margin: 22px 0 6px;
  padding: 22px 12px;
  border: 1px dashed rgba(205, 255, 230, 0.14);
  border-radius: 12px;
  color: rgba(224, 245, 233, 0.42);
  font-size: 12px;
  text-align: center;
}

.history-card .modal-actions {
  margin-top: 18px;
}

.history-card .modal-actions .btn {
  flex: 1 1 120px;
}

.history-confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 92, 103, 0.34);
  border-radius: 12px;
  background: linear-gradient(120deg, rgba(78, 25, 29, 0.62), rgba(24, 13, 15, 0.55));
}

.history-confirm[hidden] {
  display: none;
}

.history-confirm-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 170px;
}

.history-confirm-copy strong {
  color: #ffd9dc;
  font-size: 12px;
  font-weight: 700;
}

.history-confirm-copy span {
  color: rgba(255, 217, 220, 0.48);
  font-size: 10px;
}

.history-confirm-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.history-confirm-actions .btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 11.5px;
}

.btn.danger {
  border-color: rgba(255, 92, 103, 0.52);
  background: linear-gradient(160deg, rgba(118, 34, 41, 0.92), rgba(56, 17, 21, 0.94));
  color: #ffe8ea;
  box-shadow: 0 8px 24px rgba(80, 10, 18, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn.danger:hover {
  border-color: rgba(255, 120, 130, 0.8);
  background: linear-gradient(160deg, rgba(151, 44, 53, 0.96), rgba(76, 22, 28, 0.96));
}

@media (max-width: 760px) {
  .history-confirm {
    align-items: stretch;
  }
  .history-confirm-actions {
    width: 100%;
    margin-left: 0;
  }
  .history-confirm-actions .btn {
    flex: 1;
  }
}

.history-empty[hidden],
.history-list[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .top-actions { top: 12px; right: 12px; gap: 6px; }
  .top-action { min-height: 31px; padding: 0 10px; font-size: 10.5px; }
  .top-action svg { width: 13px; height: 13px; }
  .history-card { padding: 22px 18px; }
  .history-summary { gap: 18px; }
  .history-row { grid-template-columns: 26px minmax(0, 1fr); gap: 8px; padding: 7px 9px; }
  .history-badge { display: none; }
}


/* ---- 反走私宣传主题 ---- */
body.theme-customs {
  background:
    radial-gradient(ellipse at 50% 38%, #0c2b3c 0%, #041019 58%, #010508 100%);
}

.stage.theme-customs {
  --cream: #f4fbff;
  --mint: #7fe8ff;
  --mint-deep: #32b8e6;
  --lime: #ffe27a;
  --coral: #ff8a72;
  --line: rgba(170, 235, 255, 0.18);
  --line-strong: rgba(170, 235, 255, 0.32);
  --muted: rgba(220, 245, 255, 0.62);
  background: #071b26;
  border-color: rgba(160, 232, 255, 0.2);
  box-shadow:
    0 50px 130px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(0, 0, 0, 0.5) inset,
    0 0 120px rgba(74, 194, 235, 0.1);
}

.stage.theme-customs::before {
  background:
    radial-gradient(circle at 82% 14%, rgba(255, 226, 122, 0.2), transparent 24%),
    radial-gradient(circle at 12% 88%, rgba(127, 232, 255, 0.2), transparent 34%),
    radial-gradient(circle at 52% 45%, rgba(15, 64, 86, 0.9), transparent 66%),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(205, 245, 255, 0.03) 80px),
    repeating-linear-gradient(0deg, transparent 0 79px, rgba(205, 245, 255, 0.025) 80px),
    linear-gradient(150deg, #0b2b3a 0%, #061822 55%, #02090d 100%);
}

.stage.theme-customs::after {
  content: "卫";
  color: rgba(127, 232, 255, 0.055);
}

.stage.theme-customs .logo-accent {
  color: #ffe27a;
}

/* 四字主题名用紧凑字标，避免在中等宽度下被拆成两行 */
.stage.theme-customs .logo {
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 0.1em;
  margin: clamp(10px, 1.2vw, 16px) 0 clamp(10px, 1.2vw, 14px);
  font-size: clamp(46px, 6.4vw, 104px);
  line-height: 1;
  letter-spacing: 0.01em;
}

.stage.theme-customs .logo > span {
  flex: none;
  white-space: nowrap;
}

.stage.theme-customs .logo-accent::after {
  height: 2px;
  bottom: 0;
}

.stage.theme-customs .eyebrow {
  color: rgba(174, 238, 255, 0.78);
}

.stage.theme-customs .btn.primary {
  color: #06222b;
  background: linear-gradient(135deg, #fff3a6 0%, #9cf0ff 52%, #55cbea 100%);
  box-shadow: 0 12px 40px rgba(85, 203, 234, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.stage.theme-customs .btn.primary:hover {
  box-shadow: 0 18px 54px rgba(85, 203, 234, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.stage.theme-customs .how-card {
  border-color: rgba(170, 235, 255, 0.2);
}

.theme-note {
  max-width: 34em;
  margin: 13px 0 0;
  padding-left: 10px;
  border-left: 2px solid rgba(255, 226, 122, 0.72);
  color: rgba(255, 238, 176, 0.78);
  font-size: 10.5px;
  line-height: 1.65;
  letter-spacing: 0.02em;
}

.goods-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  margin-bottom: 14px;
}

.goods-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 0 9px;
  border: 1px solid rgba(170, 235, 255, 0.18);
  border-radius: 999px;
  background: rgba(8, 33, 45, 0.5);
  color: rgba(230, 249, 255, 0.8);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.goods-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.goods-claw { background: #f0c97a; box-shadow: 0 0 0 2px rgba(210, 245, 255, 0.25); }
.goods-meat { background: #e37a78; box-shadow: 0 0 0 2px rgba(255, 214, 210, 0.18); }
.goods-sugar { background: #f3fbff; box-shadow: 0 0 0 2px rgba(127, 232, 255, 0.25); }

.theme-note[hidden],
.goods-legend[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .theme-note { font-size: 9.5px; margin-top: 9px; }
  .goods-legend { gap: 5px; margin-top: 8px; }
  .goods-chip { min-height: 22px; padding: 0 7px; font-size: 9px; }
}

/* 矮窗口下优先保住操作区和隐私提示，货品图例让位 */
@media (max-height: 560px) {
  .stage.theme-customs .goods-legend { display: none; }
  .stage.theme-customs .theme-note { margin-top: 6px; }
  .stage.theme-customs .tagline { margin-bottom: 10px; }
  .stage.theme-customs .start-actions { gap: 8px; }
  .stage.theme-customs .setup-row { margin-top: 8px; }
  .stage.theme-customs .privacy { margin-top: 8px; }
}

/* 延迟诊断：按 I 打开，只在本地显示，不上传 */
.diag-panel {
  position: absolute;
  right: 18px;
  bottom: 58px;
  z-index: 22;
  width: min(286px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(174, 255, 217, 0.2);
  border-radius: 14px;
  background: rgba(3, 14, 10, 0.82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
  color: rgba(236, 252, 244, 0.9);
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.5;
  pointer-events: none;
}

.diag-panel.hidden { display: none; }

.diag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(174, 255, 217, 0.13);
  color: #b9ffdc;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.diag-head kbd {
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid rgba(185, 255, 220, 0.24);
  border-radius: 5px;
  color: rgba(225, 255, 239, 0.65);
  font: inherit;
  font-size: 9px;
  text-align: center;
}

.diag-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 0;
}

.diag-row span { color: rgba(223, 246, 235, 0.52); }
.diag-row b { color: #ecfff5; font-variant-numeric: tabular-nums; font-weight: 600; }

.diag-hint {
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 1px solid rgba(174, 255, 217, 0.1);
  color: rgba(188, 228, 207, 0.5);
  font-size: 10px;
  line-height: 1.55;
}

.theme-customs .diag-panel {
  border-color: rgba(255, 219, 126, 0.22);
  background: rgba(22, 14, 4, 0.84);
}

.theme-customs .diag-head { color: #ffe6a0; border-bottom-color: rgba(255, 219, 126, 0.14); }
.theme-customs .diag-head kbd { border-color: rgba(255, 225, 150, 0.24); color: rgba(255, 241, 205, 0.65); }

@media (max-width: 760px) {
  .diag-panel { right: 10px; bottom: 54px; width: min(250px, calc(100vw - 20px)); font-size: 10px; }
}

/* ---------- 电视 / 大屏：把界面文字和控件一起放大 ---------- */
.stage { --ui: 1; }

@media (min-width: 1200px) and (min-height: 760px) {
  .stage { --ui: 1.28; }

  .start-copy { max-width: calc(650px * var(--ui)); }
  .eyebrow { font-size: calc(11px * var(--ui)); }
  .tagline {
    font-size: calc(19px * var(--ui));
    margin-bottom: calc(36px * var(--ui));
  }
  .theme-note { font-size: calc(10.5px * var(--ui)); }
  .goods-chip {
    min-height: calc(25px * var(--ui));
    padding: 0 calc(9px * var(--ui));
    gap: calc(6px * var(--ui));
    font-size: calc(10px * var(--ui));
  }
  .goods-dot { width: calc(8px * var(--ui)); height: calc(8px * var(--ui)); }

  .start-actions { gap: calc(12px * var(--ui)); }
  .btn {
    min-height: calc(56px * var(--ui));
    padding: 0 calc(30px * var(--ui));
    gap: calc(10px * var(--ui));
    font-size: calc(15px * var(--ui));
  }
  .cam-icon { width: calc(17px * var(--ui)); height: calc(12px * var(--ui)); }

  .setup-row {
    gap: calc(8px * var(--ui));
    margin-top: calc(12px * var(--ui));
    padding: calc(8px * var(--ui)) calc(10px * var(--ui));
    border-radius: calc(12px * var(--ui));
  }
  .setup-field { gap: calc(6px * var(--ui)); font-size: calc(11px * var(--ui)); }
  .setup-field select {
    min-height: calc(30px * var(--ui));
    max-width: calc(186px * var(--ui));
    padding: 0 calc(7px * var(--ui));
    font-size: calc(11px * var(--ui));
  }
  .mini-btn,
  .mini-link {
    min-height: calc(30px * var(--ui));
    padding: 0 calc(11px * var(--ui));
    font-size: calc(11px * var(--ui));
  }

  .privacy {
    gap: calc(7px * var(--ui));
    margin-top: calc(20px * var(--ui));
    font-size: calc(11px * var(--ui));
  }

  .how-card {
    width: min(100%, calc(360px * var(--ui)));
    padding: calc(32px * var(--ui));
    border-radius: calc(26px * var(--ui));
  }
  .how-kicker { margin-bottom: calc(18px * var(--ui)); font-size: calc(9px * var(--ui)); }
  .how-list { gap: calc(18px * var(--ui)); }
  .how-list li { grid-template-columns: calc(26px * var(--ui)) 1fr; gap: calc(10px * var(--ui)); }
  .how-list b { font-size: calc(9px * var(--ui)); }
  .how-list strong { font-size: calc(14px * var(--ui)); }
  .how-list span { font-size: calc(11.5px * var(--ui)); }
  .how-foot {
    margin-top: calc(26px * var(--ui));
    padding-top: calc(16px * var(--ui));
    font-size: calc(9px * var(--ui));
  }
  .key {
    min-width: calc(20px * var(--ui));
    margin: 0 calc(3px * var(--ui)) 0 calc(8px * var(--ui));
    padding: calc(2px * var(--ui)) calc(5px * var(--ui));
    font-size: calc(8px * var(--ui));
  }

  .hud {
    top: calc(30px * var(--ui));
    left: calc(40px * var(--ui));
    right: calc(40px * var(--ui));
    gap: calc(16px * var(--ui));
  }
  .hud-card {
    min-width: calc(128px * var(--ui));
    padding: calc(9px * var(--ui)) calc(20px * var(--ui)) calc(11px * var(--ui));
    border-radius: calc(16px * var(--ui));
  }
  .hud-label { margin-bottom: calc(4px * var(--ui)); font-size: calc(10px * var(--ui)); }
  .num { font-size: calc(42px * var(--ui)); }
  .hud-right { gap: calc(18px * var(--ui)); }
  .lives {
    height: calc(34px * var(--ui));
    padding: calc(8px * var(--ui)) calc(11px * var(--ui));
    gap: calc(5px * var(--ui));
  }
  .life { width: calc(18px * var(--ui)); height: calc(18px * var(--ui)); }
  .combo-pill {
    top: calc(16px * var(--ui));
    gap: calc(6px * var(--ui));
    padding: calc(8px * var(--ui)) calc(16px * var(--ui)) calc(9px * var(--ui));
  }
  .combo-pill span { font-size: calc(10px * var(--ui)); }
  .combo-pill b { font-size: calc(28px * var(--ui)); }
  .combo-pill i { font-size: calc(12px * var(--ui)); }

  .status-pill {
    bottom: calc(82px * var(--ui));
    gap: calc(8px * var(--ui));
    padding: calc(7px * var(--ui)) calc(14px * var(--ui));
    font-size: calc(11px * var(--ui));
  }
  .status-dot { width: calc(6px * var(--ui)); height: calc(6px * var(--ui)); }

  .top-actions {
    top: calc(28px * var(--ui));
    right: calc(40px * var(--ui));
    gap: calc(8px * var(--ui));
  }
  .top-action {
    min-height: calc(34px * var(--ui));
    padding: 0 calc(13px * var(--ui));
    gap: calc(6px * var(--ui));
    font-size: calc(11.5px * var(--ui));
  }
  .top-action svg { width: calc(14px * var(--ui)); height: calc(14px * var(--ui)); }

  .stage-foot {
    left: calc(34px * var(--ui));
    right: calc(34px * var(--ui));
    bottom: calc(24px * var(--ui));
  }
  .foot-left { gap: calc(8px * var(--ui)); }
  .foot-right { gap: calc(12px * var(--ui)); }
  .icon-btn { width: calc(34px * var(--ui)); height: calc(34px * var(--ui)); }
  .icon-btn svg { width: calc(17px * var(--ui)); height: calc(17px * var(--ui)); }
  .engine-label,
  .fps { font-size: calc(9px * var(--ui)); }
  .fps { min-width: calc(38px * var(--ui)); }

  .modal-card {
    width: min(100%, calc(470px * var(--ui)));
    padding: calc(46px * var(--ui));
    border-radius: calc(28px * var(--ui));
  }
  .modal-kicker { margin-bottom: calc(12px * var(--ui)); font-size: calc(9px * var(--ui)); }
  .modal-card h2 { margin-bottom: calc(10px * var(--ui)); font-size: calc(48px * var(--ui)); }
  .modal-card > p { margin-bottom: calc(28px * var(--ui)); font-size: calc(12.5px * var(--ui)); }
  .modal-actions { gap: calc(10px * var(--ui)); margin-top: calc(28px * var(--ui)); }
  .modal-actions .btn { min-height: calc(46px * var(--ui)); font-size: calc(13px * var(--ui)); }

  .final-score { gap: calc(20px * var(--ui)); margin: calc(20px * var(--ui)) 0 calc(22px * var(--ui)); padding-bottom: calc(20px * var(--ui)); }
  .final-score span { padding-bottom: calc(9px * var(--ui)); font-size: calc(10px * var(--ui)); }
  .final-score strong { font-size: calc(82px * var(--ui)); }
  .stats-row { gap: calc(10px * var(--ui)); }
  .stats-row div { padding: calc(12px * var(--ui)); border-radius: calc(12px * var(--ui)); }
  .stats-row span { margin-bottom: calc(6px * var(--ui)); font-size: calc(9px * var(--ui)); }
  .stats-row b { font-size: calc(22px * var(--ui)); }

  .history-card { width: min(100%, calc(620px * var(--ui))); max-height: 88vh; }
  .history-summary { gap: calc(28px * var(--ui)); margin: calc(18px * var(--ui)) 0 calc(4px * var(--ui)); padding: calc(12px * var(--ui)) 0 calc(16px * var(--ui)); }
  .history-summary span { font-size: calc(10px * var(--ui)); }
  .history-summary b { font-size: calc(26px * var(--ui)); }
  .history-row { gap: calc(11px * var(--ui)); padding: calc(10px * var(--ui)) calc(12px * var(--ui)); border-radius: calc(12px * var(--ui)); }
  .history-rank { font-size: calc(10px * var(--ui)); }
  .history-score { font-size: calc(20px * var(--ui)); }
  .history-tag { font-size: calc(9px * var(--ui)); }
  .history-sub { font-size: calc(10px * var(--ui)); }
  .history-badge { font-size: calc(9px * var(--ui)); }
  .history-empty { font-size: calc(12px * var(--ui)); }
  .history-confirm { gap: calc(12px * var(--ui)); margin-top: calc(16px * var(--ui)); padding: calc(13px * var(--ui)) calc(14px * var(--ui)); }
  .history-confirm-copy strong { font-size: calc(12px * var(--ui)); }
  .history-confirm-copy span { font-size: calc(10px * var(--ui)); }
  .history-confirm-actions { gap: calc(8px * var(--ui)); }
  .history-confirm-actions .btn { min-height: calc(36px * var(--ui)); padding: 0 calc(14px * var(--ui)); font-size: calc(11.5px * var(--ui)); }

  .toast {
    max-width: min(82%, calc(520px * var(--ui)));
    padding: calc(11px * var(--ui)) calc(18px * var(--ui));
    font-size: calc(12px * var(--ui));
  }
  .rotate-hint { font-size: calc(9px * var(--ui)); }
  .stage.theme-customs .logo { font-size: calc(104px * var(--ui)); }
}

@media (min-width: 1500px) and (min-height: 850px) { .stage { --ui: 1.5; } }
@media (min-width: 1750px) and (min-height: 980px) { .stage { --ui: 1.75; } }
@media (min-width: 2400px) and (min-height: 1350px) { .stage { --ui: 2.1; } }
@media (min-width: 3000px) and (min-height: 1700px) { .stage { --ui: 2.6; } }

@media (max-width: 760px) {
  .stage.camera-preview .camera {
    top: 84px;
    right: 10px;
    width: min(40%, 180px);
    border-radius: 10px;
  }
  .camera-preview-tag {
    top: 90px;
    right: 16px;
    font-size: 8px;
    padding: 3px 6px;
  }
}

/* ---------- 阳光白天主题 ---------- */
:root {
  --ink: #0b3436;
  --ink-2: #11494a;
  --cream: #103f3b;
  --mint: #159f83;
  --mint-deep: #0b7a63;
  --lime: #e3861b;
  --coral: #e6564d;
  --gold: #d88a18;
  --line: rgba(20, 95, 82, 0.18);
  --line-strong: rgba(20, 95, 82, 0.32);
  --muted: rgba(18, 70, 64, 0.62);
}

html,
body {
  background: #dff6f7;
  color: var(--cream);
}

body {
  background:
    radial-gradient(ellipse at 50% 18%, #fff8df 0%, #bcebf2 46%, #69bfd0 100%);
}

body.theme-customs {
  background:
    radial-gradient(ellipse at 50% 18%, #f2ffff 0%, #a7e5ef 48%, #4fa8bb 100%);
}

.stage,
.stage.theme-customs {
  --cream: #103f3b;
  --mint: #159f83;
  --mint-deep: #0b7a63;
  --lime: #e3861b;
  --coral: #e6564d;
  --gold: #d88a18;
  --line: rgba(20, 95, 82, 0.18);
  --line-strong: rgba(20, 95, 82, 0.32);
  --muted: rgba(18, 70, 64, 0.62);
  border-color: rgba(255, 255, 255, 0.72);
  background: #9adfe8;
  box-shadow:
    0 40px 100px rgba(35, 100, 115, 0.32),
    0 0 0 1px rgba(255, 255, 255, 0.4) inset,
    0 0 110px rgba(255, 221, 120, 0.2);
}

.stage::before {
  background:
    radial-gradient(circle at 82% 13%, rgba(255, 251, 201, 0.98) 0 3.2%, rgba(255, 231, 126, 0.48) 10%, transparent 25%),
    radial-gradient(ellipse at 18% 19%, rgba(255, 255, 255, 0.82) 0 7.5%, transparent 7.8%),
    radial-gradient(ellipse at 29% 16%, rgba(255, 255, 255, 0.62) 0 5.5%, transparent 5.8%),
    radial-gradient(ellipse at 50% 100%, rgba(67, 180, 113, 0.74), transparent 58%),
    repeating-linear-gradient(90deg, transparent 0 119px, rgba(255, 255, 255, 0.1) 120px),
    repeating-linear-gradient(0deg, transparent 0 119px, rgba(255, 255, 255, 0.08) 120px),
    linear-gradient(165deg, #dff8ff 0%, #95dff1 38%, #62cbae 100%);
}

.stage::after {
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.36);
}

.stage.theme-customs::before {
  background:
    radial-gradient(circle at 82% 13%, rgba(255, 246, 168, 0.98) 0 3.2%, rgba(255, 222, 103, 0.44) 11%, transparent 26%),
    radial-gradient(ellipse at 17% 20%, rgba(255, 255, 255, 0.78) 0 7%, transparent 7.4%),
    radial-gradient(ellipse at 50% 100%, rgba(25, 150, 170, 0.62), transparent 58%),
    linear-gradient(165deg, #e8fdff 0%, #99e2ee 38%, #52c6d7 100%);
}

.stage.theme-customs::after {
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.28);
}

/* 开始页 */
.start-screen {
  background:
    linear-gradient(90deg, rgba(255, 253, 243, 0.46) 0%, rgba(255, 253, 243, 0.16) 55%, transparent 100%),
    linear-gradient(0deg, rgba(20, 100, 96, 0.12) 0%, transparent 38%);
}

.start-copy {
  padding: clamp(14px, 1.6vw, 24px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: clamp(20px, 2vw, 30px);
  background: linear-gradient(145deg, rgba(255, 253, 244, 0.94), rgba(255, 248, 226, 0.82));
  box-shadow:
    0 24px 60px rgba(36, 100, 105, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

.eyebrow { color: #2c7b6c; }
.eyebrow-line { background: linear-gradient(90deg, transparent, #1ca887); }
.logo > span:first-child {
  color: #0d3e3b;
  text-shadow: 0 8px 30px rgba(255, 255, 255, 0.32);
}
.logo-accent,
.stage.theme-customs .logo-accent {
  color: transparent;
  background: linear-gradient(150deg, #ffcc33 0%, #ff9b36 52%, #f05a32 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 4px 14px rgba(235, 122, 34, 0.26));
}
.logo-accent::after { background: linear-gradient(90deg, transparent, #ffbd3e, transparent); }
.tagline { color: rgba(16, 61, 58, 0.76); }
.theme-note {
  color: #8b5a0b;
  border-left-color: #f0a21c;
}
.goods-chip {
  border-color: rgba(30, 110, 95, 0.2);
  background: rgba(255, 255, 255, 0.62);
  color: #24554d;
}
.privacy { color: rgba(22, 73, 67, 0.68); }

/* 按钮与选择 */
.btn.primary,
.stage.theme-customs .btn.primary {
  color: #4a2a08;
  background: linear-gradient(135deg, #ffe27a 0%, #ffc247 48%, #ff9c4a 100%);
  box-shadow: 0 12px 36px rgba(230, 140, 35, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}
.btn.primary:hover,
.stage.theme-customs .btn.primary:hover {
  box-shadow: 0 18px 48px rgba(230, 140, 35, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.btn.ghost {
  color: #1e5b52;
  border-color: rgba(20, 95, 82, 0.24);
  background: rgba(255, 255, 255, 0.56);
}
.btn.ghost:hover {
  color: #103f3b;
  border-color: rgba(20, 95, 82, 0.42);
  background: rgba(255, 255, 255, 0.82);
}

.setup-row {
  border-color: rgba(20, 95, 82, 0.18);
  background: rgba(255, 255, 255, 0.56);
}
.setup-field { color: #31675f; }
.setup-field select {
  border-color: rgba(20, 95, 82, 0.22);
  background: #fffdf6;
  color: #174b44;
}
.mini-btn,
.mini-link {
  border-color: rgba(20, 95, 82, 0.22);
  background: rgba(255, 255, 255, 0.64);
  color: #245a51;
}
.mini-btn:hover,
.mini-link:hover {
  border-color: rgba(20, 95, 82, 0.45);
  color: #103f3b;
}

/* 玩法卡 */
.how-card,
.stage.theme-customs .how-card {
  border-color: rgba(30, 110, 95, 0.18);
  background: linear-gradient(160deg, rgba(255, 253, 244, 0.94), rgba(255, 247, 224, 0.84));
  box-shadow:
    0 24px 60px rgba(30, 100, 110, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.how-card::before {
  background: linear-gradient(90deg, transparent, rgba(27, 160, 132, 0.62), transparent);
}
.how-kicker { color: #3c7a6d; }
.how-list b { color: #12856d; }
.how-list strong { color: #183f3b; }
.how-list span { color: rgba(18, 65, 58, 0.71); }
.how-foot {
  border-top-color: rgba(20, 95, 82, 0.12);
  color: rgba(22, 74, 67, 0.62);
}
.key {
  border-color: rgba(20, 95, 82, 0.18);
  color: rgba(20, 74, 67, 0.62);
}

/* 游戏 HUD */
.hud-card {
  border-color: rgba(23, 100, 88, 0.16);
  background: rgba(255, 253, 244, 0.88);
  box-shadow:
    0 12px 30px rgba(40, 110, 110, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}
.score-card::before {
  background: linear-gradient(90deg, transparent, #1caf8c, transparent);
}
.hud-label { color: rgba(18, 68, 60, 0.7); }
.num {
  color: #0f3f3a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.66);
}
.timer-card .num { color: #c9680d; }
.lives {
  border-color: rgba(23, 100, 88, 0.16);
  background: rgba(255, 253, 244, 0.82);
}
.life { color: #e6564d; }
.combo-pill {
  border-color: rgba(216, 138, 24, 0.4);
  background: rgba(255, 248, 214, 0.92);
  box-shadow: 0 0 28px rgba(255, 201, 82, 0.22);
  color: #a55f08;
}
.combo-pill span { color: rgba(126, 85, 13, 0.72); }
.combo-pill b { color: #83500a; }
.status-pill {
  border-color: rgba(23, 100, 88, 0.16);
  background: rgba(255, 253, 244, 0.84);
  color: rgba(18, 68, 60, 0.82);
}
.status-dot {
  background: #17a887;
  box-shadow: 0 0 10px rgba(23, 168, 135, 0.8);
}

/* 顶部、底部控制 */
.top-action {
  border-color: rgba(23, 100, 88, 0.2);
  background: rgba(255, 253, 244, 0.84);
  color: #235a50;
  box-shadow: 0 8px 24px rgba(40, 100, 105, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.top-action:hover {
  border-color: rgba(23, 120, 100, 0.5);
  background: rgba(255, 255, 255, 0.96);
  color: #0c6d5b;
}
.icon-btn {
  border-color: rgba(23, 100, 88, 0.18);
  background: rgba(255, 253, 244, 0.72);
  color: rgba(20, 70, 64, 0.7);
}
.icon-btn:hover {
  color: #103f3b;
  border-color: rgba(23, 100, 88, 0.38);
  background: rgba(255, 255, 255, 0.92);
}
.engine-label,
.fps { color: rgba(20, 70, 64, 0.66); }

/* 暂停 / 结算 / 历史 */
.modal-screen {
  background: rgba(12, 62, 68, 0.34);
}
.modal-card {
  border-color: rgba(255, 255, 255, 0.78);
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 213, 112, 0.2), transparent 42%),
    linear-gradient(155deg, rgba(255, 253, 244, 0.98), rgba(255, 247, 226, 0.95));
  box-shadow:
    0 40px 110px rgba(20, 70, 80, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  color: #103f3b;
}
.modal-kicker { color: #2b8a76; }
.modal-card h2 { color: #0e3b37; }
.modal-card > p { color: rgba(18, 68, 62, 0.7); }
.over-card {
  background:
    radial-gradient(circle at 82% 0%, rgba(255, 162, 106, 0.22), transparent 42%),
    linear-gradient(155deg, rgba(255, 252, 240, 0.98), rgba(255, 241, 220, 0.96));
}
.over-card .modal-kicker { color: #c25c2e; }
.final-score span { color: rgba(20, 70, 64, 0.62); }
.final-score strong { color: #d87314; text-shadow: 0 0 30px rgba(255, 170, 60, 0.18); }
.stats-row div {
  border-color: rgba(20, 95, 82, 0.12);
  background: rgba(255, 255, 255, 0.58);
}
.stats-row span { color: rgba(20, 70, 64, 0.64); }
.stats-row b { color: #153f3a; }

.history-summary { border-bottom-color: rgba(20, 95, 82, 0.12); }
.history-summary span { color: rgba(20, 70, 64, 0.64); }
.history-summary b { color: #12856d; }
.history-row {
  border-color: rgba(20, 95, 82, 0.12);
  background: rgba(255, 255, 255, 0.58);
}
.history-row.is-best {
  border-color: rgba(28, 160, 132, 0.35);
  background: linear-gradient(100deg, rgba(215, 249, 232, 0.8), rgba(255, 255, 255, 0.6));
}
.history-rank { color: rgba(20, 70, 64, 0.62); }
.history-score { color: #153f3a; }
.history-tag {
  border-color: rgba(20, 95, 82, 0.16);
  color: rgba(20, 70, 64, 0.66);
}
.history-sub { color: rgba(20, 70, 64, 0.6); }
.history-badge { border-color: rgba(20, 150, 120, 0.35); color: #12856d; }
.history-empty { border-color: rgba(20, 95, 82, 0.16); color: rgba(20, 70, 64, 0.6); }
.history-confirm {
  border-color: rgba(220, 95, 80, 0.35);
  background: linear-gradient(120deg, rgba(255, 232, 218, 0.92), rgba(255, 248, 238, 0.9));
}
.history-confirm-copy strong { color: #9e3f2f; }
.history-confirm-copy span { color: rgba(120, 60, 48, 0.6); }

.countdown span { color: #fffdf2; text-shadow: 0 0 70px rgba(255, 190, 70, 0.45); }
.rotate-hint { color: rgba(20, 70, 64, 0.68); }

/* 自定义主题的彩色文字 */
.stage.theme-customs .eyebrow { color: #267a73; }
.stage.theme-customs .logo > span:first-child { color: #0e3d3b; }

/* 1366 电视等矮屏：开始页收紧一点，避免卡片贴底 */
@media (min-width: 1300px) and (max-height: 800px) {
  .start-screen {
    padding-top: clamp(22px, 4vw, 48px);
    padding-bottom: clamp(24px, 3vh, 32px);
  }
  .start-copy { padding: 10px 16px; }
}
