/* 章节过场（chapter-flow.mjs）：归塔演出 + 新章标题卡。全屏模态 <dialog>，电脑与手机共用。图片与影片按真实像素原尺寸或缩小显示。 */
.chapter-flow{--cf-serif:"RuneSerif","Noto Serif SC","Noto Serif CJK SC","Source Han Serif SC","Songti SC",serif;--cf-gold:#ecd49a;
  position:fixed;inset:0;width:100vw;height:100vh;height:100dvh;max-width:none;max-height:none;margin:0;padding:0;border:0;overflow:hidden;
  background:#03070c;color:#f4e8c8;isolation:isolate;z-index:90;opacity:1;transition:opacity .32s ease}
.chapter-flow::backdrop{background:#03070c}
.chapter-flow.is-leaving{opacity:0}
.chapter-flow [hidden]{display:none!important}
html.i18n-en .chapter-flow{--cf-serif:"Arcana Text","RuneSerif","Noto Serif SC",serif}

/* 归塔演出 */
.chapter-flow .cf-cinema{position:absolute;inset:0;background:radial-gradient(ellipse at 50% 45%,#0d1a26 0%,#03070c 70%)}
.chapter-flow .cf-video{position:absolute;max-width:none;max-height:none;object-fit:contain;pointer-events:none}
.chapter-flow .cf-skip{position:absolute;right:max(16px,2vw);bottom:max(16px,2.4vh);z-index:2;min-height:40px;border:1px solid #e2c78b85;background:#07111eea;border-radius:24px;
  padding:10px 20px;color:#f3e3ba;box-shadow:0 4px 22px #0008;font:14px/1.4 var(--cf-serif);letter-spacing:.08em;cursor:pointer}
/* focus is put on these buttons when each step opens (keyboard Enter / Space / Esc work at once): a soft glow, not a box */
.chapter-flow .cf-skip:focus-visible{outline:none;border-color:#f0d58e;box-shadow:0 0 0 1px #f0d58e99,0 4px 22px #0008}
.chapter-flow .cf-continue:focus-visible{outline:none;color:#fff4d6;text-shadow:0 0 10px #f0b43c99}

/* 标题卡 */
.chapter-flow .cf-card{position:absolute;inset:0;cursor:pointer}
.chapter-flow .cf-art{position:absolute;inset:0;overflow:hidden;opacity:0;transition:opacity .9s ease}
.chapter-flow .cf-card.is-loaded .cf-art{opacity:1}
.chapter-flow .cf-art img{position:absolute;max-width:none;max-height:none;object-fit:fill;pointer-events:none;user-select:none}
.chapter-flow .cf-echo{filter:blur(18px) brightness(.45) saturate(.85)}
.chapter-flow .cf-echo.top,.chapter-flow .cf-echo.bottom{transform:scaleY(-1)}
.chapter-flow .cf-echo.left,.chapter-flow .cf-echo.right{transform:scaleX(-1)}
.chapter-flow .cf-shade{position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(ellipse 70% 58% at 50% 50%,#03070ccc 0%,#03070c99 46%,#03070c55 74%,#03070c22 100%),linear-gradient(180deg,#03070c88 0%,transparent 22%,transparent 72%,#03070cb0 100%)}
.chapter-flow .cf-text{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:min(88vw,980px);display:flex;flex-direction:column;align-items:center;gap:clamp(8px,1.6vh,18px);text-align:center;pointer-events:none}
.chapter-flow .cf-kicker{display:flex;align-items:center;gap:14px;font:600 clamp(14px,2.1vh,22px)/1.2 var(--cf-serif);letter-spacing:.42em;text-indent:.42em;color:var(--cf-gold);text-shadow:0 1px 3px #000}
.chapter-flow .cf-kicker::before,.chapter-flow .cf-kicker::after{content:"";width:clamp(28px,5vw,72px);height:1px;background:linear-gradient(90deg,transparent,#ecd49acc)}
.chapter-flow .cf-kicker::after{background:linear-gradient(90deg,#ecd49acc,transparent)}
.chapter-flow .cf-name{margin:0;font:700 clamp(40px,8.4vh,92px)/1.08 var(--cf-serif);letter-spacing:.16em;text-indent:.16em;color:#fff4d6;
  text-shadow:0 0 28px #f0b43c66,0 3px 6px #000,0 0 2px #000}
.chapter-flow .cf-subtitle{margin:0;font:600 clamp(16px,2.6vh,28px)/1.3 var(--cf-serif);letter-spacing:.24em;text-indent:.24em;color:#f1dfb1;text-shadow:0 2px 4px #000}
.chapter-flow .cf-rule{display:block;width:clamp(120px,22vw,320px);height:1px;background:linear-gradient(90deg,transparent,#ecd49ab0,transparent)}
.chapter-flow .cf-story{margin:0;max-width:min(84vw,760px);font:400 clamp(14px,2.1vh,21px)/1.6 var(--cf-serif);letter-spacing:.06em;color:#e9e2cf;text-shadow:0 1px 3px #000}
.chapter-flow .cf-continue{position:absolute;left:50%;bottom:max(18px,4.5vh);transform:translateX(-50%);border:0;background:none;padding:8px 18px;color:#e9dcb8b8;
  font:400 clamp(12px,1.7vh,16px)/1.4 var(--cf-serif);letter-spacing:.3em;text-indent:.3em;cursor:pointer;white-space:nowrap}
/* card progress: a thin line under the hint fills over the card's own duration */
.chapter-flow .cf-continue::after{content:"";position:absolute;left:18px;right:18px;bottom:2px;height:1px;background:#ecd49a88;transform-origin:left;transform:scaleX(0)}
.chapter-flow .cf-card.is-in .cf-continue::after{animation:cf-progress var(--cf-card-ms,2500ms) linear forwards}
html.i18n-en .chapter-flow :is(.cf-kicker,.cf-name,.cf-subtitle,.cf-story,.cf-continue){letter-spacing:.04em;text-indent:0}
html.i18n-en .chapter-flow .cf-name{letter-spacing:.06em}

/* entrance: text rises in, staggered (opacity + small translate only; the art is never scaled) */
.chapter-flow .cf-card.is-in :is(.cf-kicker,.cf-name,.cf-subtitle,.cf-rule,.cf-story){animation:cf-rise .8s cubic-bezier(.2,.7,.2,1) both}
.chapter-flow .cf-card.is-in .cf-name{animation-delay:.12s}
.chapter-flow .cf-card.is-in .cf-subtitle{animation-delay:.3s}
.chapter-flow .cf-card.is-in .cf-rule{animation-delay:.42s}
.chapter-flow .cf-card.is-in .cf-story{animation-delay:.54s}
@keyframes cf-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
@keyframes cf-progress{to{transform:scaleX(1)}}

/* phone portrait: the art band sits higher, text below it stays readable */
@media (max-width:999px){
  .chapter-flow .cf-text{width:92vw;gap:10px}
  .chapter-flow .cf-name{font-size:clamp(34px,10.5vw,52px);letter-spacing:.1em;text-indent:.1em}
  .chapter-flow .cf-kicker{font-size:15px;letter-spacing:.3em;text-indent:.3em}
  .chapter-flow .cf-subtitle{font-size:17px;letter-spacing:.14em;text-indent:.14em}
  .chapter-flow .cf-story{font-size:15px;line-height:1.65}
}

/* reduced motion: no fades, no rise, no progress sweep */
.chapter-flow.is-reduced,.chapter-flow.is-reduced .cf-art{transition:none}
.chapter-flow.is-reduced .cf-card.is-in :is(.cf-kicker,.cf-name,.cf-subtitle,.cf-rule,.cf-story),.chapter-flow.is-reduced .cf-card.is-in .cf-continue::after{animation:none}
@media (prefers-reduced-motion:reduce){
  .chapter-flow,.chapter-flow .cf-art{transition:none}
  .chapter-flow .cf-card.is-in :is(.cf-kicker,.cf-name,.cf-subtitle,.cf-rule,.cf-story),.chapter-flow .cf-card.is-in .cf-continue::after{animation:none}
}

/* 章节过渡美术（chapterart）：标题卡底图 = 新章主视觉（开场片尾帧）。字放在主视觉下部较静的区域（宽屏）/ 图带下方（手机竖屏），
   位置由 chapter-flow.mjs placeText() 按图的实际显示框算出；Boss 剪影所在的中上部不压暗。 */
.chapter-flow .cf-card.has-keyart .cf-text{transform:translateX(-50%)}
.chapter-flow .cf-card.has-keyart .cf-shade{background:linear-gradient(180deg,#03070c40 0%,transparent 16%,transparent 44%,#03070c80 64%,#03070cd0 84%,#03070ce6 100%)}
.chapter-flow .cf-card.has-keyart.is-in .cf-shade{animation:cf-shade .9s ease both}
/* 紧接开场片：图已经在屏上（就是开场片最后一帧），不再淡入 */
.chapter-flow .cf-card.is-instant .cf-art{transition:none}
.chapter-flow .cf-video{background:#03070c}
@keyframes cf-shade{from{opacity:0}to{opacity:1}}
.chapter-flow.is-reduced .cf-card.has-keyart.is-in .cf-shade{animation:none}
@media (prefers-reduced-motion:reduce){.chapter-flow .cf-card.has-keyart.is-in .cf-shade{animation:none}}

/* mobile16pm A2 · 手机竖屏（chapter-flow.mjs phoneFrame / echoVideo）：图带按原像素 / DPR 的高度显示、两侧裁掉，上下是同一画面的模糊倒影；
   「跳过演出」「点击跳过」贴底部安全区（≥ 44 px），不悬在屏幕中间。电脑版（body.desktop-game）不受影响。 */
@media (max-width:999.98px){
  body:not(.desktop-game) .chapter-flow .cf-vecho{position:absolute;max-width:none;max-height:none;object-fit:fill;pointer-events:none;user-select:none}
  body:not(.desktop-game) .chapter-flow .cf-vecho[hidden]{display:none}
  body:not(.desktop-game) .chapter-flow .cf-echo{filter:blur(18px) brightness(.62) saturate(.9)}
  body:not(.desktop-game) .chapter-flow .cf-cinema::after{content:"";position:absolute;inset:0;pointer-events:none;background:linear-gradient(180deg,#03070c80 0%,transparent 18%,transparent 62%,#03070c40 72%,#03070cb0 100%)}
  body:not(.desktop-game) .chapter-flow .cf-skip{right:max(16px,env(safe-area-inset-right));bottom:calc(max(16px,env(safe-area-inset-bottom)) + 8px);min-width:112px;min-height:44px;font-size:15px}
  body:not(.desktop-game) .chapter-flow .cf-continue{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 6px);min-height:44px;font-size:14px}
}
