/* 鳥居のむこう（仮） — style.css（画面の骨組み・文字窓・選択肢・画面の重ね）
 * 墨色・生成り・朱。明朝体。主な読者は40〜60代：文字は大きめ・行間ゆったり・コントラスト十分。
 */
:root {
  --sumi: #0d0b0c;
  --sumi-2: #18141500;
  --ink: #161214;
  --kinari: #f1ead8;
  --kinari-dim: #cfc6b2;
  --shu: #c8432f;
  --shu-light: #e2664f;
  --gold: #c9a45c;
  --pov-color: transparent;
  --name-color: #cfc6b4;
  --font-mincho: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Noto Serif JP", "BIZ UDPMincho", serif;
  --fs: clamp(17px, 4.9vw, 24px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--sumi);
  color: var(--kinari);
  font-family: var(--font-mincho);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
body { position: fixed; inset: 0; }
button, input, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- PC用のぼかし背景 ---------- */
#backdrop {
  position: fixed; inset: -6%;
  background: var(--sumi) center / cover no-repeat;
  filter: blur(28px) brightness(.32) saturate(.7);
  transform: scale(1.08);
  transition: background-image .8s ease;
  z-index: 0;
}

/* ---------- 舞台 ---------- */
#stage {
  position: relative;
  z-index: 1;
  width: min(100vw, calc(100vh * 2 / 3));
  height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
  container-type: size;
  container-name: stage;
  user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 60px rgba(0,0,0,.8);
}
@supports (height: 100dvh) {
  #stage { width: min(100vw, calc(100dvh * 2 / 3)); height: 100dvh; }
}
/* 横に狭い端末（スマホの縦）は全画面 */
@media (max-aspect-ratio: 2/3) {
  #stage { width: 100vw; box-shadow: none; }
}
/* 文字の大きさ：舞台の幅に合わせ、高さでも抑える（低い画面で文字窓からあふれないように・1123b） */
#stage { --fs-base: clamp(17px, min(4.9vw, 3vh), 24px); }
@supports (width: 1cqw) {
  #stage > * { --fs-base: clamp(17px, min(5cqw, 3cqh), 26px); }
}
#stage.ts-s > * { --fs-k: .9; }
#stage.ts-m > * { --fs-k: 1; }
#stage.ts-l > * { --fs-k: 1.16; }
#stage > * { --fs: calc(var(--fs-base) * var(--fs-k, 1)); }

#layer-bg, #layer-ch, #layer-fx, #layer-explore, #layer-ui, #layer-modal {
  position: absolute; inset: 0;
}
#layer-bg { z-index: 1; overflow: hidden; }
#layer-ch { z-index: 2; pointer-events: none; overflow: hidden; }
#layer-fx { z-index: 3; pointer-events: none; }
#layer-explore { z-index: 4; pointer-events: none; }
#layer-explore > * { pointer-events: auto; }
#layer-ui { z-index: 5; pointer-events: none; }
#layer-ui > * { pointer-events: auto; }
#layer-modal { z-index: 10; pointer-events: none; }
#layer-modal > * { pointer-events: auto; }

/* ---------- 背景（2枚でクロスフェード） ---------- */
#layer-bg .bg-a, #layer-bg .bg-b {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity .8s ease;
}
#layer-bg .bg-a.on, #layer-bg .bg-b.on { opacity: 1; }
#layer-bg .mirror { transform: scaleX(-1); }
#layer-bg .bg-img {
  position: absolute; inset: 0;
  background: #000 center / cover no-repeat;
  transform-origin: 50% 50%;
  will-change: transform;
}
/* 絵が無いときの仮表示（id の文字） */
#layer-bg .bg-img[data-ph]::after {
  content: attr(data-ph);
  position: absolute; left: 50%; top: 30%;
  transform: translate(-50%, -50%);
  font-size: calc(var(--fs) * .9);
  letter-spacing: .1em;
  color: rgba(241,234,216,.35);
  border: 1px solid rgba(241,234,216,.2);
  padding: .4em 1em;
  white-space: nowrap;
}
#layer-bg .mirror .bg-img[data-ph]::after { transform: translate(-50%, -50%) scaleX(-1); }
#layer-bg .bg-black {
  position: absolute; inset: 0; background: #000; opacity: 0;
  pointer-events: none;
}
#layer-bg .bg-black.on { opacity: 1; }

/* ゆっくり動く（ケンバーンズ） */
.bg-img.pan-up, .bg-img.pan-down, .bg-img.pan-left, .bg-img.pan-right, .bg-img.pan-in, .bg-img.pan-out {
  animation-timing-function: cubic-bezier(.3,.1,.3,1);
  animation-fill-mode: forwards;
  animation-duration: 26s;
}
.bg-img.pan-up    { animation-name: pan-up; }
.bg-img.pan-down  { animation-name: pan-down; }
.bg-img.pan-left  { animation-name: pan-left; }
.bg-img.pan-right { animation-name: pan-right; }
.bg-img.pan-in    { animation-name: pan-in; }
.bg-img.pan-out   { animation-name: pan-out; }
@keyframes pan-up    { from { transform: scale(1.14) translateY(4%); }  to { transform: scale(1.14) translateY(-4%); } }
@keyframes pan-down  { from { transform: scale(1.14) translateY(-4%); } to { transform: scale(1.14) translateY(4%); } }
@keyframes pan-left  { from { transform: scale(1.14) translateX(4%); }  to { transform: scale(1.14) translateX(-4%); } }
@keyframes pan-right { from { transform: scale(1.14) translateX(-4%); } to { transform: scale(1.14) translateX(4%); } }
@keyframes pan-in    { from { transform: scale(1.0); }  to { transform: scale(1.16); } }
@keyframes pan-out   { from { transform: scale(1.16); } to { transform: scale(1.0); } }
#stage.calm .bg-img { animation-duration: 60s !important; }

/* ---------- 立ち絵（DESIGN §16・§17・§18：全編「顔アップ」・1123c） ----------
 * engine が left/top/width/height（舞台に対する％）を決める。顔が舞台の上半分の主役（顔の幅＝舞台の幅の5〜6割）。
 * .ch（置き場所・出入り）> .ch-breath（ごくゆっくりの呼吸）> .ch-move（表情が変わるときの小さな動き）> .ch-body（絵・120ms のクロスフェード）
 */
.ch {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  opacity: 0;
  z-index: 2;
  transform: translateY(1.2%);
  transition: opacity .26s ease, transform .32s cubic-bezier(.2,.7,.3,1), filter .3s ease,
              left .45s ease, top .45s ease, width .45s ease, height .45s ease;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,.6));
  pointer-events: none;
}
.ch.on { opacity: 1; transform: none; }
.ch.off { opacity: 0; transform: translateY(.8%); transition-duration: .18s, .18s; }
.ch.quick { transition: opacity .12s ease, transform .12s ease, filter .3s ease; }
.ch.quick.off { transition-duration: .12s; }
/* うしろに小さく暗く（手で出した人・話していない） */
.ch[data-role="back"] { z-index: 1; filter: brightness(.42) saturate(.6) blur(.6px) drop-shadow(0 6px 16px rgba(0,0,0,.6)); }
.ch.dim:not([data-role="back"]) { filter: brightness(.6) saturate(.75) drop-shadow(0 8px 22px rgba(0,0,0,.6)); }
/* close：話者が替わるたびに左右から小さくすべりこむ */
.ch.slide { animation: ch-slide .46s cubic-bezier(.2,.75,.3,1) both; }
@keyframes ch-slide { from { opacity: 0; transform: translateX(var(--slide, 6%)); } to { opacity: 1; transform: none; } }

.ch-breath, .ch-move, .ch-body { position: absolute; inset: 0; }
.ch-breath { transform-origin: 50% 100%; animation: ch-breath 5.2s ease-in-out var(--breath-delay, 0s) infinite alternate; }
@keyframes ch-breath { from { transform: translateY(0) scale(1); } to { transform: translateY(-.35%) scale(1.006); } }
.ch-body .ch-pic { position: absolute; inset: 0; opacity: 0; transition: opacity .12s linear; }
.ch-body .ch-pic.on { opacity: 1; }
.ch-body .ch-pic.out { opacity: 0; }
.ch-body img { width: 100%; height: 100%; object-fit: contain; object-position: 50% 0; display: block; }
.ch-move { transform-origin: 50% 40%; }
.ch-move.m-up { animation: m-up .5s cubic-bezier(.2,.8,.3,1); }
.ch-move.m-hop { animation: m-hop .55s ease; }
.ch-move.m-shiver { animation: m-shiver .09s linear 6; }
.ch-move.m-sink { animation: m-sink 2.4s ease forwards; }
.ch-move.m-tilt { animation: m-tilt 2.4s ease forwards; }
.ch-move.m-lean { animation: m-lean .8s ease; }
.ch-move.m-soft { animation: m-soft .6s ease; }
@keyframes m-up { 0% { transform: none; } 30% { transform: translateY(-1.6%) scaleY(1.015); } 100% { transform: none; } }
@keyframes m-hop { 0%,100% { transform: none; } 30% { transform: translateY(-2%); } 55% { transform: none; } 75% { transform: translateY(-.7%); } }
@keyframes m-shiver { 0%,100% { transform: none; } 25% { transform: translateX(-.35%); } 75% { transform: translateX(.35%); } }
@keyframes m-sink { 0% { transform: none; } 40%,100% { transform: translateY(.9%); } }
@keyframes m-tilt { 0% { transform: none; } 30%,100% { transform: rotate(-1.6deg); } }
@keyframes m-lean { 0%,100% { transform: none; } 40% { transform: scale(1.02) translateY(.5%); } }
@keyframes m-soft { 0%,100% { transform: none; } 40% { transform: translateY(-.5%); } }
#stage.calm .ch-move.m-shiver { animation: none; }
#stage.calm .ch-breath { animation-duration: 8s; }
.ch-ph {
  position: absolute; left: 22%; right: 22%; top: 10%; bottom: 30%;
  border-radius: 46% 46% 20% 20% / 40% 40% 14% 14%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ch-color) 55%, #000) 0%, color-mix(in srgb, var(--ch-color) 22%, #000) 100%);
  background-color: #333;
  border: 1px solid rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.75);
  font-size: calc(var(--fs) * .8);
  text-align: center;
}
/* emo の記号（！？汗）：顔の右上に短く */
.ch-emo {
  position: absolute; top: 10%; left: 70%;
  font-size: calc(var(--fs) * 2);
  font-weight: bold;
  color: var(--kinari);
  text-shadow: 0 0 8px rgba(0,0,0,.8);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.ch.emo-bang .ch-emo, .ch.emo-q .ch-emo { animation: emo-pop 1.2s ease forwards; }
.ch.emo-bang .ch-emo { color: var(--shu-light); }
#nameplate.emo-hop, #nameplate.emo-bang { animation: emo-hop .5s ease; }
#nameplate.emo-shiver { animation: emo-shiver .5s linear 2; }
.ch.emo-sweat .ch-emo { opacity: 1; animation: emo-sweat 1.2s ease forwards; }
.ch.emo-sweat .ch-emo::before {
  content: ""; display: block; width: .4em; height: .55em;
  background: #9cc6e8; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform: rotate(-20deg);
  box-shadow: inset -2px -2px 0 rgba(255,255,255,.4);
}
@keyframes emo-pop { 0% { opacity: 0; transform: scale(.4) translateY(10px); } 20% { opacity: 1; transform: scale(1.15); } 35% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes emo-hop { 0%,100% { margin-bottom: 0; } 35% { margin-bottom: 2.2%; } 60% { margin-bottom: 0; } 78% { margin-bottom: .8%; } }
@keyframes emo-shiver { 0%,100% { margin-left: 0; } 25% { margin-left: -3px; } 75% { margin-left: 3px; } }
@keyframes emo-sweat { 0% { opacity: 0; transform: translateY(-6px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(10px); } }
#stage.calm #nameplate.emo-shiver { animation: none; }

/* ---------- 文字窓 ---------- */
#textwin {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 30%;
  padding: calc(var(--fs) * 1.25) calc(var(--fs) * 1.1 + var(--safe-r)) calc(var(--fs) * .9 + var(--safe-b)) calc(var(--fs) * 1.1 + var(--safe-l));
  background:
    linear-gradient(180deg, rgba(10,8,9,0) 0%, rgba(10,8,9,.55) 12%, rgba(12,10,11,.86) 30%, rgba(12,10,11,.9) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .95  0 0 0 0 .92  0 0 0 0 .85  0 0 0 .06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  color: var(--kinari);
  font-size: var(--fs);
  line-height: 1.75;
  letter-spacing: .04em;
  cursor: pointer;
  transition: opacity .25s ease;
}
/* 長い行（engine が .long を付ける）：行間を詰めて窓を高く。それでも入らない行は engine がページに分け、.has-more で「続き」を出す（1123b） */
#textwin.long { height: 38%; line-height: 1.6; }
#textwin.has-more::after {
  content: "続き ▼";
  position: absolute;
  right: calc(var(--fs) * 1 + var(--safe-r));
  top: calc(var(--fs) * .2);
  font-size: calc(var(--fs) * .62);
  letter-spacing: .1em;
  color: var(--shu-light);
  opacity: .9;
  pointer-events: none;
}
#textwin::before {
  /* 上の細い線（視点の人物の色がにじむ） */
  content: ""; position: absolute; left: 6%; right: 6%; top: calc(var(--fs) * .55); height: 1px;
  background: linear-gradient(90deg, transparent, rgba(241,234,216,.28) 20%, rgba(241,234,216,.28) 80%, transparent);
}
#stage:not([data-pov="none"]) #textwin {
  box-shadow: inset 0 0 0 0 transparent;
  background:
    linear-gradient(180deg, rgba(10,8,9,0) 0%, rgba(10,8,9,.55) 12%, rgba(12,10,11,.86) 30%, rgba(12,10,11,.9) 100%),
    radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--pov-color) 22%, transparent) 0%, transparent 70%);
}
#stage:not([data-pov="none"]) #textwin::before {
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--pov-color) 60%, transparent) 20%, color-mix(in srgb, var(--pov-color) 60%, transparent) 80%, transparent);
}
#text {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.6);
  word-break: normal;
  overflow-wrap: anywhere;
  line-break: strict;
}
#text::-webkit-scrollbar { display: none; }
#textwin[data-kind="s"] #text { padding-top: calc(var(--fs) * .35); }
#textwin[data-kind="n"] #text { color: #e9e1cd; }

/* 1字ずつ */
.tc { opacity: 0; transition: opacity .18s ease; }
.tc.v { opacity: 1; }
.t-big { font-size: 1.45em; line-height: 1.2; font-weight: 600; }
.t-slow.v { transition: opacity .6s ease; }
.t-s { display: inline-block; }
.t-s.v { animation: t-shiver .18s steps(2) infinite; }
@keyframes t-shiver { 0% { transform: translate(0, 0); } 50% { transform: translate(.6px, -.6px); } 100% { transform: translate(-.6px, .5px); } }
#stage.calm .t-s.v { animation: none; }

/* 名前札 */
#nameplate {
  position: absolute;
  left: calc(var(--fs) * .8 + var(--safe-l));
  top: calc(var(--fs) * -1.0);
  min-width: 5.5em;
  padding: .28em 1.1em .3em .9em;
  font-size: calc(var(--fs) * .95);
  font-weight: 600;
  letter-spacing: .12em;
  line-height: 1.3;
  color: #fff;
  background: linear-gradient(90deg, rgba(14,11,12,.95), rgba(14,11,12,.82));
  border-left: 4px solid var(--name-color);
  border-bottom: 1px solid color-mix(in srgb, var(--name-color) 55%, transparent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--name-color) 55%, transparent);
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}

/* 次へ */
#next-mark {
  position: absolute;
  right: calc(var(--fs) * 1 + var(--safe-r));
  bottom: calc(var(--fs) * .7 + var(--safe-b));
  width: 0; height: 0;
  border-left: calc(var(--fs) * .38) solid transparent;
  border-right: calc(var(--fs) * .38) solid transparent;
  border-top: calc(var(--fs) * .48) solid var(--shu-light);
  opacity: 0;
  transition: opacity .2s ease;
}
#next-mark.on { opacity: 1; animation: next-bob 1.1s ease-in-out infinite; }
@keyframes next-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
#stage.mode-auto #next-mark.on { border-top-color: var(--gold); }

/* ---------- 案内（sys） ---------- */
#sysbox {
  position: absolute; left: 0; right: 0; top: 40%;
  display: flex; justify-content: center;
  padding: 0 1em;
  cursor: pointer;
}
#sysbox .sys-inner {
  max-width: 92%;
  padding: .85em 1.5em;
  font-size: var(--fs);
  line-height: 1.7;
  letter-spacing: .08em;
  text-align: center;
  color: var(--kinari);
  background: rgba(10,8,9,.82);
  border-top: 1px solid rgba(201,164,92,.6);
  border-bottom: 1px solid rgba(201,164,92,.6);
  box-shadow: 0 0 30px rgba(0,0,0,.6);
  animation: fade-in .4s ease;
}

/* ---------- 選択肢 ---------- */
#choices {
  position: absolute; left: 0; right: 0;
  top: 18%; bottom: 38%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: calc(var(--fs) * .8);
  padding: 0 calc(var(--fs) * 1 + var(--safe-r)) 0 calc(var(--fs) * 1 + var(--safe-l));
}
#choices.guard .choice { pointer-events: none; }
.choice {
  width: 100%;
  max-width: 30em;
  min-height: 52px;
  padding: .7em 1.2em;
  font-size: var(--fs);
  line-height: 1.5;
  letter-spacing: .06em;
  color: var(--kinari);
  background: linear-gradient(90deg, rgba(14,11,12,.72), rgba(20,15,16,.92) 50%, rgba(14,11,12,.72));
  border: 1px solid rgba(241,234,216,.35);
  border-left: 3px solid var(--shu);
  border-radius: 2px;
  cursor: pointer;
  text-align: center;
  animation: choice-in .35s ease both;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
  transition: background .2s ease, transform .15s ease;
}
.choice:nth-child(2) { animation-delay: .06s; }
.choice:nth-child(3) { animation-delay: .12s; }
.choice:nth-child(4) { animation-delay: .18s; }
.choice:hover, .choice:focus-visible { background: rgba(60,28,24,.92); outline: none; }
.choice:active { transform: scale(.98); }
.choice.seen { color: var(--kinari-dim); border-left-color: #6d5a52; }
.choice.guide { animation: choice-in .35s ease both, guide-glow 2.4s ease-in-out .4s infinite; border-color: rgba(231,206,150,.7); }
@keyframes guide-glow {
  0%,100% { box-shadow: 0 6px 20px rgba(0,0,0,.5), 0 0 0 rgba(231,206,150,0); }
  50% { box-shadow: 0 6px 20px rgba(0,0,0,.5), 0 0 22px rgba(231,206,150,.45); }
}
@keyframes choice-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#stage.calm .choice.guide { animation: choice-in .35s ease both; box-shadow: 0 0 0 2px rgba(231,206,150,.45); }

/* ---------- 遊び方（tip） ---------- */
#toast.tip {
  position: absolute; left: 50%; top: 14%;
  transform: translateX(-50%);
  width: min(88%, 26em);
  padding: 1em 1.2em .8em;
  font-size: calc(var(--fs) * .92);
  line-height: 1.75;
  background: rgba(241,234,216,.95);
  color: #241c18;
  border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
  cursor: pointer;
  animation: fade-in .35s ease;
}
#toast .tip-head { font-weight: 700; color: var(--shu); letter-spacing: .2em; font-size: .85em; margin-bottom: .3em; }
#toast .tip-foot { text-align: right; font-size: .75em; color: #6d5f55; margin-top: .4em; }

/* ---------- 章の札 ---------- */
#chapter-card {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6em;
  background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,.55) 0%, rgba(0,0,0,.85) 75%);
  opacity: 0;
  transition: opacity .6s ease;
  cursor: pointer;
}
#chapter-card.on { opacity: 1; }
#chapter-card .cc-line { width: 40%; height: 1px; background: linear-gradient(90deg, transparent, rgba(200,67,47,.9), transparent); }
#chapter-card .cc-sub { font-size: calc(var(--fs) * .85); letter-spacing: .4em; color: var(--kinari-dim); }
#chapter-card .cc-title { font-size: calc(var(--fs) * 1.65); letter-spacing: .3em; padding-left: .3em; text-align: center; line-height: 1.5; text-shadow: 0 0 20px rgba(0,0,0,.9); }
#chapter-card .cc-rec { margin-top: 1em; font-size: calc(var(--fs) * .8); color: var(--gold); letter-spacing: .15em; }

/* ---------- 古い紙（paper） ---------- */
#paper {
  position: absolute; inset: 0;
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background-color: #1a1410;
  background-position: center; background-size: cover;
  cursor: pointer;
  animation: paper-in .7s ease;
}
#paper.closing { animation: paper-out .45s ease forwards; }
#paper .paper-sheet {
  position: relative;
  width: 82%; height: 72%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(120,90,50,.18) 0%, transparent 40%),
    radial-gradient(ellipse at 75% 80%, rgba(110,80,40,.22) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 50%, #e6d8b6 0%, #cdb98d 70%, #a98f5e 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,.8), inset 0 0 50px rgba(90,60,30,.45);
  transform: rotate(-.6deg);
}
#paper.has-img .paper-sheet { background: none; box-shadow: none; }
#paper .paper-text {
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  max-height: 86%;
  max-width: 88%;
  font-size: calc(var(--fs) * 1.25);
  line-height: 1.9;
  letter-spacing: .14em;
  color: #1d1410;
  font-weight: 600;
  text-orientation: mixed;
}
#paper .paper-text .tc {
  display: inline-block;
  opacity: 0;
  filter: blur(5px);
  transform: scale(1.25);
  transition: opacity 1.1s ease, filter 1.3s ease, transform 1.1s ease;
  text-shadow: 0 0 1px rgba(30,15,10,.6), 0 0 6px rgba(60,30,20,.25);
}
#paper .paper-text .tc.v { opacity: .92; filter: blur(.25px); transform: none; }
#paper .paper-hint {
  position: absolute; bottom: calc(4% + var(--safe-b)); left: 0; right: 0;
  text-align: center; font-size: calc(var(--fs) * .75); color: rgba(241,234,216,.7);
  opacity: 0; transition: opacity .6s ease; letter-spacing: .2em;
  text-shadow: 0 1px 3px #000;
}
#paper .paper-hint.on { opacity: 1; }
@keyframes paper-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes paper-out { to { opacity: 0; } }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: calc(8px + var(--safe-t)); right: calc(8px + var(--safe-r));
  display: flex; gap: 6px; align-items: center;
}
#hud button {
  min-width: 48px; min-height: 48px;
  padding: 0 .7em;
  font-size: calc(var(--fs) * .8);
  color: rgba(241,234,216,.85);
  background: rgba(10,8,9,.45);
  border: 1px solid rgba(241,234,216,.2);
  border-radius: 24px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#hud #hud-menu { font-size: calc(var(--fs) * 1.15); width: 48px; padding: 0; }
#hud #hud-mode { color: var(--gold); border-color: rgba(201,164,92,.6); animation: pulse 1.6s ease-in-out infinite; }
#stage.exploring #textwin { display: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- ひとこと ---------- */
.ui-note {
  width: max-content;
  position: absolute; left: 50%; top: calc(70px + var(--safe-t));
  transform: translate(-50%, -8px);
  max-width: 88%;
  padding: .6em 1.2em;
  font-size: calc(var(--fs) * .85);
  line-height: 1.6;
  text-align: center;
  color: var(--kinari);
  background: rgba(10,8,9,.85);
  border: 1px solid rgba(201,164,92,.5);
  border-radius: 3px;
  opacity: 0;
  pointer-events: none !important;
  transition: opacity .4s ease, transform .4s ease;
  z-index: 3;
}
.ui-note.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- デバッグ ---------- */
#debug-info {
  position: absolute; left: 4px; top: calc(4px + var(--safe-t));
  font: 11px/1.3 ui-monospace, Consolas, monospace;
  color: #8f8; background: rgba(0,0,0,.6); padding: 2px 5px;
  pointer-events: none !important;
  z-index: 9;
}

/* ---------- 画面の重ね（モーダル） ---------- */
.modal {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: rgba(8,6,7,.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .3s ease;
  font-size: var(--fs);
}
.modal.on { opacity: 1; }
.panel {
  position: relative;
  margin: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background:
    linear-gradient(180deg, rgba(22,18,19,.97), rgba(14,11,12,.97));
  border: 1px solid rgba(241,234,216,.16);
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.modal-side .panel { margin-left: auto; width: min(86%, 22em); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5em .5em .5em 1em;
  border-bottom: 1px solid rgba(200,67,47,.45);
}
.panel-title { font-size: calc(var(--fs) * 1.05); letter-spacing: .25em; }
.panel-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1em 1em calc(1.4em + var(--safe-b));
  line-height: 1.7;
}
.btn {
  min-height: 48px;
  padding: .45em 1.1em;
  font-size: calc(var(--fs) * .92);
  letter-spacing: .08em;
  color: var(--kinari);
  background: rgba(241,234,216,.06);
  border: 1px solid rgba(241,234,216,.28);
  border-radius: 2px;
  cursor: pointer;
  transition: background .2s ease;
}
.btn:hover, .btn:focus-visible { background: rgba(241,234,216,.14); outline: none; }
.btn:active { transform: scale(.98); }
.btn-main { background: rgba(200,67,47,.85); border-color: rgba(226,102,79,.9); color: #fff; }
.btn-main:hover, .btn-main:focus-visible { background: rgba(214,80,58,.95); }
.btn-sub { background: rgba(241,234,216,.06); }
.btn-close { min-width: 48px; font-size: calc(var(--fs) * .8); border-color: transparent; background: transparent; color: var(--kinari-dim); }
.btn-danger { border-color: rgba(200,67,47,.6); color: #e9a497; background: transparent; width: 100%; }

/* メニュー */
.menu-list { display: flex; flex-direction: column; gap: .5em; }
.btn-menu { text-align: left; padding-left: 1.2em; min-height: 52px; border-left: 3px solid rgba(200,67,47,.7); }
.menu-foot { margin-top: 1.2em; font-size: calc(var(--fs) * .72); color: var(--kinari-dim); line-height: 1.6; }

/* 確認・前回まで（小さい箱） */
.modal-small { align-items: center; justify-content: center; }
.confirm-box, .recap-box {
  width: min(88%, 24em);
  padding: 1.4em 1.3em 1.2em;
  background: rgba(20,16,17,.98);
  border: 1px solid rgba(241,234,216,.2);
  border-top: 2px solid var(--shu);
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
  animation: fade-in .3s ease;
}
.confirm-text { white-space: pre-line; line-height: 1.8; margin-bottom: 1.2em; }
.confirm-row { display: flex; gap: .6em; }
.confirm-row .btn { flex: 1; }
.recap-head { color: var(--gold); letter-spacing: .3em; font-size: calc(var(--fs) * .8); margin-bottom: .4em; }
.recap-title { font-size: calc(var(--fs) * 1.05); margin-bottom: .5em; letter-spacing: .1em; }
.recap-text { line-height: 1.85; margin-bottom: 1.2em; white-space: pre-line; color: #e6decb; }
.recap-box .btn { width: 100%; }

/* ログ */
.log-list { display: flex; flex-direction: column; gap: .9em; }
.log-row { line-height: 1.75; }
.log-name { font-size: calc(var(--fs) * .82); font-weight: 600; letter-spacing: .1em; }
.log-text { white-space: pre-wrap; }
.log-n .log-text { color: #ddd4c0; }
.log-sys .log-text, .log-choice .log-text { color: var(--gold); font-size: .92em; }
.log-chapter .log-text { text-align: center; color: var(--kinari-dim); letter-spacing: .2em; font-size: .9em; }
.log-paper .log-text { color: #e7d6ae; border-left: 2px solid rgba(201,164,92,.5); padding-left: .7em; }
.log-empty { color: var(--kinari-dim); }

/* 設定 */
.set-row { margin-bottom: 1.15em; }
.set-label { font-size: calc(var(--fs) * .88); margin-bottom: .35em; letter-spacing: .06em; }
.set-val { float: right; color: var(--kinari-dim); font-size: .9em; }
.set-note { font-size: .78em; color: var(--kinari-dim); }
.seg { display: flex; gap: 4px; }
.seg-btn { flex: 1; padding: .3em .2em; font-size: calc(var(--fs) * .78); letter-spacing: 0; }
.seg-btn.on, .toggle.on { background: rgba(200,67,47,.85); border-color: rgba(226,102,79,.9); color: #fff; }
.set-row-toggle { display: flex; align-items: center; justify-content: space-between; gap: 1em; }
.set-row-toggle .set-label { margin-bottom: 0; }
.toggle { min-width: 5em; }
/* 音量スライダー：当たり判定 48px・つまみ 28px（1123b） */
.set-range {
  display: block; width: 100%; height: 48px; min-height: 48px; margin: 0; padding: 0;
  -webkit-appearance: none; appearance: none; background: transparent;
  accent-color: var(--shu); cursor: pointer;
}
.set-range:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.set-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(241,234,216,.28); }
.set-range::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(241,234,216,.28); }
.set-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--shu); }
.set-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px; margin-top: -11px; border-radius: 50%;
  background: var(--shu-light); border: 2px solid var(--kinari); box-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.set-range::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--shu-light); border: 2px solid var(--kinari); box-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.set-preview { min-height: 1.9em; margin: -.4em 0 1.1em; padding: .4em .7em; background: rgba(0,0,0,.35); font-size: var(--fs); color: #eee5d2; }
.set-danger { margin-top: 1.8em; padding-top: 1em; border-top: 1px solid rgba(241,234,216,.12); }
.set-ver { margin-top: 1em; text-align: right; font-size: .7em; color: #77706a; }

/* 合言葉 */
.pass-lead { line-height: 1.8; margin-bottom: .8em; font-size: calc(var(--fs) * .9); }
.pass-code {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: calc(var(--fs) * 1.5);
  letter-spacing: .12em;
  text-align: center;
  padding: .5em .3em;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(201,164,92,.45);
  color: #fff;
  user-select: all; -webkit-user-select: all;
}
.pass-status { text-align: center; margin: .5em 0 .8em; font-size: calc(var(--fs) * .82); color: var(--gold); }
.pass-status.online { color: #9fd3a6; }
.modal-pass .btn-sub { width: 100%; }
.pass-sec { margin-top: 1.4em; padding-top: 1em; border-top: 1px solid rgba(241,234,216,.12); display: flex; flex-direction: column; gap: .55em; }
.pass-sec-title { letter-spacing: .1em; }
.pass-input, .pass-text {
  width: 100%;
  font-size: max(16px, var(--fs));
  padding: .5em .6em;
  color: #fff;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(241,234,216,.3);
  border-radius: 2px;
  user-select: text; -webkit-user-select: text;
}
.pass-text { font-size: 14px; font-family: ui-monospace, Consolas, monospace; resize: vertical; }
.pass-row { display: flex; gap: .5em; }
.pass-row .btn { flex: 1; }
.pass-msg { min-height: 1.4em; font-size: calc(var(--fs) * .8); color: var(--gold); }
.pass-note { font-size: calc(var(--fs) * .75); color: var(--kinari-dim); line-height: 1.7; }

/* 記録帳（records.js が無いときの簡易版） */
.rec-count { color: var(--gold); margin-bottom: .8em; letter-spacing: .1em; }
.rec-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(7em, 1fr)); gap: .5em; }
.rec-item { min-height: 3em; padding: .5em; border: 1px solid rgba(241,234,216,.25); text-align: center; font-size: calc(var(--fs) * .8); display: flex; align-items: center; justify-content: center; }
.rec-item.unknown { color: #6e665e; border-style: dashed; }

/* 制作中 */
.modal-stop { align-items: center; justify-content: center; background: rgba(5,4,5,.86); }
.stop-box { text-align: center; padding: 1.5em; width: min(92%, 24em); animation: fade-in .8s ease; }
.stop-end { font-size: calc(var(--fs) * 2); letter-spacing: .5em; padding-left: .5em; color: var(--shu-light); margin-bottom: .2em; }
.stop-endtitle { margin-bottom: 1em; letter-spacing: .15em; }
.stop-main { font-size: calc(var(--fs) * 1.15); letter-spacing: .15em; line-height: 1.8; margin-bottom: .6em; }
.stop-sub { color: var(--gold); font-size: calc(var(--fs) * .85); margin-bottom: 1.6em; letter-spacing: .1em; }
.stop-row { display: flex; flex-direction: column; gap: .6em; }

/* ---------- タイトル ---------- */
.modal-title { background: #000; backdrop-filter: none; -webkit-backdrop-filter: none; }
.title-bg {
  position: absolute; inset: 0;
  background: #000 center / cover no-repeat;
  animation: title-drift 40s ease-in-out infinite alternate;
}
@keyframes title-drift { from { transform: scale(1.04); } to { transform: scale(1.1) translateY(-1.5%); } }
#stage.calm .title-bg { animation: none; }
.title-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,.72) 0%, rgba(0,0,0,.25) 30%, rgba(0,0,0,0) 45%, rgba(0,0,0,.25) 62%, rgba(0,0,0,.82) 100%);
}
.title-head {
  position: relative;
  padding: calc(13% + var(--safe-t)) 1em 0;
  text-align: center;
}
.title-main {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  color: #f4eee0;
  text-shadow: 0 0 18px rgba(0,0,0,.95), 0 0 40px rgba(120,160,230,.25);
  animation: fade-in 2.4s ease;
}
.title-text {
  white-space: nowrap;
  display: block;
  font-size: calc(var(--fs) * 2.55);
  font-size: min(calc(var(--fs) * 2.55), 11.5cqw);
  letter-spacing: .28em;
  padding-left: .28em;
}
.title-kari {
  display: block;
  margin-top: .5em;
  font-size: calc(var(--fs) * .85);
  letter-spacing: .3em;
  color: var(--kinari-dim);
}
.title-menu {
  position: relative;
  margin-top: auto;
  padding: 0 12% 1em;
  display: flex; flex-direction: column; gap: .55em;
  animation: fade-in 1.6s ease .4s both;
}
.btn-title {
  min-height: 52px;
  font-size: calc(var(--fs) * 1);
  letter-spacing: .3em;
  padding-left: 1.3em;
  background: rgba(8,6,7,.55);
  border-color: rgba(241,234,216,.3);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.btn-title.btn-continue { border-color: rgba(226,102,79,.85); background: rgba(120,34,24,.6); }
.title-row { display: flex; gap: .55em; }
.btn-half { flex: 1; padding-left: .6em; padding-right: .4em; letter-spacing: .2em; }   /* 1123g：字間のぶん（.2em）だけ左を広く＝文字が真ん中に来る（前は右の余白が広くて左寄りだった） */
.title-foot {
  position: relative;
  padding: .3em 1em calc(.9em + var(--safe-b));
  text-align: center;
  line-height: 1.7;
  animation: fade-in 2s ease .8s both;
}
.title-note { font-size: calc(var(--fs) * .78); color: #e9e1cd; text-shadow: 0 1px 4px #000; }
/* 保存できない設定のときの注意（1123b） */
.title-nosave { margin: 0 auto .5em; max-width: 92%; padding: .35em .8em; font-size: calc(var(--fs) * .68); line-height: 1.6; color: #f3d9a0; background: rgba(60,20,14,.72); border: 1px solid rgba(226,102,79,.6); border-radius: 3px; text-wrap: pretty; }
.pass-status.nosave { color: #f3d9a0; }
.title-credit { font-size: calc(var(--fs) * .72); color: var(--kinari-dim); letter-spacing: .08em; text-shadow: 0 1px 4px #000; }
.title-sound { font-size: calc(var(--fs) * .7); color: var(--gold); margin-top: .2em; transition: opacity .6s ease; }
.title-sound.gone { opacity: 0; }
.title-ver { position: absolute; right: calc(8px + var(--safe-r)); bottom: calc(4px + var(--safe-b)); font-size: 10px; color: rgba(255,255,255,.3); font-family: ui-monospace, monospace; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* 低い画面（スマホ横・小さいPC窓） */
@media (max-height: 560px) {
  .title-head { padding-top: calc(5% + var(--safe-t)); }
  .btn-title { min-height: 48px; }
  .title-menu { gap: .35em; }
}
/* とても狭い（320px） */
@media (max-width: 340px) {
  .title-text { letter-spacing: .18em; padding-left: .18em; }
  .title-menu { padding: 0 7% .8em; }
}

/* こわさ控えめ／動きを減らす */
@media (prefers-reduced-motion: reduce) {
  .title-bg { animation: none; }
  #next-mark.on { animation: none; }
}

/* ---------- 改行を自然に（DESIGN §15・つなぎこみで追加） ---------- */
/* .ph＝文節のかたまり（TORII.text が作る）。かたまりの中では折らない */
.ph { white-space: nowrap; }
#stage { line-break: strict; word-break: normal; overflow-wrap: anywhere; }
@supports (word-break: auto-phrase) { #stage { word-break: auto-phrase; } }
#text, .sys-inner, #toast, .recap-text, .log-text, .confirm-text, .pass-lead, .pass-note, .bk-detail-note { text-wrap: pretty; }
.choice, .xp-label, .bk-cell-where, .bk-cell-name, .cc-title, .stop-main, .menu-foot, .title-note { text-wrap: balance; }
/* 探索の見出しは短いので1行で（book.css より強く） */
#layer-explore .xp-prompt { white-space: nowrap; max-width: 94%; }
/* 記録の札：名前が2行に割れないように（book.css より強く） */
#layer-modal .bk-get-card { max-width: min(96%, 560px); }
#layer-modal .bk-get-tag { padding-left: .9em; padding-right: .9em; }
#layer-modal .bk-get-name { white-space: nowrap; }
@container stage (max-width: 420px) { #layer-modal .bk-get-name { font-size: 1.2em; letter-spacing: .02em; } }

/* ================================================================
 * 1123c（第2段・engine2）：目線・顔アップ・手ざわり・章の終わり
 * ================================================================ */

/* ---------- 目線（§14 cam）：絵は止めない ----------
 * .bg-cam は #layer-bg の中の入れもの（fx が使う #layer-bg の translate/scale/rotate には触らない）。
 * 呼吸する寄り引き（scale）＋手持ちのわずかな揺れ（translate）。足音・振り向き・息をのむは engine が transform で一度だけ。 */
#layer-bg .bg-cam { position: absolute; inset: 0; transform-origin: 50% 45%; transition: filter .5s ease; }
/* 1123d：breath・walk・still は同じアニメーション（名前も長さも同じ）。still は play-state を止めるだけにして、その場で止める
 * （前は still で animation を外して scale を決めうちしていたので、呼吸の途中の絵が「カクッ」と跳んだ。walk も長さを替えると進み具合が計算し直されて跳んだ）。
 * walk の上下は audio.onStep の WAAPI（engine）だけで出す。 */
#stage[data-cam="breath"] #layer-bg .bg-cam,
#stage[data-cam="walk"] #layer-bg .bg-cam,
#stage[data-cam="still"] #layer-bg .bg-cam { animation: cam-breath 17s ease-in-out infinite alternate, cam-hand 11s ease-in-out infinite; }
#stage[data-cam="still"] #layer-bg .bg-cam,
#stage.close-up #layer-bg .bg-cam { animation-play-state: paused; }
@keyframes cam-breath { from { scale: 1.025; } to { scale: 1.05; } }
@keyframes cam-hand {
  0%   { translate: 0 0; }
  22%  { translate: .35% -.2%; }
  47%  { translate: -.2% .3%; }
  71%  { translate: .25% .15%; }
  100% { translate: 0 0; }
}
#stage.calm #layer-bg .bg-cam { animation: cam-breath 30s ease-in-out infinite alternate !important; }
#stage.calm[data-cam="still"] #layer-bg .bg-cam,
#stage.calm.close-up #layer-bg .bg-cam { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) { #layer-bg .bg-cam { animation: none !important; scale: 1.025; } }

/* ---------- 顔アップ close:true（§17）：背景をぼかして暗く・文字窓を少し下げる ----------
 * 1123d：顔アップのあいだは .bg-cam の動きを止める（上の play-state: paused）。全画面のぼかしを毎コマ合成し直さないように（安いスマホで重い） */
#stage.close-up #layer-bg .bg-cam { filter: blur(2.5px) brightness(.72) saturate(.9); } /* 1123f：背景も見えるように弱めた（前は blur 5px・明るさ .5） */
#stage.close-up #textwin:not(.long) { height: 29%; }
#stage.close-up #textwin.long { height: 37%; }

/* ---------- あと少しの線（§12-7）：章の中の進み具合・数字は出さない ---------- */
/* 1123d：文字窓のいちばん上のふち（top:0）に置き、名前札より手前に（前は名前札の後ろに隠れ、線の始まり30％も透明で、章の前半は見えなかった） */
#chapter-progress {
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  pointer-events: none; z-index: 3;
}
#chapter-progress::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(var(--p, 0) * 100%);
  background: linear-gradient(90deg, rgba(201,164,92,.45), rgba(201,164,92,.8) 40%, rgba(226,180,110,.92));
  border-radius: 2px;
  transition: width .6s ease;
}
#chapter-progress.near::after { background: linear-gradient(90deg, rgba(200,67,47,.45), rgba(226,102,79,.85) 40%, rgba(240,150,110,.95)); box-shadow: 0 0 6px rgba(226,102,79,.5); }

/* ---------- タップのごほうび（§14・§12-6） ---------- */
#next-mark.on.pop { animation: next-pop .42s cubic-bezier(.3,1.6,.5,1), next-bob 1.1s ease-in-out .42s infinite; }
@keyframes next-pop { 0% { transform: translateY(-8px) scale(.6); opacity: 0; } 60% { transform: translateY(2px) scale(1.15); opacity: 1; } 100% { transform: none; } }
#textwin.tw-sink { animation: tw-sink .34s ease; }
@keyframes tw-sink { 0%,100% { transform: none; } 35% { transform: translateY(2px); } }
#textwin.tw-glow #text { animation: tw-glow .42s ease; }
@keyframes tw-glow { 0% { filter: brightness(1.25); } 100% { filter: none; } }
.tap-ink {
  position: absolute; z-index: 6; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(241,234,216,.32) 0%, rgba(241,234,216,.12) 45%, rgba(241,234,216,0) 70%);
  animation: tap-ink .6s ease-out forwards;
}
@keyframes tap-ink { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
#stage.calm .tap-ink { display: none; }

/* 選んだ選択肢が墨でにじんで残り、ほかが消える */
#choices.picked .choice { pointer-events: none; animation: none; }
#choices.picked .choice:not(.chosen) { opacity: 0; transform: translateY(4px); transition: opacity .28s ease, transform .28s ease; }
#choices .choice.chosen { position: relative; overflow: hidden; box-shadow: none; }
#choices .choice.chosen::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 140%; padding-bottom: 140%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6,4,5,.92) 0%, rgba(20,10,10,.85) 45%, rgba(120,34,24,.55) 62%, rgba(0,0,0,0) 72%);
  transform: translate(-50%, -50%) scale(0);
  animation: ink-bleed .65s cubic-bezier(.25,.8,.3,1) forwards;
  z-index: 0;
}
#choices .choice.chosen > * { position: relative; z-index: 1; }
/* fx.inkspread（audio2）を選んだボタンの中に置く：文字の下・CSS の墨の上 */
#choices .choice.chosen > .fx-ink { position: absolute; z-index: 0; pointer-events: none; opacity: .75; }
#choices .choice.chosen { color: #fff; border-left-color: var(--shu-light); }
@keyframes ink-bleed { to { transform: translate(-50%, -50%) scale(1); } }

/* ---------- 章の終わりの札＋次の気配（§12-1） ---------- */
#chapter-end {
  position: absolute; inset: 0; z-index: 7;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,3,4,.84);
  opacity: 0; transition: opacity .45s ease;
}
#chapter-end.on { opacity: 1; }
#chapter-end .ce-img {
  position: absolute; inset: 0;
  background: #000 center / cover no-repeat;
  filter: brightness(.48) contrast(1.25) saturate(.3) blur(1.2px);   /* 1123d：.3→.48（スマホでほぼ見えなかった） */
  opacity: 0; transition: opacity 1.1s ease;
  pointer-events: none;
}
#chapter-end.tz-on .ce-img { opacity: 1; }
#chapter-end.tz-off .ce-img { opacity: .18; transition-duration: 1.6s; }
#chapter-end .ce-box {
  position: relative;
  width: min(90%, 26em);
  text-align: center;
  padding: 1.4em 1.2em;
}
#chapter-end .ce-head { font-size: calc(var(--fs) * .78); letter-spacing: .4em; padding-left: .4em; color: var(--gold); margin-bottom: .5em; }
#chapter-end .ce-title { font-size: calc(var(--fs) * 1.3); letter-spacing: .18em; line-height: 1.5; text-wrap: balance; text-shadow: 0 0 18px rgba(0,0,0,.9); }
#chapter-end .ce-rec { margin-top: .6em; font-size: calc(var(--fs) * .8); color: var(--kinari-dim); letter-spacing: .1em; }
#chapter-end .ce-line {
  margin: 1.4em auto 0; max-width: 22em;
  font-size: var(--fs); line-height: 1.85; letter-spacing: .05em;
  color: #d9d0bd; text-wrap: pretty;
  opacity: 0; transform: translateY(6px); transition: opacity 1.2s ease .2s, transform 1.2s ease .2s;
  text-shadow: 0 1px 3px #000, 0 0 10px rgba(0,0,0,.8);
}
#chapter-end.tz-on .ce-line { opacity: 1; transform: none; }
#chapter-end .ce-btns {
  margin-top: 1.6em; display: flex; flex-direction: column; align-items: center; gap: .7em;
  opacity: 0; transition: opacity .5s ease; pointer-events: none;
}
#chapter-end.btn-on .ce-btns { opacity: 1; pointer-events: auto; }
#chapter-end .ce-go { width: 100%; min-height: 52px; font-size: var(--fs); letter-spacing: .2em; }
#chapter-end .ce-close {
  min-height: 44px; padding: .2em 1.2em;
  background: none; border: none; color: var(--kinari-dim);
  font-size: calc(var(--fs) * .78); letter-spacing: .12em;
  text-decoration: underline; text-underline-offset: .3em; text-decoration-color: rgba(207,198,178,.4);
  cursor: pointer;
}
#chapter-end .ce-close:hover, #chapter-end .ce-close:focus-visible { color: var(--kinari); outline: none; }

/* ---------- 「前回まで」の札（§12-8・1123d）：押さなくても消える・文字窓の上 ---------- */
.recap-float {
  position: absolute; left: 5%; right: 5%;
  bottom: calc(30% + var(--fs) * 1.9);
  z-index: 6;
  padding: .8em 1.1em .9em;
  background: rgba(12,10,11,.88);
  border: 1px solid rgba(201,164,92,.45);
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  box-shadow: 0 6px 24px rgba(0,0,0,.6);
  font-size: calc(var(--fs) * .92);
  opacity: 0; transform: translateY(6px);
  transition: opacity .5s ease, transform .5s ease;
  cursor: pointer; pointer-events: auto;
}
.recap-float.on { opacity: 1; transform: none; }
.recap-float.off { opacity: 0; transform: translateY(-4px); transition-duration: .55s; }
.recap-float .recap-head { margin-bottom: .2em; }
.recap-float .recap-title { font-size: 1em; margin-bottom: .3em; }
.recap-float .recap-text { margin-bottom: 0; line-height: 1.75; text-wrap: pretty; }
#stage.close-up .recap-float { bottom: calc(29% + var(--fs) * 1.9); }

/* ---------- タイトルの「つづきから：<章の名前>」（§12-8） ---------- */
.btn-title.btn-continue .cont-ch { font-size: .78em; letter-spacing: .06em; color: #f0dcc0; }
.btn-title.btn-continue { text-wrap: balance; line-height: 1.45; }

/* 確かめ用（?notrans=1・1123c つなぎこみ）：headless の撮影で transition の途中が写らないように */
html.shot-notrans *, html.shot-notrans *::before, html.shot-notrans *::after { transition: none !important; }

/* ================================================================
 * 1123f（本人 11/23「キャラが出てくるときのアニメーションはごく控えめに。酔います」）
 * 立ち絵の出入りは、その場でふわっと出て消えるだけ（動かさない・すべらせない・大きさも動かさない）。
 * 表情が変わるときの小さな動きも 1/3 ほどに弱め、傾き（回転）と跳ねはやめる。
 * ================================================================ */
.ch { transform: none; transition: opacity .32s ease, filter .3s ease; }
.ch.on, .ch.off { transform: none; }
.ch.off { transition-duration: .22s, .3s; }
.ch.quick, .ch.quick.off { transition: opacity .16s ease, filter .3s ease; }
.ch.slide { animation: ch-fadein .32s ease both; }
@keyframes ch-fadein { from { opacity: 0; } to { opacity: 1; } }
.ch-breath { animation-duration: 7s; }
@keyframes ch-breath { from { transform: none; } to { transform: translateY(-.15%); } }
@keyframes m-up { 0%,100% { transform: none; } 30% { transform: translateY(-.5%); } }
@keyframes m-hop { 0%,100% { transform: none; } 35% { transform: translateY(-.5%); } }
@keyframes m-shiver { 0%,100% { transform: none; } 25% { transform: translateX(-.15%); } 75% { transform: translateX(.15%); } }
@keyframes m-sink { 0% { transform: none; } 40%,100% { transform: translateY(.3%); } }
@keyframes m-tilt { 0% { transform: none; } 40%,100% { transform: translateY(.3%); } }
@keyframes m-lean { 0%,100% { transform: none; } 40% { transform: translateY(.3%); } }
@keyframes m-soft { 0%,100% { transform: none; } 40% { transform: translateY(-.2%); } }

/* 1123f：ひとつ戻る。戻れないときは薄く */
#hud #hud-back:disabled, #hud #hud-back.off { opacity: .32; cursor: default; }

/* 1123f：探索の一覧「…（説明）」のかっこの中は、次の行に小さく */
.xp-label .xp-sub { display: block; font-size: .78em; opacity: .78; white-space: nowrap; letter-spacing: 0; margin-top: .1em; }

/* 1123g：ルビ（ふりがな）。文字送りのあいだは、その語の最初の字が出てから読みを出す */
rt { font-size: .46em; letter-spacing: 0; opacity: .82; font-weight: 400; user-select: none; text-shadow: 0 1px 2px rgba(0,0,0,.9); }
#text ruby:not(:has(.tc.v)) rt, .sys-inner ruby:not(:has(.tc.v)) rt { opacity: 0; }
#text rt, .sys-inner rt { transition: opacity .18s ease; }
