/* ══════════════════════════════════════════════════
   NANBU —— 剧情演出界面
   ══════════════════════════════════════════════════ */

body.story-mode { overflow: hidden; height: 100vh; }

/* ══════════ 章节选择 ══════════ */

#chapterSelect {
  min-height: 100vh;
  padding-bottom: 80px;
}
.chap-row {
  display: grid;
  gap: 16px;
}
.chap-line {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .3s, border-color .3s, box-shadow .3s;
}
.chap-line:hover { transform: translateX(6px); border-color: var(--line-2); box-shadow: var(--shadow); }
.chap-line .thumb {
  position: relative;
  width: 210px; flex-shrink: 0;
  background: linear-gradient(140deg, #241d3d, #100e1e);
  overflow: hidden;
}
.chap-line .thumb img { width: 100%; height: 100%; object-fit: cover; }
.chap-line .thumb .ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 36px; letter-spacing: .16em; color: rgba(230, 164, 192, .3);
}
.chap-line .info { flex: 1; padding: 22px 26px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.chap-line .no { font-size: 10.5px; letter-spacing: .34em; color: var(--pink-deep); text-transform: uppercase; }
.chap-line h3 { margin: 7px 0 8px; font-family: var(--serif); font-size: 24px; font-weight: 500; letter-spacing: .12em; color: #fff; }
.chap-line p { margin: 0; font-size: 13px; color: var(--text-mute); line-height: 1.9; }
.chap-line .side {
  width: 150px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border-left: 1px solid rgba(255, 255, 255, .05);
  background: rgba(0, 0, 0, .18);
}
.chap-line .side .pct { font-family: var(--serif); font-size: 26px; color: var(--pink); letter-spacing: .04em; }
.chap-line .side .lb { font-size: 10.5px; letter-spacing: .24em; color: var(--text-mute); }
.chap-line .side .go {
  margin-top: 4px; padding: 5px 16px; font-size: 11.5px; letter-spacing: .18em;
  border: 1px solid var(--line-2); color: var(--pink); border-radius: 2px;
}
.chap-line:hover .side .go { background: var(--pink); color: #241321; border-color: transparent; }

@media (max-width: 720px) {
  .chap-line { flex-direction: column; }
  .chap-line .thumb { width: 100%; aspect-ratio: 16/7; }
  .chap-line .side { width: 100%; flex-direction: row; padding: 12px; border-left: none; border-top: 1px solid rgba(255,255,255,.05); }
}

/* ══════════ 演出舞台 ══════════ */

#stage { position: fixed; inset: 0; display: none; background: #050409; z-index: 100; }
#stage.on { display: block; }

.bg-layer {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity .85s ease;
  will-change: opacity;
}
.bg-layer.on { opacity: 1; }

.stage-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(4, 3, 10, .34) 0%, rgba(4, 3, 10, 0) 22%, rgba(4, 3, 10, 0) 52%, rgba(4, 3, 10, .62) 82%, rgba(4, 3, 10, .82) 100%);
  pointer-events: none;
}

/* 立绘层 */
.sprites { position: absolute; inset: 0; pointer-events: none; }
.sprite {
  position: absolute;
  bottom: 0;
  height: 92%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 22px 50px rgba(0, 0, 0, .72));
  transition: opacity .55s ease, transform .55s cubic-bezier(.2, .9, .3, 1), filter .4s;
  will-change: opacity, transform;
}
.sprite[data-slot="center"] { left: 50%; transform: translateX(-50%); }
.sprite[data-slot="left"] { left: 20%; transform: translateX(-50%); }
.sprite[data-slot="right"] { left: 80%; transform: translateX(-50%); }
.sprite[data-slot="farleft"] { left: 7%; transform: translateX(-50%); }
.sprite[data-slot="farright"] { left: 93%; transform: translateX(-50%); }

.sprite.enter { opacity: 0; transform: translateX(-50%) translateY(26px) scale(.985); }
.sprite.dim { filter: brightness(.56) saturate(.72) drop-shadow(0 22px 50px rgba(0,0,0,.72)); }
.sprite.flip { scale: -1 1; }

@media (max-width: 860px) {
  .sprite { height: 70%; }
  .sprite[data-slot="left"] { left: 16%; }
  .sprite[data-slot="right"] { left: 84%; }
}

/* 特效 */
.fx { position: absolute; inset: 0; pointer-events: none; }
.fx .flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  animation: fxFlash .5s ease-out;
}
@keyframes fxFlash { 0% { opacity: .82; } 100% { opacity: 0; } }

.fx .vignette {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 45%, transparent 42%, rgba(0, 0, 0, .6) 100%);
}
#stage.shake { animation: stageShake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes stageShake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
#stage.zoomIn { animation: stageZoom 1.2s ease-out; }
@keyframes stageZoom { from { transform: scale(1); } to { transform: scale(1.05); } }

/* ══════════ 顶部工具条 ══════════ */

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 54px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(5, 4, 10, .82), transparent);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .3s, transform .3s;
}
#stage:hover .hud, .hud.show { opacity: 1; transform: none; }
.hud .title {
  flex: 1; min-width: 0;
  font-family: var(--serif); font-size: 15px; letter-spacing: .16em; color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .9);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hud-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12, 10, 22, .68);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  transition: all .2s;
  backdrop-filter: blur(8px);
}
.hud-btn:hover { color: #fff; background: rgba(230, 164, 192, .26); border-color: var(--pink); }
.hud-btn.act { color: var(--pink); border-color: var(--line-2); background: rgba(230, 164, 192, .16); }

/* ══════════ 对话框 ══════════ */

.dialogue {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 15;
  padding: 0 4vw 3.2vh;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .32s, transform .32s;
  pointer-events: none;
}
.dialogue.on { opacity: 1; transform: none; }
.dialogue .box {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  min-height: 168px;
  padding: 30px 40px 34px;
  background: linear-gradient(180deg, rgba(12, 10, 24, .90), rgba(9, 8, 18, .95));
  border: 1px solid rgba(230, 164, 192, .26);
  border-radius: 5px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .78), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
  cursor: pointer;
}
.dialogue .box::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--pink), transparent);
  opacity: .8;
}
.speaker {
  position: absolute;
  top: -17px; left: 34px;
  padding: 5px 24px;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: .2em;
  color: #241321;
  background: linear-gradient(100deg, var(--pink-soft), var(--pink));
  border-radius: 3px;
  box-shadow: 0 6px 22px rgba(230, 164, 192, .34);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
.speaker.on { opacity: 1; transform: none; }

.dtext {
  font-size: clamp(15px, 1.32vw, 18.5px);
  line-height: 2.15;
  letter-spacing: .05em;
  color: #f4f1f8;
  white-space: pre-wrap;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .8);
  min-height: 3.6em;
}
.dtext .caret {
  display: inline-block;
  width: 8px; height: 1.05em;
  vertical-align: -0.16em;
  margin-left: 2px;
  background: var(--pink);
  animation: caretBlink 1s steps(1) infinite;
}
@keyframes caretBlink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

.dnext {
  position: absolute;
  right: 28px; bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: .26em; color: var(--pink);
  opacity: 0;
  transition: opacity .3s;
}
.dnext.on { opacity: 1; animation: nextFloat 1.5s ease-in-out infinite; }
@keyframes nextFloat { 0%, 100% { transform: translateY(0); opacity: .55; } 50% { transform: translateY(4px); opacity: 1; } }

/* 旁白样式（无说话人） */
.dialogue.narration .box {
  background: linear-gradient(180deg, rgba(10, 9, 20, .86), rgba(8, 7, 16, .92));
  border-color: rgba(255, 255, 255, .12);
}
.dialogue.narration .dtext { color: #ded8ea; font-family: var(--serif); letter-spacing: .1em; font-style: normal; }

@media (max-width: 720px) {
  .dialogue { padding: 0 12px 16px; }
  .dialogue .box { padding: 24px 20px 28px; min-height: 150px; }
  .speaker { left: 16px; font-size: 14px; padding: 4px 16px; }
  .dtext { font-size: 15px; line-height: 2; }
  .dnext { right: 16px; }
}

/* ══════════ 选项 ══════════ */

.choices {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 24px;
  background: radial-gradient(circle at 50% 50%, rgba(5, 4, 12, .58), rgba(5, 4, 12, .78));
  backdrop-filter: blur(2px);
}
.choices.on { display: flex; animation: fadeUp .38s ease both; }
.choice {
  position: relative;
  width: min(660px, 100%);
  padding: 19px 30px;
  text-align: left;
  font-size: 15.5px;
  letter-spacing: .08em;
  color: #f2eef6;
  background: linear-gradient(100deg, rgba(24, 20, 44, .94), rgba(14, 12, 26, .96));
  border: 1px solid rgba(230, 164, 192, .30);
  border-radius: 4px;
  cursor: pointer;
  transition: all .26s cubic-bezier(.2, .9, .3, 1);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .5);
  animation: choiceIn .45s cubic-bezier(.2, .9, .3, 1) both;
}
.choice:nth-child(1) { animation-delay: .04s; }
.choice:nth-child(2) { animation-delay: .12s; }
.choice:nth-child(3) { animation-delay: .20s; }
.choice:nth-child(4) { animation-delay: .28s; }
@keyframes choiceIn { from { opacity: 0; transform: translateX(-22px); } to { opacity: 1; transform: none; } }
.choice::after {
  content: "▸";
  position: absolute; right: 24px; top: 50%; transform: translateY(-50%);
  color: var(--pink); opacity: 0; transition: all .26s;
}
.choice:hover {
  border-color: var(--pink);
  background: linear-gradient(100deg, rgba(230, 164, 192, .22), rgba(30, 22, 48, .96));
  transform: translateX(6px) scale(1.008);
  box-shadow: 0 16px 48px rgba(230, 164, 192, .26);
}
.choice:hover::after { opacity: 1; right: 18px; }

/* ══════════ 结束 / 结局 ══════════ */

.ending {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: radial-gradient(circle at 50% 40%, rgba(20, 16, 38, .92), rgba(4, 3, 9, .98));
  text-align: center;
  padding: 40px 24px;
}
.ending.on { display: flex; animation: fadeUp .8s ease both; }
.ending .kicker { font-size: 11px; letter-spacing: .5em; color: var(--pink-deep); text-transform: uppercase; }
.ending h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 500;
  letter-spacing: .2em;
  background: linear-gradient(100deg, #fff, var(--pink-soft) 52%, var(--gold));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.ending .line { width: 120px; height: 1px; background: linear-gradient(90deg, transparent, var(--pink), transparent); }
.ending .sub { font-size: 14px; color: var(--text-dim); letter-spacing: .14em; max-width: 560px; line-height: 2.1; white-space: pre-wrap; }
.ending .acts { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* ══════════ 章节内进度条 ══════════ */

.progress-bar {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: rgba(255, 255, 255, .07);
  z-index: 25;
}
.progress-bar i {
  display: block; height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--pink-deep), var(--pink), var(--gold));
  transition: width .45s cubic-bezier(.2, .9, .3, 1);
  box-shadow: 0 0 12px rgba(230, 164, 192, .7);
}

/* ══════════ 存档面板 ══════════ */

.save-panel {
  position: absolute;
  top: 54px; right: 18px;
  z-index: 28;
  width: min(360px, calc(100% - 36px));
  padding: 20px;
  background: rgba(14, 12, 26, .97);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .8);
  display: none;
}
.save-panel.on { display: block; animation: fadeUp .28s ease both; }
.save-panel h5 {
  margin: 0 0 14px; font-size: 11px; letter-spacing: .34em; color: var(--pink-deep);
  text-transform: uppercase;
}
.save-panel .row { display: flex; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 12.5px; }
.save-panel .row .k { color: var(--text-mute); flex: 1; letter-spacing: .1em; }
.save-panel .row .v { color: var(--pink); font-family: var(--serif); letter-spacing: .08em; }
.save-panel .hint { margin-top: 14px; font-size: 11.5px; color: var(--text-mute); line-height: 1.9; letter-spacing: .06em; }

/* ══════════ 全屏 CG 插画 ══════════ */

.cg-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s ease;
}
.cg-layer.on { opacity: 1; }
.cg-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  animation: cgSlowZoom 14s ease-out both;
}
@keyframes cgSlowZoom { from { transform: scale(1.04); } to { transform: scale(1); } }

/* 打开篇章时：三态切换 */.save-panel .seg {
  display: flex; gap: 6px; margin-top: 6px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 4px; padding: 4px;
}
.save-panel .seg-btn {
  flex: 1; padding: 7px 4px; font-size: 11.5px; letter-spacing: .04em;
  background: transparent; border: none; border-radius: 3px;
  color: var(--text-mute); cursor: pointer; transition: all .2s; font-family: inherit;
}
.save-panel .seg-btn:hover { color: var(--pink); }
.save-panel .seg-btn.act { background: var(--pink-deep); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35); }

/* ══════════ 开场选择（从头看 / 按记录看） ══════════ */

.start-picker {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(6, 5, 12, .82);
  backdrop-filter: blur(6px);
  padding: 24px;
}
.start-picker.on { display: flex; animation: spFadeIn .26s ease both; }
@keyframes spFadeIn { from { opacity: 0; } to { opacity: 1; } }
.start-picker .sp-box {
  width: min(460px, 100%);
  padding: 30px 28px 22px;
  background: rgba(16, 14, 30, .98);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  box-shadow: 0 30px 90px rgba(0,0,0,.85);
  text-align: center;
  animation: spRise .3s ease both;
}
@keyframes spRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.start-picker .sp-kicker {
  font-size: 10.5px; letter-spacing: .44em; color: var(--pink-deep);
  text-transform: uppercase; margin-bottom: 12px;
}
.start-picker h4 {
  margin: 0 0 12px; font-size: 19px; font-family: var(--serif);
  letter-spacing: .06em; color: var(--text);
}
.start-picker p {
  margin: 0 0 24px; font-size: 12.5px; line-height: 1.9;
  color: var(--text-mute); letter-spacing: .05em;
}
.start-picker .sp-acts {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.start-picker .sp-acts .btn { min-width: 140px; }
.start-picker .sp-cancel {
  margin-top: 18px; padding: 6px 2px; font-size: 11.5px; letter-spacing: .1em;
  background: none; border: none; color: var(--text-mute); cursor: pointer;
  border-bottom: 1px solid transparent; transition: all .2s; font-family: inherit;
}
.start-picker .sp-cancel:hover { color: var(--pink); border-bottom-color: var(--pink-deep); }

/* ══════════ 章节内浮层提示 ══════════ */

.stage-toast {
  position: absolute;
  top: 72px; left: 50%; transform: translateX(-50%);
  z-index: 26;
  padding: 8px 20px;
  background: rgba(12, 10, 22, .88);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--pink);
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.stage-toast.on { opacity: 1; }

/* 解锁 CG 提示 */
.unlock-pop {
  position: absolute;
  right: 22px; bottom: 200px;
  z-index: 27;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: rgba(14, 12, 26, .95);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--gold);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .7);
  animation: unlockIn .6s cubic-bezier(.2, .9, .3, 1) both;
  pointer-events: none;
}
@keyframes unlockIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.unlock-pop img { width: 76px; height: 48px; object-fit: cover; border-radius: 2px; }
.unlock-pop .t { font-size: 10.5px; letter-spacing: .3em; color: var(--gold); text-transform: uppercase; }
.unlock-pop .n { font-size: 13px; color: #fff; letter-spacing: .06em; margin-top: 3px; }
