/* ============================================================
   叙事层样式 — Galgame 式沉浸:全屏背景 + 贴底对白框 + 抉择
   ============================================================ */

#narrative {
  position: fixed; inset: 0; z-index: 200;
  display: none; overflow: hidden;
  background: #0b0a08;
  font-family: inherit;
}
#narrative.open { display: block; }

/* 背景容器:双层交叉淡化 */
.ng-bg-wrap { position: absolute; inset: 0; overflow: hidden; z-index: 1; }

/* 背景层:全屏、缓慢 Ken-Burns 呼吸,层间交叉淡化 */
.ng-bg {
  position: absolute; inset: -4%;
  background-size: cover; background-position: center;
  transform: scale(1.06);
  opacity: 0;
  transition: opacity 1.1s ease;
  will-change: opacity, transform;
}
.ng-bg.show { opacity: 1; }
/* Ken-Burns:每次换图重启,缓慢推近平移 */
.ng-bg.kb { animation: ngBreathe 20s ease-out forwards; }
@keyframes ngBreathe {
  from { transform: scale(1.05) translate(0,0); }
  to   { transform: scale(1.13) translate(-1.6%, -1.1%); }
}

/* 暗角 + 情绪色叠加(减弱,让普桑式油画本身透出) */
.ng-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(125% 95% at 50% 20%, transparent 52%, rgba(0,0,0,.42) 100%),
    linear-gradient(180deg, transparent 45%, rgba(8,6,4,.35) 100%);
  transition: background .8s ease;
}
.ng-vignette.mood-tense { box-shadow: inset 0 0 180px rgba(60,20,10,.35); }
.ng-vignette.mood-blood { box-shadow: inset 0 0 200px rgba(120,20,15,.42); }
.ng-vignette.mood-pride { box-shadow: inset 0 0 180px rgba(150,60,20,.3); }
.ng-vignette.mood-home  { box-shadow: inset 0 0 200px rgba(200,140,60,.28); }
.ng-vignette.mood-hope  { box-shadow: inset 0 0 200px rgba(230,210,150,.24); }
.ng-vignette.mood-calm  { box-shadow: inset 0 0 140px rgba(0,0,0,.22); }

/* 退出按钮 */
.ng-exit {
  position: absolute; top: max(56px, env(safe-area-inset-top, 0px)); right: 14px; z-index: 6;
  background: rgba(0,0,0,.4); color: rgba(255,242,211,.85);
  border: 1px solid rgba(255,242,211,.25); border-radius: 20px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
  backdrop-filter: blur(4px);
}
.ng-exit:hover { background: rgba(0,0,0,.6); }

/* 微光暗示层 */
.ng-flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  opacity: 0; transition: opacity .35s ease;
}
.ng-flash.on { opacity: 1; }
.flash-pride.on { background: radial-gradient(circle at 50% 60%, rgba(170,50,30,.35), transparent 70%); }
.flash-home.on  { background: radial-gradient(circle at 50% 70%, rgba(210,150,70,.35), transparent 70%); }
.flash-calm.on  { background: radial-gradient(circle at 50% 60%, rgba(120,150,110,.22), transparent 70%); }
.flash-blood.on { background: radial-gradient(circle at 50% 55%, rgba(150,20,15,.4), transparent 70%); }
.flash-tense.on { background: radial-gradient(circle at 50% 55%, rgba(90,60,120,.25), transparent 70%); }

/* 长卷卡上的"可玩"徽标 */
.playable {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: linear-gradient(180deg,#c98a3a,#9c6522); color: #1a1206;
  font-size: 11px; font-weight: 800; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  animation: pulseGlow 2.2s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 2px 8px rgba(0,0,0,.4); }
  50%     { box-shadow: 0 2px 16px rgba(224,168,84,.8); }
}

/* ---- 舞台与贴底对白框 ---- */
.ng-stage {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 20px 16px max(34px, env(safe-area-inset-bottom, 0px));
  cursor: pointer;
}
.ng-box {
  width: 100%; max-width: 620px;
  background: linear-gradient(180deg, rgba(20,16,12,.82), rgba(12,10,8,.94));
  border: 1px solid rgba(255,242,211,.18);
  border-radius: 16px;
  padding: 20px 22px 22px;
  backdrop-filter: blur(8px);
  box-shadow: 0 -8px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,242,211,.08);
  animation: ngBoxUp .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes ngBoxUp { from { opacity:0; transform: translateY(18px); } to { opacity:1; transform:none; } }

.ng-name {
  display: inline-block; margin-bottom: 10px;
  font-size: 15px; font-weight: 700; letter-spacing: .04em;
  color: #f4d58a;
  border-bottom: 2px solid rgba(244,213,138,.4); padding-bottom: 3px;
}
.ng-text {
  margin: 0; font-size: 17px; line-height: 1.85;
  color: rgba(255,246,224,.94); min-height: 1.85em;
  letter-spacing: .01em;
}
/* 换句时的轻微淡入,减少硬切 */
.ng-text.swap { animation: ngTextIn .42s ease; }
@keyframes ngTextIn { from { opacity: .15; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* 说话人名字换人时也轻微淡入 */
.ng-name { transition: opacity .3s ease; }
/* 旁白语气(古朴):偏斜体、微弱 */
.ng-box.narr .ng-text { font-style: italic; color: rgba(238,228,200,.86); }
.ng-box.char .ng-text { font-style: normal; }

.ng-next {
  display: inline-block; margin-top: 14px;
  font-size: 13px; color: rgba(255,242,211,.55);
  animation: ngBlink 1.4s ease-in-out infinite;
}
@keyframes ngBlink { 0%,100%{opacity:.35} 50%{opacity:.9} }

/* ---- 抉择 ---- */
.ng-choices {
  margin-top: 8px; opacity: 0; transform: translateY(8px);
  transition: opacity .4s ease, transform .4s ease;
  pointer-events: none;
}
.ng-choices.show { opacity: 1; transform: none; pointer-events: auto; }
.ng-prompt {
  margin: 14px 0 12px; font-size: 14px; color: #f4d58a; font-weight: 600;
}
.ng-choice {
  display: block; width: 100%; text-align: left;
  margin: 9px 0; padding: 14px 16px;
  background: rgba(40,30,20,.7);
  border: 1px solid rgba(244,213,138,.3); border-radius: 12px;
  color: rgba(255,246,224,.95); font-size: 15.5px; line-height: 1.5;
  cursor: pointer; transition: all .18s ease;
  font-family: inherit;
}
.ng-choice:hover, .ng-choice:focus {
  background: rgba(90,60,30,.75); border-color: #f4d58a;
  transform: translateX(3px); outline: none;
}

/* ---- 结算 ---- */
.ng-end {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(56px, env(safe-area-inset-top, 0px)) 22px max(34px, env(safe-area-inset-bottom, 0px)); gap: 18px; overflow-y: auto;
  animation: ngFade 1s ease;
}
@keyframes ngFade { from{opacity:0} to{opacity:1} }
.ng-end-eyebrow {
  font-size: 13px; letter-spacing: .3em; color: rgba(244,213,138,.7);
  text-transform: none; margin: 0;
}
.ng-end-echo {
  max-width: 560px; text-align: center; margin: 0;
  font-size: 21px; line-height: 1.75; color: #fff6e0; font-style: italic;
  text-shadow: 0 2px 20px rgba(0,0,0,.6);
}
.ng-motifs {
  width: 100%; max-width: 520px; margin-top: 6px;
  background: rgba(14,11,8,.7); border: 1px solid rgba(255,242,211,.14);
  border-radius: 14px; padding: 16px 18px; backdrop-filter: blur(6px);
}
.ng-motifs-title { margin: 0 0 12px; font-size: 13px; color: rgba(255,242,211,.6); letter-spacing:.06em; }
.ng-motif { display: flex; gap: 12px; align-items: flex-start; margin: 11px 0; opacity: .72; transition: opacity .3s; }
.ng-motif.strong { opacity: 1; }
.ng-motif.strong .ng-motif-k { box-shadow: 0 0 14px currentColor; }
.ng-motif-k {
  flex: none; display: inline-block; padding: 4px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 700; color: #fff; letter-spacing: .05em;
}
.ng-motif p { margin: 0; font-size: 14px; line-height: 1.6; color: rgba(255,246,224,.85); }

.ng-end-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; margin-top: 6px; }
.ng-btn {
  padding: 13px 18px; border-radius: 12px; cursor: pointer; font-size: 15px; font-family: inherit;
  background: rgba(30,24,16,.8); color: rgba(255,246,224,.9);
  border: 1px solid rgba(244,213,138,.3); transition: all .18s;
}
.ng-btn.primary { background: linear-gradient(180deg,#c98a3a,#9c6522); color:#1a1206; font-weight:700; border-color:#e0a854; }
.ng-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.ng-end-foot { font-size: 13px; color: rgba(255,242,211,.5); margin: 4px 0 0; font-style: italic; }

@media (min-width: 640px) {
  .ng-text { font-size: 18px; }
}
