:root {
  --ink: #f3f0e6;
  --ink-dim: #c9c6bb;
  --paper: #f3eddb;
  --paper-ink: #2a2620;
  --accent: #b8342b;
  --box: rgba(9, 13, 11, .8);
  --mincho: "Shippori Mincho", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", serif;
  --gothic: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--ink); font-family: var(--mincho); overflow: hidden; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none; background: #000; }
#bg, #chars, #overlay-fx, #wave-layer { position: absolute; inset: 0; }
.bg-layer { position: absolute; inset: 0; opacity: 0; transition: opacity .8s ease; }
.bg-layer.in { opacity: 1; }
svg.scene { width: 100%; height: 100%; display: block; }
.scene-img { width: 100%; height: 100%; background: center / cover no-repeat; }

/* 立ち絵 */
#chars { pointer-events: none; }
.ch { position: absolute; bottom: 0; height: 86%; width: min(46vh, 44vw); transform: translate(-50%, 24px); opacity: 0; transition: opacity .4s, transform .4s; }
.ch.in { opacity: 1; transform: translate(-50%, 0); }
.ch.leaving { opacity: 0; transform: translate(-50%, 0); pointer-events: none; }
.ch svg, .ch img { width: 100%; height: 100%; display: block; object-fit: contain; object-position: bottom; filter: drop-shadow(0 0 18px rgba(0,0,0,.35)); }
.ch[data-pos="l"] { left: 24%; } .ch[data-pos="c"] { left: 50%; } .ch[data-pos="r"] { left: 76%; }

/* 文章欄 */
#textbox {
  position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(1080px, calc(100% - 32px)); min-height: 148px;
  background: var(--box); border: 1px solid rgba(255,255,255,.16); border-radius: 10px;
  padding: 26px 30px 30px; font-size: clamp(16px, 1.9vw, 21px); line-height: 1.95; letter-spacing: .04em;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); backdrop-filter: blur(3px);
}
#namebox { position: absolute; top: -17px; left: 22px; background: var(--ink); color: #1b1a17; padding: 3px 18px; font-weight: 700; font-size: .85em; border-radius: 3px; letter-spacing: .12em; }
#text { white-space: pre-wrap; min-height: 2em; }
#textbox.thought #text { color: #cfe0cf; }
#next-mark { position: absolute; right: 22px; bottom: 10px; font-size: 14px; opacity: 0; }
#next-mark.on { animation: blink 1s infinite; }
@keyframes blink { 0%,100% { opacity: .2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(3px); } }

/* 上部の操作ボタン */
#hud { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; display: flex; gap: 6px; z-index: 5; }
#hud button { background: rgba(0,0,0,.45); color: var(--ink); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 5px 12px; font-family: var(--gothic); font-size: 12px; }
#hud button.on { background: var(--ink); color: #111; }
#hud button.off { text-decoration: line-through; opacity: .6; }

/* スマホのメッセージ画面 */
#phone {
  position: absolute; left: 50%; top: 9%; width: min(330px, 84vw); height: min(520px, 62vh); z-index: 3;
  background: #e9ecef; border: 10px solid #15171a; border-radius: 34px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); font-family: var(--gothic); animation: phoneIn .35s ease;
}
#phone { transform: translateX(-50%); }
@keyframes phoneIn { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); } }
.phone-head { background: #2f3a4a; color: #fff; padding: 14px 16px 10px; font-size: 15px; font-weight: 700; }
.phone-head::before { content: "‹  "; opacity: .6; }
#phone-body { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; background: #8aa1b8; }
.bubble { align-self: flex-start; max-width: 85%; background: #fff; color: #111; padding: 8px 12px; border-radius: 16px 16px 16px 4px; font-size: 15px; line-height: 1.5; animation: pop .25s ease; }
.photo-bubble { padding: 4px; width: 85%; }
.photo-bubble svg { width: 100%; height: auto; aspect-ratio: 1456 / 380; display: block; border-radius: 12px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* 選択肢 */
#choices { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(0,0,0,.35); z-index: 4; padding: 16px; }
#choices button { width: min(520px, 100%); padding: 18px 20px; font-size: clamp(17px, 2vw, 21px); color: var(--ink); background: rgba(12,16,14,.88); border: 1px solid rgba(255,255,255,.35); border-radius: 6px; letter-spacing: .15em; transition: background .2s, transform .2s; }
#choices button:hover, #choices button:focus-visible { background: var(--ink); color: #111; transform: scale(1.02); outline: none; }

/* 章見出し */
#chapter-card { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(0,0,0,.65), rgba(0,0,0,.92)); cursor: pointer; opacity: 0; }
#chapter-card.in { animation: ccIn 2.6s ease forwards; }
@keyframes ccIn { 0% { opacity: 0; } 15%,80% { opacity: 1; } 100% { opacity: 1; } }
.cc-num { font-size: clamp(14px, 1.6vw, 18px); letter-spacing: .5em; color: var(--ink-dim); margin-bottom: 14px; }
.cc-title { font-size: clamp(30px, 5vw, 56px); letter-spacing: .3em; font-weight: 700; }

/* 演出 */
#stage.fx-shake #bg, #stage.fx-shake #chars { animation: shake .5s; }
@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-12px,4px); } 40% { transform: translate(10px,-6px); } 60% { transform: translate(-8px,2px); } 80% { transform: translate(6px,-2px); } }
#stage.fx-flash #overlay-fx { animation: flash .7s; }
@keyframes flash { 0% { background: rgba(255,255,255,.85); } 100% { background: rgba(255,255,255,0); } }
#overlay-fx { pointer-events: none; z-index: 2; }
#stage.fx-chill #overlay-fx { animation: chill 2.6s ease; }
@keyframes chill { 0% { box-shadow: inset 0 0 0 rgba(120,170,220,0); } 30% { box-shadow: inset 0 0 220px rgba(120,170,220,.75); background: rgba(160,200,230,.12); } 100% { box-shadow: inset 0 0 0 rgba(120,170,220,0); } }
#stage.fx-zoom #bg .bg-layer:last-child svg { transform: scale(2.6); transition: transform 4s cubic-bezier(.2,.6,.2,1); }
#stage.fx-zoom3 #bg .bg-layer:last-child svg { transform: scale(3); transition: transform 3.5s cubic-bezier(.2,.6,.2,1); }
#bg .bg-layer svg { transition: transform 1s; }
#stage.fx-kune #bg, #stage.fx-kune #chars { animation: kune 3.2s ease-in-out infinite; }
#stage.fx-kune #overlay-fx { background: radial-gradient(ellipse at center, rgba(255,255,255,0) 40%, rgba(255,255,255,.35)); }
@keyframes kune { 0%,100% { transform: skewX(0) scaleY(1); filter: none; } 25% { transform: skewX(4deg) scaleY(1.02); filter: blur(.6px); } 75% { transform: skewX(-4deg) scaleY(.99); filter: blur(.4px) saturate(.6); } }
#stage.swinging #bg { transform: translateX(3px); }

/* 背景の小さな動き */
.sway { animation: sway 3.4s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: rotate(-5deg); } 50% { transform: rotate(6deg); } }
.poles-pass { animation: poles .9s linear infinite; }
@keyframes poles { to { transform: translateX(-700px); } }
.rain { animation: rain .35s linear infinite; }
@keyframes rain { to { transform: translate(-30px, 240px); } }
.firefly { animation: firefly 3.6s ease-in-out infinite; }
@keyframes firefly { 0%,100% { opacity: 0; } 50% { opacity: .95; } }
.smoke { animation: smoke 4s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom; }
@keyframes smoke { 0%,100% { transform: skewX(-6deg); opacity: .5; } 50% { transform: skewX(8deg); opacity: .25; } }
.spin { animation: spin .25s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.fanhead { animation: fan 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes fan { 0%,100% { transform: scaleX(1); } 50% { transform: scaleX(.55); } }
.flow { animation: flow 1.6s linear infinite; }
@keyframes flow { to { transform: translateX(120px); } }
.kid-body { animation: bob .45s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.kid .leg1 { animation: leg .45s ease-in-out infinite; transform-box: fill-box; transform-origin: top; }
.kid .leg2 { animation: leg .45s ease-in-out infinite reverse; transform-box: fill-box; transform-origin: top; }
@keyframes leg { 0%,100% { transform: rotate(18deg); } 50% { transform: rotate(-18deg); } }
.kid.stop .kid-body, .kid.stop rect { animation-play-state: paused; }
.kids-photo { animation: bob .45s ease-in-out infinite; }
#kids-g.stop .kids-photo { animation-play-state: paused; }
svg.photo { filter: sepia(.25) contrast(1.05) saturate(.85); }

/* モーダル（資料・謎） */
#modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.74); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .3s; }
@keyframes fade { from { opacity: 0; } }
.modal-inner { width: min(900px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: #1b1d1b; border: 1px solid rgba(255,255,255,.15); border-radius: 10px; overflow: hidden; }
#modal-body { overflow: auto; padding: 22px; flex: 1; }
#modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.1); background: #121412; }
#modal-foot:empty { display: none; }
#modal-foot button, .pz button { border-radius: 6px; }
#modal-foot button { padding: 9px 22px; background: transparent; color: var(--ink); border: 1px solid rgba(255,255,255,.35); font-family: var(--gothic); }
#modal-foot button.primary { background: var(--ink); color: #111; border-color: var(--ink); font-weight: 700; }

/* 資料の紙 */
.paper { background: var(--paper); color: var(--paper-ink); padding: 28px 30px; border-radius: 3px; box-shadow: 0 2px 0 #d6cdb2, 0 10px 30px rgba(0,0,0,.4); line-height: 1.9; }
.paper h3 { margin: 0 0 .6em; letter-spacing: .1em; }
.vert { writing-mode: vertical-rl; height: min(56vh, 480px); overflow-x: auto; overflow-y: hidden; margin: 0 auto; max-width: 100%; }
.vert p { margin: 0 0 0 1.1em; }
.small { font-size: .85em; opacity: .75; }
.em { color: var(--accent); font-weight: 700; }

.poster { max-width: 520px; margin: 0 auto; font-family: var(--gothic); text-align: center; border: 6px solid #c33; background: #fbf6e6; }
.poster-head { font-size: 26px; font-weight: 700; color: #c33; margin-bottom: 12px; letter-spacing: .08em; }
.poster p { margin: .6em 0; }
.poster-org { font-size: 14px; color: #555; }
.poster-hand { margin-top: 22px !important; font-family: var(--mincho); font-size: 20px; color: #1b2a6b; transform: rotate(-2deg); border-top: 1px dashed #aaa; padding-top: 14px; letter-spacing: .15em; }

.enikki { max-width: 560px; margin: 0 auto; background: #fffef8; font-family: var(--gothic); }
.enikki-pic { border: 2px solid #333; margin-bottom: 10px; }
.enikki-pic svg, .enikki-pic img { display: block; width: 100%; height: auto; }
.enikki-date { font-size: 14px; border-bottom: 2px solid #333; padding-bottom: 4px; margin-bottom: 8px; }
.enikki-text { white-space: pre-wrap; font-size: 18px; line-height: 2.1; letter-spacing: .12em; background: repeating-linear-gradient(transparent 0 calc(2.1em - 1px), #9bb7d8 calc(2.1em - 1px) 2.1em); color: #222; }

.news { background: #e7e2d3; font-family: var(--mincho); }
.news-date { font-size: 13px; border-bottom: 3px double #333; margin-bottom: 14px; padding-bottom: 4px; }
.news-vert { writing-mode: vertical-rl; height: min(54vh, 440px); overflow-x: auto; margin: 0 auto; }
.news-vert h3 { font-size: 26px; margin: 0 0 0 .4em; }
.news-vert h4 { font-size: 18px; margin: 0 0 0 1em; color: #444; }
.news-vert p { margin: 0 0 0 .8em; text-indent: 1em; font-size: 16px; }

.kaisoku, .nisshi { background: #f1ead2; }
.kaisoku .vert p { font-size: 18px; }
.nisshi { background: #ece6d6 repeating-linear-gradient(90deg, transparent 0 34px, rgba(120,90,60,.18) 34px 35px); }
.nisshi .vert p { font-size: 18px; }
.nisshi .sign { margin-top: auto; text-align: end; }

.meibo table { width: 100%; border-collapse: collapse; font-size: 17px; }
.meibo th, .meibo td { border: 1px solid #8d8470; padding: 8px 10px; text-align: left; }
.meibo th { background: #e1d8bd; }
.meibo .red { color: var(--accent); }
.meibo .hand { margin-top: 14px; color: #1b2a6b; font-size: 17px; }

/* 謎 */
.pz { color: var(--ink); font-family: var(--gothic); }
.pz h2 { font-family: var(--mincho); font-size: 20px; letter-spacing: .1em; margin: 0 0 14px; }
.pz-q { font-family: var(--mincho); font-size: 18px; margin: 14px 0 10px; }
.pz-msg { min-height: 2.2em; margin-top: 10px; color: #f0d9a8; line-height: 1.7; }
.pz-msg .okmsg { color: #fff; font-family: var(--mincho); font-size: 20px; letter-spacing: .1em; }
.pz-msg .hint { color: #a9d4ff; }
.btn-hint { margin-right: auto; }

.replay { display: flex; gap: 14px; align-items: center; background: #0d0f0d; padding: 10px; border-radius: 8px; }
.replay-svg { width: 260px; max-width: 50%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 4px; flex: none; }
.replay-svg svg { width: 100%; height: 100%; }
.replay p { margin: 0; font-family: var(--mincho); }
.signal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.sig { background: #f3eddb; color: #2a2620; border: 2px solid transparent; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; transition: transform .15s; }
.sig:hover, .sig:focus-visible { border-color: #fff; transform: translateY(-2px); outline: none; }
.sig .mini-fig { width: 100%; height: 110px; display: block; }
.sig b { font-family: var(--mincho); font-size: 17px; }
.sig span { font-size: 12px; color: #555; line-height: 1.4; }
.ok { border-color: #6fbf73 !important; box-shadow: 0 0 0 3px #6fbf73; }
.ng { animation: ng .5s; border-color: var(--accent) !important; }
@keyframes ng { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.recall { margin: 6px 0 12px; }
.recall summary { cursor: pointer; color: #a9d4ff; }
.recall .enikki { margin-top: 10px; transform: scale(.92); transform-origin: top center; }
.diary-list { display: grid; gap: 8px; }
.dentry { text-align: left; display: grid; grid-template-columns: 11em 7em 1fr; gap: 10px; align-items: baseline; background: #ece6d6; color: #2a2620; border: 2px solid transparent; padding: 10px 12px; font-family: var(--mincho); line-height: 1.6; }
.dentry:hover, .dentry:focus-visible { border-color: #fff; outline: none; }
.d-date { font-weight: 700; }
.d-post { color: #6b5a40; font-size: .9em; }

.photo-wrap { position: relative; background: #fff; padding: 8px 8px 26px; border-radius: 2px; box-shadow: 0 6px 24px rgba(0,0,0,.5); transform: rotate(-.6deg); }
.photo-svg svg { width: 100%; height: auto; aspect-ratio: 1416 / 300; display: block; cursor: crosshair; }
.marks { position: absolute; inset: 0; pointer-events: none; }
.mark { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border: 3px solid #e23b2e; border-radius: 50%; animation: pop .25s; }
.counter { font-size: 16px; margin: 14px 0 0; }
.counter b { font-size: 22px; color: #fff; }
.posts { display: flex; flex-wrap: wrap; gap: 8px; }
.posts button { padding: 10px 16px; background: #f3eddb; color: #2a2620; border: 2px solid transparent; font-family: var(--mincho); font-size: 17px; }

.pz-final { text-align: center; padding: 20px 0; }
.yota-q { font-family: var(--mincho); font-size: 24px; letter-spacing: .1em; }
.final-form { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; font-family: var(--mincho); font-size: 20px; }
.final-form input { font: inherit; width: 9em; padding: 8px 10px; border: none; border-bottom: 2px solid var(--ink); background: rgba(255,255,255,.08); color: #fff; text-align: center; border-radius: 4px 4px 0 0; }
.final-form input:focus { outline: none; background: rgba(255,255,255,.16); }
.final-form button { padding: 9px 24px; background: var(--ink); color: #111; border: none; font-weight: 700; font-family: var(--gothic); font-size: 16px; }

/* 腕を振る */
#wave-layer { z-index: 4; touch-action: none; cursor: ew-resize; }
.wave-kids { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wave-ui { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); text-align: center; font-family: var(--gothic); pointer-events: none; }
.wave-top { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.55); padding: 8px 14px; border-radius: 999px; }
.gauge { flex: 1; height: 12px; background: rgba(255,255,255,.2); border-radius: 999px; overflow: hidden; }
.gauge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #fff, #ffe9a8); transition: width .1s; }
.dist { font-size: 13px; min-width: 7.5em; text-align: right; color: #ffd0c8; }
.wave-help { margin: 10px 0 0; font-size: 15px; text-shadow: 0 1px 4px #000, 0 0 10px #000; line-height: 1.6; }
.sleeves { position: absolute; inset: 0; pointer-events: none; }
.sleeve { position: absolute; bottom: -80px; width: 24vw; max-width: 300px; height: 50vh; background: linear-gradient(100deg, #d9d6cc 0%, #fbfaf6 35%, #ecebe4 55%, #fffefa 70%, #d2cfc4 100%); border-radius: 48% 48% 14% 14% / 26% 26% 10% 10%; filter: blur(9px); opacity: .93; transition: transform .14s ease-out; }
.sleeve.l { left: 4%; transform-origin: 50% 100%; transform: rotate(-10deg); }
.sleeve.r { right: 4%; transform-origin: 50% 100%; transform: rotate(10deg); }
.wave-btns { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 12px; }
.wave-btns button { white-space: nowrap; padding: 14px 22px; font-size: 17px; background: rgba(0,0,0,.6); color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; font-family: var(--gothic); touch-action: manipulation; }
.wave-btns button:active { background: #fff; color: #111; }
.shout { position: absolute; right: 5%; top: 46%; padding: 14px 22px; font-size: 18px; background: #8f1d16; color: #fff; border: 2px solid #ffb3a8; border-radius: 6px; font-family: var(--mincho); animation: tempt 1.1s ease-in-out infinite; }
@keyframes tempt { 0%,100% { transform: scale(1); box-shadow: 0 0 0 rgba(255,80,60,0); } 50% { transform: scale(1.06); box-shadow: 0 0 28px rgba(255,80,60,.7); } }
.wave-msg { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); background: rgba(0,0,0,.78); padding: 20px 26px; border-radius: 8px; text-align: center; font-size: 19px; line-height: 1.8; width: min(520px, calc(100% - 32px)); }
.wave-msg .retry { margin-top: 12px; padding: 9px 22px; background: var(--ink); color: #111; border: none; border-radius: 6px; font-family: var(--gothic); }

/* ログ・エンディング一覧 */
.log h2, .endlist h2 { margin: 0 0 12px; font-size: 20px; letter-spacing: .1em; }
.log p { margin: 0 0 8px; line-height: 1.8; color: var(--ink-dim); }
.log b { color: var(--ink); margin-right: .8em; }
.endrow { display: flex; gap: 14px; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid rgba(255,255,255,.1); color: #777; }
.endrow.got { color: var(--ink); }
.ek { font-family: var(--gothic); font-size: 12px; width: 6.5em; letter-spacing: .1em; }

/* タイトル */
#title { position: fixed; inset: 0; z-index: 30; background: #000; }
#title-bg { position: absolute; inset: 0; }
#title-bg svg { width: 100%; height: 100%; }
#title::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.7) 0%, rgba(0,0,0,.25) 55%, rgba(0,0,0,0) 100%); pointer-events: none; }
.title-inner { position: absolute; left: 7%; top: 50%; transform: translateY(-50%); z-index: 1; }
#title h1 { margin: 0 0 40px; display: flex; flex-direction: column; gap: 10px; font-weight: 700; }
.t-main { font-size: clamp(56px, 10vw, 128px); letter-spacing: .12em; line-height: 1; text-shadow: 0 0 30px rgba(255,255,255,.25); animation: titleHaze 6s ease-in-out infinite; }
@keyframes titleHaze { 0%,100% { transform: skewX(0); filter: blur(0); } 50% { transform: skewX(-3deg); filter: blur(.7px); } }
.t-sub { font-size: clamp(18px, 2.4vw, 28px); letter-spacing: .4em; color: var(--ink-dim); }
.title-menu { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.title-menu button { background: none; border: none; color: var(--ink); font-size: clamp(18px, 2vw, 22px); letter-spacing: .25em; padding: 6px 0; position: relative; }
.title-menu button::before { content: "―"; opacity: 0; margin-right: .4em; transition: opacity .2s; }
.title-menu button:hover::before, .title-menu button:focus-visible::before { opacity: 1; }
.title-menu button:disabled { color: #666; cursor: default; }
.title-menu button.small { font-size: 14px; letter-spacing: .15em; color: var(--ink-dim); margin-top: 10px; }
.title-note { margin-top: 30px; font-family: var(--gothic); font-size: 12px; color: #aaa; letter-spacing: .08em; }

/* エンディング */
#ending { position: fixed; inset: 0; z-index: 25; background: #000; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; }
#ending.in { animation: fade 2s; }
#ending.true-end { background: radial-gradient(ellipse at center, #1b1d18, #000); }
.end-kind { font-family: var(--gothic); letter-spacing: .5em; color: #999; font-size: 14px; }
.end-title { font-size: clamp(40px, 7vw, 76px); letter-spacing: .3em; margin: 16px 0 24px; }
.end-desc { color: var(--ink-dim); line-height: 2; font-size: 17px; }
.end-count { margin-top: 18px; font-size: 13px; color: #777; font-family: var(--gothic); }
.end-buttons { margin-top: 30px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.end-buttons button { min-width: 260px; padding: 12px 20px; background: transparent; color: var(--ink); border: 1px solid rgba(255,255,255,.4); border-radius: 6px; font-family: var(--gothic); }
.end-buttons button.primary { background: var(--ink); color: #111; }

/* スマホ */
@media (max-width: 760px) {
  #textbox { padding: 22px 18px 26px; min-height: 132px; }
  #phone { top: 52px; height: min(400px, 48dvh); animation: none; }
  .signal-grid { grid-template-columns: repeat(2, 1fr); }
  .dentry { grid-template-columns: 1fr; gap: 2px; }
  .replay { flex-direction: column; }
  .replay-svg { max-width: 100%; width: 100%; }
  #hud button { padding: 4px 9px; font-size: 11px; }
  .ch { height: 70%; width: 62vw; }
  .ch[data-pos="l"] { left: 26%; } .ch[data-pos="r"] { left: 74%; }
  .title-inner { left: 24px; right: 24px; }
  .sleeve { width: 30vw; height: 34vh; }
  .shout { right: 16px; top: 38%; font-size: 16px; }
  #modal-body { padding: 14px; }
  .paper { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .t-main, #stage.fx-kune #bg, #stage.fx-kune #chars { animation: none; }
}

/* エンディング後アンケート（仕様書準拠・世界観に合わせた配色） */
.modal { display: none; position: fixed; inset: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, .85); z-index: 99998; align-items: center; justify-content: center; padding: 16px; }
.modal.show { display: flex; animation: fade .5s; }
.modal-card { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 30px 28px 26px; background: linear-gradient(180deg, #1d211b, #121510); border: 1px solid rgba(243, 240, 230, .18); border-radius: 12px; position: relative; color: var(--ink); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.modal-x { position: absolute; top: 8px; right: 12px; cursor: pointer; font-size: 26px; line-height: 1; background: none; border: none; color: var(--ink-dim); padding: 6px; }
.modal-x:hover { color: #fff; }
.pop-head { font-size: clamp(18px, 4.6vw, 22px); line-height: 1.7; letter-spacing: .1em; margin: 4px 0 18px; }
.pop-label { font-family: var(--gothic); font-size: 14px; color: var(--ink-dim); margin: 16px 0 8px; letter-spacing: .08em; }
.stars { display: flex; justify-content: center; gap: 12px; font-size: clamp(30px, 9vw, 42px); }
.star { color: #555b52; cursor: pointer; transition: color .15s, transform .15s; user-select: none; }
.star:hover { transform: scale(1.1); }
.star.on { color: #f0c34a; }
.fb-text { width: 100%; min-height: 96px; resize: vertical; padding: 10px 12px; background: rgba(243, 240, 230, .06); color: var(--ink); border: 1px solid rgba(243, 240, 230, .25); border-radius: 6px; font: 15px/1.7 var(--gothic); }
.fb-text:focus { outline: none; border-color: rgba(243, 240, 230, .6); }
.fb-err { min-height: 1.4em; margin: 8px 0 0; color: #f0a99f; font-family: var(--gothic); font-size: 14px; }
.fb-send { margin: 8px auto 0; display: block; font-size: clamp(15px, 4.2vw, 18px); letter-spacing: .2em; padding: 10px 40px; background: var(--ink); color: #111; border: none; border-radius: 6px; font-family: var(--mincho); font-weight: 700; }
.fb-send:disabled { opacity: .5; }
.fb-thanks { display: none; text-align: center; padding: 20px; font-size: 18px; letter-spacing: .1em; }
.pop-div { height: 1px; background: rgba(243, 240, 230, .15); margin: 22px 0 16px; }
.line-pitch { font-family: var(--gothic); font-size: 14px; line-height: 1.7; color: var(--ink-dim); }
.line-btn { display: block; margin: 14px auto 0; padding: 12px 26px; background: #06c755; color: #fff; border: none; border-radius: 24px; font-family: var(--gothic); font-weight: 700; font-size: 15px; }
.line-btn:hover { filter: brightness(1.08); }
.end-buttons button.survey { border-style: dashed; color: var(--ink-dim); }

/* 横向きスマホなど、高さが低い画面 */
@media (max-height: 500px) {
  #textbox { min-height: 92px; padding: 16px 22px 18px; font-size: 15px; line-height: 1.75; bottom: 8px; }
  #namebox { top: -14px; font-size: 12px; padding: 2px 12px; }
  #phone { top: 46px; height: calc(100dvh - 166px); border-width: 7px; border-radius: 22px; animation: none; }
  .phone-head { padding: 8px 14px 6px; font-size: 13px; }
  #phone-body { padding: 8px 10px; gap: 6px; }
  .bubble { font-size: 13px; padding: 6px 10px; }
  .ch { height: 96%; }
  #title h1 { margin-bottom: 14px; gap: 4px; }
  .t-main { font-size: clamp(40px, 14vh, 64px); }
  .t-sub { font-size: 15px; }
  .title-menu { gap: 0; }
  .title-menu button { font-size: 16px; padding: 4px 0; }
  .title-menu button.small { margin-top: 4px; }
  .title-note { margin-top: 10px; }
  #chapter-card .cc-title { font-size: 34px; }
  .wave-ui { top: 44px; }
  .wave-help { font-size: 13px; margin-top: 4px; }
  .sleeve { height: 60vh; }
}
