* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #06080d;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: #e8f6ff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* 捏脸拖拽不能触发页面滚动/缩放 */
}

/* ---- 摄像头底层（镜像 + cover） ---- */
#cam {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  background: #06080d;
}

/* Pixi 画布由 JS 注入，叠在 video 上 */
canvas.stage {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---- 时停暗角 ---- */
#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0) 45%,
    rgba(4, 10, 24, 0.55) 100%);
}
#vignette.on { opacity: 1; }

/* ---- 抓取白闪 ---- */
#flash {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 7;
  background: #cfeaff;
  opacity: 0;
}
#flash.go { animation: flash-anim 0.28s ease-out; }
@keyframes flash-anim {
  0% { opacity: 0.75; }
  100% { opacity: 0; }
}

/* ---- 悬停进度环 ---- */
#ring {
  position: fixed;
  width: 64px; height: 64px;
  margin: -32px 0 0 -32px;
  left: 0; top: 0;
  pointer-events: none;
  z-index: 8;
  display: none;
}
#ring.show { display: block; }
#ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#ring .ring-bg {
  fill: none; stroke: rgba(125, 249, 255, 0.18); stroke-width: 4;
}
#ring .ring-fg {
  fill: none; stroke: #7df9ff; stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 163.4; /* 2πr, r=26 */
  stroke-dashoffset: 163.4;
  filter: drop-shadow(0 0 6px rgba(125, 249, 255, 0.9));
}

/* ---- 状态文字 ---- */
#status {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(8, 16, 30, 0.62);
  border: 1px solid rgba(125, 249, 255, 0.28);
  backdrop-filter: blur(8px);
  font-size: 15px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(125, 249, 255, 0.5);
  transition: opacity 0.25s;
}
#status:empty { opacity: 0; }

/* ---- toast 提示 ---- */
#toast {
  position: fixed;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  padding: 10px 20px;
  border-radius: 10px;
  background: rgba(40, 14, 14, 0.75);
  border: 1px solid rgba(255, 120, 120, 0.4);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ---- 鼠标调试角标 ---- */
#badge-mouse {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 9;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(8, 16, 30, 0.7);
  border: 1px solid rgba(255, 210, 90, 0.5);
  color: #ffd25a;
  font-size: 12px;
  display: none;
}
#badge-mouse.show { display: block; }

/* ---- 切换摄像头按钮 ---- */
#btn-cam {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 9;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(125, 249, 255, 0.35);
  background: rgba(8, 16, 30, 0.7);
  color: #7df9ff;
  font-size: 20px;
  cursor: pointer;
  display: none;
  backdrop-filter: blur(8px);
  transition: transform 0.15s;
}
#btn-cam:hover { transform: rotate(40deg); }
#btn-cam.show { display: block; }

/* ---- 录制按钮 ---- */
#btn-rec {
  position: fixed;
  right: 76px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 9;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 110, 110, 0.45);
  background: rgba(8, 16, 30, 0.7);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
#btn-rec.show { display: flex; }
#btn-rec .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ff5e5e;
  transition: border-radius 0.2s;
}
#btn-rec.recording .dot {
  border-radius: 3px;
  animation: rec-pulse 1.2s infinite;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---- debug HUD ---- */
#debug-hud {
  position: fixed;
  left: 16px;
  top: max(16px, env(safe-area-inset-top));
  z-index: 9;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #9fe8a0;
  font: 11px/1.5 Menlo, Consolas, monospace;
  white-space: pre;
  pointer-events: none;
}

/* ---- 开始界面 ---- */
#start-overlay {
  position: fixed; inset: 0;
  z-index: 20;
  display: flex;
  /* 卡片多过一屏时可滚动：靠 .panel 的 margin:auto 居中，align/justify 居中会裁掉溢出部分 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: max(24px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 30% 20%, rgba(40, 90, 140, 0.25), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(90, 40, 140, 0.2), transparent 60%),
    #06080d;
  transition: opacity 0.5s ease;
}
#start-overlay.hide { opacity: 0; pointer-events: none; }

#start-overlay .panel {
  max-width: 520px;
  width: calc(100% - 48px);
  margin: auto;
  padding: 32px 36px;
  border-radius: 20px;
  background: rgba(10, 18, 34, 0.8);
  border: 1px solid rgba(125, 249, 255, 0.22);
  box-shadow: 0 0 80px rgba(60, 140, 220, 0.18);
  text-align: center;
}
#start-overlay h1 {
  font-size: 40px;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  background: linear-gradient(120deg, #7df9ff, #b48dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#start-overlay .en {
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.55em;
  color: rgba(160, 210, 255, 0.55);
}
#start-overlay .desc {
  margin: 22px 0 18px;
  font-size: 15px;
  line-height: 1.8;
  color: #bcd8ec;
}
#start-overlay .steps {
  text-align: left;
  margin: 0 auto 26px;
  max-width: 380px;
  font-size: 13px;
  line-height: 2;
  color: #8fb4cc;
  padding-left: 22px;
}
/* ---- 模式选择卡片 ---- */
.modes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0 6px;
}
.mode-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(20, 36, 60, 0.55);
  border: 1px solid rgba(125, 249, 255, 0.18);
  color: #e8f6ff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.mode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(125, 249, 255, 0.55);
  background: rgba(26, 48, 78, 0.7);
  box-shadow: 0 6px 30px rgba(90, 176, 255, 0.25);
}
.mode-card.disabled { opacity: 0.45; pointer-events: none; }
.mc-emoji { font-size: 34px; flex: 0 0 auto; }
.mc-body { display: block; }
.mc-body b {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  letter-spacing: 0.06em;
}
.mc-body small {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.7;
  color: #8fb4cc;
}
.badge {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 999px;
  color: #06121e;
  background: linear-gradient(120deg, #7df9ff, #5ab0ff);
}
.badge.exp { background: rgba(180, 141, 255, 0.85); }
#load-msg {
  margin-top: 16px;
  min-height: 20px;
  font-size: 13px;
  color: #6f95ad;
}
#load-msg.err { color: #ff8d8d; }

/* ---------- 穿越传送门：素材选择 ---------- */
#portal-picker {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 64px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 30;
}
#portal-picker.hide { display: none; }
#portal-picker button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(12, 16, 28, 0.62);
  color: #eef3ff;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}
#portal-picker button.on {
  border-color: rgba(122, 220, 255, 0.85);
  box-shadow: 0 0 12px rgba(122, 220, 255, 0.35);
}
