@font-face {
  font-family: "PixelFang";
  src: url("../2正式页面/网页字体/A75方正像素12.ttf") format("truetype");
  font-display: swap;
}

:root {
  --dialogue-bar-width: min(74vw, 1020px);
  /* 浏览器光标 PNG 一般不超过 128px，原图过大时会静默失效 */
  --game-cursor-ui: url("../2正式页面/光标2-128.png") 8 6, auto;
  --game-cursor-find: url("../2正式页面/光标1-128.png") 30 22, auto;
  /*
   * ========== 结局信封（自行微调）==========
   * 测试：index.html#envelope  素材：3结局/*-展示.png
   * 合上 / 打开分开尺寸（按素材内容比例）；底边中心叠在同一锚点
   *
   * --envelope-closed-width / --envelope-closed-height  合上（展示图内容 601×339）
   * --envelope-open-width / --envelope-open-height      打开（同底边锚点；宽度与合上等比，601/434）
   * --envelope-closed-rotate / --envelope-open-rotate   倾角
   * --envelope-dialogue-reserve                         底部对话框留白
   * --envelope-*-nudge-x/y                              各态微调（y 正值=下移）
   * --envelope-stage-nudge-x/y                          整体微调
   */
  --envelope-closed-width: 26vw;
  --envelope-closed-height: calc(var(--envelope-closed-width) * 339 / 601);
  /* 展示图里打开内容较窄(434px)，放大容器使可见宽度与合上(601px)一致 */
  --envelope-open-width: calc(var(--envelope-closed-width) * 601 / 434);
  --envelope-open-height: calc(var(--envelope-closed-height) * 601 / 434);
  --envelope-closed-rotate: 15deg;
  --envelope-open-rotate: 15deg;
  --envelope-dialogue-reserve: 26vh;
  --envelope-closed-nudge-x: 0px;
  --envelope-closed-nudge-y: 0px;
  --envelope-open-nudge-x: 0px;
  --envelope-open-nudge-y: 0px;
  --envelope-stage-nudge-x: 0px;
  --envelope-stage-nudge-y: 0vh;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
  font-family: "PixelFang", monospace;
  cursor: var(--game-cursor-ui);
}

#app,
#app * {
  cursor: var(--game-cursor-ui);
}

body.cursor-find {
  cursor: var(--game-cursor-find);
}

body.cursor-find #app,
body.cursor-find #app * {
  cursor: var(--game-cursor-find);
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* —— 开屏 —— */
#screen-splash {
  flex-direction: column;
  background: #000;
  gap: 1.2rem;
}

.splash-logo-wrap {
  width: min(88vw, 760px);
  max-height: min(78vh, 680px);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-logo-wrap video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.splash-loading-ui {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  width: 100%;
}

#screen-splash.splash-after-logo .splash-logo-wrap {
  display: none;
}

#screen-splash.splash-after-logo .splash-loading-ui {
  display: flex;
}

.splash-loading-label {
  font-family: "PixelFang", monospace;
  font-size: clamp(14px, 2vw, 22px);
  letter-spacing: 0.35em;
  color: #8a8a8a;
}

.splash-progress {
  width: min(420px, 72vw);
  height: auto;
  image-rendering: pixelated;
}

.splash-enter {
  width: min(320px, 58vw);
  max-width: 420px;
  height: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.2s ease;
  filter: drop-shadow(0 0 24px rgba(200, 120, 40, 0.55));
}

.splash-enter.visible {
  opacity: 1;
  pointer-events: auto;
}

.splash-enter:hover {
  transform: scale(1.04);
}

/* —— 黑屏文字 —— */
#screen-black {
  background: #000;
  padding: 2rem;
}

.black-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 4vh, 2.5rem);
  max-width: 820px;
  margin: 0 auto;
}

.fail-restart {
  filter: drop-shadow(0 0 20px rgba(160, 40, 40, 0.5));
}

.fail-restart:hover {
  transform: scale(1.05);
}

.black-text {
  max-width: 720px;
  text-align: center;
  font-family: "PixelFang", monospace;
  font-size: 24px;
  line-height: 1.85;
  color: #f5f5f5;
  white-space: pre-wrap;
}

/* —— 全屏视频 —— */
#screen-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* —— 探索场景 —— */
#screen-explore {
  display: none;
  background: #000;
  z-index: 2;
  overflow: hidden;
}

#screen-explore.active {
  display: block;
}

#screen-explore .portrait {
  z-index: 5;
}

.scene-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.scene-bg {
  touch-action: manipulation;
}

.scene-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  line-height: 0;
}

.scene-layer .scene-bg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center center;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  pointer-events: auto;
  cursor: inherit;
  border: none;
  background: transparent;
  padding: 0;
}

.hotspot-snake {
  z-index: 4;
}

.hotspot-npc {
  z-index: 2;
}

.hotspot-item {
  z-index: 3;
}

.hotspot:focus-visible {
  outline: 1px dashed rgba(120, 220, 220, 0.6);
}

/* 调试：必收集物热点（DEBUG_HIGHLIGHT_REQUIRED 开启时） */
.hotspot-debug-required {
  background: rgba(0, 230, 200, 0.35);
  border: 2px solid rgba(0, 255, 220, 0.95);
  box-shadow: 0 0 14px rgba(0, 255, 220, 0.55);
  border-radius: 6px;
  animation: hotspot-debug-pulse 1.6s ease-in-out infinite;
}

.hotspot-debug-required::before {
  content: attr(data-label);
  position: absolute;
  left: 0;
  top: -1.35rem;
  z-index: 1;
  padding: 0.1rem 0.35rem;
  font-family: "PixelFang", monospace;
  font-size: 11px;
  line-height: 1.3;
  color: #eaffff;
  background: rgba(0, 40, 36, 0.88);
  border: 1px solid rgba(0, 255, 220, 0.7);
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

@keyframes hotspot-debug-pulse {
  0%,
  100% {
    background: rgba(0, 230, 200, 0.28);
  }
  50% {
    background: rgba(0, 255, 220, 0.48);
  }
}

.portrait {
  position: absolute;
  bottom: 26%;
  left: 50%;
  transform: translateX(-50%);
  max-height: 46%;
  max-width: min(78vw, 780px);
  height: auto;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 5;
  object-fit: contain;
  object-position: center bottom;
}

.portrait.show {
  opacity: 1;
}

/* 参考「与NPC对话」：大蛇贴底、约占屏高 70%，对话框宽约 60% */
.portrait.snake-hero,
.portrait.snake-big {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 90vh;
  width: auto;
  max-width: 115vw;
  max-height: none;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  line-height: 0;
}

.portrait.npc-center {
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  height: min(62vh, 640px);
  width: auto;
  max-height: none;
  max-width: min(92vw, 900px);
  object-fit: contain;
  object-position: center bottom;
}

.portrait.npc-left {
  left: 6%;
  bottom: 28%;
  transform: none;
  width: auto;
  max-height: 38%;
  max-width: min(40vw, 400px);
}

.portrait.npc-right {
  right: 8%;
  left: auto;
  bottom: 22%;
  transform: none;
  width: auto;
  max-height: 42%;
  max-width: min(44vw, 440px);
  object-position: right bottom;
}

/* —— 全局 UI 层（均在场景之上） —— */
.advance-layer {
  position: absolute;
  inset: 0;
  z-index: 15;
  cursor: inherit;
  background: transparent;
  pointer-events: none;
  visibility: hidden;
}

.advance-layer.is-active {
  visibility: visible;
  pointer-events: auto;
}

/* 选项打开时：禁止「点击继续」层与底部对话框抢点击 */
body.is-choosing .advance-layer,
body.is-choosing .advance-layer.is-active {
  visibility: hidden !important;
  pointer-events: none !important;
}

body.is-choosing .dialogue-ui {
  pointer-events: none !important;
}

body.is-choosing #screen-explore {
  pointer-events: none;
}

.dialogue-ui {
  position: absolute;
  left: 50%;
  bottom: max(14px, 1.8vh);
  transform: translateX(-50%);
  /* 参考图：对话框略宽于 60%，保证长句显示全 */
  width: var(--dialogue-bar-width);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.dialogue-ui.visible {
  opacity: 1;
  pointer-events: auto;
}

.dialogue-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1279 / 319;
  height: auto;
  border: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  font-family: "PixelFang", monospace;
  color: #2a1a10;
}

.dialogue-box.mode-talk {
  background-image: url("../2正式页面/对话框-对话-条.png");
}

.dialogue-box.mode-explore {
  background-image: url("../2正式页面/对话框-探索-条.png");
  aspect-ratio: 1277 / 326;
}

/* 文字区域限制在卷轴内（避开左右锯齿与左上气泡/放大镜） */
.dialogue-content {
  position: absolute;
  left: 12.5%;
  right: 9%;
  top: 24%;
  bottom: 20%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

.dialogue-box.mode-explore .dialogue-content {
  left: 13%;
  top: 26%;
  bottom: 18%;
}

.dialogue-box.has-speaker .dialogue-content {
  justify-content: flex-start;
  top: 22%;
}

.dialogue-speaker {
  display: none;
  flex: 0 0 auto;
  font-family: "PixelFang", monospace;
  font-size: 24px;
  font-weight: normal;
  line-height: 1.35;
  margin: 0 0 6px;
  padding: 0;
  color: #1a1008;
  letter-spacing: 0;
}

.dialogue-box.has-speaker .dialogue-speaker {
  display: block;
}

.dialogue-text {
  flex: 1 1 auto;
  font-family: "PixelFang", monospace;
  font-size: 22px;
  font-weight: normal;
  line-height: 1.55;
  margin: 0;
  padding: 0;
  color: #2a1a10;
  word-break: break-word;
  overflow: visible;
  white-space: pre-wrap;
}

.dialogue-box.mode-explore .dialogue-text {
  font-size: 22px;
  text-align: center;
  white-space: nowrap;
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
  max-width: 100%;
}

.dialogue-box.mode-explore .dialogue-content {
  align-items: center;
}

.dialogue-box.mode-explore .dialogue-arrow {
  display: none;
}

.dialogue-text-body {
  display: inline;
}

.dialogue-box.mode-talk .dialogue-arrow {
  display: none;
}

.dialogue-text .dialogue-arrow-inline {
  flex-shrink: 0;
  width: auto;
  height: clamp(32px, 1.65em, 46px);
  max-height: 46px;
  vertical-align: middle;
  margin-left: 0.25em;
  animation: blink-arrow 0.8s step-end infinite;
  image-rendering: pixelated;
}

.item-pickup {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  z-index: 22;
  width: min(36vw, 400px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.item-pickup.show {
  opacity: 1;
}

.item-pickup img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(34vh, 380px);
  object-fit: contain;
  filter: drop-shadow(0 0 32px rgba(220, 235, 255, 0.55))
    drop-shadow(0 0 64px rgba(180, 210, 255, 0.25));
}

#app.item-pickup-active .floating-lines {
  top: 54%;
  bottom: auto;
  transform: translate(-50%, 0);
  width: min(70vw, 760px);
}

.dialogue-arrow {
  position: absolute;
  z-index: 2;
  right: 7%;
  bottom: 32%;
  width: clamp(22px, 2.5vw, 32px);
  height: auto;
  animation: blink-arrow 0.8s step-end infinite;
}

@keyframes blink-arrow {
  50% {
    opacity: 0;
  }
}

.floating-lines {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dialogue-bar-width) / 4 + 2.4vh);
  transform: translateX(-50%);
  width: min(58vw, 820px);
  text-align: center;
  z-index: 23;
  pointer-events: none;
}

.floating-lines p {
  margin: 0.35em 0;
  font-family: "PixelFang", monospace;
  font-size: 22px;
  color: #ece8e0;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
  line-height: 1.6;
}

#screen-explore.is-choosing .hotspot-layer {
  visibility: hidden;
  pointer-events: none;
}

/* —— 选项 —— */
#options-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: transparent;
  padding: 0;
  pointer-events: none;
  touch-action: manipulation;
}

#options-overlay.open {
  display: flex;
  pointer-events: auto;
}

#options-list {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: min(96vw, 920px);
  pointer-events: auto;
}

/* 参考「选项分支页面」：三选项居中，整体略上移给底部对话框留空 */
#options-overlay.mode-intro {
  justify-content: center;
  align-items: center;
  padding-bottom: 15vh;
}

.option-btn {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  pointer-events: auto;
  touch-action: manipulation;
  /* 参考图宽约 34% 屏宽，保证长句单行 */
  width: clamp(320px, 34.5vw, 392px);
  aspect-ratio: 534 / 148;
  height: auto;
  min-height: 0;
  padding: 0 9%;
  border: none;
  background: url("../2正式页面/选项框-条.png") center / 100% 100% no-repeat;
  font-family: "PixelFang", monospace;
  font-size: 21px;
  font-weight: normal;
  color: #f6f2e8;
  white-space: nowrap;
  text-shadow:
    1px 0 0 #3d2414,
    -1px 0 0 #3d2414,
    0 1px 0 #3d2414,
    0 -1px 0 #3d2414;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  cursor: inherit;
  transition: filter 0.15s ease, transform 0.15s ease;
  line-height: 1;
  letter-spacing: 0;
  flex-shrink: 0;
}

.option-btn:hover {
  filter: brightness(1.12);
  transform: scale(1.02);
}

.option-btn.done {
  opacity: 0.42;
  color: #c8c0b4;
}

.confirm-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: min(640px, 96vw);
}

.confirm-row .option-btn {
  flex: 0 0 auto;
  width: clamp(140px, 22vw, 200px);
  max-width: none;
  aspect-ratio: 534 / 148;
}

/* —— 结局（信封布局见 :root 里 --envelope-*） —— */
body.is-envelope-ending #app {
  overflow: visible;
}

#screen-ending {
  background: #000;
  padding: 0;
  overflow: hidden;
  z-index: 10;
}

#screen-ending.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

#screen-ending.active.mode-restart {
  justify-content: center;
  padding: 1rem;
}

#screen-ending.mode-envelope.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 在「全屏减去底栏留白」里垂直居中，改 center-y 百分比无效 */
  justify-content: center;
  min-height: 100%;
  padding-top: 5vh;
  padding-bottom: var(--envelope-dialogue-reserve);
  box-sizing: border-box;
  overflow: visible;
}

#screen-ending.mode-envelope #ending-content.envelope-stage {
  position: relative;
  flex-shrink: 0;
  width: max(var(--envelope-closed-width), var(--envelope-open-width));
  height: max(var(--envelope-closed-height), var(--envelope-open-height));
  margin: 0;
  transform: translate(var(--envelope-stage-nudge-x), var(--envelope-stage-nudge-y));
  pointer-events: none;
  z-index: 1;
}

.ending-envelope {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  transform-origin: center bottom;
  filter: drop-shadow(0 0 20px rgba(210, 225, 255, 0.28));
  cursor: var(--game-cursor-ui);
  pointer-events: auto;
  will-change: transform;
}

.ending-envelope--closed {
  width: var(--envelope-closed-width);
  height: var(--envelope-closed-height);
  transform: translateX(-50%)
    translate(var(--envelope-closed-nudge-x), var(--envelope-closed-nudge-y))
    rotate(var(--envelope-closed-rotate));
}

.ending-envelope--open {
  width: var(--envelope-open-width);
  height: var(--envelope-open-height);
  transform: translateX(-50%)
    translate(var(--envelope-open-nudge-x), var(--envelope-open-nudge-y))
    rotate(var(--envelope-open-rotate));
}

#ending-content {
  flex-shrink: 0;
}

.ending-restart {
  width: min(220px, 50vw);
  filter: drop-shadow(0 0 20px rgba(160, 40, 40, 0.5));
  transition: transform 0.2s ease;
}

.ending-restart:hover {
  transform: scale(1.05);
}

.ending-dialogue {
  width: min(96vw, 900px);
}

/* —— 光标（见 :root --game-cursor-ui / --game-cursor-find） —— */

.hidden {
  display: none !important;
}
