/* ============================================================
   本地英文字体 Remem：Light(300) / Regular(400) / Bold(700)
   仅覆盖英文字形，中文字符会自动回退到后续字体
   ============================================================ */
@font-face {
  font-family: "Remem";
  src: url("Remem/Remem-Light.ttf") format("truetype");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Remem";
  src: url("Remem/Remem-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Remem";
  src: url("Remem/Remem-Bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

/* Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* 舞台 1% 尺寸单位：--sh = 舞台高的 1%，--sw = 舞台宽的 1%
   横屏舞台铺满视口时等价于 1vh / 1vw；竖屏（旋转 90°）时舞台高对应视口宽，
   由各竖屏媒体查询中的 vw 覆盖直接表达；PC 端（见文件末尾 PC 媒体查询）
   舞台按 16:9 定框，此处会重新覆盖。 */
:root {
  --sh: 1vh;
  --sw: 1vw;
}

html {
  width: 100%;
  height: 100%;
  background-color: #000000 !important;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background-color: #000000 !important;

  font-family:
    "Remem",
    /* 英文：Remem */ "LiSu",
    "隶书",
    /* 中文：隶书（Windows 系统字体） */ "STLiti",
    /* 中文：华文隶书（macOS） */ "Noto Sans SC",
    /* 兜底：移动端无隶书时使用 */ -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  color: #ffffff;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

/* ============================================================
   0. 图片长按保护
   默认禁用微信内「保存图片 / 转发给朋友」等长按菜单：
   - -webkit-touch-callout: none + 取消图片拖拽/选中（iOS / 部分安卓内核）
   - pointer-events: none 让触摸落到父元素，安卓 X5 内核也不会命中图片
   需要允许长按保存的图片，加上 class="img-saveable" 即可恢复长按菜单。
   （仅对图片生效，按钮等元素的点击不受影响）
   ============================================================ */
img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

img:not(.img-saveable) {
  pointer-events: none;
}

img.img-saveable {
  pointer-events: auto;
  -webkit-touch-callout: default;
}

/* ============================================================
   1. 开屏 Loading 页
   ============================================================ */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(
      circle at 50% 42%,
      rgba(255, 71, 87, 0.12) 0%,
      rgba(0, 0, 0, 0) 62%
    ),
    #000000;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-inner {
  width: 68%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.loading-brand {
  width: 92%;
  height: auto;
  margin-bottom: 6%;
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.6));
  animation: fadeUp 0.8s ease both;
}

.loading-progress {
  position: relative;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff4757 0%, #ff9a3c 60%, #ffd700 100%);
  box-shadow: 0 0 12px rgba(255, 71, 87, 0.85);
}

.loading-percent {
  margin-top: 3%;
  font-size: 12px;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.55);
}

.loading-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14%;
  padding: 10px 22px 10px 16px;
  border: 1px solid rgba(255, 215, 0, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.88);
  animation: fadeUp 0.8s 0.2s ease both;
}

/* 双语文案：英文在上（弱化），中文在下（强调） */
.loading-hint-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.loading-hint-en {
  font-size: 11px;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.62);
}

.loading-hint-zh {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.92);
}

.rotate-icon {
  width: 22px;
  height: 22px;
  color: #ffd700;
  flex-shrink: 0;
  transform-origin: 50% 50%;
  animation: rotatePhone 2.2s ease-in-out infinite;
}

/* ============================================================
   2. 进入流程：开始页 → 选角色页（两页各自独立背景）
   ============================================================ */
.entry-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.entry-screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 舞台：与长图页 / 视频页共用同一套横屏旋转逻辑 */
.entry-stage {
  position: absolute;
  overflow: hidden;
}

/* 横屏背景：铺满所在页面；开始页与选角色页各自持有一张独立背景 */
.entry-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 开始页：水平垂直居中 */
.entry-start {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}

.entry-start.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 开始页右上角推广标 */
.advertorial-badge {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
  padding: calc(var(--sh) * 0.9) calc(var(--sw) * 1.4);
  font-size: calc(var(--sh) * 1.8);
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

/* 开始 / 确认按钮共用样式：底层图 + 居中文字图两层结构 */
.start-btn {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  width: calc(var(--sh) * 40);
  transition: transform 0.2s ease;
}

.start-btn-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 25%;
  height: auto;
  animation: arrowBreath 2s ease-in-out infinite;
}

/* 右箭头呼吸：缩放 + 阴影同步呼吸（drop-shadow 沿图片透明形状投影） */
@keyframes arrowBreath {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    filter: drop-shadow(0 0.2vh 0.5vh rgba(0, 0, 0, 0.25));
  }
  50% {
    transform: translate(-50%, -50%) scale(1.14);
    filter: drop-shadow(0 0.5vh 1.2vh rgba(0, 0, 0, 0.55));
  }
}

.start-btn img {
  display: block;
}

/* 底层图：顺时针缓慢旋转 */
.start-btn .start-btn-base {
  width: 100%;
  height: auto;
  animation: startSpin 12s linear infinite;
}

/* 文字图：垂直水平居中叠在底层中间，不随底层旋转 */
.start-btn .start-btn-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50%;
  height: auto;
}

.start-btn:active {
  transform: scale(0.96);
}

/* 选角色页：默认隐藏，点击开始按钮后显示 */
.entry-character {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.45s ease,
    visibility 0.45s ease;
}

.entry-character.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 三列布局 */
.character-columns {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6%;
}

/* 左列：头像（男上女下，中间间隔） */
.character-avatars {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--sh) * 7);
  margin-left: 4%;
}

.avatar-item {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  line-height: 0;
}

.avatar-img {
  display: block;
  height: calc(var(--sh) * 14);
  width: auto;
  filter: saturate(0.7) brightness(0.78);
  z-index: 3;
  position: relative;
  transition:
    height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.35s ease;
}

.avatar-item.is-active .avatar-img {
  height: calc(var(--sh) * 19);
  filter: none;
}

/* 中列：人物肖像（底部对齐） */
.character-portrait {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  height: 100%;
}

.character-portrait img {
  display: block;
  height: calc(var(--sh) * 95);
  width: auto;
  animation: portraitIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* 右列：提示文字（垂直居中） */
.character-guide {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--sh) * 3);
  margin-right: 4%;
}

.guide-image {
  display: block;
  height: auto;
}

.guide-image-en {
  width: calc(var(--sh) * 44);
}

.guide-image-zh {
  width: calc(var(--sh) * 32);
}

/* 右下角：复用开始按钮作为确认按钮 */
.character-confirm-btn {
  position: absolute;
  right: 12%;
  bottom: 16%;
  width: calc(var(--sh) * 26);
}

/* 确认按钮：底层保持静态不旋转（同特异性，靠源码顺序覆盖上面的旋转动画） */
.character-confirm-btn .start-btn-base {
  animation: none;
}

/* 确认按钮内部只有一张绝对定位的箭头图，按钮自身没有高度；
   图片统一 pointer-events:none 后触摸会穿透到背景，故补一块与箭头同区域的透明热区 */
.character-confirm-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 25%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

/* 开始按钮底层：顺时针匀速旋转一圈 */
@keyframes startSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes portraitIn {
  from {
    opacity: 0;
    transform: translateY(3vh) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 竖屏时舞台高度 = 100vw，用 vw 覆盖表示「舞台高度的百分比」 */
@media screen and (orientation: portrait) {
  .start-btn {
    width: 40vw;
  }

  .character-avatars {
    gap: 7vw;
    margin-left: 4%;
  }

  .avatar-img {
    height: 14vw;
  }

  .avatar-item.is-active .avatar-img {
    height: 22vw;
  }

  .character-portrait img {
    height: 95vw;
  }

  .character-guide {
    gap: 3vw;
  }

  .guide-image-en {
    width: 44vw;
  }

  .guide-image-zh {
    width: 32vw;
  }

  .character-confirm-btn {
    width: 26vw;
  }
}

/* ============================================================
   3. 开场视频
   ============================================================ */
.video-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.video-screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.video-screen.is-insert-mode {
  z-index: 150;
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}

/* 视频舞台：与长图页保持同一套横屏旋转逻辑 */
.video-stage {
  position: absolute;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.open-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-play-btn {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  padding: 12px 30px;
  border: 1px solid rgba(255, 215, 0, 0.7);
  border-radius: 40px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffd700;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 22px rgba(255, 215, 0, 0.35);
}

.video-play-btn[hidden] {
  display: none;
}

/* 视频播放中右上角跳过按钮 */
.video-skip-btn {
  position: absolute;
  top: 4%;
  right: 4%;
  z-index: 5;
  padding: 8px 22px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 40px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  pointer-events: auto;
}

.video-skip-btn[hidden] {
  display: none;
}

.video-skip-btn:active {
  transform: scale(0.96);
}

/* ============================================================
   3. 主内容（横屏全景长图）
   ============================================================ */
.main-screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
}

/* 主内容入场：柔和淡入 + 轻微缩放归位，与视频层淡出交叉衔接 */
.main-screen.is-visible {
  visibility: visible;
  animation: mainFadeIn 1s ease-out both;
}

@keyframes mainFadeIn {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Outer Viewport locking body */
.landscape-viewport {
  position: fixed;
  top: 0;
  left: 0;
  /* vh/vw = 大视口（含被地址栏/工具栏遮挡区域），作旧浏览器回退；
     dvh/dvw = 动态视口（当前真正可见区域），iOS 横屏时避开顶部地址栏；
     --vpw/--vph = JS 实测可视区 px（见 index.html），微信老内核 vh 失真时精确兜底 */
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  width: var(--vpw, 100dvw);
  height: var(--vph, 100dvh);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
}

/* 全屏遮罩/页面层：fixed inset:0 依赖布局视口，微信老内核下同样失真导致不满屏，
   统一改用 JS 实测视口尺寸（--vpw/--vph）铺满 */
.loading-screen,
.video-screen,
.entry-screen,
.main-screen,
.ending-screen,
.poster-overlay {
  width: var(--vpw, 100vw);
  height: var(--vph, 100vh);
}

/* 
  Landscape Wrapper:
  Handles Portrait (rotate 90deg) vs Landscape (direct fill)
*/
.landscape-wrapper {
  position: absolute;
  overflow: hidden;
  touch-action: auto;
}

/* Portrait Mode (Vertical Screen): Rotate 90deg */
@media screen and (orientation: portrait) {
  .landscape-wrapper,
  .video-stage,
  .entry-stage,
  .ending-stage {
    /* 物理竖持时可见视口轴互换：宽度对应视口高（dvh）、高度对应视口宽（dvw）；
       JS 实测变量作老内核精确兜底 */
    width: 100vh;
    height: 100vw;
    width: 100dvh;
    height: 100dvw;
    width: var(--vph, 100dvh);
    height: var(--vpw, 100dvw);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }
}

/* Landscape Mode (Horizontal Screen): Normal fit */
@media screen and (orientation: landscape) {
  .landscape-wrapper,
  .video-stage,
  .entry-stage,
  .ending-stage {
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    width: var(--vpw, 100dvw);
    height: var(--vph, 100dvh);
    top: 0;
    left: 0;
    transform: none;
  }
}

/* PC / 桌面宽屏（宽 ≥ 1024px 且横屏）：舞台按 16:9 定框并居中，
   超出部分由父层黑底形成上下（视口更高时）或左右留白；
   同时覆盖 --sh/--sw，使舞台内以「舞台高百分比」表达的尺寸随之等比缩放。
   门槛 1024px 高于手机横屏最大 CSS 宽度，手机端行为保持不变。 */
@media screen and (min-width: 1024px) and (orientation: landscape) {
  :root {
    /* 舞台高 = min(100vh, 56.25vw)，故舞台高的 1% = min(1vh, 0.5625vw) */
    --sh: min(1vh, 0.5625vw);
    --sw: min(1vw, 1.7778vh);
  }

  .landscape-wrapper,
  .video-stage,
  .entry-stage,
  .ending-stage {
    width: min(100vw, 177.7778vh);
    height: min(100vh, 56.25vw);
    width: min(100dvw, 177.7778dvh);
    height: min(100dvh, 56.25dvw);
    width: min(var(--vpw, 100vw), calc(var(--vph, 100vh) * 1.777778));
    height: min(var(--vph, 100vh), calc(var(--vpw, 100vw) * 0.5625));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

/* Scroll Container */
.scroll-container {
  width: 100%;
  height: 100%;
  /* 禁止手动滑动：overflow 隐藏后仍可通过 JS 设置 scrollLeft 自动前进 */
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  display: flex;
  align-items: center;
  transform: translateZ(0);
}

/* 长图总比例固定，分片加载前后 scrollWidth 不变 */
.image-stage {
  position: relative;
  height: 100%;
  display: block;
  aspect-ratio: 12788 / 852;
  min-width: 100%;
  flex-shrink: 0;
  transform: translateZ(0);
}

/* 前景贴图（黄花石碑、垂柳等）：贴在背景长图固定位置，由 JS 随背景滚动同步平移；
   层级高于主角（z-index 2），低于士兵（同层靠后绘制） */
.foreground-image {
  position: absolute;
  left: 0%;
  bottom: -5%;
  height: 45%;
  width: auto;
  z-index: 5;
  pointer-events: none;
  will-change: transform;
}

#willowImage {
  height: 65%;
}

/* 大明宫边缘高亮：与背景 1:1 比例贴合宫殿轮廓（243/852），
   改为容器结构（描边图 + 指引箭头），高度/基线不变，
   位于主角身后仅作背景标记，底部对齐城墙基线 */
#palaceHighlightImage {
  height: 29%;
  bottom: 35%;
  z-index: 1;
}

/* 高亮描边图：撑满容器高度，宽度按原图比例自适应 */
.spot-highlight-img {
  display: block;
  height: 100%;
  width: auto;
}

/* 右上角指引箭头：仅在高亮展示态淡入并上下浮动，隐藏态不占交互；
   水平翻转（scaleX(-1)）需同步写进浮动动画，否则会被 transform 覆盖 */
.spot-highlight-arrow {
  position: absolute;
  top: -25%;
  left: 12%;
  width: 15%;
  height: auto;
  opacity: 0;
  transition: opacity 0.4s ease 0.25s; /* 跟随高亮淡入，稍作延迟突出层级 */
}

.spot-highlight.is-visible .spot-highlight-arrow {
  opacity: 1;
  animation: floatHintFlipped 1.6s ease-in-out infinite;
}

/* 翻转版浮动动画：透明度呼吸不作用于此箭头 */
@keyframes floatHintFlipped {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* 大唐芙蓉园边缘高亮：与背景 1:1 比例贴合花园轮廓（243/852），
   位于主角身后仅作背景标记，底部对齐城墙基线 */
#gardenHighlightImage {
  height: 26.5%;
  bottom: 33%;
  z-index: 1;
}

/* 大唐不夜城边缘高亮：与背景 1:1 比例贴合花园轮廓（243/852），
   位于主角身后仅作背景标记，底部对齐城墙基线 */
#cityHighlightImage {
  height: 34%;
  bottom: 24.8%;
  z-index: 1;
}

/* 长安十二时辰边缘高亮：与背景 1:1 比例贴合花园轮廓（243/852），
   位于主角身后仅作背景标记，底部对齐城墙基线 */
#timeHighlightImage {
  height: 50%;
  bottom: 25.66%;
  z-index: 1;
}
/* 华清宫边缘高亮：与背景 1:1 比例贴合宫殿轮廓（243/852），
   位于主角身后仅作背景标记，底部对齐城墙基线 */
#huaqingHighlightImage {
  height: 24.4%;
  bottom: 34.5%;
  z-index: 1;
}

/* 景点边缘高亮通用显隐：触发前隐藏，剧情触发后立即全亮展示（不做淡化过渡）；
   展示态开放点击（点击高亮开始插播视频），隐藏态不拦截任何点击 */
.spot-highlight {
  opacity: 0;
  visibility: hidden;
}

.spot-highlight.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  cursor: pointer;
}

/* 呼吸效果只作用于高亮图本身（大明宫为嵌套内层图，其余四张图为元素本身），
   不带动容器内的指引箭头 */
.spot-highlight.is-visible .spot-highlight-img,
img.spot-highlight.is-visible {
  /* 展示即刻进入全亮呼吸，不延迟启动：避免「先淡后亮」的亮度跳变 */
  animation: spotBreath 1.8s ease-in-out infinite;
  /* 高亮图为半透明金色描边（无全不透明像素，均值 #FFD247 / maxA=240）。
     第一层 0 偏移 0 模糊的 drop-shadow 等于在描边背后垫一份同形状副本，
     把整体不透明度按 a'=a+a(1-a) 抬高一档（柔边过渡带提升最明显），
     垫层本身沿用描边原色，只加密不改色；
     后面两层由内到外叠橙色光晕：亮橙近晕 → 深橙大范围远晕。
     垫层同时抬高了后续光晕的源 alpha，光晕也会一并变亮。
     注：高亮图为透明 PNG，用 drop-shadow 沿描边形状发光（不用 box-shadow） */
  filter: drop-shadow(0 0 0 rgba(255, 210, 71, 1))
    drop-shadow(0 0 5px rgba(255, 170, 40, 1))
    drop-shadow(0 0 24px rgba(255, 110, 0, 0.85));
}

/* 高亮呼吸：展示态下透明度与光晕大小同步往复，谷值也保持明亮发光，
   提示用户可点击 */
@keyframes spotBreath {
  0%,
  100% {
    opacity: 1;
    filter: drop-shadow(0 0 0 rgba(255, 210, 71, 1))
      drop-shadow(0 0 5px rgba(255, 170, 40, 1))
      drop-shadow(0 0 24px rgba(255, 110, 0, 0.85));
  }
  50% {
    opacity: 0.85;
    filter: drop-shadow(0 0 0 rgba(255, 210, 71, 1))
      drop-shadow(0 0 3px rgba(255, 170, 40, 0.85))
      drop-shadow(0 0 14px rgba(255, 110, 0, 0.6));
  }
}

#danceImage {
  bottom: 1%;
  height: 45%;
}

#buddhaImage {
  bottom: 0%;
  height: 60%;
}

#sugarStallImage {
  height: 60%;
}

/* 前景6-枝干灌木：叠在糖人摊上层，位置略偏左 */
#sugarShrubImage {
  height: 30%;
  z-index: 6;
}

#greenTreeImage {
  height: 65%;
}

/* 分片绝对定位，重叠像素覆盖缩放时的接缝 */
.long-image {
  position: absolute;
  top: 0;
  left: calc(var(--tile-left) / 12788 * 100%);
  height: 100%;
  width: calc(var(--tile-width) / 12788 * 100%);
  max-height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: auto;
  flex-shrink: 0;
}

/* 前景装饰人物 GIF：相对屏幕固定不动，背景长图向左移动营造行走感 */
.man-gif {
  position: absolute;
  left: 35%;
  bottom: 11%;
  height: 45%;
  width: auto;
  z-index: 2;
  transition: opacity 0.35s ease;
}

/* 路过的 NPC（如士兵）：初始在屏幕右侧外，由 JS 驱动向左走出视图 */
.walk-gif {
  position: absolute;
  left: 100%;
  bottom: 5%;
  height: 52%;
  width: auto;
  z-index: 3;
  transition: opacity 0.35s ease;
}

/* 路过的小装饰 GIF（如小孩跑）：比士兵矮一些，贴着地面由右向左跑过 */
#childRunGif {
  height: 32%;
  bottom: 7%;
}

/* 路过的女孩：与小孩跑同款尺寸/贴地高度 */
#girlRunGif {
  height: 36%;
  bottom: 7%;
}

/* 主角与走路 GIF 的隐藏态 */
.man-gif.is-faded,
.walk-gif.is-faded {
  opacity: 0;
}

/* NPC 走出视图后，在主角男右侧出现的正/侧面特写（默认隐藏，由 JS 切换 is-visible）
   默认高度由 JS 按场景配置覆盖，未配置时回落到此处 */
.npc-closeup {
  position: absolute;
  left: 53%;
  bottom: 13.5%;
  height: 40%;
  width: auto;
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.npc-closeup.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   NPC 剧情：半身像对话
   整体为纵向 flex：上方半身像行，下方对话框，二者始终贴合
   ============================================================ */
.npc-scene {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 20px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.45s ease,
    visibility 0.45s ease;
}

.npc-scene.is-active {
  opacity: 1;
  visibility: visible;
}

/* 半身像行：宽度与对话框一致，两端对齐 */
.npc-portraits {
  position: relative;
  /* 不能设 z-index（保持 auto），否则会生成层叠上下文，
     把里面的 .npc-name 一起锁在这一层，名字就压不到对话框上 */
  z-index: auto;
  width: 65%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

/* 纯定位容器：不能带 transform / opacity，否则会生成层叠上下文，
   半身像和名字就无法分别压在对话框的上下层 */
.npc-character {
  position: relative;
  margin: 0;
}

/* 当前说话的一方显示，另一方隐藏：动画下沉到子元素，
   这样容器本身不产生层叠上下文 */
.npc-character.is-visible .npc-bust,
.npc-character.is-visible .npc-name {
  opacity: 1;
}

.npc-bust {
  width: auto;
  display: block;
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}

.npc-character.is-visible .npc-bust {
  transform: translateY(0);
}

/* 名字图：一半压在半身像底部，一半露在对话框上 */
.npc-name {
  position: absolute;
  left: 50%;
  bottom: 0%;
  height: auto;
  opacity: 0;
  /* 与半身像同步做上滑入场，可见时回到基准位置 */
  transform: translate(-50%, calc(50% + 16px));
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
  /* 高于 .npc-dialog(3)，名字压在对话框之上 */
  z-index: 4;
}

.npc-character.is-visible .npc-name {
  transform: translate(-50%, 50%);
}

/* 圆角对话框
   字号在横竖屏媒体查询里按舞台高缩放（PC 舞台更大时文字同步放大），
   框内的内边距 / 圆角 / 提示箭头用 em 跟随字号等比变化 */
.npc-dialog {
  position: relative;
  z-index: 3;
  width: 65%;
  font-size: 13px;
  padding: 1.08em 1.38em;
  border: 1px solid #373327;
  border-radius: 1.4em;
  background: #fbf4e0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  margin-bottom: 3%;
}

.npc-dialog:active {
  transform: scale(0.99);
}

/* 字号继承 .npc-dialog，由媒体查询统一缩放（与中文一致） */
.npc-dialog-en {
  line-height: 1.5;
  color: #442f13;
}

.npc-dialog-zh {
  margin-top: 0.31em;
  line-height: 1.5;
  color: #442f13;
}

.npc-dialog-next {
  display: block;
  width: 1.23em;
  height: auto;
  margin-top: 0.77em;
  margin-left: auto; /* 替代原文字的 text-align: right，保持右对齐 */
  animation: floatHint 1.6s ease-in-out infinite;
}

/* ============================================================
   TIPS 提示图：对话结束后覆盖展示，点击右上角关闭按钮后继续前进
   ============================================================ */
.tips-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  cursor: default;
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}

.tips-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 指南图 + 关闭按钮的定位容器：宽度由内容（即图片）撑开，
   并受 max-width 约束（相对已撑满宽度的 .tips-body，即舞台宽度），
   使关闭按钮能贴合图片右上角而不是舞台右缘 */
.tips-image-wrap {
  position: relative;
  display: flex;
  max-width: 65%;
}

/* 指南图：撑满 wrap 宽度并等比缩放，随舞台等比缩放；
   PC 大舞台下图片同步放大 */
.tips-image {
  display: block;
  width: 90%;
  height: auto;
  max-width: 100%;
  max-height: 80%;
  object-fit: contain;
  margin: 0 auto;
}

/* 右上角关闭按钮：定位在图片右上角，仅点击它才关闭提示层 */
.tips-close-btn {
  position: absolute;
  top: 4%;
  right: 9%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--sh) * 5);
  height: calc(var(--sh) * 5);
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease;
}

.tips-close-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tips-close-btn:active {
  transform: scale(0.88);
}

/* 指南图 + 底部双语小字的纵向容器。
   必须显式撑满宽度：否则作为 flex 项宽度由内容撑开，
   .tips-image-wrap 的 max-width 百分比会相对「图片自身像素宽」计算，
   导致指南图尺寸固定、PC 大舞台下显得很小 */
.tips-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-height: 92%;
}

/* 多张指南图的左右切换按钮：图片下方，点击切换上/下一张 */
.tips-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
}

/* 覆盖 [hidden] 的默认 display:none，单张指南图时隐藏按钮行 */
.tips-nav[hidden] {
  display: none;
}

/* 圆形带底背景按钮：保证箭头图片有足够点击热区（图片本身 pointer-events 被全局禁用） */
.tips-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--sh) * 7);
  height: calc(var(--sh) * 7);
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  pointer-events: auto;
  transition:
    transform 0.15s ease,
    background 0.2s ease;
}

.tips-nav-btn img {
  width: 55%;
  height: 55%;
  object-fit: contain;
}

.tips-nav-btn:active {
  transform: scale(0.88);
  background: rgba(0, 0, 0, 0.78);
}

/* 边界禁用态：首张的「上一张」/ 末张的「下一张」变暗且点击无效 */
.tips-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.tips-nav-btn:disabled:active {
  transform: none;
  background: rgba(0, 0, 0, 0.55);
}

/* 图片底部双语提示小字：告知用户可长按保存 */
.tips-caption {
  margin: 14px 0 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.tips-caption .tips-caption-en {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
}

/* PC / 桌面宽屏（与舞台定框同一门槛）：鼠标环境无「长按保存」，隐藏该提示 */
@media screen and (min-width: 1024px) and (orientation: landscape) {
  .tips-caption {
    display: none;
  }
}

/* ============================================================
   分享海报：结束页点击「分享」后覆盖展示，点击空白处关闭，长按可保存
   ============================================================ */
.poster-overlay {
  position: fixed;
  inset: 0;
  z-index: 160; /* 高于结束页(140)与插播视频层(150) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  cursor: pointer;
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}

.poster-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 海报舞台：随页面视野方向展示，横屏视野内缩小居中（不按物理竖屏铺满） */
.poster-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 物理竖持（页面旋转模拟横屏）时，海报舞台与页面其他舞台一同旋转 90°，
   使海报在横屏视野内水平垂直居中缩小展示，而不是旋转为竖屏呈现 */
@media screen and (orientation: portrait) {
  .poster-stage {
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    width: 100dvh;
    height: 100dvw;
    width: var(--vph, 100dvh);
    height: var(--vpw, 100dvw);
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }
}

/* 海报 + 底部双语小字的纵向容器 */
.poster-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 94%;
}

/* 海报为竖版：以高度为约束等比缩放
   父级 .poster-body 高度为 auto，百分比约束会解析失效导致图片按原始尺寸溢出，
   故改用视口单位：横屏视野高 = 100dvh、宽 = 100dvw（vh/vw 作旧浏览器回退） */
.poster-image {
  width: auto;
  height: auto;
  max-width: 65vw;
  max-height: 80vh;
  max-width: 65dvw;
  max-height: 80dvh;
  max-width: calc(var(--vpw, 100vw) * 0.65);
  max-height: calc(var(--vph, 100vh) * 0.8);
  object-fit: contain;
}

/* 物理竖持（页面旋转模拟横屏）时，海报舞台已旋转 90°，
   此处视野高 = 100dvw、宽 = 100dvh，约束轴需随之互换 */
@media screen and (orientation: portrait) {
  .poster-image {
    max-width: 65vh;
    max-height: 80vw;
    max-width: 65dvh;
    max-height: 80dvw;
    max-width: calc(var(--vph, 100vh) * 0.65);
    max-height: calc(var(--vpw, 100vw) * 0.8);
  }
}

/* PC 端舞台按 16:9 定框（见文件开头 PC 媒体查询），
   海报约束轴改用舞台尺寸，避免溢出到上下留白区 */
@media screen and (min-width: 1024px) and (orientation: landscape) {
  .poster-image {
    max-width: calc(var(--sw) * 65);
    max-height: calc(var(--sh) * 80);
  }
}

/* Glassmorphism Floating UI Header */
.ui-header {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

/* 右下角前进区：长按提示 + 前进按钮横向排布
   层级高于前景贴图/特写(5)，低于 NPC 对话(20)/TIPS(30)，
   对话期间被覆盖无法点击，与 JS 的 paused 状态双重防护 */
.go-cluster {
  position: absolute;
  right: 4%;
  bottom: 5%;
  z-index: 8;
  display: flex;
  align-items: center;
}

/* 长按提示：中文/英文文案 + 右箭头，指向前进按钮。
   首次长按前进按钮后由 JS 添加 .is-hidden 永久隐藏 */
.go-hint {
  display: flex;
  align-items: center;
  margin-right: calc(var(--sh) * 1.5);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 12px;
  border: 1px solid rgba(255, 215, 0, 0.28);
  border-radius: 14px;
  background: rgba(21, 16, 17, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.9);
  animation: fadeUp 0.8s 0.2s ease both;
}

/* 隐藏态需 animation: none 关闭入场动画：
   入场动画 fill-mode 为 both 会持续占用 opacity，覆盖此处的 opacity: 0 */
.go-hint.is-hidden {
  animation: none;
  opacity: 0;
}

.go-hint-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: calc(var(--sh) * 2);
  line-height: 1.3;
  white-space: nowrap;
}

.go-hint-arrow {
  width: calc(var(--sh) * 4);
  height: auto;
  margin-left: calc(var(--sh) * 0.8);
}

.go-btn {
  position: relative;
  /* 与竖屏 18vw 对齐（横屏舞台高 = 100vh，舞台高 18% = 18vh） */
  width: calc(var(--sh) * 18);
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  transition:
    transform 0.15s ease,
    opacity 0.3s ease;
}

/* 到达尚未加载的分片时提示等待，图片就绪后继续前进。 */
.go-btn.is-loading::before {
  content: "场景加载中";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}

.go-btn img {
  display: block;
  width: 100%;
  height: auto;
}

/* 按下态 */
.go-btn.is-pressed {
  transform: scale(0.92);
}

/* 提示脉动：首次按下前轻微呼吸，引导玩家点击 */
.go-btn.is-hint {
  animation: goPulse 1.6s ease-in-out infinite;
}

@keyframes goPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
}

/* 剧情进行中隐藏：NPC 出现时背景强制停住，按钮一并淡出防止误触。
   放在 .is-hint 之后，保证 animation: none 能覆盖脉动动画 */
.go-btn.is-hidden {
  animation: none;
  opacity: 0;
  pointer-events: none;
}

/* 竖屏时按钮尺寸跟随 vw */
@media screen and (orientation: portrait) {
  .go-btn {
    width: 18vw;
  }

  .go-hint {
    margin-right: 1.7vw;
  }

  .go-hint-text {
    font-size: 2.4vw;
  }

  .go-hint-arrow {
    width: 4.5vw;
    margin-left: 0.9vw;
  }
}

/* 左上角背景音乐开关：点击切换播放/静音
   层级与前进按钮一致(8)，高于前景贴图/特写(5) */
.sound-btn {
  position: absolute;
  top: 3%;
  left: 4%;
  /* 与竖屏 8.5vw 对齐（横屏舞台高 = 100vh，舞台高 8.5% = 8.5vh） */
  width: calc(var(--sh) * 8.5);
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(255, 215, 0, 0.7);
  border-radius: 50%;
  padding: 0;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 图标尺寸用百分比，相对按钮内容盒(即按钮宽度)计算
   注意：按钮自身的 padding 百分比会按父容器宽度解析，故不用 padding 做内边距 */
.sound-btn img {
  display: block;
  width: 62%;
  height: auto;
}

/* 竖屏时按钮尺寸跟随 vw */
@media screen and (orientation: portrait) {
  .sound-btn {
    width: 8.5vw;
  }
}

/* Keyframe Animations */
@keyframes floatHint {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 手机旋转提示图标：横向摆动 */
@keyframes rotatePhone {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-90deg);
  }
}

/* ============================================================
   NPC 图片尺寸
   横屏时容器高 = 100vh，竖屏时容器高 = 100vw，
   因此用 vh / vw 直接表示“屏幕高度的百分比”，
   避免多层百分比高度逐级传递导致尺寸失效
   ============================================================ */
/* 只下移守卫方的「半身像」，名字图不动，
   从而与左侧名字一起保持在对话框上沿、左右对称 */
.npc-character#npcGuard .npc-bust {
  position: relative;
  top: calc(var(--sh) * 2);
}

@media screen and (orientation: landscape) {
  /* 两侧半身像向中间收拢：左侧留左边距、右侧留右边距 */
  .npc-character#npcTraveler {
    margin-left: calc(var(--sh) * 6);
  }

  .npc-character#npcGuard {
    margin-right: calc(var(--sh) * 6);
  }

  .npc-bust {
    height: calc(var(--sh) * 40);
  }

  .npc-name {
    width: calc(var(--sh) * 25);
  }

  /* 顶部留白给名字图让位，避免遮住对话框文字；
     字号按舞台高缩放，PC 大舞台下文字同步变大 */
  .npc-dialog {
    font-size: calc(var(--sh) * 4);
    padding-top: 1.45em;
  }
}

@media screen and (orientation: portrait) {
  /* 两侧半身像向中间收拢（竖屏舞台高对应视口宽，用 vw 表达） */
  .npc-character#npcTraveler {
    margin-left: 6vw;
  }

  .npc-character#npcGuard {
    margin-right: 6vw;
  }

  .npc-character#npcGuard .npc-bust {
    position: relative;
    top: 4vw;
  }

  .npc-bust {
    height: 40vw;
  }

  .npc-name {
    width: 25vw;
  }

  /* 竖屏舞台高对应视口宽，故用 vw 表达字号 */
  .npc-dialog {
    font-size: 4vw;
    padding-top: 1.45em;
  }
}

/* ============================================================
   5. 结束页：走到尽头播放结束视频后无缝衔接
   ============================================================ */
.ending-screen {
  position: fixed;
  inset: 0;
  z-index: 140; /* 低于插播视频层(150)，高于长图主内容，实现视频淡出后露出结束页 */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.ending-screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 舞台：与长图页 / 视频页 / 进入页共用同一套横屏旋转逻辑 */
.ending-stage {
  position: absolute;
  overflow: hidden;
}

/* 结束页背景：铺满舞台 */
.ending-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(8px);
}

/* 居中的内容面板：标题 + 两个按钮上下竖排 */
.ending-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 标题与按钮：淡入上移，无缝衔接后出现 */
.ending-title,
.ending-btn {
  opacity: 0;
  transform: translateY(3%);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
}

.ending-screen.is-revealed .ending-title,
.ending-screen.is-revealed .ending-btn {
  opacity: 1;
  transform: translateY(0);
}

.ending-title {
  width: 62%;
  height: auto;
  margin-bottom: 7%;
}

.ending-btn {
  width: 24%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  /* 未揭示前禁用点击，避免误触 */
  pointer-events: none;
}

.ending-screen.is-revealed .ending-btn {
  pointer-events: auto;
}

.ending-btn img {
  display: block;
  width: 100%;
  height: auto;
}

.ending-btn + .ending-btn {
  margin-top: 4%;
}

.ending-screen.is-revealed .ending-btn:active {
  transform: scale(0.95);
}
