:root {
  --ink: #e9eef0;
  --sub: #9fb0b7;
  --line: rgba(226, 192, 120, .45);
  --gold: #e2c078;
  --teal: #7fe3d0;
  --red: #e0524f;
  --panel: rgba(6, 12, 15, .92);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "Noto Serif CJK JP", serif;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", Meiryo, sans-serif;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: var(--ink); font-family: var(--sans); overflow: hidden; overscroll-behavior: none; }
body { display: flex; justify-content: center; background: radial-gradient(circle at 50% 30%, #101b20, #000 70%); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

#app { position: relative; width: 100%; max-width: 480px; height: 100vh; height: 100dvh; overflow: hidden; background: #000; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
@media (min-width: 481px) { #app { box-shadow: 0 0 80px rgba(0, 0, 0, .9), 0 0 0 1px #1a2a30; } }

/* ---------- 舞台 ---------- */
#stage, #bg, #tint, #cg, #vignette, #fx-dark, #fx-flash { position: absolute; inset: 0; }
#bg > svg, #bg > img { width: 100%; height: 100%; object-fit: cover; display: block; }
#bg { transition: opacity .5s; }
#tint { pointer-events: none; opacity: 0; transition: opacity .6s; background: radial-gradient(circle at 50% 20%, rgba(255, 185, 165, .92), rgba(175, 55, 50, .95)); mix-blend-mode: multiply; }
#app.alert #tint { opacity: 1; animation: alert 2.4s ease-in-out infinite; }
@keyframes alert { 50% { opacity: .72; } }
#vignette { pointer-events: none; background: radial-gradient(ellipse at 50% 38%, transparent 38%, rgba(0, 0, 0, .78) 100%); }
#fx-dark { background: #000; opacity: 0; pointer-events: none; transition: opacity .12s; }
#fx-dark.on { opacity: 1; }
#fx-flash { pointer-events: none; opacity: 0; background: #fff; }
#fx-flash.go { animation: flash .5s ease-out; }
#fx-flash.red { background: #b30f14; }
#fx-flash.red.go { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
#app.shake #stage { animation: shake .45s; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translate(-9px, 4px); } 40% { transform: translate(8px, -5px); } 60% { transform: translate(-6px, 3px); } 80% { transform: translate(4px, -2px); } }
#stage.flicker #bg { animation: flicker .7s steps(1); }
@keyframes flicker { 0% { opacity: 0; } 12% { opacity: 1; } 20% { opacity: .1; } 34% { opacity: 1; } 46% { opacity: .3; } 60% { opacity: 1; } }

#portrait { position: absolute; left: 50%; bottom: 196px; width: 112%; max-width: 540px; height: 62%; transform: translateX(-50%); pointer-events: none; opacity: 0; transition: opacity .25s, filter .3s;
  -webkit-mask-image: linear-gradient(#000 80%, transparent 99%); mask-image: linear-gradient(#000 80%, transparent 99%);
  filter: drop-shadow(0 0 26px rgba(0, 0, 0, .8)); }
#portrait.on { opacity: 1; }
#portrait.dim { filter: brightness(.55) saturate(.7) drop-shadow(0 0 26px rgba(0, 0, 0, .8)); }
#portrait.pop { animation: pop .28s ease-out; }
@keyframes pop { 0% { transform: translateX(-50%) translateY(12px); } 100% { transform: translateX(-50%); } }
#portrait > svg, #portrait > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom; }

#cg { opacity: 0; transition: opacity .6s; pointer-events: none; }
#cg.on { opacity: 1; }
.cg-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cg-title { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.cg-title-sub, .t-sub { font-family: Georgia, serif; letter-spacing: .5em; font-size: 12px; color: var(--sub); text-indent: .5em; }
.cg-title-main, #title h1 { font-family: var(--serif); font-weight: 600; font-size: 46px; letter-spacing: .16em; margin: 0; display: flex; }
.cg-title-main span { opacity: 0; animation: rise .9s forwards; }
.cg-title-main span:nth-child(2) { animation-delay: .22s; } .cg-title-main span:nth-child(3) { animation-delay: .44s; }
.cg-title-main span:nth-child(4) { animation-delay: .66s; } .cg-title-main span:nth-child(5) { animation-delay: 1.2s; }
.red { color: var(--red); text-shadow: 0 0 24px rgba(224, 82, 79, .7); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.cg-list { position: absolute; inset: 0; background: rgba(0, 0, 0, .8); display: flex; align-items: flex-start; justify-content: center; padding-top: calc(9vh + var(--sat)); }
.cg-list-page { width: 76%; background: linear-gradient(#efe6d0, #d9cdb0); color: #2a2622; font-family: var(--serif); padding: 20px 24px 16px; transform: rotate(-2deg); box-shadow: 0 16px 50px #000; background-image: repeating-linear-gradient(transparent 0 33px, rgba(60, 80, 120, .22) 33px 34px), linear-gradient(#efe6d0, #d9cdb0); }
.cg-list-head { font-size: 13px; letter-spacing: .12em; border-bottom: 2px solid #2a2622; padding-bottom: 6px; margin-bottom: 4px; }
.cg-list ol { margin: 0; padding-left: 1.6em; font-size: 19px; line-height: 34px; }
.cg-list-foot { text-align: right; font-size: 13px; margin-top: 6px; color: #8a2a2a; }

/* ---------- HUD ---------- */
#hud { position: absolute; top: calc(10px + var(--sat)); left: 12px; right: 12px; display: flex; justify-content: space-between; pointer-events: none; font-size: 13px; z-index: 5; }
#hud > div { background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px; padding: 5px 12px; display: flex; align-items: center; gap: 8px; backdrop-filter: blur(4px); }
#hud .lbl { font-size: 10px; letter-spacing: .14em; color: var(--sub); }
#clock-v { font-family: Georgia, serif; font-size: 17px; color: var(--gold); font-variant-numeric: tabular-nums; }
#trust-v { display: flex; gap: 4px; }
#trust-v i { width: 9px; height: 14px; border-radius: 2px; background: rgba(255, 255, 255, .14); }
#trust-v i.on { background: var(--teal); box-shadow: 0 0 8px rgba(127, 227, 208, .7); }
#trust.low i.on { background: var(--red); box-shadow: 0 0 8px rgba(224, 82, 79, .8); }
#trust.hit { animation: hit .5s; } #trust.up { animation: up .5s; }
@keyframes hit { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); background: rgba(224, 82, 79, .5); } 75% { transform: translateX(6px); } }
@keyframes up { 50% { transform: scale(1.12); background: rgba(127, 227, 208, .35); } }

#toast { position: absolute; top: calc(52px + var(--sat)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 6; }
#toast div { background: rgba(8, 16, 20, .94); border: 1px solid var(--line); color: var(--gold); padding: 7px 16px; border-radius: 6px; font-size: 13px; animation: toast 2.8s forwards; max-width: 88%; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- メッセージ ---------- */
#msg { position: absolute; left: 0; right: 0; bottom: calc(46px + var(--sab)); height: 164px; padding: 26px 20px 12px; background: linear-gradient(rgba(4, 9, 11, 0), rgba(4, 9, 11, .9) 18%, rgba(4, 9, 11, .97)); z-index: 4; cursor: pointer; }
#msg::before { content: ""; position: absolute; left: 20px; right: 20px; top: 22px; height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
#name { position: absolute; left: 20px; top: 2px; font-family: var(--serif); font-size: 16px; font-weight: 600; padding: 2px 14px 2px 10px; border-left: 4px solid var(--c, #fff); background: linear-gradient(90deg, rgba(0, 0, 0, .75), rgba(0, 0, 0, 0)); letter-spacing: .08em; }
#text { font-size: 17px; line-height: 1.72; letter-spacing: .02em; padding-top: 6px; height: 124px; overflow: hidden; word-break: normal; line-break: strict; }
#text.nar { font-family: var(--serif); color: #dfe6e8; }
#text.voice { color: var(--teal); font-family: var(--serif); text-shadow: 0 0 12px rgba(127, 227, 208, .35); }
#text.self { color: #c8d6e2; }
#text .ghost { opacity: 0; }
#caret { position: absolute; right: 18px; bottom: 8px; font-size: 11px; color: var(--gold); opacity: 0; }
#msg.wait #caret { opacity: 1; animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }
@media (max-height: 620px) { #text { font-size: 15.5px; } #portrait { height: 56%; } }

#toolbar { position: absolute; left: 0; right: 0; bottom: 0; height: calc(46px + var(--sab)); padding-bottom: var(--sab); display: flex; background: #04090b; border-top: 1px solid rgba(255, 255, 255, .08); z-index: 7; }
#toolbar button { flex: 1; font-size: 13px; color: var(--sub); letter-spacing: .1em; position: relative; }
#toolbar button:active { background: rgba(255, 255, 255, .06); }
#toolbar button.on { color: #04090b; background: var(--gold); }
#note-badge { position: absolute; top: 9px; right: calc(50% - 28px); width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ---------- 選択肢・調査・提示 ---------- */
#panel { position: absolute; left: 0; right: 0; bottom: calc(46px + var(--sab)); max-height: 78%; z-index: 8; display: flex; flex-direction: column; background: linear-gradient(rgba(3, 7, 9, 0), rgba(3, 7, 9, .96) 40px, #03070a 90px); padding: 46px 16px 14px; animation: up2 .25s ease-out; }
@keyframes up2 { from { opacity: 0; transform: translateY(14px); } }
.p-prompt { font-family: var(--serif); font-size: 16px; color: var(--gold); text-align: center; margin: 0 0 12px; letter-spacing: .06em; line-height: 1.5; }
.p-list { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px; padding-bottom: 2px; }
.choice { text-align: left; padding: 15px 16px; min-height: 54px; font-size: 16px; line-height: 1.45; border: 1px solid rgba(226, 192, 120, .5); background: rgba(16, 26, 31, .95); border-radius: 6px; position: relative; }
.choice::before { content: "◆"; color: var(--gold); margin-right: 10px; font-size: 11px; vertical-align: 2px; }
.choice:active { background: rgba(226, 192, 120, .22); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cell { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-height: 56px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(16, 26, 31, .95); border-radius: 6px; font-size: 15px; text-align: left; }
.cell:active { background: rgba(127, 227, 208, .18); }
.cell.done { opacity: .38; }
.cell .av { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex: none; background: #1a2a31; border: 2px solid var(--c, #567); }
.cell .av svg, .cell .av img { width: 100%; height: 100%; object-fit: cover; }
.cell .ic { width: 40px; height: 40px; border-radius: 6px; flex: none; display: grid; place-items: center; background: #1a2a31; border: 1px solid #3a4c54; color: var(--gold); font-family: var(--serif); font-size: 18px; }
.cell small { display: block; font-size: 11px; color: var(--sub); }
.wide { grid-column: 1 / -1; justify-content: center; border-color: var(--red); color: #ffd9d6; background: rgba(60, 14, 14, .9); min-height: 50px; font-family: var(--serif); letter-spacing: .1em; }
.wide[disabled] { opacity: .4; }
.ev { text-align: left; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(16, 26, 31, .95); border-radius: 6px; }
.ev b { font-size: 15px; font-weight: 600; } .ev em { font-style: normal; font-size: 10px; color: #04090b; background: var(--gold); border-radius: 3px; padding: 1px 5px; margin-right: 8px; vertical-align: 1px; }
.ev p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--sub); display: none; }
.ev.sel { border-color: var(--gold); background: rgba(52, 42, 18, .95); } .ev.sel p { display: block; color: var(--ink); }
.p-go { margin-top: 10px; min-height: 52px; border-radius: 6px; background: var(--red); color: #fff; font-family: var(--serif); font-size: 18px; letter-spacing: .3em; text-indent: .3em; flex: none; box-shadow: 0 0 24px rgba(224, 82, 79, .4); }
.p-go[disabled] { background: #3a2a2a; color: #8a7a7a; box-shadow: none; }

/* ---------- オーバーレイ(手帳・ログ・設定・結末) ---------- */
#overlay { position: absolute; inset: 0; z-index: 20; background: #03070a; display: flex; flex-direction: column; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.o-head { padding: calc(14px + var(--sat)) 18px 10px; font-family: var(--serif); font-size: 18px; letter-spacing: .2em; color: var(--gold); border-bottom: 1px solid var(--line); flex: none; }
.o-tabs { display: flex; flex: none; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.o-tabs button { flex: 1; padding: 12px 0; font-size: 14px; color: var(--sub); border-bottom: 2px solid transparent; }
.o-tabs button.on { color: var(--ink); border-bottom-color: var(--gold); }
.o-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px; user-select: text; -webkit-user-select: text; }
.o-foot { flex: none; padding: 10px 16px calc(12px + var(--sab)); border-top: 1px solid rgba(255, 255, 255, .1); }
.o-close { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 6px; font-size: 16px; letter-spacing: .2em; background: rgba(16, 26, 31, .95); }
.person { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.person .av { width: 64px; height: 76px; border-radius: 6px; overflow: hidden; flex: none; background: #14222a; border-bottom: 3px solid var(--c); }
.person .av svg, .person .av img { width: 100%; height: 100%; object-fit: cover; }
.person.gone .av { filter: grayscale(1) brightness(.6); }
.person h3 { margin: 0; font-family: var(--serif); font-size: 17px; } .person h3 small { font-size: 11px; color: var(--sub); margin-left: 8px; font-family: var(--sans); font-weight: 400; }
.person .role { font-size: 12px; color: var(--c); margin: 2px 0 4px; }
.person p { margin: 0; font-size: 13px; line-height: 1.6; color: #c5d0d4; }
.person ul { margin: 6px 0 0; padding-left: 1.1em; font-size: 13px; line-height: 1.6; color: var(--gold); }
.tag { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px; background: var(--red); color: #fff; margin-left: 8px; vertical-align: 2px; font-family: var(--sans); }
.note { padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.note b { font-size: 15px; } .note em { font-style: normal; font-size: 10px; color: #04090b; background: var(--gold); border-radius: 3px; padding: 1px 5px; margin-right: 8px; vertical-align: 1px; }
.note p { margin: 5px 0 0; font-size: 13.5px; line-height: 1.65; color: #c5d0d4; }
.seatmap { width: 100%; max-width: 380px; display: block; margin: 0 auto; }
.seat-cap { font-size: 12.5px; color: var(--sub); line-height: 1.7; margin-top: 8px; }
.log p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.7; } .log b { display: block; font-size: 12px; color: var(--c, var(--sub)); font-weight: 600; }
.log .nar { color: #b9c5ca; font-family: var(--serif); } .log .pick { color: var(--gold); font-size: 13px; }
.set h4 { margin: 18px 0 8px; font-size: 13px; color: var(--sub); font-weight: 400; letter-spacing: .1em; }
.seg { display: flex; gap: 6px; } .seg button { flex: 1; min-height: 46px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px; font-size: 14px; }
.seg button.on { background: var(--gold); color: #04090b; border-color: var(--gold); }
.set .danger { margin-top: 28px; width: 100%; min-height: 46px; border: 1px solid rgba(224, 82, 79, .6); color: #ffb6b3; border-radius: 6px; font-size: 14px; }
.empty { color: var(--sub); font-size: 13px; padding: 20px 0; text-align: center; }

.end { justify-content: center; padding: 0 22px calc(20px + var(--sab)); text-align: center; background: radial-gradient(circle at 50% 30%, rgba(90, 8, 10, .55), rgba(0, 0, 0, .98) 70%); animation: fadein 1.2s; }
.end.clear { background: radial-gradient(circle at 50% 30%, rgba(20, 60, 60, .5), rgba(0, 0, 0, .98) 70%); }
.end .kind { font-family: Georgia, serif; letter-spacing: .5em; text-indent: .5em; font-size: 14px; color: var(--red); }
.end.clear .kind { color: var(--teal); }
.end h2 { font-family: var(--serif); font-size: 32px; margin: 14px 0 18px; letter-spacing: .14em; font-weight: 600; }
.end .txt { font-family: var(--serif); font-size: 15px; line-height: 1.9; color: #d5dde0; white-space: pre-line; margin: 0 0 14px; }
.end .hint { font-size: 13px; color: var(--gold); line-height: 1.7; border: 1px dashed var(--line); border-radius: 6px; padding: 10px 12px; margin: 0 0 22px; }
.end .stat { font-size: 13px; color: var(--sub); line-height: 1.9; margin: 0 0 22px; }
.end .btns { display: flex; flex-direction: column; gap: 10px; }
.end .btns button { min-height: 52px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 6px; font-size: 15px; background: rgba(16, 26, 31, .9); }
.end .btns button.main { background: var(--red); border-color: var(--red); color: #fff; font-size: 16px; letter-spacing: .08em; }
.end.clear .btns button.main { background: #1d6f66; border-color: var(--teal); }

/* ---------- タイトル ---------- */
#title { position: absolute; inset: 0; z-index: 30; background: radial-gradient(circle at 50% 28%, #14262c, #020405 72%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 24px calc(30px + var(--sab)); text-align: center; transition: opacity .8s; }
#title.out { opacity: 0; pointer-events: none; }
.t-9 { position: absolute; top: 4%; left: 50%; transform: translateX(-50%); font-family: Georgia, serif; font-size: 440px; line-height: 1; color: rgba(255, 255, 255, .035); pointer-events: none; }
#title h1 { font-size: 50px; animation: rise 1.6s; }
.t-copy { font-family: var(--serif); font-size: 15px; line-height: 2; color: #c5d0d4; margin: 6px 0 26px; }
.t-btns { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; position: relative; }
.t-btns button { min-height: 56px; border: 1px solid var(--line); border-radius: 6px; font-family: var(--serif); font-size: 18px; letter-spacing: .3em; text-indent: .3em; background: rgba(10, 18, 22, .8); }
.t-btns button:active { background: rgba(226, 192, 120, .25); }
.t-note { font-size: 11px; color: var(--sub); letter-spacing: .08em; margin-top: 16px; }
