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

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: Georgia, 'Times New Roman', 'Songti SC', 'STSong', 'SimSun', serif;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game {
  display: block;
  cursor: none;
  background: #030208;
  /* 触摸按住是核心操作：禁止浏览器把手势抢走（会发 pointercancel 而非 pointerup） */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    rgba(0,0,0,0) 45%,
    rgba(0,0,0,0.45) 78%,
    rgba(0,0,0,0.8) 100%);
}

/* ---------- HUD ---------- */
#objective {
  position: absolute;
  top: 4.5%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: 0.35em;
  color: #8d8172;
  opacity: 0;
  transition: opacity 1.2s;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(0,0,0,0.9);
  white-space: nowrap;
}
#objective.show { opacity: 0.85; }

#msg {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 72%;
  text-align: center;
  font-size: clamp(15px, 2.5vw, 21px);   /* 小屏不霸屏 */
  line-height: 1.8;
  color: #cfc4b0;
  text-shadow: 0 1px 4px #000, 0 0 14px rgba(0,0,0,0.9);
  opacity: 0;
  transition: opacity 0.45s;
  pointer-events: none;
  letter-spacing: 0.06em;
}
#msg.show { opacity: 1; }

#inv {
  position: absolute;
  left: 3%;
  bottom: 5%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: 26%;
}

/* 全屏提示（进入后短暂显示） */
#fs-hint {
  position: absolute;
  top: 3%;
  left: 3%;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: #9a8f7c;
  text-shadow: 0 1px 4px #000;
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
  z-index: 6;
}
#fs-hint.show { opacity: 0.9; }
.inv-chip {
  display: inline-block;
  border: 1px solid rgba(160, 140, 95, 0.55);
  background: rgba(12, 9, 6, 0.72);
  color: #c9b98f;
  font-size: 14px;
  letter-spacing: 0.15em;
  padding: 7px 16px;
  border-radius: 2px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s, transform 0.6s;
}
.inv-chip.show { opacity: 1; transform: translateY(0); }

/* ---------- 通用覆盖层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s;
}
.hidden { display: none !important; }
.fade { opacity: 0; pointer-events: none; }

/* 矮屏/小窗兜底：内容超高时在卡片内部滚动，不被 flex 居中裁掉。
   滚动条永远隐藏——结局/卡片画面上露出系统滚动条太出戏 */
#paper, #rules-inner, #choice-inner, .ending-inner, .intro-inner {
  max-height: 94vh;
  overflow-y: auto;
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* 旧 Edge */
}
#paper::-webkit-scrollbar, #rules-inner::-webkit-scrollbar,
#choice-inner::-webkit-scrollbar, .ending-inner::-webkit-scrollbar,
.intro-inner::-webkit-scrollbar {
  display: none;               /* Chrome / Safari */
}

/* ---------- 开场 ---------- */
#intro {
  background: #050308;
  flex-direction: column;
  z-index: 30;
  overflow: hidden;
}
#intro-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
  animation: introDrift 90s ease-in-out infinite alternate;
}
@keyframes introDrift {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.09) translate(-1.5%, -1%); }
}
#intro::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(5,3,8,0.25) 30%, rgba(5,3,8,0.82) 100%);
}
.intro-inner { position: relative; z-index: 2; }
.intro-inner { text-align: center; padding: 0 8%; }
#intro h1 {
  font-size: clamp(32px, 8.5vw, 72px);   /* 窄屏不换行 */
  white-space: nowrap;
  font-weight: normal;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: #b7a98e;
  text-shadow: 0 0 24px rgba(140, 110, 70, 0.35);
  margin-bottom: 18px;
}
#intro .sub {
  font-size: 16px;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: #6e6353;
  margin-bottom: 52px;
}
#intro .story {
  font-size: 17px;
  line-height: 2.4;
  color: #9a8f7c;
  margin-bottom: 26px;
}
#intro .replay {
  font-size: 15px;
  color: #7e3b3b;
  letter-spacing: 0.2em;
  margin-bottom: 26px;
}
#start-btn, #restart-btn, #ch2-btn {
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: #cfc4b0;
  background: transparent;
  border: 1px solid #6b5f45;
  padding: 13px 46px;
  cursor: pointer;
  transition: background 0.4s, color 0.4s, box-shadow 0.4s;
  margin-top: 14px;
}
#start-btn:hover, #restart-btn:hover, #ch2-btn:hover {
  background: rgba(140, 110, 70, 0.12);
  color: #efe6d2;
  box-shadow: 0 0 22px rgba(140, 110, 70, 0.25);
}
#intro .tip {
  margin-top: 42px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: #4d463c;
}

/* ---------- 作者署名 ---------- */
.author-line {
  margin-top: 20px;
  font-size: 11px;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: #4d463c;
}
#author-credit {
  position: absolute;
  right: 3%;
  bottom: 4.5%;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: rgba(90, 80, 65, 0.5);
  pointer-events: none;
  z-index: 6;
}

/* 彩蛋：结局插图双击反色 */
#ending-img { transition: opacity 2.4s, filter 0.5s; }
#ending-img.invert { filter: invert(0.88) hue-rotate(160deg); }
#skip-ch2 {
  margin-top: 22px;
  font-size: 13px;
  letter-spacing: 0.25em;
  color: #6e5a4a;
  cursor: pointer;
  transition: color 0.4s;
}
#skip-ch2:hover { color: #a8503c; }

/* ---------- 规则排序卡（第二章） ---------- */
#rules {
  background: rgba(2, 1, 4, 0.82);
  z-index: 22;
}
#rules-inner {
  width: 620px;
  max-width: 88%;
  background: linear-gradient(178deg, #141010 0%, #0d0a09 100%);
  border: 1px solid rgba(160, 140, 95, 0.35);
  padding: 34px 40px 28px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.9);
  text-align: center;
}
.rules-title {
  color: #a89a7d;
  font-size: 17px;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  margin-bottom: 10px;
}
.rules-sub {
  color: #6e6353;
  font-size: 13px;
  letter-spacing: 0.15em;
  margin-bottom: 26px;
}
.rule-frag {
  display: block;
  width: 100%;
  margin: 12px 0;
  padding: 16px 20px;
  background: linear-gradient(175deg, #d9cfb6 0%, #c8bb9e 100%);
  color: #2a2320;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.7;
  text-align: left;
  border: none;
  cursor: pointer;
  transform: rotate(-0.4deg);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.rule-frag:nth-child(odd) { transform: rotate(0.5deg); }
.rule-frag:hover { transform: scale(1.02); box-shadow: 0 6px 22px rgba(0,0,0,0.6); }
.rule-frag .order-badge {
  position: absolute;
  right: 14px;
  top: 10px;
  color: #8a3a3a;
  font-size: 20px;
}
.rules-hint {
  margin-top: 22px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: #4d463c;
}

/* 结局双按钮：往下走是主行动，略作强调 */
#ch2-btn {
  margin-right: 18px;
  color: #e6d9bc;
  border-color: #8a7550;
  box-shadow: 0 0 14px rgba(140, 110, 70, 0.14);
}

/* ---------- 选择支（第三章双结局） ---------- */
#choice {
  background: rgba(2, 1, 4, 0.86);
  z-index: 24;
}
#choice-inner {
  width: 560px;
  max-width: 86%;
  text-align: center;
}
#choice-title {
  color: #a89a7d;
  font-size: 19px;
  line-height: 2.2;
  letter-spacing: 0.12em;
  margin-bottom: 40px;
  text-shadow: 0 1px 6px #000;
  white-space: pre-wrap;
}
#choice-btns {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;   /* 窄屏竖排 */
}
.choice-btn {
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.22em;
  color: #cfc4b0;
  background: transparent;
  border: 1px solid #6b5f45;
  padding: 16px 30px;
  cursor: pointer;
  transition: background 0.4s, color 0.4s, box-shadow 0.4s;
}
.choice-btn:hover {
  background: rgba(140, 110, 70, 0.12);
  color: #efe6d2;
  box-shadow: 0 0 22px rgba(140, 110, 70, 0.25);
}
.choice-btn.danger:hover {
  border-color: #8a3a3a;
  box-shadow: 0 0 22px rgba(138, 42, 42, 0.3);
}

.flicker { animation: flick 7s infinite; }
@keyframes flick {
  0%, 100% { opacity: 1; }
  3% { opacity: 0.6; }
  4% { opacity: 1; }
  41% { opacity: 1; }
  42% { opacity: 0.35; }
  43.5% { opacity: 0.95; }
  44% { opacity: 0.5; }
  45% { opacity: 1; }
  78% { opacity: 1; }
  79% { opacity: 0.7; }
  80% { opacity: 1; }
}

/* ---------- 信号特效系统 ---------- */
/* 标题 glitch：暗红/冷蓝双层切片，每 5 秒闪错一次 */
#title-signal { position: relative; }
#title-signal::before,
#title-signal::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  letter-spacing: inherit;
  text-indent: inherit;
  pointer-events: none;
  opacity: 0;
}
#title-signal::before {
  color: #8a2f2f;
  clip-path: polygon(0 0, 100% 0, 100% 34%, 0 34%);
  animation: fxTitleGlitch 5s infinite;
}
#title-signal::after {
  color: #4a6a72;
  clip-path: polygon(0 66%, 100% 66%, 100% 100%, 0 100%);
  animation: fxTitleGlitch 5s infinite reverse;
}
@keyframes fxTitleGlitch {
  0%, 90%, 100% { transform: translate(0); opacity: 0; }
  92% { transform: translate(4px, -2px); opacity: 0.7; }
  95% { transform: translate(-4px, 2px); opacity: 0.7; }
  97% { transform: translate(2px, 1px); opacity: 0.7; }
}

/* 危险红光：屏幕边缘脉冲，熊逼近/音乐播放时与心跳同频 */
#fx-danger {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  box-shadow: inset 0 0 130px rgba(150, 12, 22, 0.55);
}
#fx-danger.active { animation: fxDangerPulse 1.1s ease-in-out infinite; }
#fx-danger.active.fast { animation-duration: 0.5s; }
@keyframes fxDangerPulse {
  0%, 100% { opacity: 0.12; }
  50% { opacity: 0.8; }
}

/* 尊重系统"减少动态效果"偏好 */
@media (prefers-reduced-motion: reduce) {
  #title-signal::before, #title-signal::after { animation: none !important; }
  #fx-danger.active { animation: none; opacity: 0.3; }
  .flicker { animation: none !important; }
  #intro-bg { animation: none !important; }
}

/* ---------- 阅读卡片 ---------- */
#card {
  background: rgba(2, 1, 4, 0.78);
  z-index: 20;
  cursor: pointer;
}
#paper {
  width: 560px;
  max-width: 86%;
  min-height: 300px;
  background: linear-gradient(175deg, #d9cfb6 0%, #cfc2a4 55%, #c3b494 100%);
  color: #2a2320;
  padding: 38px 44px 30px;
  transform: rotate(-0.7deg);
  box-shadow: 0 18px 60px rgba(0,0,0,0.85), inset 0 0 60px rgba(120, 95, 55, 0.18);
}
#paper-title {
  font-size: 15px;
  letter-spacing: 0.3em;
  color: #5a4a35;
  border-bottom: 1px solid rgba(90, 74, 53, 0.35);
  padding-bottom: 10px;
  margin-bottom: 20px;
}
#paper-img {
  display: block;
  max-width: 62%;
  margin: 0 auto 18px;
  transform: rotate(1.6deg);
  filter: brightness(0.92);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
#paper-body {
  font-size: 17px;
  line-height: 2.2;
  min-height: 170px;
  white-space: pre-wrap;
}
#paper-hint {
  margin-top: 22px;
  text-align: right;
  font-size: 12px;
  letter-spacing: 0.25em;
  color: rgba(90, 74, 53, 0.6);
}

/* ---------- 结局 ---------- */
#ending {
  background: #000;
  z-index: 40;
}
.ending-inner { text-align: center; max-width: 80%; }
#ending-img {
  max-width: 420px;
  max-height: 32vh;   /* 40vh 会让整页在常见屏幕高度上超出 94vh，逼出内部滚动 */
  margin: 0 auto 26px;
  display: block;
  opacity: 0;
  transition: opacity 2.4s;
  /* 黑底图边缘羽化进黑幕 */
  -webkit-mask-image: radial-gradient(ellipse at center, #000 55%, transparent 78%);
  mask-image: radial-gradient(ellipse at center, #000 55%, transparent 78%);
}
#ending-img.show { opacity: 1; }
#ending-lines {
  font-size: clamp(15px, 2.4vw, 21px);
  line-height: 2.8;
  letter-spacing: 0.12em;
  color: #a99d88;
  white-space: pre-wrap;
  min-height: 220px;
}
#ending-lines .em { color: #8a3a3a; }

/* ---------- 窄屏（手机竖屏） ---------- */
@media (max-width: 640px) {
  #paper { padding: 24px 22px 20px; min-height: 0; }
  #paper-body { font-size: 15px; line-height: 2; min-height: 120px; }
  #paper-img { max-width: 78%; }
  #rules-inner { padding: 22px 18px 18px; }
  .rule-frag { padding: 12px 14px; font-size: 15px; }
  #choice-title { font-size: 16px; margin-bottom: 26px; }
  #choice-btns { flex-direction: column; align-items: center; }
  #intro .story { font-size: 15px; line-height: 2.1; }
  #intro h1 { margin-bottom: 12px; }
  #intro .sub { margin-bottom: 30px; }
  #msg { max-width: 88%; }
  #ending-lines { min-height: 0; }
  #ending-img { max-width: 78vw; }
  /* 结局双按钮竖排时居中对称 */
  #start-btn, #restart-btn, #ch2-btn { margin-left: 8px; margin-right: 8px; }
}

/* ---------- 矮屏（笔记本小屏 / 手机横屏）：压缩行距与插图，整页放得下 ---------- */
@media (max-height: 700px) {
  #ending-img { max-height: 27vh; margin-bottom: 12px; }
  #ending-lines { line-height: 2.15; min-height: 0; }
  #paper { padding: 24px 30px 20px; min-height: 0; }
  #paper-body { font-size: 15px; line-height: 1.9; min-height: 0; }
  #paper-img { max-height: 24vh; }
  #paper-hint { margin-top: 12px; }
  #rules-inner { padding-top: 22px; padding-bottom: 18px; }
  .rule-frag { padding-top: 10px; padding-bottom: 10px; margin: 8px 0; }
  #intro h1 { margin-bottom: 8px; }
  #intro .sub { margin-bottom: 22px; }
  #intro .story { line-height: 2; margin-bottom: 14px; }
  #intro .tip { margin-top: 20px; }
  #start-btn, #restart-btn, #ch2-btn { padding: 10px 34px; }
}
