:root {
  --paper: #EDE6D8;
  --paper-deep: #E2D8C4;
  --screen: #FBF8F1;
  --ink: #4A4038;
  --ink-soft: #8A7E6E;
  --green: #7BA05B;
  --green-deep: #5E7E42;
  --card: #F3ECDC;
  --shadow: rgba(74, 64, 56, 0.18);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
#stage {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* 旁白（全局浮层） */
#narration {
  position: fixed;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 460px;
  text-align: center;
  font-family: "STKaiti", "KaiTi", "楷体", "PingFang SC", serif;
  font-size: 19px;
  line-height: 1.7;
  color: var(--ink);
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 1.1s ease;
  pointer-events: none;
  padding: 0 20px;
  z-index: 50;
}
#narration.show { opacity: 1; }

/* 手机 */
.phone {
  width: 360px;
  height: 720px;
  perspective: 1600px;
}
.phone-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.6s cubic-bezier(.6,.02,.3,1);
}
.phone-inner.flipped { transform: rotateY(180deg); }
.phone-face {
  position: absolute;
  inset: 0;
  border-radius: 44px;
  background: #2c2a27;
  padding: 14px;
  backface-visibility: hidden;
  box-shadow: 0 24px 60px var(--shadow);
  overflow: hidden;
}
.phone-face.back { transform: rotateY(180deg); }
.screen {
  width: 100%; height: 100%;
  border-radius: 32px;
  background: var(--screen);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 状态栏 */
.statusbar {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px;
  color: var(--ink-soft);
  flex: none;
}

.scene { flex: 1; display: none; flex-direction: column; }
.scene.active { display: flex; }

/* 桌面 */
.desktop {
  flex: 1;
  padding: 18px 22px 30px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: min-content;
  gap: 18px 12px;
  align-content: start;
}
.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
  border-radius: 12px;
  transition: transform .12s ease;
}
.app-icon:active { transform: scale(.92); }
.app-glyph {
  width: 54px; height: 54px;
  border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  color: #fff;
  box-shadow: 0 3px 8px var(--shadow);
}
.app-label { font-size: 13px; color: #6f6453; font-weight: 500; letter-spacing: .3px; }
/* 目标“聊聊”故意藏：小、不显眼 */
.app-icon.target .app-glyph { width: 46px; height: 46px; font-size: 24px; background: var(--green); margin-top: 8px; }
.app-icon.target .app-label { font-size: 12px; color: #8a7e6e; font-weight: 500; letter-spacing: .2px; }

/* 聊天列表 */
.app-header {
  flex: none;
  padding: 12px 18px;
  font-size: 17px;
  font-weight: 500;
  border-bottom: 1px solid #ece3d2;
  display: flex; align-items: center; gap: 8px;
}
.back-btn { font-size: 18px; color: var(--green-deep); cursor: pointer; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  cursor: pointer;
  border-bottom: 1px solid #f1ead9;
}
.chat-row:active { background: #f3ecdc; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; flex: none;
}
.chat-meta { flex: 1; min-width: 0; }
.chat-name { font-size: 15px; }
.chat-prev { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 目标孙子：头像小、混在中间 */
.chat-row.target .avatar { width: 36px; height: 36px; font-size: 18px; }
.chat-row.target .chat-name { font-size: 14px; color: #6f6453; font-weight: 500; }

/* 对话页 */
.bubbles { flex: 1; padding: 20px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.bubble {
  max-width: 76%; padding: 11px 14px; border-radius: 14px; font-size: 15px; line-height: 1.6;
}
.bubble.them { background: #e7e0cf; align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--green); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.call-bar {
  flex: none; padding: 14px 18px 22px; border-top: 1px solid #ece3d2;
  display: flex; align-items: center; justify-content: center; gap: 26px;
}
.call-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; color: var(--ink-soft);
}
.call-btn .ring {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.call-btn.voice .ring { background: #e3dccb; }
.call-btn.video .ring { background: var(--green); color: #fff; width: 48px; height: 48px; font-size: 22px; }
.call-btn .cap { font-size: 12px; }

/* 通话中 */
.calling {
  flex: 1; background: #20201e; color: #e9e3d6;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
}
.calling .who { font-size: 19px; }
.calling .spin {
  width: 64px; height: 64px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.18); border-top-color: var(--green);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.calling .tip { font-size: 14px; color: #9a9384; }

/* 接通 */
.connected {
  flex: 1; background: #2a2a28; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.face {
  width: 180px; height: 180px; border-radius: 28px;
  background: radial-gradient(circle at 50% 40%, #ffd9a8, #e8b078);
  display: flex; align-items: center; justify-content: center; font-size: 92px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: breathe 3.4s ease-in-out infinite;
}
@keyframes breathe { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.03);} }
.connected .who { font-size: 17px; color: #d9d2c4; }
.hang { margin-top: 6px; font-size: 12px; color: #9a9384; }

/* 纸条（背面） */
.note-back {
  width: 100%; height: 100%;
  border-radius: 32px;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 30px, rgba(150,130,100,.07) 31px),
    #fffdf6;
  padding: 30px 26px;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  color: #5a4a36;
  display: flex; flex-direction: column;
}
.note-back h3 { margin: 0 0 18px; font-size: 21px; font-weight: 600; letter-spacing: 1px; }
.note-back ol { margin: 0; padding-left: 26px; font-size: 20px; font-weight: 500; line-height: 2.25; }
.note-back .note-tail { margin-top: auto; font-size: 17px; font-weight: 500; color: #6b5a44; line-height: 2.1; }
.note-back .stamp { align-self: flex-end; margin-top: 18px; font-size: 14px; font-weight: 600; color: #b08; opacity: .6; transform: rotate(-6deg); }

.chapter-end {
  position: absolute; bottom: 22px; left: 0; right: 0; text-align: center;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif; font-size: 18px; font-weight: 500; color: #8a7a62;
}
.retry {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: #b08; opacity: .55; cursor: pointer; border: 1px solid #d9b3c9; padding: 5px 14px; border-radius: 20px;
}
.retry:hover { opacity: .9; }

/* 首页 / 标题页 */
#home {
  position: fixed; inset: 0; z-index: 70;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 1s ease;
}
#home.hidden { opacity: 0; pointer-events: none; }

/* 游戏内常驻：重新开始 */
#restartBtn {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 80;
  display: none;
  font-size: 13px;
  color: #6f6453;
  background: rgba(255, 255, 255, .72);
  border: 1px solid #e2d8c6;
  border-radius: 18px;
  padding: 5px 14px;
  cursor: pointer;
  opacity: .6;
  transition: opacity .2s;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
#restartBtn:hover { opacity: 1; }
.home-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 24px; text-align: center; padding: 40px;
}
.home-title {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 52px; font-weight: 500; letter-spacing: 10px;
  line-height: 1.35; color: var(--ink); margin: 0;
}
.home-sub {
  font-size: 15px; color: var(--ink-soft); letter-spacing: 5px; margin: 0;
}
.home-line {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 21px; line-height: 2.2; color: var(--ink);
  letter-spacing: 2px; margin: 4px 0 8px;
}
.home-actions { display: flex; gap: 16px; align-items: center; margin-top: 4px; }
.home-foot {
  font-size: 13px; color: var(--ink-soft); letter-spacing: 1px;
  margin: 0; opacity: .8;
}

/* 开场遮罩（全局，最高层） */
#intro {
  position: fixed; inset: 0; background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 30px; z-index: 60; transition: opacity 1s ease;
}
#intro h1 { font-family: "STKaiti","KaiTi",serif; font-size: 30px; font-weight: 500; letter-spacing: 4px; margin: 0; color: var(--ink); }
#intro p { max-width: 360px; text-align: center; font-family: "STKaiti","KaiTi",serif; font-size: 18px; line-height: 1.9; color: var(--ink-soft); margin: 0 24px; }
#startBtn {
  font-size: 17px; color: #fff; background: var(--green-deep); border: none;
  padding: 14px 40px; border-radius: 26px; cursor: pointer; letter-spacing: 3px;
  box-shadow: 0 6px 16px var(--shadow);
}
#startBtn:active { transform: translateY(1px); }

/* 手指指针（笨拙跟随，全局浮层） */
#finger {
  position: fixed; top: 0; left: 0; width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(123,160,91,.9);
  background: rgba(123,160,91,.18);
  pointer-events: none; z-index: 40;
  transform: translate(-50%, -50%);
  transition: width .15s, height .15s, background .15s;
}
#finger.press { width: 26px; height: 26px; background: rgba(123,160,91,.42); }
.hint { font-size: 13px; color: var(--ink-soft); text-align: center; padding: 10px; }

/* ---------- 通用按钮 ---------- */
.btn {
  font-size: 16px; border: none; border-radius: 24px;
  padding: 11px 30px; cursor: pointer; letter-spacing: 2px; font-family: inherit;
  transition: opacity .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-ok { color: #fff; background: var(--green-deep); box-shadow: 0 5px 14px var(--shadow); }
.btn-ghost { color: var(--ink-soft); background: #e7ddc9; }

/* ---------- 第 1 章：描红 ---------- */
.ch1 { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px; }
.ch1-label { font-size: 15px; color: var(--ink-soft); letter-spacing: 2px; }
.sheet {
  background: #fffdf6; border-radius: 14px; padding: 14px;
  box-shadow: 0 14px 36px var(--shadow);
}
.tracing { width: 300px; height: 300px; display: block; touch-action: none; }
.ge { fill: #fffdf6; stroke: #C8553D; stroke-width: 3; }
.ge-cross { stroke: #C8553D; stroke-width: 1.4; stroke-dasharray: 5 6; opacity: .5; }
.tracing #print { pointer-events: none; }
.print-glyph { fill: #C8553D; opacity: .17; }
.print-outline {
  fill: none; stroke: #C8553D; stroke-width: 1.6;
  stroke-linejoin: round; stroke-dasharray: 4.5 5; opacity: .5;
}
.ink-stroke {
  fill: none; stroke: #3a322a; stroke-width: 12;
  stroke-linecap: round; stroke-linejoin: round;
}
#tracePad { pointer-events: all; cursor: crosshair; }
.ch1-tools { display: flex; gap: 14px; }
.ch1-done { display: flex; flex-direction: column; align-items: center; gap: 16px; min-height: 60px; }
.done-line {
  font-size: 20px; color: var(--ink); letter-spacing: 1px;
  text-align: center; max-width: 340px; line-height: 1.8;
}

/* ---------- 占位章 / 结尾页 ---------- */
.placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 18px; padding: 40px; text-align: center;
}
.ph-age { font-size: 15px; color: var(--ink-soft); letter-spacing: 2px; }
.ph-title { font-family: "STKaiti", "KaiTi", serif; font-size: 30px; color: var(--ink); letter-spacing: 3px; }
.ph-note { font-size: 15px; color: var(--ink-soft); max-width: 320px; line-height: 1.8; }

/* ---------- 第 7 章背面「继续往后」 ---------- */
.phone-face.back .continue {
  position: absolute; bottom: 22px; right: 18px;
  font-size: 13px; color: #b08; opacity: .7; cursor: pointer;
  border: 1px solid #d9b3c9; padding: 6px 16px; border-radius: 20px;
}
.phone-face.back .continue:hover { opacity: .95; }

/* ---------- 第 2 章：学骑车 ---------- */
.ch2 { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px; width: 100%; height: 100%; }
.ch2-hud { font-size: 16px; color: var(--ink-soft); letter-spacing: 1px; }
.ch2-play {
  flex: 1; width: 100%; max-width: 520px;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; cursor: grab;
}
.ch2-play:active { cursor: grabbing; }
.ride-svg { width: 100%; max-width: 420px; height: auto; display: block; }
.ride-svg .ground { stroke: #cdbfa6; stroke-width: 3; }
.ride-svg .wheel { fill: none; stroke: #5b5147; stroke-width: 5; }
.ride-svg .frame { stroke: #5b5147; stroke-width: 5; stroke-linecap: round; }
.ride-svg .handle { stroke: #5b5147; stroke-width: 5; stroke-linecap: round; }
.ride-svg .head { fill: #e8b078; stroke: #5b5147; stroke-width: 3; }
.ride-svg .limb { stroke: #5b5147; stroke-width: 5; stroke-linecap: round; }
.ride-svg .bruise { fill: #C8553D; opacity: .6; }

/* ---------- 抉择浮层（有重量的选择，无对错） ---------- */
.choice-layer {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(40,34,26,.5);
  display: flex; align-items: center; justify-content: center;
  animation: choiceIn .3s ease;
}
@keyframes choiceIn { from { opacity: 0; } to { opacity: 1; } }
.choice-box {
  background: #fffdf6; border-radius: 18px; padding: 24px 26px;
  max-width: 340px; width: 82%;
  box-shadow: 0 16px 44px rgba(0,0,0,.28);
  display: flex; flex-direction: column; gap: 11px;
}
.choice-prompt {
  font-size: 16px; color: #5a4a36; line-height: 1.7;
  margin-bottom: 4px; text-align: center; font-weight: 500;
}
.choice-btn {
  font-family: inherit; font-size: 15px; color: #5a4a36;
  background: #f3ead7; border: 1px solid #e3d6bd;
  padding: 13px 16px; border-radius: 14px; cursor: pointer;
  text-align: center; transition: background .18s;
}
.choice-btn:hover { background: #ece0c8; }
.choice-btn:active { transform: translateY(1px); }
