*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

:root {
  --bg-void: #050606;
  --crt-green: rgba(118, 224, 152, 0.72);
  --crimson: rgba(168, 18, 22, 0.88);
  --brass: #8c7a4b;
  --ink: #c8cbc2;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* 桌面宽屏暗调实体画框背景（将留白化为隧道视野） */
.desk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 48%, rgba(28, 36, 30, 0.32) 0%, rgba(7, 9, 8, 0.94) 55%, #020303 100%);
  pointer-events: none;
}

.desk-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 180px rgba(0, 0, 0, 0.95);
}

.desk-grain {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background-image: repeating-radial-gradient(circle at 17% 32%, rgba(255,255,255,0.14) 0, rgba(0,0,0,0) 2px);
  background-size: 4px 4px;
}

.desk-etch {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: clamp(14px, 1.5vw, 22px);
  letter-spacing: 0.45em;
  color: rgba(130, 140, 128, 0.12);
  writing-mode: vertical-rl;
  pointer-events: none;
  transition: color 0.6s ease, opacity 0.6s ease;
}

.desk-etch-left { left: 4vw; }
.desk-etch-right { right: 4vw; }
.desk-etch.hostile { color: rgba(165, 24, 28, 0.36); }

/* 低存在感静音按钮 */
.mute-btn {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(12, 14, 13, 0.68);
  border: 1px solid rgba(140, 145, 132, 0.22);
  color: rgba(190, 196, 184, 0.65);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: opacity 0.25s ease, border-color 0.25s ease;
}

.mute-btn:hover {
  border-color: rgba(190, 196, 184, 0.5);
  color: rgba(220, 224, 214, 0.92);
}

.mute-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6f9e79;
  box-shadow: 0 0 6px rgba(111, 158, 121, 0.6);
}

.mute-btn.muted .mute-dot {
  background: #555;
  box-shadow: none;
}

/* 9:16 竖屏实体画框 */
.frame-shell {
  position: relative;
  z-index: 2;
  height: min(94vh, 920px);
  aspect-ratio: 9 / 16;
  max-width: 96vw;
  padding: 7px;
  background: linear-gradient(160deg, #1a1c1a 0%, #0b0c0b 52%, #151412 100%);
  border: 1px solid rgba(110, 114, 102, 0.22);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.95),
    0 0 0 1px rgba(0, 0, 0, 0.9),
    inset 0 0 18px rgba(0, 0, 0, 0.85);
}

.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

/* 稳镜头微震红线：<= 6px, < 180ms（防 3D 眩晕） */
.viewport.shake-sm {
  animation: microShakeSm 110ms linear 1;
}
.viewport.shake-md {
  animation: microShakeMd 150ms linear 1;
}
.viewport.shake-lg {
  animation: microShakeLg 160ms linear 1;
}

@keyframes microShakeSm {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, 1px); }
  100% { transform: translate(0, 0); }
}

@keyframes microShakeMd {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 3px); }
  45% { transform: translate(5px, -4px); }
  70% { transform: translate(-4px, -2px); }
  88% { transform: translate(3px, 2px); }
  100% { transform: translate(0, 0); }
}

@keyframes microShakeLg {
  0% { transform: translate(0, 0); }
  18% { transform: translate(-6px, 4px); }
  38% { transform: translate(6px, -5px); }
  58% { transform: translate(-5px, -3px); }
  78% { transform: translate(4px, 4px); }
  100% { transform: translate(0, 0); }
}

/* 场景基础层 */
.scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
  background: #000;
}

.scene.active {
  opacity: 1;
  pointer-events: auto;
}

.scene.instant {
  transition: none !important;
}

.scene-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scene-img-overlay {
  opacity: 0;
  pointer-events: none;
}

/* 胶片暗角与噪点 */
.film-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, rgba(0,0,0,0) 46%, rgba(0,0,0,0.62) 100%);
}

.screen-flash {
  position: absolute;
  inset: 0;
  z-index: 28;
  pointer-events: none;
  opacity: 0;
  background: #d8e8dc;
}

/* ==================== 正面防盗门（Scene 1） ==================== */
.peephole-leak {
  position: absolute;
  left: 50.2%;
  top: 34.8%;
  width: 16%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(208, 232, 214, 0.34) 0%, rgba(154, 198, 168, 0.1) 46%, rgba(0,0,0,0) 74%);
  animation: peepFlicker 3.6s infinite;
}

.peephole-leak.fog-urgent {
  width: 24%;
  background: radial-gradient(circle, rgba(226, 245, 232, 0.56) 0%, rgba(162, 212, 180, 0.18) 52%, rgba(0,0,0,0) 76%);
  animation: peepUrgent 1.3s infinite;
}

.peephole-leak.dead {
  opacity: 0 !important;
  animation: none;
}

@keyframes peepFlicker {
  0%, 100% { opacity: 0.45; }
  38% { opacity: 0.72; }
  41% { opacity: 0.12; }
  44% { opacity: 0.85; }
  76% { opacity: 0.32; }
  79% { opacity: 0.65; }
}

@keyframes peepUrgent {
  0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.96); }
  48% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  53% { opacity: 0.25; }
}

/* 门框极短敌意刻痕（零保姆） */
.door-scratch {
  position: absolute;
  left: 50%;
  top: 26.8%;
  transform: translateX(-50%) rotate(-3deg);
  font-size: 13px;
  letter-spacing: 0.35em;
  color: rgba(190, 196, 176, 0.34);
  text-shadow: 0 1px 3px rgba(0,0,0,0.95);
  pointer-events: none;
  transition: color 0.4s ease;
}

.door-scratch.mutate {
  color: rgba(196, 38, 42, 0.72);
  animation: hostileTwitch 2.2s infinite;
}

@keyframes hostileTwitch {
  0%, 88%, 100% { transform: translateX(-50%) rotate(-3deg); }
  90% { transform: translate(-48%, -1px) rotate(-1deg); }
  94% { transform: translate(-52%, 1px) rotate(-4deg); }
}

/* 投信口异变渗暗红呼吸光（仅 B02 诱饵激活时显现） */
.mailslot-bleed {
  position: absolute;
  left: 50%;
  top: 61.5%;
  width: 24%;
  height: 5.5%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  border-radius: 3px;
  background: radial-gradient(ellipse at center, rgba(160, 24, 24, 0.62) 0%, rgba(120, 14, 16, 0.22) 55%, rgba(0,0,0,0) 80%);
  transition: opacity 0.4s ease;
}

.mailslot-bleed.bait {
  opacity: 1;
  animation: slotTwitch 1.4s infinite;
}

@keyframes slotTwitch {
  0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scaleX(0.96); }
  45% { opacity: 0.98; transform: translate(-50%, -48%) scaleX(1.06); }
  52% { opacity: 0.3; transform: translate(-49%, -52%) scaleX(0.98); }
}

/* 真实物件本体隐形可点击热区 */
.hotspot {
  position: absolute;
  background: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  z-index: 6;
}

.hotspot-peephole {
  left: 38%;
  top: 28%;
  width: 24%;
  height: 14%;
  border-radius: 50%;
}

.hotspot-peephole.bait-ring::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  border: 1px solid rgba(206, 224, 198, 0.26);
  animation: ringPulse 2.4s infinite;
}

.hotspot-chain {
  left: 58%;
  top: 40%;
  width: 26%;
  height: 15%;
}

.hotspot-mailslot {
  left: 36%;
  top: 56%;
  width: 28%;
  height: 12%;
}

.hotspot-mailslot.bait-ring::after {
  content: "";
  position: absolute;
  inset: 24% 12%;
  border: 1px solid rgba(188, 42, 42, 0.48);
  animation: ringPulse 1.5s infinite;
}

.hotspot.disabled {
  pointer-events: none;
}

@keyframes ringPulse {
  0%, 100% { opacity: 0.18; transform: scale(0.96); }
  50% { opacity: 0.72; transform: scale(1.06); }
}

/* ==================== 背后旧镜与对讲机（Scene 2） ==================== */
.rear-crt-glow {
  position: absolute;
  left: 68.5%;
  top: 61.5%;
  width: 26%;
  height: 18%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(114, 232, 152, 0.38) 0%, rgba(80, 190, 120, 0.12) 48%, rgba(0,0,0,0) 76%);
}

.rear-crt-glow.active {
  opacity: 1;
  animation: crtPulse 0.9s infinite;
}

@keyframes crtPulse {
  0%, 100% { opacity: 0.72; }
  45% { opacity: 1; }
  50% { opacity: 0.35; }
}

.rear-mirror-whisper {
  position: absolute;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  letter-spacing: 0.45em;
  color: rgba(196, 26, 30, 0.92);
  text-shadow: 0 0 12px rgba(180, 16, 20, 0.75);
  opacity: 0;
  pointer-events: none;
  z-index: 8;
}

.rear-mirror-whisper.flash {
  opacity: 1;
}

.hotspot-intercom {
  left: 56%;
  top: 56%;
  width: 26%;
  height: 15%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 6px;
}

.intercom-led {
  position: absolute;
  right: 17%;
  bottom: 34%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(190, 26, 28, 0.95);
  box-shadow: 0 0 10px rgba(220, 32, 34, 0.95);
  opacity: 0;
}

.hotspot-intercom.ringing .intercom-led {
  opacity: 1;
  animation: ledBlink 0.55s infinite;
}

@keyframes ledBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

.intercom-tag {
  font-size: 11px;
  letter-spacing: 0.25em;
  padding: 2px 7px;
  background: rgba(10, 14, 11, 0.78);
  border: 1px solid rgba(154, 42, 42, 0.65);
  color: rgba(214, 184, 178, 0.9);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.hotspot-intercom.ringing .intercom-tag {
  opacity: 1;
  animation: hostileTwitch 1.6s infinite;
}

/* ==================== B01 猫眼频闪近景（Scene 3） ==================== */
.peephole-zoom-stage {
  position: absolute;
  inset: 0;
  transform-origin: 50% 46%;
  transform: scale(1);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.peephole-zoom-stage.closer {
  transform: scale(1.07);
}

.strobe-blackout {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}

.edge-back {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 7px 18px;
  background: rgba(6, 8, 7, 0.72);
  border: 1px solid rgba(154, 162, 146, 0.26);
  color: rgba(196, 202, 188, 0.72);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.3em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.edge-back.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== B02 投信口猎奇特写（Scene 4） ==================== */
.mailslot-zoom-stage {
  position: absolute;
  inset: 0;
  transform-origin: 54% 48%;
  transform: scale(1);
  transition: transform 180ms ease-out;
}

.mailslot-stain-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background:
    radial-gradient(ellipse at 52% 48%, rgba(0,0,0,0) 32%, rgba(92, 6, 10, 0.52) 78%, rgba(28, 2, 4, 0.88) 100%);
  transition: opacity 240ms ease;
}

.hotspot-mailslot-close {
  left: 16%;
  top: 30%;
  width: 68%;
  height: 44%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 12px;
}

.hostile-stamp {
  padding: 6px 18px;
  background: rgba(12, 10, 10, 0.78);
  border: 1px solid rgba(176, 46, 42, 0.56);
  color: rgba(214, 198, 190, 0.88);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.35em;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.85);
}

.hostile-stamp.shaking {
  border-color: rgba(212, 32, 36, 0.88);
  color: #e2b8b4;
  animation: stampJitter 0.24s infinite;
}

@keyframes stampJitter {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1.5px, 1px); }
  50% { transform: translate(1.5px, -1px); }
  75% { transform: translate(-1px, -1px); }
  100% { transform: translate(0, 0); }
}

/* ==================== B03 起雾猫眼擦拭 + L5 重击（Scene 5） ==================== */
.wipe-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.wipe-under-hall {
  filter: blur(2px) brightness(0.66) contrast(1.08);
}

.wipe-under-shadow {
  opacity: 0.42;
  filter: blur(5px) brightness(0.5);
  animation: fogSway 3.4s ease-in-out infinite;
}

@keyframes fogSway {
  0%, 100% { transform: translateX(-2.5%) scale(1.06); }
  50% { transform: translateX(2.5%) scale(1.09); }
}

.fog-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  touch-action: none;
  cursor: crosshair;
}

.jumpscare-img {
  z-index: 9;
  transform-origin: 48% 48%;
  transform: scale(0.76);
  opacity: 0;
}

.jumpscare-img.slam {
  opacity: 1;
  animation: l5Slam 95ms cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
}

.jumpscare-img.stare {
  opacity: 1;
  transform: scale(1.02);
  animation: deadStareTwitch 180ms steps(2) infinite;
}

@keyframes l5Slam {
  0% { transform: scale(0.76); filter: brightness(1.55) contrast(1.3); }
  75% { transform: scale(1.08); filter: brightness(1.18) contrast(1.22); }
  100% { transform: scale(1.02); filter: brightness(1.0) contrast(1.12); }
}

@keyframes deadStareTwitch {
  0% { transform: scale(1.02) translate(0, 0); }
  50% { transform: scale(1.028) translate(-1px, 1px); }
  100% { transform: scale(1.02) translate(1px, 0); }
}

.wipe-flash {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: #e2eee5;
  opacity: 0;
  pointer-events: none;
}

.wipe-darkcut {
  position: absolute;
  inset: 0;
  z-index: 14;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

/* ==================== B04 终局 L5 扑脸（Scene 6） ==================== */
.scene-finale {
  z-index: 20;
}

.finale-img {
  transform-origin: 50% 42%;
  transform: scale(0.8);
}

.scene-finale.active .finale-img {
  animation: finaleLunge 110ms cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
}

@keyframes finaleLunge {
  0% { transform: scale(0.8); filter: brightness(1.6) contrast(1.35); }
  72% { transform: scale(1.12); filter: brightness(1.15) contrast(1.25); }
  100% { transform: scale(1.04); filter: brightness(1.0) contrast(1.18); }
}

.finale-scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.32) 3px
  );
}

.finale-redflash {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: rgba(168, 12, 18, 0.45);
}

/* ==================== Adapter B：180° 转身边缘触点 ==================== */
.turn-edge {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 18;
  width: 34px;
  height: 112px;
  border: none;
  border-right: 1px solid rgba(154, 166, 150, 0.18);
  border-top: 1px solid rgba(154, 166, 150, 0.12);
  border-bottom: 1px solid rgba(154, 166, 150, 0.12);
  background: linear-gradient(90deg, rgba(12, 16, 13, 0.72) 0%, rgba(12, 16, 13, 0.12) 100%);
  color: rgba(196, 206, 190, 0.56);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.turn-edge:hover {
  color: rgba(226, 234, 220, 0.9);
  border-color: rgba(176, 190, 170, 0.44);
}

.turn-edge.hidden {
  opacity: 0;
  pointer-events: none;
}

.turn-edge.urgent-green {
  width: 46px;
  background: linear-gradient(90deg, rgba(42, 124, 68, 0.76) 0%, rgba(20, 62, 34, 0.14) 100%);
  border-color: rgba(124, 232, 156, 0.72);
  color: #d6f5de;
  animation: edgeGreenCall 0.85s infinite;
}

@keyframes edgeGreenCall {
  0%, 100% { box-shadow: 0 0 14px rgba(102, 224, 140, 0.32); }
  50% { box-shadow: 0 0 28px rgba(102, 224, 140, 0.82); }
}

.turn-arrow {
  font-size: 24px;
  line-height: 1;
}

.turn-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(204, 28, 32, 0.95);
  box-shadow: 0 0 10px rgba(224, 34, 38, 0.95);
  opacity: 0;
}

.turn-edge.urgent-green .turn-pulse-dot {
  opacity: 1;
}

/* ==================== 仪式入口与终局黑屏 ==================== */
.gate-overlay,
.end-overlay {
  position: absolute;
  inset: 0;
  z-index: 32;
  background: radial-gradient(circle at 50% 42%, rgba(16, 20, 17, 0.94) 0%, #020303 78%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 550ms ease;
}

.gate-overlay.gone {
  opacity: 0;
  pointer-events: none;
}

.end-overlay {
  opacity: 0;
  pointer-events: none;
  background: #000;
}

.end-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.gate-plate,
.end-plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  padding: 24px;
}

.gate-number,
.end-num {
  font-size: 56px;
  font-weight: 400;
  letter-spacing: 0.24em;
  padding-left: 0.24em;
  color: rgba(182, 166, 118, 0.84);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.95);
  border-top: 1px solid rgba(140, 122, 75, 0.36);
  border-bottom: 1px solid rgba(140, 122, 75, 0.36);
  padding-top: 10px;
  padding-bottom: 10px;
}

.gate-scratch {
  font-size: 14px;
  letter-spacing: 0.42em;
  padding-left: 0.42em;
  color: rgba(176, 182, 170, 0.62);
}

.gate-btn,
.end-replay {
  margin-top: 16px;
  padding: 12px 30px;
  background: rgba(16, 18, 16, 0.85);
  border: 1px solid rgba(140, 122, 75, 0.56);
  color: rgba(218, 214, 198, 0.92);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.34em;
  padding-left: calc(30px + 0.34em);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.gate-btn:hover,
.end-replay:hover {
  background: rgba(34, 30, 22, 0.92);
  border-color: rgba(196, 174, 116, 0.85);
  color: #f0ece0;
}

.gate-status {
  min-height: 16px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(154, 164, 150, 0.45);
}

.end-line {
  font-size: 15px;
  letter-spacing: 0.45em;
  padding-left: 0.45em;
  color: rgba(186, 36, 40, 0.84);
}

.end-replay {
  margin-top: 28px;
  font-size: 12px;
  padding: 9px 22px;
  padding-left: calc(22px + 0.34em);
  border-color: rgba(130, 134, 126, 0.34);
  color: rgba(182, 188, 178, 0.68);
}

@media (max-width: 520px) {
  .frame-shell {
    height: 100vh;
    width: 100vw;
    max-width: 100vw;
    padding: 0;
    border: none;
  }
}
