/* ============================================================
 * 《目的地》样式 —— 淡雅浅绿 × 低饱和紫 亮色主题
 * 主色调：#BFD4AD（浅绿基底）  主要字色：#526635
 * 交互强调：暗绿 #5E9468 / 亮绿 #C3FFC4
 * 副色调：暗紫 #914BB0 / 亮紫 #C474D6
 * 移动端优先，PC 居中兼容
 * ============================================================ */

/* ---------------- 全局颜色变量 ---------------- */
:root {
  /* 主色调：绿（全局核心交互色） */
  --c-green:     #5E9468;   /* 暗绿：重点按钮底色、强调边框 */
  --c-green-hi:  #C3FFC4;   /* 亮绿：高亮填充、悬停底色 */

  /* 副色调：紫（次要装饰 / 辅助标识） */
  --c-purple:    #914BB0;   /* 暗紫：分区标题、标签、装饰 */
  --c-purple-hi: #C474D6;   /* 亮紫：hover 悬浮、特效点缀 */

  /* 背景中性色系（淡雅浅色基底） */
  --c-bg:        #BFD4AD;   /* 主背景：页面底层 */
  --c-bg-panel:  #FFFFFF;   /* 面板底色 / 按钮反白文字 */
  --c-gray:      #8FA08A;   /* 灰绿弱化色：禁用文字、分割线 */

  /* 文字、光标、选框基础色 */
  --c-fg:        #526635;   /* 主要字颜色 */
  --c-text:      #5F7350;   /* 次要文字 */
  --c-text-hi:   #526635;   /* 强调文字（正文） */
  --c-cursor:    #526635;   /* 光标颜色 */
  --c-sel-bg:    #FFFFFF;   /* 选中背景 */

  /* RGB 分量（供 rgba() 透明度混合使用） */
  --rgb-green:     94, 148, 104;
  --rgb-green-hi:  195, 255, 196;
  --rgb-purple:    145, 75, 176;
  --rgb-purple-hi: 196, 116, 214;
  --rgb-fg:        82, 102, 53;
  --rgb-bg:        191, 212, 173;
  --rgb-panel:     255, 255, 255;
  --rgb-gray:      143, 160, 138;

  /* 点缀颜色（严格按色号） */
  --c-red-d:      #C56262;
  --c-red-l:      #FF7779;
  --c-yellow-d:   #A1933C;
  --c-yellow-l:   #FFF894;
  --c-blue-d:     #3C719C;
  --c-blue-l:     #9BFFFB;
  --c-cyan-d:     #35A6B5;
  --c-cyan-l:     #C4FFF7;
  --c-white:      #FFFFFF;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Cascadia Code", "Cascadia Mono", "Consolas", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--c-fg);
  user-select: none;
}

/* 选框 / 光标：白底深绿字 */
::selection { background: var(--c-sel-bg); color: var(--c-fg); }
input, textarea { caret-color: var(--c-cursor); }
#nick-input::placeholder { color: var(--c-gray); }

#app {
  position: relative;
  width: 100%; height: 100%;
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
}

/* 开始页 / 结局页：去掉游戏界面边框，背景图铺满整个屏幕（iOS 与 PC 通用） */
body.fb-on #app { max-width: none; }

#stage { position: absolute; inset: 0; }

/* ---------------- 背景 ---------------- */
#bg { position: absolute; inset: 0; }
.bg-layer {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.1s ease;
}
/* 第三场剧情需要的“漆黑教室”：纯黑 */
.bg-layer.bg-dark {
  background: #000000;
}
/* 竖图等不适合裁切的背景：整图居中放入，不裁切 */
.bg-layer.bg-fit {
  background-size: contain; background-repeat: no-repeat;
  background-position: center; background-color: #000000;
}
.bg-lit-veil {
  position: absolute; inset: 0; z-index: 40;
  background: #FFFFFF; opacity: .92;
  transition: opacity 1.4s ease; pointer-events: none;
}

/* ---------------- 生日现场特效：飘落彩带 + 明灭星星 ---------------- */
#party-fx {
  position: absolute; inset: 0; overflow: hidden;
  pointer-events: none; z-index: 48;
}
/* 绿色生日现场持续背景：盖住天台照片，沿用到全部礼物拆完 */
#party-bg {
  position: absolute; inset: 0; z-index: 4;
  background: radial-gradient(ellipse at 50% 30%, #FFFFFF 0%, #C3FFC4 45%, #BFD4AD 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
  opacity: 0; transition: opacity 1.1s ease;
}
#party-bg.show { opacity: 1; }
#party-bg .cg-scene { transform: scale(.9); }
/* 生日现场期间：拆礼物等交互覆盖层减淡，让绿色现场透出来（书架层无蒙层，排除，避免立绘被模糊） */
#stage.party-on .overlay.interact-ov:not(.cg-ov):not(.shelf-ov) {
  background: rgba(var(--rgb-panel), .35);
  -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px);
}
#party-fx .confetti {
  position: absolute; top: 0;
  width: 7px; height: 15px; border-radius: 2px;
  opacity: .9;
  animation: confettiFall linear infinite;
}
#party-fx .p-star {
  position: absolute;
  color: #FFF3B0;
  text-shadow: 0 0 6px rgba(255, 240, 160, .9), 0 0 14px rgba(255, 240, 160, .5);
  opacity: 0;
  animation: starTwinkle ease-in-out infinite;
}
@keyframes confettiFall {
  0%   { transform: translate3d(0, -12vh, 0) rotate(0turn); }
  100% { transform: translate3d(var(--dx, 0px), 112vh, 0) rotate(var(--rz, 1.5turn)); }
}
@keyframes starTwinkle {
  0%, 100% { opacity: 0; transform: scale(.5); }
  50%      { opacity: 1; transform: scale(1.15); }
}
.bg-lit-veil.lift { opacity: 0; }

/* ---------------- 立绘 ---------------- */
/* bottom 默认 22vh（约等于对话框高度），JS 会按对话框实际高度动态贴紧 */
#sprites { position: absolute; left: 0; right: 0; bottom: 22vh; top: 4vh; pointer-events: none; z-index: 5; }
html.no-sprites #sprites { display: none; }

.sprite-box { position: absolute; bottom: 0; height: 100%; display: flex; align-items: flex-end; }
.sprite-box.left  { left: 2%; }
.sprite-box.right { right: 2%; }
.sprite-box img {
  height: min(72vh, 100%); width: auto; max-width: 46vw;
  object-fit: contain; object-position: bottom;
  position: absolute; bottom: 0; opacity: 0;
  transition: opacity .7s ease, filter .5s ease, transform .5s ease;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.35));
}
.sprite-box.left  img { left: 0; }
.sprite-box.right img { right: 0; }

/* 说话人高亮：乐随说话轮次明暗变化；何不管是否说话都一直亮着 */
#sprites[data-speaker="he"] #sprite-le img[style*="opacity: 1"] {
  filter: brightness(.72) saturate(.85) drop-shadow(0 6px 18px rgba(0,0,0,.35));
}
/* 带蒙层的交互期间（礼盒/长剑/送达等）：立绘浮到蒙层之上，避免被半透明蒙层冲淡 */
#stage.interact-on #sprites { z-index: 51; }
#sprites[data-speaker="le"] #sprite-le img[style*="opacity: 1"],
#sprites[data-speaker="he"] #sprite-he img[style*="opacity: 1"] {
  transform: translateY(-1.2vh);
}

/* ---------------- 顶部工具 ---------------- */
#ui-top { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; z-index: 60; display: flex; gap: 8px; }
#btn-settings, #btn-skip {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(var(--rgb-green), .5);
  background: rgba(var(--rgb-panel), .7); color: var(--c-green);
  font-size: 19px; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  cursor: pointer;
}
#btn-skip { font-size: 15px; }

/* ---------------- 对话框 ---------------- */
#dialog {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  min-height: 22vh; padding: 16px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(var(--rgb-panel), .86), rgba(var(--rgb-panel), .96));
  border-top: 1px solid rgba(var(--rgb-green), .55);
  box-shadow: 0 -4px 24px rgba(var(--rgb-fg), .12);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  cursor: pointer;
}
#dlg-name {
  display: inline-block; margin-bottom: 8px; padding: 3px 16px;
  border-radius: 999px; font-weight: 700; letter-spacing: 2px;
  color: var(--c-white);
  background: linear-gradient(90deg, var(--c-green), #7AB286);
  box-shadow: 0 2px 10px rgba(var(--rgb-green), .35);
}
#dialog[data-mode="narration"] #dlg-text {
  text-align: center; font-style: italic; color: var(--c-text);
  padding: 1.5vh 12px; display: flex; align-items: center; justify-content: center;
  min-height: 12vh;
}
#dlg-text { line-height: 1.9; word-break: break-word; white-space: pre-wrap; color: var(--c-text-hi); }
#dlg-text.fade-in { animation: txtIn .5s ease both; }
@keyframes txtIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#dlg-next {
  position: absolute; right: 16px; bottom: calc(10px + env(safe-area-inset-bottom));
  color: var(--c-green); animation: bob 1.2s infinite; font-size: 13px;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* 文字大小设置 */
html[data-ts="small"]  #dlg-text { font-size: 15px; }
html[data-ts="medium"] #dlg-text { font-size: 18px; }
html[data-ts="large"]  #dlg-text { font-size: 22px; }

/* ---------------- 选项（屏幕正中弹出） ---------------- */
#choices[hidden], #dialog[hidden] { display: none !important; }
#choices {
  position: absolute; inset: 0; z-index: 45;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center;
  padding: 24px 18px;
  background: rgba(var(--rgb-panel), .45);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
#choices .choice-btn { width: min(480px, 90vw); text-align: center; }
.choice-btn {
  padding: 13px 16px; border-radius: 14px; text-align: left;
  line-height: 1.6; font-size: 16px; color: var(--c-fg);
  border: 1px solid rgba(var(--rgb-green), .55);
  background: rgba(var(--rgb-panel), .92);
  box-shadow: 0 2px 10px rgba(var(--rgb-fg), .08);
  transition: transform .15s ease, box-shadow .15s ease, background .2s, border-color .2s;
  cursor: pointer;
}
.choice-btn:hover, .choice-btn:active {
  transform: translateY(-2px);
  color: var(--c-text-hi);
  border-color: rgba(var(--rgb-purple-hi), .85);
  background: rgba(var(--rgb-green-hi), .45);
  box-shadow: 0 6px 18px rgba(var(--rgb-purple-hi), .3);
}
.choice-btn .rec { color: var(--c-purple); font-weight: 700; }

/* ---------------- 通用覆盖层 ---------------- */
.overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(var(--rgb-panel), .72);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.ov-btn {
  margin-top: 22px; padding: 12px 46px; border-radius: 999px;
  font-size: 17px; letter-spacing: 4px; color: var(--c-white);
  font-weight: 700; border: none; cursor: pointer;
  background: linear-gradient(90deg, var(--c-green), #7AB286);
  box-shadow: 0 4px 20px rgba(var(--rgb-green), .45);
  transition: transform .15s ease;
}
.ov-btn:hover { transform: scale(1.05); }
.ov-continue { margin-top: 18px; color: var(--c-green); font-size: 13px; letter-spacing: 2px; animation: bob 1.3s infinite; }

/* ---------------- 标题页 ---------------- */
/* 背景图直接完整展示：不加暗罩、不模糊 */
.title-screen { background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.title-mid { text-align: center; }
.game-title {
  font-size: clamp(52px, 14vw, 96px); letter-spacing: 18px; text-indent: 18px;
  font-weight: 800; color: var(--c-fg);
  text-shadow: 0 0 24px rgba(var(--rgb-green-hi), .8), 0 0 60px rgba(var(--rgb-purple-hi), .4);
  animation: titleGlow 3.2s ease-in-out infinite;
}
@keyframes titleGlow {
  0%,100% { text-shadow: 0 0 24px rgba(var(--rgb-green-hi), .8), 0 0 60px rgba(var(--rgb-purple-hi), .35); }
  50%     { text-shadow: 0 0 34px rgba(var(--rgb-green-hi), 1), 0 0 80px rgba(var(--rgb-purple-hi), .55); }
}
.game-sub { margin-top: 10px; color: var(--c-green); letter-spacing: 6px; font-size: 14px; font-weight: 700; }

/* 开始游戏：固定底部、无色块底、微微发光的白色字 */
.title-start {
  position: absolute; left: 0; right: 0;
  bottom: max(9vh, calc(28px + env(safe-area-inset-bottom)));
  margin: 0 auto; width: max-content;
  padding: 14px 36px; border: none; border-radius: 0;
  background: none; box-shadow: none; cursor: pointer;
  color: var(--c-white); font-weight: 800; font-size: 22px;
  letter-spacing: 12px; text-indent: 12px;
  text-shadow: 0 0 10px rgba(255,255,255,.95), 0 0 26px rgba(255,255,255,.7), 0 1px 5px rgba(var(--rgb-fg), .35);
  transition: transform .15s ease;
}
.title-start:hover { transform: scale(1.06); }

/* ---------------- 输入 / 选择卡片 ---------------- */
.ui-card {
  width: min(560px, 92vw); max-height: 82vh; overflow-y: auto;
  padding: 26px 22px; border-radius: 20px;
  background: linear-gradient(160deg, rgba(var(--rgb-panel), .97), rgba(244, 250, 238, .98));
  border: 1px solid rgba(var(--rgb-green), .45);
  box-shadow: 0 10px 40px rgba(var(--rgb-fg), .2);
  text-align: center;
}
.ui-card.wide { width: min(680px, 94vw); }
.ui-title { font-size: 20px; font-weight: 800; letter-spacing: 6px; color: var(--c-green); margin-bottom: 18px; }
.ui-tip { margin-top: 12px; color: var(--c-purple); font-size: 13px; }

#nick-input {
  width: 100%; padding: 13px 16px; border-radius: 12px; font-size: 17px; text-align: center;
  color: var(--c-fg); background: rgba(var(--rgb-panel), .9);
  border: 1px solid rgba(var(--rgb-green), .5); outline: none;
}
#nick-input:focus { border-color: var(--c-green); box-shadow: 0 0 12px rgba(var(--rgb-green), .3); }

.persona-list { display: flex; flex-direction: column; gap: 9px; text-align: left; }
.persona-group { margin: 10px 0 2px; color: var(--c-purple); font-weight: 700; text-align: center; letter-spacing: 2px; }

.ui-card.shake { animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------------- 过场 *移动中…* ---------------- */
.trans-ov { background: #EDF4E2; opacity: 0; transition: opacity .7s ease; }
.trans-ov.show { opacity: 1; }
.trans-text {
  color: var(--c-green); font-size: 18px; letter-spacing: 4px; font-style: italic;
  animation: drift 2s ease-in-out infinite;
}
@keyframes drift { 0%,100% { transform: translateX(-14px); opacity: .6; } 50% { transform: translateX(14px); opacity: 1; } }

/* ---------------- 指引图片（直接作为背景，只保留点击提示） ---------------- */
.img-ov.bg-hint {
  background: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  justify-content: flex-end; padding: 20px;
  padding-bottom: calc(10vh + env(safe-area-inset-bottom));
}

/* ---------------- 场次结束 / 结局 ---------------- */
/* 结束页/标题页期间：立绘与对话框一并隐藏，避免透过半透明覆盖层露出 */
#stage.end-on #sprites,
#stage.end-on #dialog { display: none !important; }
/* 引路图展示期间：立绘隐藏，避免挡住背景图 */
#stage.hint-on #sprites { display: none !important; }
.end-ov { background: rgba(var(--rgb-panel), .88); }
.end-card { text-align: center; padding: 0 24px; animation: txtIn .8s ease both; }
.end-title { font-size: clamp(26px, 7vw, 40px); font-weight: 800; letter-spacing: 8px; color: var(--c-fg); text-shadow: 0 0 18px rgba(var(--rgb-green-hi), .9); }
.end-tip { margin-top: 18px; line-height: 2; color: var(--c-text); font-size: 15px; }
.end-badge {
  display: inline-block; padding: 6px 26px; border-radius: 999px; margin-bottom: 20px;
  font-size: 20px; font-weight: 800; letter-spacing: 8px; color: var(--c-white);
  background: linear-gradient(90deg, var(--c-purple), var(--c-purple-hi)); box-shadow: 0 4px 20px rgba(var(--rgb-purple), .4);
}
.end-lore { max-width: 540px; margin: 0 auto; line-height: 2.1; color: var(--c-text); font-size: 16px; }
/* 好结局：去掉白色半透明蒙层与按钮，只留微光文字，整体贴底 */
.end-ov.ending {
  background: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  justify-content: flex-end;
  padding-bottom: calc(9vh + env(safe-area-inset-bottom));
}
.ending-line {
  max-width: 640px; margin: 0 auto; line-height: 2;
  color: var(--c-white); font-size: clamp(16px, 4vw, 22px); letter-spacing: 2px;
  font-family: "楷体", "KaiTi", "STKaiti", "Kaiti SC", serif;
  text-shadow: 0 0 12px rgba(255,255,255,.75), 0 0 30px rgba(255,255,255,.45);
}
.ending-back {
  margin-top: 48px; cursor: pointer; user-select: none;
  color: var(--c-white); font-size: 15px; letter-spacing: 6px;
  text-shadow: 0 0 10px rgba(255,255,255,.7), 0 0 24px rgba(255,255,255,.4);
  animation: bob 1.6s infinite;
}

/* ---------------- 第三场：开关 ---------------- */
.sw-hint { color: var(--c-green); font-size: 15px; letter-spacing: 3px; margin-bottom: 26px; animation: bob 2s infinite; }
.sw-panel { display: flex; gap: 18px; }
.sw-toggle {
  width: 52px; height: 92px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, var(--c-white), #F0F6E8);
  border: 1px solid rgba(var(--rgb-green), .45);
  position: relative; transition: box-shadow .2s;
}
.sw-toggle:hover { box-shadow: 0 0 16px rgba(var(--rgb-green), .4); }
.sw-nub {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--c-gray); transition: .3s;
}
.sw-panel.picked .sw-toggle:first-child .sw-nub { top: 58px; background: var(--c-green); box-shadow: 0 0 14px var(--c-green); }
.sw-flash { position: absolute; inset: 0; background: var(--c-white); animation: flash 1s ease both; pointer-events: none; }
@keyframes flash { 0% { opacity: 0; } 35% { opacity: .95; } 100% { opacity: 0; } }

/* ---------------- 生日现场 CG（亮色浅绿布置） ---------------- */
.cg-ov {
  background: radial-gradient(ellipse at 50% 30%, #FFFFFF 0%, #C3FFC4 45%, #BFD4AD 100%);
  cursor: pointer;
}
.cg-lights { position: absolute; top: 7%; left: 5%; right: 5%; display: flex; justify-content: space-between; }
.cg-lights i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--c-red-l); box-shadow: 0 0 12px var(--c-red-l);
  animation: blink 1.6s infinite;
}
.cg-lights i:nth-child(4n+1) { background: var(--c-yellow-l); box-shadow: 0 0 12px var(--c-yellow-l); }
.cg-lights i:nth-child(4n+2) { background: var(--c-blue-l); box-shadow: 0 0 12px var(--c-blue-l); animation-delay: .5s; }
.cg-lights i:nth-child(4n+3) { background: var(--c-purple-hi); box-shadow: 0 0 12px var(--c-purple-hi); animation-delay: 1s; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.cg-scene { text-align: center; position: relative; }
.cg-confetti { position: absolute; top: -70px; left: 0; right: 0; }
.cg-confetti span { display: inline-block; margin: 0 8px; font-size: 22px; animation: floatUp 3s ease-in-out infinite; }
.cg-confetti span:nth-child(even) { animation-delay: 1.2s; }
@keyframes floatUp { 0%,100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-16px) rotate(8deg); } }
.cg-cake span { font-size: 84px; display: inline-block; animation: cakePop 2.4s ease infinite; filter: drop-shadow(0 8px 24px rgba(var(--rgb-green), .5)); }
@keyframes cakePop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.cg-garland { margin-top: 18px; font-size: 26px; letter-spacing: 10px; }
.cg-text { margin-top: 14px; color: var(--c-fg); letter-spacing: 4px; font-size: 18px; font-weight: 800; text-shadow: 0 0 12px rgba(var(--rgb-green-hi), .9); }

/* ---------------- 礼盒 / 采花 / 玩偶 ---------------- */
.gift-stage { text-align: center; }
.gift-box { font-size: 96px; cursor: pointer; animation: giftBounce 1.6s ease-in-out infinite; filter: drop-shadow(0 10px 30px rgba(var(--rgb-purple-hi), .5)); }
@keyframes giftBounce { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-14px) rotate(3deg); } }
.gift-box.open { animation: giftOpen .8s ease both; }
@keyframes giftOpen { 0% { transform: scale(1); } 40% { transform: scale(1.25) rotate(10deg); } 100% { transform: scale(0); opacity: 0; } }
.gift-tip { margin-top: 16px; color: var(--c-green); font-size: 14px; letter-spacing: 3px; animation: bob 1.4s infinite; }

.pick-area, .plush-area {
  position: absolute; left: 4%; right: 4%; top: 8%; bottom: 14%;
}
.pick-item {
  position: absolute; background: none; border: none; cursor: pointer;
  transition: transform .3s, opacity .5s; padding: 6px;
}
.pick-item:hover { transform: scale(1.2) !important; }
.pick-item.got { opacity: 0; transform: translateY(-60px) scale(.4) !important; pointer-events: none; }
.pick-count {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  padding: 6px 22px; border-radius: 999px; font-size: 14px; color: var(--c-fg); font-weight: 700;
  background: rgba(var(--rgb-panel), .85); border: 1px solid rgba(var(--rgb-green), .45);
  box-shadow: 0 2px 10px rgba(var(--rgb-fg), .12);
}
/* 玩偶弹出：两行两列（上二下二）网格排布，避免 iOS 竖屏横向一排互相遮挡 */
.plush-area {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, auto));
  place-content: center;
  justify-items: center;
  gap: 3vh 8vw;
}
/* 关键：hidden 属性必须仍然生效，否则空的网格层会盖住礼盒、拦截点击 */
.plush-area[hidden] { display: none; }
.plush-item {
  position: static; background: none; border: none; cursor: pointer;
  font-size: 56px; text-align: center; transition: transform .25s;
}
.plush-item.drop { animation: dropIn .7s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes dropIn { from { transform: translateY(-90vh) rotate(40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.plush-item.viewed { transform: translateY(-26px) scale(1.15); }
.plush-name { display: block; font-size: 12px; color: var(--c-text); margin-top: 4px; letter-spacing: 1px; }
/* 玩偶图片：限定尺寸并等比显示 */
.plush-item .ph { display: block; width: 96px; height: 96px; object-fit: contain; border-radius: 14px; margin: 0 auto; }
.plush-done { position: absolute; bottom: 5%; }

/* ---------------- 书架 ---------------- */
.shelf-ov { background: none; backdrop-filter: none; pointer-events: none; z-index: 20;
  justify-content: flex-start; padding-top: 3vh; }
.shelf {
  pointer-events: auto; width: min(88vw, 520px);
  background: linear-gradient(180deg, rgba(var(--rgb-panel), .97), rgba(240, 248, 232, .97));
  border: 2px solid rgba(var(--rgb-green), .4); border-radius: 14px;
  padding: 10px 14px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 12px 40px rgba(var(--rgb-fg), .25);
  transition: opacity .6s, transform .6s;
}
.shelf-ov.leave .shelf { opacity: 0; transform: translateY(-40px); }
.shelf-row {
  min-height: 86px; display: flex; align-items: center; gap: 10px;
  border-bottom: 6px solid var(--c-purple); padding: 6px;
}
.shelf-row:last-child { border-bottom: none; }
.shelf-slot {
  width: 64px; height: 64px; border-radius: 10px; border: 1px dashed rgba(var(--rgb-green), .5);
  background: rgba(var(--rgb-panel), .6); font-size: 34px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.shelf-slot.glow { animation: glowPulse 1.4s infinite; border-color: var(--c-green); }
@keyframes glowPulse { 0%,100% { box-shadow: 0 0 4px rgba(var(--rgb-green), .2); } 50% { box-shadow: 0 0 22px rgba(var(--rgb-green), .75); } }
.shelf-slot.filled { border-style: solid; border-color: rgba(var(--rgb-green), .6); }
.shelf-pop {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, 0) scale(.5);
  text-align: center; pointer-events: none; z-index: 56;
  padding: 16px 30px; border-radius: 16px;
  background: rgba(var(--rgb-panel), .95); border: 1px solid rgba(var(--rgb-purple-hi), .55);
  box-shadow: 0 10px 36px rgba(var(--rgb-fg), .25);
}
.shelf-pop .ph { font-size: 52px; display: block; }
.shelf-pop-name { margin-top: 8px; font-size: 15px; color: var(--c-fg); letter-spacing: 1px; max-width: 70vw; }
.shelf-pop.anim { animation: popOut .5s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes popOut { from { transform: translate(-50%, 30px) scale(.4); opacity: 0; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }
/* 物品弹出后的全屏点击层：等玩家点击再继续 */
.pop-catcher { position: absolute; inset: 0; pointer-events: auto; z-index: 57; cursor: pointer; }
.pop-continue { margin-top: 10px; color: var(--c-green); font-size: 12px; letter-spacing: 2px; animation: bob 1.3s infinite; }

/* ---------------- 长剑 ---------------- */
/* 万家灯火剑：整层浮到立绘之上，图片与【剑名】文字不再被立绘挡住 */
.sword-ov { z-index: 52; }
.sword-stage { text-align: center; }
.sword-box { position: relative; width: min(80vw, 320px); height: 130px; margin: 0 auto; cursor: pointer; }
.sword-body { position: absolute; inset: 0; border-radius: 14px;
  background: linear-gradient(160deg, var(--c-white), #EFF6E6); border: 2px solid var(--c-green);
  display: flex; align-items: center; justify-content: center; font-size: 40px; }
.sword-lid { position: absolute; inset: 0; border-radius: 14px; transform-origin: bottom center;
  background: linear-gradient(160deg, #FFFFFF, #F5FAEC); border: 2px solid #7AB286; z-index: 2;
  transition: transform .8s ease; }
.sword-box.open .sword-lid { transform: rotateX(120deg) translateY(-10px); opacity: 0; }
.sword-tip { margin-top: 18px; color: var(--c-green); font-size: 14px; letter-spacing: 3px; animation: bob 1.4s infinite; }
.sword-reveal { animation: txtIn .8s ease both; }
.sword-icon { font-size: 100px; filter: drop-shadow(0 0 30px rgba(var(--rgb-green), .8)); animation: swordGlow 2s infinite; cursor: pointer; }
.sword-icon img { display: block; max-width: min(70vw, 340px); max-height: 44vh; border-radius: 12px; }
@keyframes swordGlow { 0%,100% { transform: scale(1); filter: drop-shadow(0 0 18px rgba(var(--rgb-green), .6)); } 50% { transform: scale(1.06); filter: drop-shadow(0 0 40px rgba(var(--rgb-purple-hi), .7)); } }
.sword-name { margin-top: 16px; font-size: 20px; letter-spacing: 4px; color: var(--c-purple); text-shadow: 0 0 14px rgba(var(--rgb-purple-hi), .5); }

/* ---------------- 确定送达 ---------------- */
.deliver-stage { text-align: center; }
.deliver-btn {
  padding: 18px 60px; border-radius: 999px; border: none; cursor: pointer;
  font-size: 22px; font-weight: 800; letter-spacing: 8px; color: var(--c-white);
  background: linear-gradient(90deg, var(--c-green), #7AB286);
  box-shadow: 0 6px 26px rgba(var(--rgb-green), .5);
  animation: glowPulse 1.6s infinite;
}
.deliver-anim { font-size: 64px; }
.d-scooter { display: inline-block; animation: ride 1.6s ease-in both; }
@keyframes ride { from { transform: translateX(-46vw); } to { transform: translateX(46vw); } }
.d-dust { display: inline-block; animation: dust 1.4s infinite; }
@keyframes dust { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------------- 设置面板 ---------------- */
#settings-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 200;
  width: min(400px, 92vw); padding: 16px;
  background: linear-gradient(200deg, rgba(var(--rgb-panel), .98), rgba(246, 251, 240, .99));
  border-left: 1px solid rgba(var(--rgb-green), .4);
  box-shadow: -10px 0 40px rgba(var(--rgb-fg), .25);
  animation: slideIn .3s ease both; overflow-y: auto;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
.sp-card { color: var(--c-text); font-size: 14px; }
.sp-head { display: flex; justify-content: space-between; align-items: center; font-size: 17px; font-weight: 800; letter-spacing: 6px; color: var(--c-green); margin-bottom: 18px; }
#sp-close { background: none; border: 1px solid rgba(var(--rgb-green), .45); color: var(--c-green); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.sp-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px dashed rgba(var(--rgb-gray), .4); }
.sp-seg button, .sp-toggle-btn {
  padding: 5px 14px; margin-left: 6px; border-radius: 8px; cursor: pointer; font-size: 13px;
  border: 1px solid rgba(var(--rgb-green), .45); background: rgba(var(--rgb-panel), .75); color: var(--c-text);
}
.sp-seg button.active { background: linear-gradient(90deg, var(--c-green), #7AB286); color: var(--c-white); font-weight: 700; }
.sp-toggle-btn.off { color: var(--c-gray); border-color: rgba(var(--rgb-gray), .5); }
/* 音量滑块 */
.sp-vol { gap: 12px; }
.sp-vol #sp-vol { flex: 1; min-width: 0; accent-color: var(--c-green); cursor: pointer; }
.sp-vol-val { width: 42px; text-align: right; color: var(--c-green); font-size: 13px; }
.sp-sec { margin: 18px 0 8px; color: var(--c-purple); font-weight: 700; letter-spacing: 3px; }
/* 章节跳转按钮 */
.sp-jump { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 8px; }
.sp-jump button {
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(var(--rgb-green), .55);
  background: rgba(var(--rgb-panel), .8); color: var(--c-fg);
  font-size: 13px; letter-spacing: 2px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.sp-jump button:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(var(--rgb-green), .35); }
.sp-history { line-height: 1.8; }
.h-row { display: flex; gap: 10px; }
.h-row b { color: var(--c-green); flex-shrink: 0; }
.h-row span { word-break: break-all; }
.h-sec { color: var(--c-green); margin: 10px 0 4px; }
.h-choice { padding: 8px 10px; margin: 6px 0; border-radius: 10px; background: rgba(var(--rgb-panel), .7); border: 1px solid rgba(var(--rgb-green), .25); display: flex; flex-direction: column; gap: 2px; }
.h-q { color: var(--c-fg); font-size: 12px; }
.h-a { color: var(--c-text-hi); }
.h-t { color: var(--c-gray); font-size: 11px; }
.sp-clear {
  margin-top: 20px; width: 100%; padding: 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(var(--rgb-purple-hi), .55); background: rgba(var(--rgb-purple), .12); color: var(--c-purple);
  letter-spacing: 4px;
}

/* emoji 占位符通用 */
.ph { line-height: 1; }

/* PC 适配：宽屏时使用 16:9 横向长方形舞台（横版背景图完整显示），两侧留浅绿底 */
@media (min-width: 900px) {
  #app {
    max-width: none;
    width: min(100vw, calc(100vh * 16 / 9));
    box-shadow: 0 0 80px rgba(var(--rgb-fg), .35);
  }
  body { background: #DCE8CC; }
  /* 开始页 / 结局页：解除 16:9 限宽与阴影，画面铺满整个屏幕 */
  body.fb-on #app {
    width: 100%;
    max-width: none;
    box-shadow: none;
  }
}

/* ---------------- 手机竖屏适配 ----------------
 * 竖屏时背景图完整显示并整体上移到画面上部（立绘上方，留一点间距），
 * 避免被大占比立绘挡住；四周空白用浅绿游戏底色填充；
 * PC 宽屏与手机横屏保持原来的 cover 铺满效果不变。
 * “漆黑教室”背景（bg-dark）除外，保持全屏纯黑。 */
@media (orientation: portrait) and (max-width: 899px) {
  .bg-layer:not(.bg-dark) {
    top: 0; bottom: auto; height: 42vh;    /* 背景图区域收缩到画面上部 */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;    /* 图片底边贴住区域下沿，紧挨立绘头顶 */
    background-color: var(--c-bg);
  }
  /* 生日现场：仅手机竖屏时缩小并上移到立绘上方；PC 恢复居中大图 */
  #party-bg { justify-content: flex-start; padding-top: 11vh; }
  #party-bg .cg-scene { transform: scale(.78); }
  .cg-ov { justify-content: flex-start; padding-top: 13vh; }
  .cg-ov .cg-scene { transform: scale(.8); }
  .cg-lights { top: 3%; }
}
