/* ==========================================================================
   西华·女娲传说 非遗竖版 H5 — 全局基础样式
   基准设计稿：750 × 1334（等比缩放适配手机）
   ========================================================================== */

:root {
  --ochre: #c8a26b;
  --ochre-dark: #9c7440;
  --ochre-deep: #7a5530;
  --sand: #e8dcc4;
  --sand-dark: #d4c4a0;
  --celadon: #6e7b7a;
  --celadon-light: #a7b8b5;
  --celadon-deep: #465251;
  --ink: #2c2a28;
  --c-red: #b8412e;
  --c-yellow: #d9a441;
  --c-white: #efe6d2;
  --c-black: #2c2a28;
  --c-cyan: #3e6e7a;
  --gold: #e8c878;
  --gold-deep: #b8893a;
  --title-font: 'ZCOOL XiaoWei', 'STLiti', 'LiSu', 'KaiTi', 'STKaiti', serif;
  --body-font: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'SimSun', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
svg { display: block; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0a08;
  font-family: var(--body-font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  position: fixed;
  inset: 0;
}

/* ===== 视口：等比缩放 + iPhone 安全区 ===== */
#viewport {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0b0a08;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
#app {
  position: relative;
  width: 750px;
  height: 1334px;
  flex: 0 0 auto;
  transform-origin: center center;
  overflow: hidden;
  background: #15120f;
  box-shadow: 0 0 90px rgba(0, 0, 0, .8);
}

/* 全局纸张肌理 / 斑驳 / 暗角（覆盖在所有页面之上，不拦截点击） */
#app::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 95;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='240'%20height='240'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.85'%20numOctaves='2'%20stitchTiles='stitch'/%3E%3CfeColorMatrix%20type='saturate'%20values='0'/%3E%3C/filter%3E%3Crect%20width='100%25'%20height='100%25'%20filter='url(%23n)'/%3E%3C/svg%3E");
}
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 96;
  pointer-events: none;
  box-shadow: inset 0 0 150px 34px rgba(20, 14, 8, .5);
}

/* ===== 页面容器与横向翻页转场 ===== */
.page {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  z-index: 1;
  transition: transform .72s cubic-bezier(.45, .05, .25, 1), opacity .72s ease;
  will-change: transform, opacity;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.page.is-active { display: block; }
.page > * { position: absolute; }

/* ===== 全局固定控件：静音（56×56，热区 88×88） ===== */
.mute-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  z-index: 300;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sand);
  background: rgba(28, 21, 14, .55);
  border: 1.5px solid rgba(232, 220, 196, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4), 0 0 14px rgba(232, 200, 120, .18);
  transition: transform .25s ease, background .25s ease, color .25s ease;
}
.mute-btn::after { content: ''; position: absolute; inset: -16px; }
.mute-btn:hover { transform: scale(1.06); background: rgba(50, 36, 22, .7); }
.mute-btn:active { transform: scale(.94); }
.mute-btn.is-muted { color: rgba(232, 220, 196, .45); }
.mute-btn svg { width: 30px; height: 30px; }

/* ===== 全局固定控件：返回首页 ===== */
.home-btn {
  position: absolute;
  top: 24px;
  left: 24px;
  height: 60px;
  padding: 0 22px 0 18px;
  z-index: 210;
  display: none;
  align-items: center;
  gap: 8px;
  border-radius: 30px;
  font-family: var(--title-font);
  font-size: 24px;
  letter-spacing: 2px;
  color: var(--sand);
  background: rgba(28, 21, 14, .55);
  border: 1.5px solid rgba(232, 220, 196, .5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  transition: transform .25s ease, background .25s ease;
}
.home-btn.is-show { display: flex; }
.home-btn::before { content: '⌂'; font-size: 24px; line-height: 1; }
.home-btn:hover { transform: translateY(-2px); background: rgba(50, 36, 22, .72); }
.home-btn:active { transform: scale(.95); }

/* ===== 全局固定控件：记忆图鉴栏（左侧，避免遮挡右侧内容） ===== */
.codex {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 210;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 58px;
  padding: 16px 0 14px;
  border-radius: 16px;
  background: rgba(28, 21, 14, .58);
  border: 1.5px solid rgba(232, 220, 196, .45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
  transition: transform .25s ease, background .25s ease;
}
.codex.is-show { display: flex; }
.codex:hover { transform: translateY(-50%) scale(1.05); background: rgba(50, 36, 22, .72); }
.codex .codex-tab {
  writing-mode: vertical-rl;
  letter-spacing: 5px;
  font-family: var(--title-font);
  font-size: 22px;
  color: var(--sand);
}
.codex .codex-num {
  font-family: var(--title-font);
  font-size: 22px;
  color: var(--gold);
  background: rgba(0, 0, 0, .32);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.codex .codex-total { font-size: 16px; color: var(--celadon-light); letter-spacing: 1px; }

/* ===== 国风弹窗 ===== */
.modal {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, .74);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  padding: 24px;
}
.modal.open { display: flex; animation: fadeIn .35s ease; }
.modal-card {
  position: relative;
  width: 600px;
  max-width: 94%;
  max-height: 88%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, #efe6d2, #e0d2b4);
  border: 2px solid var(--ochre-dark);
  border-radius: 14px;
  padding: 56px 40px 36px;
  box-shadow: 0 0 0 1px rgba(122, 85, 48, .4), 0 20px 60px rgba(0, 0, 0, .65);
  animation: popIn .45s cubic-bezier(.2, .9, .3, 1.25);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.modal-card.is-wide {
  width: 100%;
  max-width: 700px;
  padding: 52px 24px 24px;
}
.modal-card::before, .modal-card::after {
  content: '';
  position: absolute;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ochre-deep);
}
.modal-card::before { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.modal-card::after { bottom: 10px; right: 10px; border-left: none; border-top: none; }
.modal-title {
  flex: 0 0 auto;
  font-family: var(--title-font);
  font-size: 34px;
  text-align: center;
  color: var(--ochre-deep);
  letter-spacing: 4px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(122, 85, 48, .4);
}
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  font-size: 26px;
  line-height: 1.85;
  color: var(--ink);
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  -webkit-overflow-scrolling: touch;
}
.modal-body p { margin-bottom: 12px; }
.modal-body strong { color: var(--ochre-deep); }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  z-index: 2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  color: var(--ochre-deep);
  background: rgba(122, 85, 48, .12);
  transition: background .2s;
}
.modal-close::after { content: ''; position: absolute; inset: -12px; }
.modal-close:hover { background: rgba(122, 85, 48, .26); }

/* ===== Toast ===== */
.toast {
  position: absolute;
  left: 50%;
  bottom: 200px;
  z-index: 600;
  transform: translateX(-50%) scale(.92);
  opacity: 0;
  pointer-events: none;
  padding: 16px 30px;
  border-radius: 30px;
  max-width: 620px;
  text-align: center;
  font-family: var(--title-font);
  font-size: 26px;
  letter-spacing: 2px;
  color: var(--sand);
  background: rgba(28, 21, 14, .9);
  border: 1.5px solid rgba(232, 200, 120, .6);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55);
  transition: opacity .3s ease, transform .3s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) scale(1); }

/* ===== 图鉴卡片 ===== */
.codex-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  text-align: left;
}
.codex-card {
  border: 1.5px solid var(--ochre-dark);
  border-radius: 10px;
  padding: 16px 14px;
  text-align: center;
  background: rgba(255, 255, 255, .35);
  transition: transform .25s ease;
}
.codex-card.unlocked {
  background: linear-gradient(160deg, #f3ead5, #e3d2af);
  box-shadow: 0 0 16px rgba(232, 200, 120, .45);
}
.codex-card.locked { filter: grayscale(.7); opacity: .55; }
.codex-card .codex-icon { font-size: 30px; color: var(--gold-deep); margin-bottom: 6px; }
.codex-card .codex-name {
  font-family: var(--title-font);
  font-size: 25px;
  color: var(--ochre-deep);
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.codex-card .codex-desc { font-size: 18px; line-height: 1.6; color: var(--celadon-deep); }
.codex-card .codex-page { margin-top: 8px; font-size: 17px; color: var(--ochre-dark); }

/* ===== 石块按钮 ===== */
.stone-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--title-font);
  letter-spacing: 3px;
  color: var(--ink);
  background: radial-gradient(ellipse at 35% 28%, #e6d3a8, #c8a26b 55%, #9c7440 100%);
  border: 2px solid #7a5530;
  border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%;
  box-shadow:
    inset 0 3px 10px rgba(255, 245, 220, .6),
    inset 0 -6px 14px rgba(80, 52, 24, .5),
    0 8px 20px rgba(0, 0, 0, .42),
    0 0 18px rgba(232, 200, 120, .22);
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .28s ease, filter .28s ease, box-shadow .28s ease;
  pointer-events: auto;
  cursor: pointer;
}
.stone-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='120'%20height='60'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='1.2'%20numOctaves='2'/%3E%3C/filter%3E%3Crect%20width='100%25'%20height='100%25'%20filter='url(%23n)'%20opacity='.22'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  opacity: .55;
}
.stone-btn:hover {
  transform: translateY(-4px);
  filter: brightness(1.07);
  box-shadow:
    inset 0 3px 10px rgba(255, 245, 220, .7),
    inset 0 -6px 14px rgba(80, 52, 24, .45),
    0 14px 26px rgba(0, 0, 0, .48),
    0 0 26px rgba(232, 200, 120, .42);
}
.stone-btn:active { transform: translateY(-1px) scale(.98); }
.stone-btn:disabled { filter: grayscale(.55) brightness(.75); cursor: not-allowed; }

/* ===== 篇章页公共排版 ===== */
.chapter-title {
  left: 40px;
  top: 112px;
  width: 428px;
  padding: 18px 24px 20px;
  background: rgba(26, 19, 13, .56);
  border: 1.5px solid rgba(232, 220, 196, .42);
  border-left: 5px solid var(--gold);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 12;
}
.chapter-title h2 {
  font-family: var(--title-font);
  font-size: 44px;
  letter-spacing: 6px;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .6);
  word-break: break-word;
}
.chapter-title .title-sub {
  margin-top: 8px;
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--celadon-light);
}
.chapter-body {
  left: 40px;
  right: 96px;
  bottom: 322px;
  z-index: 12;
  padding: 14px 20px;
  font-size: 25px;
  line-height: 1.85;
  color: var(--sand);
  background: rgba(24, 18, 12, .5);
  border-left: 3px solid rgba(232, 200, 120, .45);
  border-radius: 6px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  text-shadow: 0 1px 4px rgba(0, 0, 0, .65);
}
.chapter-hint {
  left: 0;
  right: 0;
  bottom: 268px;
  z-index: 12;
  padding: 0 40px;
  text-align: center;
  font-size: 22px;
  letter-spacing: 2px;
  color: #f2d492;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, .85);
  animation: hintPulse 2.6s ease-in-out infinite;
}

/* 继续前行：完成交互后出现 */
.continue-btn {
  left: 215px;
  right: 215px;
  height: 84px;
  bottom: 178px;
  z-index: 20;
  font-size: 29px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
  transition: opacity .55s ease, transform .55s ease;
}
.continue-btn.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ===== 篇章底部导航（上一页 / 进度 / 下一页） ===== */
.chapter-nav {
  left: 24px;
  right: 24px;
  bottom: 28px;
  height: 76px;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.chapter-nav .nav-btn {
  pointer-events: auto;
  width: 132px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 31px;
  font-family: var(--title-font);
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--sand);
  background: rgba(28, 21, 14, .55);
  border: 1.5px solid rgba(232, 220, 196, .42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  transition: transform .2s ease, background .2s ease, opacity .2s ease;
}
.chapter-nav .nav-btn:hover { background: rgba(56, 40, 24, .75); transform: translateY(-2px); }
.chapter-nav .nav-btn:active { transform: scale(.95); }
.chapter-nav .nav-btn[disabled] { opacity: .35; pointer-events: none; }
.chapter-nav .chapter-progress {
  font-family: var(--title-font);
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--sand);
  padding: 6px 18px;
  border-radius: 24px;
  background: rgba(28, 21, 14, .45);
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
}

/* ===== 通用动画 ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: scale(1); } }
@keyframes hintPulse { 0%, 100% { opacity: .58; } 50% { opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes twinkle { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.25); } }
@keyframes ripple { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(3); opacity: 0; } }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 12px 2px rgba(232, 200, 120, .5); }
  50% { box-shadow: 0 0 26px 8px rgba(232, 200, 120, .85); }
}
.anim-shake { animation: shake .38s ease; }
