/* ============================================================
   布虎闲语 · 绘本样式
   色调参考：暖橙黄为主，紫蓝冷调点缀，写意笔触氛围
   ============================================================ */

:root {
  --warm-orange: #e8a33d;
  --warm-deep: #c85a2a;
  --warm-red: #d94f3a;
  --warm-yellow: #f2c14e;
  --warm-cream: #f7e4b8;
  --cool-purple: #4a3a6b;
  --cool-blue: #3b4a6b;
  --ink-brown: #5a3a2a;
  --paper: #f5e6c8;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "KaiTi", "楷体", "STKaiti", "Noto Serif SC", serif;
  color: var(--ink-brown);
  /* 移动端防误触：禁缩放、禁长按选中、禁点击高亮、禁页面回弹 */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  /* 适配全面屏/刘海屏安全区 */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ============== 全局写意背景 ============== */
.bg-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  /* 暖色调径向渐变，模拟烛光/夕照氛围 */
  background:
    radial-gradient(ellipse at 20% 30%, rgba(242, 193, 78, 0.55) 0%, transparent 45%),
    radial-gradient(ellipse at 80% 70%, rgba(217, 79, 58, 0.35) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(74, 58, 107, 0.4) 0%, transparent 55%),
    linear-gradient(135deg, #3b2a1a 0%, #5a3a2a 30%, #c85a2a 60%, #e8a33d 100%);
  filter: saturate(1.1);
}

/* 笔触/噪点纹理层，模拟油画质感 */
.bg-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ============== 书本容器 ============== */
.book-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2500px;
}

.book {
  position: relative;
  /* 固定 16:9：宽度受视口宽/高同时约束，保证任何窗口下比例不变 */
  width: min(92vw, 152.9vh, 1180px);
  aspect-ratio: 16 / 9;
  transform-style: preserve-3d;
  /* 开场：立体倾斜 → 旋转摆正呈现封面 */
  animation: book-intro 1.7s cubic-bezier(0.25, 0.9, 0.35, 1) both;
}

/* 开场动画期间锁定书页交互，避免翻到一半被点击 */
.book.intro-lock {
  pointer-events: none;
}

/* turn.js 初始化前强制隐藏所有页面（包括 DOM 展平前的 .sheet），防止结局页闪出来 */
.book.book-loading .page,
.book.book-loading .sheet {
  visibility: hidden;
}

@keyframes book-intro {
  0% {
    opacity: 0;
    transform: rotateY(-52deg) rotateX(14deg) scale(0.78);
  }
  60% {
    opacity: 1;
    transform: rotateY(-8deg) rotateX(2deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: rotateY(0deg) rotateX(0deg) scale(1);
  }
}

/* ============== turn.js 单页翻折模式：纸张由 turn.js 自动管理 3D transform 与层级 ============== */
.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;          /* 超出部分不裁剪 */
  transform-origin: left center;
  background: #ffffff;        /* 翻页时露出白色纸背 */
  backface-visibility: hidden;
}

/* turn.js 内部页面：翻页时超出 book 边界的部分不裁剪 */
#book {
  overflow: visible !important;
}
#book .turn-page,
#book .turn-page-wrapper {
  overflow: visible !important;
}

.page-inner {
  position: absolute;
  inset: 0;
  padding: 36px 44px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at top left, rgba(247, 228, 184, 0.95) 0%, rgba(232, 163, 61, 0.85) 100%);
  border: 1px solid rgba(90, 58, 42, 0.2);
  box-shadow: inset 0 0 60px rgba(90, 58, 42, 0.15);
  display: flex;
  flex-direction: column;
}

/* 书页纸张纹理 */
.page-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.08'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* 书脊阴影统一由 .page-inner::after 提供 */
.page-inner::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 30px;
  background: linear-gradient(to right, rgba(0,0,0,0.2), transparent);
  pointer-events: none;
}

/* ============== 封面 / 封底 ============== */
.cover-page {
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.55) 100%),
    url("../images/cover-new.jpeg") center/cover no-repeat !important;
  color: var(--warm-cream);
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* 全屏图片页（图片比例与页面一致，cover 完美铺满无白边无裁剪）
   背景图由页面本身的内联 background-image 提供，路径相对 index.html 解析，
   这样 file:// 与本地服务器下都能正确加载 */
.full-image-page {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  padding: 0 !important;
  border: none !important;
  justify-content: flex-end;
}
.full-image-caption {
  position: relative;
  z-index: 2;
  padding: 28px 36px 32px;
  color: #fff;
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 2;
  text-indent: 2em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  letter-spacing: 0.06em;
}
.full-image-page::before { display: none; }

/* ============== 扉页 ============== */
.flyleaf {
  background:
    radial-gradient(ellipse at center, rgba(247, 228, 184, 0.9) 0%, rgba(232, 163, 61, 0.7) 100%) !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flyleaf-content {
  text-align: center;
  color: var(--ink-brown);
}
.flyleaf-line {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  line-height: 2.4;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}
.flyleaf-line:last-child {
  font-size: 0.9rem;
  opacity: 0.7;
  margin-top: 20px;
}

.cover-page::before { opacity: 0.15; }

.book-title {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  letter-spacing: 0.3em;
  margin-bottom: 18px;
  color: var(--warm-yellow);
  text-shadow: 2px 3px 8px rgba(0,0,0,0.5);
  font-weight: bold;
}

.book-subtitle {
  font-size: clamp(0.9rem, 1.6vw, 1.2rem);
  letter-spacing: 0.15em;
  opacity: 0.85;
}

.cover-hint {
  position: absolute;
  bottom: 30px;
  right: 40px;
  font-size: 0.9rem;
  opacity: 0.6;
  animation:
    hint-fade-in 0.6s ease-out 1.6s backwards,
    hint-blink 2s ease-in-out 2.2s infinite;
}

@keyframes hint-fade-in {
  from { opacity: 0; }
  to { opacity: 0.6; }
}

@keyframes hint-blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.9; }
}

/* 布老虎剪影（封面装饰，纯 CSS 写意） */
.cover-art {
  width: 160px;
  height: 160px;
  margin-bottom: 30px;
  position: relative;
}

.tiger-silhouette {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 40%, var(--warm-yellow) 0%, var(--warm-red) 70%, var(--warm-deep) 100%);
  border-radius: 45% 45% 40% 40%;
  position: relative;
  box-shadow: 0 0 40px rgba(242, 193, 78, 0.5);
}

.tiger-silhouette::before,
.tiger-silhouette::after {
  content: "";
  position: absolute;
  top: 20%;
  width: 18%;
  height: 22%;
  background: var(--warm-yellow);
  border-radius: 50%;
}
.tiger-silhouette::before { left: 18%; box-shadow: 0 8px 0 var(--warm-deep); }
.tiger-silhouette::after { right: 18%; box-shadow: 0 8px 0 var(--warm-deep); }

.tiger-silhouette.small {
  width: 80px; height: 80px;
  margin: 20px auto;
}

/* 封底 */
.back-text {
  font-size: 2.2rem;
  letter-spacing: 0.3em;
  color: var(--warm-yellow);
  margin-bottom: 16px;
}
.back-sub {
  font-size: 1rem;
  opacity: 0.8;
  margin-bottom: 30px;
  line-height: 1.8;
}

/* ============== 故事页 ============== */
.page-title {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  color: var(--warm-deep);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px dashed rgba(200, 90, 42, 0.4);
  letter-spacing: 0.1em;
}

.story-text {
  font-size: clamp(0.95rem, 1.3vw, 1.15rem);
  line-height: 2;
  color: var(--ink-brown);
  text-indent: 2em;
  margin-bottom: 20px;
}

.story-text p {
  margin-bottom: 14px;
}

.illustration-area {
  flex: 1;
  min-height: 180px;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(90, 58, 42, 0.25);
}

/* ============== 360 全景容器 ============== */
.pano-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 180px;
  background: linear-gradient(135deg, #3b2a1a, #6b3a2a);
  border-radius: 12px;
  cursor: grab;
}

.pano-container:active { cursor: grabbing; }

.pano-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

.pano-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: rgba(255, 240, 200, 0.85);
  background: rgba(0,0,0,0.35);
  padding: 3px 12px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
}

/* ============== 游戏页 ============== */
/* 游戏页与绘本图一样整幅铺满，不留内边距，视觉上融进书页 */
.game-page {
  padding: 0 !important;
  overflow: hidden;
}

.game-intro {
  font-size: 1rem;
  margin-bottom: 16px;
  color: var(--ink-brown);
  line-height: 1.7;
}

.game-area {
  flex: 1;
  min-height: 260px;
  background: rgba(247, 228, 184, 0.6);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

/* 游戏二：找出不同的布老虎 */
.diff-game-info {
  font-size: 1.05rem;
  color: var(--ink-brown);
}

.diff-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: min(100%, 470px);
  padding: 10px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 12px;
}

.diff-cell {
  aspect-ratio: 1;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease;
  padding: 0;
}

.diff-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.diff-cell:hover {
  transform: scale(1.06);
}

.diff-cell.wrong {
  border-color: #d94f3a;
  animation: diff-shake 0.3s ease;
}

.diff-cell.found {
  border-color: #5b8c5a;
  box-shadow: 0 0 14px rgba(91, 140, 90, 0.8);
  transform: scale(1.1);
}

@keyframes diff-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 结局选择按钮（全图页底部居中） */
.ending-choice {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 86%;
  z-index: 5;
}

.ending-btn {
  font-size: clamp(0.95rem, 1.6vw, 1.2rem);
  padding: 12px 26px;
  letter-spacing: 2px;
  line-height: 1.7;
  white-space: normal;
  width: 100%;
  max-width: 640px;
  border-radius: 999px;
  color: #fdf6ec;
  background: rgba(30, 18, 10, 0.62);
  border: 1.5px solid rgba(242, 193, 78, 0.85);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55), 0 0 14px rgba(242, 193, 78, 0.18);
  backdrop-filter: blur(2px);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.ending-btn:hover {
  transform: translateY(-2px);
  background: rgba(60, 34, 16, 0.78);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6), 0 0 22px rgba(242, 193, 78, 0.35);
}

/* 结束阅读遮罩（默认绝对不可见，JS 初始化完成后才允许显示） */
.reading-end {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(12, 7, 4, 0.9);
  color: var(--warm-cream);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.reading-end.show {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.reading-end-text {
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: var(--warm-yellow);
  text-shadow: 0 0 24px rgba(242, 193, 78, 0.45);
}

.reading-end-sub {
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  opacity: 0.65;
}

/* 第 1 页：文字区域音频热区（覆盖图中文字，点击播放录音） */
.audio-hotspot {
  position: absolute;
  top: 9%;
  left: 33%;
  width: 56%;
  height: 13%;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  z-index: 5;
  transition: box-shadow 0.3s;
}

.audio-hotspot:hover {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45);
}

/* 文字位于图片底部的热区变体 */
.audio-hotspot.at-bottom {
  top: auto;
  bottom: 2%;
  left: 25%;
  width: 50%;
  height: 16%;
}

/* 文字位于图片中部的热区变体（单行） */
.audio-hotspot.at-mid {
  top: 29%;
  left: 17%;
  width: 67%;
  height: 13%;
}

/* 文字位于图片上部、多行宽幅的热区变体 */
.audio-hotspot.at-topwide {
  top: 26%;
  left: 4%;
  width: 93%;
  height: 22%;
}

/* 文字位于图片顶部的热区变体（多行） */
.audio-hotspot.at-top {
  top: 7%;
  left: 19%;
  width: 79%;
  height: 23%;
}

/* 文字位于图片左上角的热区变体（第 8 页） */
.audio-hotspot.at-topleft {
  top: 2%;
  left: 6%;
  width: 48%;
  height: 18%;
}

/* 文字位于图片中右部的热区变体（第 8 页第二处文字） */
.audio-hotspot.at-rightmid {
  top: 53.5%;
  left: 38%;
  width: 51%;
  height: 11.5%;
}

/* 文字位于图片上方居中、两行的热区变体（第 10 页） */
.audio-hotspot.at-topcenter {
  top: 2.5%;
  left: 32%;
  width: 62%;
  height: 14%;
}

/* 文字位于图片中部、单行的热区变体（第 11 页） */
.audio-hotspot.at-midline {
  top: 27.5%;
  left: 22%;
  width: 66%;
  height: 7.2%;
}

/* 文字位于图片下方居中、多行的热区变体（第 12 页） */
.audio-hotspot.at-bottomcenter {
  top: auto;
  bottom: 13%;
  left: 31%;
  width: 42%;
  height: 14%;
}

/* 文字位于图片左上角的热区变体（第 15 页上方文字） */
.audio-hotspot.at-topleft {
  top: 9.5%;
  left: 5%;
  width: 37%;
  height: 15%;
}

/* 文字位于图片左下角的热区变体（第 15 页下方文字） */
.audio-hotspot.at-bottomleft {
  top: auto;
  bottom: 4%;
  left: 13%;
  width: 34%;
  height: 13.5%;
}

/* 播放中：柔和呼吸光圈提示 */
.audio-hotspot.playing {
  animation: audio-pulse 1.6s ease-in-out infinite;
}

@keyframes audio-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
  50% { box-shadow: 0 0 14px 4px rgba(255, 255, 255, 0.75); }
}

/* 游戏一：上色 */
.color-palette {
  display: flex;
  gap: 14px;
}
.color-chip {
  width: 50px; height: 50px;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  transition: transform 0.2s;
}
.color-chip:hover { transform: scale(1.12); }

.shoe-outline {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.shoe-part {
  width: 90px;
  height: 90px;
  border: 2px dashed var(--warm-deep);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.4);
  transition: all 0.3s;
}
.shoe-part.filled {
  border-style: solid;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

/* 游戏二：拼图 */
.puzzle-board {
  display: grid;
  grid-template-columns: repeat(3, 70px);
  grid-template-rows: repeat(2, 70px);
  gap: 8px;
  margin-bottom: 10px;
}
.puzzle-slot {
  border: 2px dashed var(--cool-blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.4);
  transition: all 0.3s;
}
.puzzle-slot.correct {
  border-style: solid;
  background: rgba(91, 140, 90, 0.4);
}
.puzzle-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.piece {
  padding: 6px 12px;
  border: 2px solid var(--warm-deep);
  border-radius: 20px;
  background: var(--warm-cream);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.2s;
}
.piece:hover { background: var(--warm-yellow); }
.piece.used { opacity: 0.3; pointer-events: none; }

/* 游戏三：打老鼠 */
.mouse-field { text-align: center; width: 100%; }
.mouse-game-info {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 12px;
  font-size: 1rem;
}
.mouse-arena {
  width: 100%;
  max-width: 400px;
  height: 200px;
  margin: 0 auto 14px;
  background: radial-gradient(ellipse at center, #c85a2a, #5a2a1a);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  border: 3px solid var(--ink-brown);
}
.mouse {
  position: absolute;
  font-size: 1.8rem;
  cursor: pointer;
  animation: mouse-pop 0.3s ease;
}
/* 布老虎图片样式 */
.mouse img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
@keyframes mouse-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.btn {
  padding: 10px 26px;
  background: var(--warm-deep);
  color: var(--warm-cream);
  border: none;
  border-radius: 24px;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
.btn:hover { background: var(--warm-red); transform: translateY(-2px); }

.game-feedback {
  min-height: 24px;
  text-align: center;
  font-size: 0.95rem;
  margin-top: 10px;
  color: var(--warm-deep);
}

/* 尾声 */
.ending { align-items: center; text-align: center; }
.ending .story-text { text-indent: 0; }
.ending-line {
  margin-top: 24px;
  font-size: 1.2rem;
  letter-spacing: 0.3em;
  color: var(--warm-deep);
}

/* 结束页（布老虎装饰） */
.ending-page {
  align-items: center;
  justify-content: center;
}
.ending-page .ending-art {
  width: 180px;
  height: 180px;
}
.ending-page .ending-art .tiger-silhouette {
  width: 100%;
  height: 100%;
}

/* ============== 翻页控制 ============== */
.page-controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 100;
  animation: controls-fade-in 0.6s ease-out 1.5s backwards;
}

@keyframes controls-fade-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.nav-btn {
  padding: 8px 20px;
  background: rgba(90, 58, 42, 0.7);
  color: var(--warm-cream);
  border: 1px solid rgba(247, 228, 184, 0.3);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}
.nav-btn:hover:not(:disabled) {
  background: rgba(200, 90, 42, 0.8);
}
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-indicator {
  color: var(--warm-cream);
  font-size: 0.9rem;
  background: rgba(0,0,0,0.3);
  padding: 5px 16px;
  border-radius: 12px;
}

/* 滚动条美化 */
.page-inner::-webkit-scrollbar { width: 6px; }
.page-inner::-webkit-scrollbar-thumb {
  background: rgba(200, 90, 42, 0.4);
  border-radius: 3px;
}

/* ============== 缝补布老虎游戏（第 7 页） ============== */
.stitch-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stitch-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

/* 可点击的缝补点 */
.stitch-point {
  position: absolute;
  width: 8%;
  height: 8%;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
  z-index: 3;
}

.stitch-point:hover {
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 16px 4px rgba(255, 255, 255, 0.5);
}

/* 缝补中的脉冲动画 */
.stitch-point.stitching {
  animation: stitch-pulse 0.6s ease;
}

@keyframes stitch-pulse {
  0% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 0 0 rgba(200, 90, 42, 0.6); }
  50% { transform: translate(-50%, -50%) scale(1.3); box-shadow: 0 0 20px 8px rgba(200, 90, 42, 0.4); }
  100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 0 0 rgba(200, 90, 42, 0); }
}

/* 已缝好的状态 */
.stitch-point.stitched {
  background: rgba(200, 90, 42, 0.5);
  box-shadow: 0 0 12px 3px rgba(200, 90, 42, 0.4);
  cursor: default;
  pointer-events: none;
}

.stitch-point.stitched::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 3px;
  background: var(--warm-red);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(200, 90, 42, 0.6);
}

/* 游戏 UI */
.stitch-ui {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 4;
  background: rgba(0, 0, 0, 0.45);
  padding: 12px 28px;
  border-radius: 16px;
  backdrop-filter: blur(4px);
}

.stitch-hint {
  color: var(--warm-cream);
  font-size: 0.95rem;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.stitch-progress {
  color: var(--warm-yellow);
  font-size: 1rem;
  font-weight: bold;
}

.stitch-complete {
  color: #7bc47f;
  font-size: 1.1rem;
  font-weight: bold;
  margin-top: 6px;
  animation: complete-glow 1s ease infinite alternate;
}

@keyframes complete-glow {
  from { text-shadow: 0 0 6px rgba(123, 196, 127, 0.4); }
  to { text-shadow: 0 0 16px rgba(123, 196, 127, 0.8); }
}

/* ============== 穿针游戏（第 15 页） ============== */
#game-thread {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.thread-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.thread-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.thread-tip {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  background: rgba(0, 0, 0, 0.45);
  color: var(--warm-cream);
  padding: 10px 24px;
  border-radius: 14px;
  font-size: 0.95rem;
  letter-spacing: 1px;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  pointer-events: none;
}

.thread-tip.fail { color: #ffb4a2; }
.thread-tip.success {
  color: #7bc47f;
  font-weight: bold;
  animation: complete-glow 1s ease infinite alternate;
}

/* ============== 响应式 ============== */

/* 竖屏手机专属（宽 < 高，窄屏） */
@media (max-width: 900px) and (orientation: portrait) {
  .book-wrapper {
    flex-direction: column;
    padding-top: 6px;
    padding-bottom: 6px;
    height: 100dvh;
    overflow: hidden;
    gap: 4px;
  }

  /* 内容必须一屏放得下，禁止滚动 */
  .page-inner { padding: 10px 10px; overflow-y: hidden; }
  .game-page { overflow: hidden !important; }
  .cover-art { width: 72px; height: 72px; }
  .puzzle-board { grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(2, 42px); }

  .book { aspect-ratio: 16 / 9; flex-shrink: 0; }

  .page-controls {
    position: relative;
    bottom: auto; left: auto; transform: none;
    margin-top: 0;
    padding-bottom: env(safe-area-inset-bottom);
    gap: 10px;
    animation: none;
    flex-shrink: 0;
    height: 32px;
  }
  .nav-btn { padding: 4px 12px; font-size: 0.72rem; }
  .page-indicator { font-size: 0.72rem; padding: 2px 10px; }

  /* === 缝补游戏：顶部极薄单行提示，背景透明，不挡关键点击区 === */
  .stitch-container { padding-top: 28px; box-sizing: border-box; }
  .stitch-ui {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: auto;
    padding: 3px 8px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    line-height: 1.1;
    background: rgba(0, 0, 0, 0.38);
    height: 24px;
  }
  .stitch-hint {
    font-size: 0.6rem; margin-bottom: 0; letter-spacing: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 55%;
  }
  .stitch-progress { font-size: 0.68rem; font-weight: bold; white-space: nowrap; }
  .stitch-complete { font-size: 0.7rem; margin-top: 0; }
  .stitch-point { min-width: 36px; min-height: 36px; }

  /* === 找花布游戏：标题、说明文字、网格全都极度紧凑 === */
  .page-title { font-size: 0.88rem; margin-bottom: 4px; padding-bottom: 3px; }
  .game-intro { font-size: 0.65rem; margin-bottom: 4px; line-height: 1.3; }
  .game-area { padding: 6px; gap: 4px; min-height: 0; flex: 0 1 auto; }
  .diff-game-info { font-size: 0.68rem; }
  .diff-board { gap: 3px; padding: 4px; width: 100%; }
  .game-feedback { font-size: 0.65rem; margin-top: 2px; min-height: 10px; }
  .btn { padding: 4px 14px; font-size: 0.72rem; }

  /* === 穿针游戏 === */
  .thread-tip {
    bottom: auto; top: 0;
    padding: 3px 8px;
    font-size: 0.62rem;
    white-space: nowrap;
    max-width: 88%;
    line-height: 1.2;
  }

  /* === 结局选择按钮 === */
  .ending-btn { font-size: 0.72rem; padding: 6px 10px; letter-spacing: 0.5px; line-height: 1.5; }
  .ending-choice { gap: 6px; width: 92%; bottom: 16%; }
  }

  /* 全书完遮罩 */
  .reading-end-text {
    font-size: 1.4rem;
  }
  .reading-end-sub {
    font-size: 0.78rem;
  }
}

/* 横屏手机（landscape）和小桌面平板：保持原有 16:9 但缩小控件 */
@media (max-width: 900px) and (orientation: landscape) {
  .page-inner { padding: 16px 14px; }
  .cover-art { width: 90px; height: 90px; }
  .page-controls { bottom: 6px; gap: 10px; padding-bottom: env(safe-area-inset-bottom); }
  .nav-btn { padding: 5px 14px; font-size: 0.78rem; }
  .page-indicator { font-size: 0.75rem; padding: 3px 12px; }
  .stitch-ui { bottom: auto; top: 8px; padding: 6px 14px; }
  .stitch-hint { font-size: 0.72rem; margin-bottom: 2px; }
  .stitch-progress { font-size: 0.78rem; }
  .stitch-point { min-width: 44px; min-height: 44px; }
  .thread-tip { bottom: auto; top: 8px; padding: 6px 12px; font-size: 0.75rem; max-width: 88%; white-space: normal; }
  .ending-btn { font-size: 0.82rem; padding: 8px 14px; }
  .ending-choice { gap: 8px; width: 90%; bottom: 10%; }
}

/* 超小屏幕兼容（iPhone SE 之类） */
@media (max-width: 380px) and (orientation: portrait) {
  .nav-btn { padding: 4px 10px; font-size: 0.7rem; }
  .page-indicator { font-size: 0.7rem; padding: 2px 10px; }
  .stitch-hint, .thread-tip { font-size: 0.68rem; }
  .stitch-point { min-width: 38px; min-height: 38px; }
  .ending-btn { font-size: 0.75rem; padding: 6px 12px; }
}
