* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0e14;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* 摄像头画面：完整显示、保持原始比例、镜像 */
#cam {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  transform: scaleX(-1);
  filter: brightness(0.9) saturate(1.05);
}

/* Three.js 叠加层 */
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.55);
  backdrop-filter: blur(8px);
  color: #e8eefc;
  font-size: 13px;
  letter-spacing: 0.4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chip-dim {
  color: #93a1bd;
}

/* 状态文字太长时截断，别把 FPS 胶囊挤出屏幕 */
#status {
  max-width: 58vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 分数 */
#scoreboard {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
  pointer-events: none;
}

#score {
  font-size: 44px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 18px rgba(90, 200, 250, 0.55);
  line-height: 1;
}

#lives {
  margin-top: 6px;
  font-size: 17px;
  letter-spacing: 2px;
  transition: color 0.2s;
}

#lives.pulse {
  animation: lifePulse 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

@keyframes lifePulse {
  0%   { transform: scale(1);    filter: none; }
  35%  { transform: scale(1.22); filter: drop-shadow(0 0 10px rgba(255, 90, 140, 0.95)); }
  100% { transform: scale(1);    filter: none; }
}

#hint {
  position: fixed;
  bottom: 54px;              /* 抬高一点，避开左下角诊断条 */
  left: 50%;
  transform: translateX(-50%);
  max-width: 76vw;
  text-align: center;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
  letter-spacing: 1px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 1s;
  opacity: 0;
}

/* 诊断信息条（左下角） */
#diag {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 10;
  max-width: 62vw;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(10, 14, 22, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b9ab7;
  font-size: 12px;
  letter-spacing: 0.3px;
  line-height: 1.6;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* 得分飘字 */
.pop {
  position: fixed;
  z-index: 20;
  font-weight: 800;
  font-size: 22px;
  pointer-events: none;
  animation: popUp 0.8s ease-out forwards;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

@keyframes popUp {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -14px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -56px) scale(1); }
}

/* ===== 开局启动确认 ===== */
#startScreen {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 42%, rgba(8, 12, 20, 0.5), rgba(5, 7, 12, 0.9));
  backdrop-filter: blur(3px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

#startScreen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.startCard {
  width: min(540px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px 32px 22px;
  border-radius: 22px;
  text-align: center;
  background: rgba(14, 19, 29, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.startKicker {
  color: #6ee7ff;
  font-size: 11px;
  letter-spacing: 5px;
  opacity: 0.75;
  margin-bottom: 10px;
}

.startCard h1 {
  color: #fff;
  font-size: 38px;
  letter-spacing: 6px;
  font-weight: 800;
  text-shadow: 0 4px 26px rgba(90, 200, 250, 0.4);
}

.startLead {
  margin-top: 10px;
  color: #a9b6d1;
  font-size: 14px;
  letter-spacing: 0.6px;
}

.startRules {
  list-style: none;
  margin: 18px auto 16px;
  max-width: 400px;
  text-align: left;
  color: #c8d3e8;
  font-size: 13.5px;
  line-height: 2.1;
}

.startRules b {
  color: #fff;
  font-weight: 600;
}

#startCamStatus {
  min-height: 34px;
  padding: 8px 16px;
  margin: 0 auto 16px;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: #ffd54f;
  background: rgba(255, 213, 79, 0.1);
  border: 1px solid rgba(255, 213, 79, 0.28);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

#startCamStatus.ok {
  color: #6ef7c4;
  background: rgba(110, 247, 196, 0.1);
  border-color: rgba(110, 247, 196, 0.3);
}

#startCamStatus.bad {
  color: #ff9a8a;
  background: rgba(255, 110, 90, 0.12);
  border-color: rgba(255, 110, 90, 0.32);
}

#modelRetry {
  display: none;
  margin: 0 auto 10px;
  padding: 9px 22px;
  font-size: 13px;
  letter-spacing: 1px;
  color: #ffd54f;
  background: rgba(255, 213, 79, 0.1);
  border: 1px solid rgba(255, 213, 79, 0.4);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

#modelRetry:hover {
  background: rgba(255, 213, 79, 0.2);
  transform: translateY(-1px);
}

#startBtn {
  display: block;
  width: 100%;
  margin: 4px 0 12px;
  padding: 16px 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #04121d;
  background: linear-gradient(135deg, #7ef0ff, #4f9dff);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(79, 157, 255, 0.38);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s;
  animation: btnPulse 2.2s ease-in-out infinite;
}

#startBtn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 44px rgba(79, 157, 255, 0.55);
  filter: brightness(1.06);
}

#startBtn:active {
  transform: scale(0.98);
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 10px 34px rgba(79, 157, 255, 0.38); }
  50%      { box-shadow: 0 10px 44px rgba(120, 220, 255, 0.62); }
}

.startNote {
  color: #7f8ca8;
  font-size: 12px;
  letter-spacing: 0.6px;
  line-height: 1.7;
}

/* 摄像头错误遮罩 */
#camError {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(6, 8, 13, 0.9);
  backdrop-filter: blur(8px);
  padding: 24px;
  text-align: center;
}

#camError.show {
  display: flex;
}

#camError h1 {
  color: #ffb74d;
  font-size: 28px;
  letter-spacing: 2px;
}

#camError p {
  color: #e8eefc;
  font-size: 15px;
}

#camErrorTips {
  list-style: none;
  color: #93a1bd;
  font-size: 13px;
  line-height: 2;
  max-width: 520px;
  text-align: left;
}

#camErrorTips b {
  color: #6ee7ff;
}

#retryCam {
  margin-top: 6px;
  padding: 12px 42px;
  font-size: 15px;
  letter-spacing: 3px;
  color: #06121f;
  background: linear-gradient(135deg, #ffd54f, #ff9f1c);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
}

#retryCam:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 30px rgba(255, 180, 60, 0.45);
}

#openLocal {
  padding: 12px 32px;
  font-size: 15px;
  letter-spacing: 1px;
  color: #06121f;
  background: linear-gradient(135deg, #6ee7ff, #4f9dff);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
}

#openLocal:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 30px rgba(90, 180, 255, 0.5);
}

/* 游戏结束遮罩 */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  background: rgba(6, 8, 13, 0.72);
  backdrop-filter: blur(6px);
}

#overlay.show {
  display: flex;
}

#overlay h1 {
  color: #fff;
  font-size: 42px;
  letter-spacing: 6px;
}

#overlay p {
  color: #aeb9d4;
  font-size: 16px;
}

#restart {
  margin-top: 8px;
  padding: 12px 42px;
  font-size: 16px;
  letter-spacing: 4px;
  color: #06121f;
  background: linear-gradient(135deg, #6ee7ff, #4f9dff);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
}

#restart:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 30px rgba(90, 180, 255, 0.5);
}

/* 被炸时的红闪 */
#flash {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: radial-gradient(circle, rgba(255, 60, 60, 0.35), rgba(255, 0, 0, 0.15));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

/* ===== 热身提示（开局 60 秒，独立贴右上角） ===== */
#warm {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  color: #ffd479;
  border-color: rgba(255, 212, 121, 0.35);
  background: rgba(48, 32, 6, 0.55);
  font-variant-numeric: tabular-nums;
}
#warm.show { display: inline-block; }

/* ===== 识别自查小窗（没检测到手时自动出现） ===== */
#mpPreview {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  width: 240px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(8, 12, 20, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#mpPreview.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
}
#mpCanvas {
  display: block;
  width: 100%;
  border-radius: 8px;
  transform: scaleX(-1);      /* 与镜像画面一致 */
  background: #000;
}
#mpPreviewLabel {
  margin-top: 5px;
  color: #9fb0cc;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.3px;
}

/* ===== 摄像头选择下拉框（多摄像头时可切换） ===== */
#camPick {
  min-width: 260px;
  max-width: 80vw;
  padding: 9px 12px;
  margin: 2px 0 2px;
  color: #e8eefc;
  font-size: 13px;
  font-family: inherit;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid rgba(110, 231, 255, 0.35);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
}
#camPick:focus {
  border-color: rgba(110, 231, 255, 0.75);
}

/* ===== 两指清屏技能状态（贴在热身胶囊下方） ===== */
#aoe {
  display: none;
  position: fixed;
  top: 52px;
  right: 16px;
  z-index: 10;
  color: #8fd8ff;
  border-color: rgba(143, 216, 255, 0.3);
  background: rgba(10, 26, 40, 0.55);
  font-variant-numeric: tabular-nums;
}
#aoe.show { display: inline-block; }
#aoe.ready {
  color: #b6ffd6;
  border-color: rgba(150, 255, 200, 0.45);
  background: rgba(10, 42, 28, 0.58);
  box-shadow: 0 0 14px rgba(110, 255, 190, 0.25);
}
