/* ===========================================================
   手势粒子圣诞树 · 界面样式
   深墨绿 / 香槟金 / 电影感 HUD
   =========================================================== */
:root {
  --gold: #e9c987;
  --gold-dim: #a08452;
  --ink: #04070a;
  --panel: rgba(8, 14, 17, 0.55);
  --line: rgba(233, 201, 135, 0.16);
  --white-70: rgba(255, 255, 255, 0.7);
  --white-40: rgba(255, 255, 255, 0.4);
  --serif: "Bodoni 72", "Didot", Georgia, "Songti SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 30%, #0d2a20 0%, #06100f 40%, #02050a 72%, #000 100%);
  color: #f2efe8;
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------------- 通用控件 ---------------- */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 13px 26px;
  transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.995); }

.btn.primary {
  background: linear-gradient(135deg, #f2d9a4, #cfa55c 45%, #a67f3d);
  color: #1a1206;
  font-weight: 600;
  box-shadow: 0 10px 34px -12px rgba(233, 201, 135, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.btn.primary:hover { box-shadow: 0 14px 40px -10px rgba(233, 201, 135, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.7); }
.btn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2b1b06;
  box-shadow: 0 0 0 3px rgba(43, 27, 6, 0.18);
}
.btn.ghost {
  background: transparent;
  color: var(--gold-dim);
  border: 1px solid rgba(233, 201, 135, 0.28);
}
.btn.ghost:hover { color: var(--gold); border-color: rgba(233, 201, 135, 0.55); }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; }
.is-hidden { opacity: 0; pointer-events: none; }

/* ---------------- 启动层 ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(6, 16, 12, 0.35), rgba(0, 0, 0, 0.86) 70%);
  transition: opacity 0.8s ease, visibility 0.8s;
}
.overlay.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.boot-card { max-width: 560px; text-align: center; }

.eyebrow {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--gold-dim);
  text-transform: uppercase;
}

.boot-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(46px, 8vw, 84px);
  letter-spacing: 0.06em;
  line-height: 1.02;
  color: #f7efdd;
  text-shadow: 0 0 60px rgba(233, 201, 135, 0.28);
}
.boot-card h1 span {
  background: linear-gradient(180deg, #fff3d2, #d9ac62);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  margin: 22px 0 34px;
  font-size: 15px;
  line-height: 1.9;
  color: var(--white-70);
}

.boot-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.privacy {
  margin: 28px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.32);
}

/* ---------------- HUD ---------------- */
.hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.6s ease;
  opacity: 1;
}
.hud.is-hidden { opacity: 0; }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 30px;
}

.brand {
  opacity: 0.62;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.34em;
  color: rgba(233, 201, 135, 0.78);
}
.brand-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px 2px rgba(233, 201, 135, 0.7);
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.12); }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--white-70);
  transition: color 0.3s, border-color 0.3s;
}
.pill-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #5a6a6e;
  transition: background 0.3s, box-shadow 0.3s;
}
.pill[data-state="tracking"] { color: #e6f7ee; border-color: rgba(120, 235, 175, 0.4); }
.pill[data-state="tracking"] .pill-dot {
  background: #6ff0b3;
  box-shadow: 0 0 12px 2px rgba(111, 240, 179, 0.8);
}
.pill[data-state="active"] { color: #ffe9bd; border-color: rgba(233, 201, 135, 0.5); }
.pill[data-state="active"] .pill-dot {
  background: var(--gold);
  box-shadow: 0 0 12px 2px rgba(233, 201, 135, 0.9);
}

/* ---------------- 主标题 ---------------- */
.masthead {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  user-select: none;
}
.masthead h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(20px, 2.2vw, 32px);
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: #f6e6c4;
  text-shadow:
    0 0 26px rgba(233, 201, 135, 0.55),
    0 0 60px rgba(233, 201, 135, 0.22);
}
.masthead i {
  display: block;
  width: 78px;
  height: 1px;
  margin: 12px auto 0;
  background: linear-gradient(90deg, transparent, rgba(233, 201, 135, 0.7), transparent);
}

@media (max-width: 1180px) {
  .masthead { display: none; }
}

/* ---------------- 摄像头面板 ---------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
}

.cam-panel {
  position: absolute;
  left: 30px;
  bottom: 84px;
  width: 248px;
  overflow: hidden;
  transition: opacity 0.4s;
}

.cam-wrap { position: relative; aspect-ratio: 4 / 3; background: #000; }
.cam-wrap video,
.cam-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cam-wrap video { transform: scaleX(-1); filter: saturate(0.85) contrast(1.05) brightness(0.9); }
.cam-wrap canvas { pointer-events: none; }

.cam-badge {
  position: absolute;
  top: 8px; left: 8px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  padding: 3px 7px;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.45);
}

.cam-panel[data-mode="demo"] .cam-wrap::after {
  content: "MOUSE DEMO";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.34em;
  color: rgba(233, 201, 135, 0.42);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 9px),
    radial-gradient(circle at 50% 50%, rgba(20, 40, 34, 0.9), #05090c 70%);
}

.cam-meta { padding: 10px 12px 12px; }
.cam-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 8px;
}
.cam-row .mono { color: rgba(255, 255, 255, 0.35); }
.meter {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, #6ff0b3, #e9c987);
  transition: width 0.18s ease;
}

/* ---------------- 手势指南 ---------------- */
.legend {
  position: absolute;
  right: 30px;
  bottom: 84px;
  width: 268px;
  padding: 18px 20px 16px;
  transition: opacity 0.4s;
}
.legend h2 {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--gold);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.legend h2 .mono { color: rgba(255, 255, 255, 0.22); font-size: 9px; letter-spacing: 0.24em; }
.legend ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.legend li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}
.legend li b { font-weight: 500; color: rgba(255, 255, 255, 0.9); white-space: nowrap; }
.legend-foot {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.3);
}

/* ---------------- 底栏 ---------------- */
.bottombar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 30px 22px;
}
.tips {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.02em;
}
.tools { display: flex; gap: 8px; pointer-events: auto; }
.chip {
  appearance: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.25s ease;
  font-family: var(--sans);
}
.chip:hover { color: var(--gold); border-color: rgba(233, 201, 135, 0.45); background: rgba(233, 201, 135, 0.07); }
.chip.on { color: #150e03; background: linear-gradient(135deg, #f0d39b, #c9a15b); border-color: transparent; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  top: 76px;
  transform: translate(-50%, -12px);
  z-index: 60;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(8, 14, 17, 0.82);
  border: 1px solid rgba(233, 201, 135, 0.35);
  color: #ffe9bd;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .legend { display: none; }
  .cam-panel { width: 176px; bottom: 74px; left: 16px; }
  .topbar { padding: 16px 18px; }
  .brand-text { font-size: 9px; letter-spacing: 0.24em; }
  .bottombar { padding: 14px 18px 18px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .tips { display: none; }
  .tools { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .boot-card h1 { font-size: clamp(40px, 12vw, 60px); }
  .lede { font-size: 13.5px; }
}

/* ===========================================================
   手机适配（放在最后，覆盖上面的桌面/平板规则）
   =========================================================== */
@media (max-width: 600px) {
  .topbar {
    padding: calc(12px + env(safe-area-inset-top)) 14px 8px;
  }
  .brand { font-size: 8.5px; letter-spacing: 0.2em; gap: 7px; }
  .brand-dot { width: 5px; height: 5px; }
  .pill { padding: 6px 12px; font-size: 11px; }
  .pill-dot { width: 6px; height: 6px; }

  /* 摄像头预览缩成一枚圆形小窗，别挡住树 */
  .cam-panel {
    top: calc(56px + env(safe-area-inset-top));
    left: 14px;
    bottom: auto;
    width: 88px;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: visible;
  }
  .cam-wrap {
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid rgba(233, 201, 135, 0.42);
    box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.95), 0 0 24px -8px rgba(233, 201, 135, 0.25);
  }
  .cam-wrap::after,
  .cam-panel[data-mode="demo"] .cam-wrap::after { display: none; }
  .cam-badge { display: none; }
  .cam-meta { padding: 7px 0 0; }
  .cam-row { justify-content: center; font-size: 9.5px; margin-bottom: 0; }
  .cam-row .mono { display: none; }
  .meter { display: none; }

  .bottombar {
    padding: 8px 14px calc(12px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .tips { display: none; }
  .tools { width: 100%; gap: 7px; flex-wrap: wrap; }
  .chip { padding: 9px 13px; font-size: 11px; }

  .overlay { padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
  .boot-card h1 { font-size: clamp(38px, 13vw, 54px); }
  .lede { font-size: 13px; margin: 18px 0 26px; }
  .btn { padding: 12px 22px; font-size: 13px; }
  .privacy { font-size: 10.5px; margin-top: 22px; }

  .toast { top: calc(64px + env(safe-area-inset-top)); font-size: 11.5px; padding: 8px 16px; }
}

/* 横屏手机：高度很矮，所有 HUD 再收一档 */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { padding: 10px 16px; }
  .bottombar {
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    flex-direction: row;
    align-items: center;
  }
  .tips { display: none; }
  .masthead { display: none; }
  .legend { display: none; }
  .cam-panel {
    top: auto;
    bottom: calc(56px + env(safe-area-inset-bottom));
    left: 16px;
    width: 92px;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .cam-wrap {
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid rgba(233, 201, 135, 0.42);
  }
  .cam-wrap::after,
  .cam-panel[data-mode="demo"] .cam-wrap::after { display: none; }
  .cam-badge { display: none; }
  .cam-meta { padding: 6px 0 0; }
  .cam-row { justify-content: center; font-size: 9px; margin-bottom: 0; }
  .cam-row .mono { display: none; }
  .meter { display: none; }
  .chip { padding: 7px 12px; font-size: 10.5px; }
}


/* ---------------- 无摄像头时的手势按钮条 ---------------- */
.gesture-bar {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 7px;
  border-radius: 999px;
  background: rgba(8, 14, 17, 0.62);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 50px -26px rgba(0, 0, 0, 0.9);
  pointer-events: auto;
  z-index: 30;
}
.gesture-bar[hidden] { display: none; }

.gbtn {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.gbtn b { font-size: 15px; line-height: 1; }
.gbtn:hover {
  color: var(--gold);
  border-color: rgba(233, 201, 135, 0.45);
  background: rgba(233, 201, 135, 0.08);
}
.gbtn:active { transform: scale(0.96); }
.gbtn.on {
  color: #171004;
  background: linear-gradient(135deg, #f2d9a4, #cfa55c);
  border-color: transparent;
  box-shadow: 0 6px 20px -8px rgba(233, 201, 135, 0.8);
}

@media (max-width: 600px) {
  .gesture-bar {
    left: 12px;
    right: 12px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    transform: none;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 18px;
    padding: 8px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .gesture-bar::-webkit-scrollbar { display: none; }
  .gbtn {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 3px;
    padding: 8px 12px;
    min-width: 58px;
    border-radius: 13px;
    font-size: 10px;
  }
  .gbtn b { font-size: 17px; }
}

.btn[disabled] {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}

/* 演示模式下，圆形预览本身就是一个"开启摄像头"按钮 */
.cam-retry {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(233, 201, 135, 0.9);
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.06em;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.2s ease, color 0.2s ease;
}
.cam-retry-icon { font-size: 20px; line-height: 1; }
.cam-panel[data-mode="demo"] .cam-retry { display: flex; }
.cam-retry:hover, .cam-retry:active { background: rgba(233, 201, 135, 0.18); color: #ffe9bd; }

/* 摄像头被拦截时的说明面板 */
.cam-help {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 14, 17, 0.62);
  text-align: left;
  font-size: 12px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.58);
}
.cam-help[hidden] { display: none; }
.cam-help-title { margin: 0 0 8px; color: var(--gold); font-size: 12.5px; letter-spacing: 0.06em; }
.cam-help ul { margin: 0 0 12px; padding-left: 16px; }
.cam-help b { color: rgba(255, 255, 255, 0.9); font-weight: 500; }
.cam-help .btn { margin-top: 2px; }
