:root {
  color-scheme: dark;
  --ink: #f6f0e5;
  --muted: #b8c2d5;
  --navy: #071327;
  --panel: rgba(6, 15, 33, .88);
  --line: rgba(195, 218, 255, .22);
  --gold: #e9ca83;
  --accent: #a9caff;
  --speaker-color: #e9ca83;
  --speaker-glow: rgba(233, 202, 131, .24);
  --shadow: 0 24px 80px rgba(0, 0, 0, .48);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #020712; color: var(--ink); font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; }
button, input, select { font: inherit; }
button { position: relative; color: var(--ink); border: 1px solid var(--line); background: linear-gradient(110deg, rgba(10, 23, 43, .9), rgba(22, 36, 57, .76)); cursor: pointer; transition: .2s ease; }
button:hover, button:focus-visible { border-color: var(--gold); background: linear-gradient(110deg, rgba(35, 46, 61, .96), rgba(48, 47, 57, .9)); box-shadow: 0 0 0 1px rgba(233,202,131,.15), 0 8px 24px rgba(0,0,0,.32); transform: translateY(-1px); outline: none; }
button:disabled { opacity: .42; cursor: default; transform: none; }

.app { position: relative; width: 100vw; height: 100dvh; min-height: 520px; overflow: hidden; background: var(--navy); }
.screen { position: absolute; inset: 0; display: none; }
.screen.is-active { display: flex; }

.title-screen { align-items: center; justify-content: center; flex-direction: column; isolation: isolate; background: #050b18 url("assets/images/title-bg.webp") center / cover no-repeat; }
.stars, .ending-stars { position: absolute; inset: 0; z-index: -2; opacity: .85; background-image: radial-gradient(circle, #fff 0 1px, transparent 1.5px), radial-gradient(circle, #d6e6ff 0 1px, transparent 1.5px); background-size: 63px 63px, 97px 97px; background-position: 12px 9px, 31px 44px; animation: drift 28s linear infinite; }
.title-screen .stars { display: none; }
.stars::after { content: ""; position: absolute; width: 34vw; height: 1px; left: 55%; top: 20%; background: linear-gradient(90deg, transparent, #fff, transparent); transform: rotate(-18deg); filter: drop-shadow(0 0 8px white); animation: meteor 8s ease-in-out infinite; }
.tower { position: absolute; bottom: -2%; left: 50%; width: min(38vw, 420px); height: 62%; transform: translateX(-50%); z-index: -1; background: linear-gradient(90deg, #050915, #101a2a 44%, #080e1c); clip-path: polygon(21% 100%, 21% 40%, 34% 40%, 34% 25%, 42% 15%, 58% 15%, 66% 25%, 66% 40%, 79% 40%, 79% 100%); opacity: .68; }
.title-screen .tower { display: none; }
.tower span { position: absolute; width: 8%; height: 8%; background: #d4ae62; box-shadow: 0 0 25px #f2c867; left: 46%; top: 45%; }
.title-copy { width: min(760px, 58vw); margin-right: 38vw; text-align: center; padding: 1rem; text-shadow: 0 5px 30px #000; }
.title-logo { display: block; width: 100%; height: auto; filter: drop-shadow(0 7px 18px rgba(0,0,0,.75)); }
.eyebrow { letter-spacing: .22em; color: #c9d5e9; font-size: clamp(.68rem, 1.2vw, .92rem); }
h1 { margin: .8rem 0; font-size: clamp(2rem, 5vw, 4.75rem); line-height: 1.25; font-weight: 500; letter-spacing: .08em; }
h1 em { color: var(--gold); font-style: normal; font-size: .8em; }
.trial-label { display: inline-block; padding: .3rem 1.25rem; border-block: 1px solid rgba(233, 202, 131, .55); letter-spacing: .35em; color: #e7d9b5; }
.title-menu { width: min(330px, 78vw); display: grid; gap: .55rem; margin-top: 1.2rem; }
.title-menu button, .ending-actions button { padding: .72rem 1.2rem; letter-spacing: .18em; backdrop-filter: blur(8px); }
.title-menu button::before, .title-menu button::after { content: ""; position: absolute; top: 50%; width: 16px; height: 1px; background: linear-gradient(90deg, transparent, rgba(233,202,131,.7)); }
.title-menu button::before { left: 10px; }
.title-menu button::after { right: 10px; transform: rotate(180deg); }
.primary-btn { border-color: rgba(233, 202, 131, .72); background: linear-gradient(90deg, rgba(131, 99, 45, .65), rgba(72, 66, 75, .7)); }
.title-note { position: absolute; bottom: max(12px, env(safe-area-inset-bottom)); color: #8795ae; font: .72rem/1.4 system-ui, sans-serif; }

.game-screen { background: #030a16; }
.game-screen.is-cinematic-slow .backdrop, .game-screen.is-cinematic-slow .event-cg, .game-screen.is-cinematic-slow .if-battle-fx { animation: ifCinematicSlow 1.25s ease-out 1; }
@keyframes ifCinematicSlow { 0% { filter: saturate(.72) contrast(1.08) blur(.6px); scale: 1.012; } 62% { filter: saturate(.78) contrast(1.06); scale: 1.006; } 100% { filter: none; scale: 1; } }
.backdrop { position: absolute; inset: 0; overflow: hidden; transition: filter .8s ease; }
.backdrop::before, .backdrop::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.backdrop::after { background: radial-gradient(circle at center, transparent 36%, rgba(0,0,0,.52)); }
.bg-night-tower { background: #050b18 url("assets/images/bg-tower-night.webp") center / cover no-repeat; }
.bg-seaside { background: #74b8e5 url("assets/images/bg-seaside-slope-day.webp") center / cover no-repeat; }
.bg-seaside-observation { background: #75b9e5 url("assets/images/bg-seaside-observation-point-day-v1.webp") center / cover no-repeat; }
.bg-seaside-shelter-rain { background: #293a46 url("assets/images/bg-seaside-shelter-rain-v1.webp") center / cover no-repeat; }
.bg-hall { background: #1a1716 url("assets/images/bg-entrance-hall.webp") center / cover no-repeat; }
.bg-presentation-hall { background: #191714 url("assets/images/bg-presentation-hall-v1.webp") center / cover no-repeat; }
.bg-rooftop-day { background: #76b9e8 url("assets/images/bg-rooftop-day.webp") center / cover no-repeat; }
.bg-rooftop-dusk { background: #b77f67 url("assets/images/bg-rooftop-dusk.webp") center / cover no-repeat; }
.bg-clubroom { background: #493629 url("assets/images/bg-clubroom-evening.webp") center / cover no-repeat; }
.bg-clubroom-morning { background: #708798 url("assets/images/bg-clubroom-morning-v1.webp") center / cover no-repeat; }
.bg-clubroom-day { background: #7696a8 url("assets/images/bg-clubroom-day.webp") center / cover no-repeat; }
.bg-clubroom-night { background: #080d18 url("assets/images/bg-clubroom-night-v1.webp") center / cover no-repeat; }
.bg-clubroom-rain { background: #27313a url("assets/images/bg-clubroom-rain.webp") center / cover no-repeat; }
.bg-temporary-clubroom { background: #77756f url("assets/images/bg-temporary-clubroom-v1.webp") center / cover no-repeat; }
.bg-equipment { background: #080d14 url("assets/images/bg-equipment-room.webp") center / cover no-repeat; }
.bg-editing-room { background: #080d14 url("assets/images/bg-editing-room-dusk-v1.webp") center / cover no-repeat; }
.bg-emergency-stairs { background: #090807 url("assets/images/bg-tower-emergency-stairs-v1.webp") center / cover no-repeat; }
.bg-underground-power { background: #080a0d url("assets/images/bg-underground-power-room-v1.webp") center / cover no-repeat; }
.bg-maintenance-passage { background: #050914 url("assets/images/bg-maintenance-passage-v1.webp") center / cover no-repeat; }
.bg-courtyard { background: #a86845 url("assets/images/bg-courtyard-sunset.webp") center / cover no-repeat; }
.bg-records { background: #33261f url("assets/images/bg-record-room.webp") center / cover no-repeat; }
.bg-records-past { background: #171a20 url("assets/images/bg-record-room-overlap-past.webp") center / cover no-repeat; }
.bg-seaside-night { background: #06132e url("assets/images/bg-seaside-slope-night.webp") center / cover no-repeat; }
.bg-presentation-exhibit { background: #241b16 url("assets/images/bg-presentation-exhibit.webp") center / cover no-repeat; }
.bg-screening-evening { background: #171c28 url("assets/images/bg-courtyard-screening-night-v1.webp") center / cover no-repeat; filter: brightness(1.13) saturate(.88) sepia(.08); }
.bg-screening-night { background: #080f20 url("assets/images/bg-courtyard-screening-night-v1.webp") center / cover no-repeat; }
.bg-rooftop-night { background: #070e1d url("assets/images/bg-rooftop-night.webp") center / cover no-repeat; }
.bg-rooftop-if-shutdown { background: #070e1d url("assets/images/bg-rooftop-if-shutdown-v1.png") center / cover no-repeat; }
.bg-tower-aftermath-dawn { background: #8ba5ba url("assets/images/bg-tower-aftermath-dawn-v1.png") center / cover no-repeat; }
.bg-used-bookstore-day { background: #493725 url("assets/images/bg-used-bookstore-day.webp") center / cover no-repeat; }
.bg-used-bookstore-tearoom-rain { background: #2d2825 url("assets/images/bg-used-bookstore-tearoom-rain.webp") center / cover no-repeat; }
.bg-coastal-bus-stop-rain-dusk { background: #172333 url("assets/images/bg-coastal-bus-stop-rain-dusk.webp") center / cover no-repeat; }
.bg-coastal-station-morning { background: #80b7d5 url("assets/images/bg-coastal-station-morning.webp") center / cover no-repeat; }
.bg-seaside-aquarium-day { background: #79b9df url("assets/images/bg-seaside-aquarium-day.webp") center / cover no-repeat; }
.bg-aquarium-main-gallery { background: #082a4c url("assets/images/bg-aquarium-main-gallery.webp") center / cover no-repeat; }
.bg-aquarium-cafe { background: #8bb2c5 url("assets/images/bg-aquarium-cafe.webp") center / cover no-repeat; }
.bg-aquarium-jellyfish { background: #071238 url("assets/images/bg-aquarium-jellyfish.webp") center / cover no-repeat; }
.bg-seaside-aquarium-sunset { background: #bd7555 url("assets/images/bg-seaside-aquarium-sunset.webp") center / cover no-repeat; }
.bg-botanical-garden-entrance-day { background: #91c790 url("assets/images/bg-botanical-garden-entrance-day.webp") center / cover no-repeat; }
.bg-botanical-greenhouse { background: #315f42 url("assets/images/bg-botanical-greenhouse.webp") center / cover no-repeat; }
.bg-botanical-cafe { background: #79996b url("assets/images/bg-botanical-cafe.webp") center / cover no-repeat; }
.bg-botanical-pond-sunset { background: #9a7546 url("assets/images/bg-botanical-pond-sunset.webp") center / cover no-repeat; }
.bg-botanical-exit-sunset { background: #a67358 url("assets/images/bg-botanical-exit-sunset.webp") center / cover no-repeat; }
.bg-school-gate-september-day { background: #78b8df url("assets/images/bg-school-gate-september-day.webp") center / cover no-repeat; }
.bg-seaside-promenade-sunset { background: #bc7459 url("assets/images/bg-seaside-promenade-sunset.webp") center / cover no-repeat; }
.bg-bedroom-desk-night { background: #091329 url("assets/images/bg-bedroom-desk-night.webp") center / cover no-repeat; }
.bg-starfalled { background: #070e1d url("assets/images/bg-rooftop-night.webp") center / cover no-repeat; }

.camera-status { position: absolute; z-index: 18; top: 76px; right: 22px; display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid rgba(111,139,151,.5); border-radius: 4px; background: rgba(3,12,18,.78); opacity: 0; transform: translateY(-5px); transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.camera-status.is-visible { opacity: 1; transform: none; }
.camera-status span { width: 10px; height: 10px; border-radius: 50%; background: #65777e; }
.camera-status strong { font: 700 11px/1 monospace; letter-spacing: .12em; }
.camera-status[data-status="recording"] { border-color: rgba(243,154,66,.66); }
.camera-status[data-status="recording"] span { background: #f39a42; box-shadow: 0 0 12px #f39a42; animation: cameraRecPulse 1s ease-in-out infinite; }
.camera-status[data-status="recording"] strong { color: #ffc078; }
.camera-status[data-status="confirmed"] { border-color: rgba(126,224,173,.6); }
.camera-status[data-status="confirmed"] span { background: #7ee0ad; box-shadow: 0 0 10px rgba(126,224,173,.65); }
.camera-status[data-status="confirmed"] strong { color: #9cf0c3; }
@keyframes cameraRecPulse { 50% { opacity: .42; box-shadow: 0 0 3px #f39a42; } }
.bg-starfalled::before {
  inset: -32% 0;
  background:
    linear-gradient(97deg, transparent 25%, rgba(130,240,180,.08) 25.3%, rgba(130,240,180,.85) 25.5%, transparent 25.9%),
    linear-gradient(91deg, transparent 43%, rgba(117,200,255,.08) 43.3%, rgba(117,200,255,.85) 43.5%, transparent 43.9%),
    linear-gradient(86deg, transparent 58%, rgba(240,243,255,.08) 58.3%, rgba(240,243,255,.9) 58.5%, transparent 58.9%),
    linear-gradient(82deg, transparent 72%, rgba(255,173,92,.08) 72.3%, rgba(255,173,92,.85) 72.5%, transparent 72.9%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: blur(.4px) drop-shadow(0 0 10px rgba(218,230,255,.65));
  animation: four-starfall 5.5s ease-in-out infinite;
}
.standing-layer { position: absolute; z-index: 1; inset: 0; overflow: hidden; opacity: 0; transition: opacity .35s ease; pointer-events: none; }
.if-scene-fx { position: absolute; z-index: 1; inset: 0; overflow: hidden; pointer-events: none; opacity: 0; }
.if-scene-sparks { position: absolute; inset: 0; background: radial-gradient(circle at 28% 40%, #fff 0 1px, #75b8ff 2px, transparent 8px), radial-gradient(circle at 72% 58%, #fff 0 1px, #ffb067 2px, transparent 7px), radial-gradient(circle at 44% 78%, #fff 0 1px, #9ff2c0 2px, transparent 6px); filter: drop-shadow(0 0 6px #fff); }
.game-screen[data-scene-effect="if-chase"] .if-scene-fx { opacity: 1; background: linear-gradient(90deg, rgba(0,0,0,.72), transparent 36% 68%, rgba(0,0,0,.58)); }
.game-screen[data-scene-effect="if-chase"] .if-scene-sparks { animation: ifSparkBurst .58s steps(2,end) infinite; }
@keyframes ifSparkBurst { 50% { opacity: .2; filter: brightness(2.2) drop-shadow(0 0 12px #fff); } }
.standing-layer.is-visible { opacity: 1; }
.standing-sprite { position: absolute; right: clamp(2rem, 8vw, 9rem); bottom: 0; height: min(92dvh, 1000px); max-width: 62vw; object-fit: contain; object-position: right bottom; filter: drop-shadow(0 20px 32px rgba(0,0,0,.55)); }
.standing-layer[data-effect="record-fade"] .standing-sprite { opacity: .52; filter: grayscale(.38) saturate(.72) contrast(.86) brightness(.92) drop-shadow(0 14px 25px rgba(43,90,116,.3)); -webkit-mask-image: linear-gradient(to bottom, #000 0 38%, rgba(0,0,0,.88) 53%, rgba(0,0,0,.52) 72%, transparent 98%), repeating-linear-gradient(to bottom, #000 0 17px, rgba(0,0,0,.76) 18px 20px); -webkit-mask-composite: source-in; mask-image: linear-gradient(to bottom, #000 0 38%, rgba(0,0,0,.88) 53%, rgba(0,0,0,.52) 72%, transparent 98%); animation: jemRecordFade 2.6s ease-in-out infinite alternate; }
.standing-layer[data-effect="record-fade-strong"] .standing-sprite { opacity: .34; filter: grayscale(.58) saturate(.52) contrast(.82) brightness(.88) drop-shadow(0 10px 20px rgba(43,90,116,.24)); -webkit-mask-image: linear-gradient(to bottom, #000 0 25%, rgba(0,0,0,.72) 47%, rgba(0,0,0,.32) 68%, transparent 92%); mask-image: linear-gradient(to bottom, #000 0 25%, rgba(0,0,0,.72) 47%, rgba(0,0,0,.32) 68%, transparent 92%); animation: jemRecordFade 2.2s ease-in-out infinite alternate; }
@keyframes jemRecordFade { from { transform: translateX(0); } to { transform: translateX(2px); } }
.event-cg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; visibility: hidden; transition: opacity .65s ease; }
.event-cg.is-hidden { transition: none; }
.event-cg.is-visible { opacity: 1; }
.event-cg.is-visible:not(.is-hidden) { visibility: visible; }
.event-cg[data-scene="sixth-observer"] { z-index: 3; inset: auto 4% 16% auto; width: min(24vw, 350px); height: min(64dvh, 700px); object-fit: contain; object-position: right bottom; mix-blend-mode: screen; -webkit-mask-image: radial-gradient(ellipse 62% 54% at 52% 52%, #000 42%, rgba(0,0,0,.88) 61%, transparent 91%); mask-image: radial-gradient(ellipse 62% 54% at 52% 52%, #000 42%, rgba(0,0,0,.88) 61%, transparent 91%); pointer-events: none; transition: opacity .45s ease, filter .45s ease; }
.event-cg[data-scene="sixth-observer"][data-variant="sixth-faint"] { opacity: .44; filter: grayscale(1) blur(1.25px) brightness(1.02) contrast(1.06); }
.event-cg[data-scene="sixth-observer"][data-variant="sixth-id"] { opacity: .68; filter: grayscale(.82) blur(.45px) brightness(1.06) contrast(1.1); }
.event-cg[data-scene="intentional-blank"] { z-index: 3; inset: 4% 5% 20%; width: 90%; height: 76%; object-fit: contain; filter: drop-shadow(0 18px 40px rgba(0,0,0,.62)); opacity: .92; pointer-events: none; }
.event-cg[data-scene="if-hostile-observatory"] { object-position: center top; }
.event-cg[data-scene="if-four-line-disconnect"] { object-position: center center; }
.event-cg[data-scene="if-observatory-shutdown"] { object-position: center top; }
.event-cg[data-scene="if-manual-terminal"] { z-index: 3; inset: 7dvh 8% 23dvh; width: 84%; height: 70dvh; object-fit: contain; object-position: center top; filter: drop-shadow(0 16px 28px rgba(0,0,0,.72)); pointer-events: none; }
.event-cg[data-scene="if-manual-terminal"][data-variant="walking"] { top: 5dvh; }
.event-cg[data-scene="if-manual-terminal"][data-variant="disassembled"] { inset: 10dvh 3% 24dvh; width: 94%; height: 64dvh; }
.if-battle-fx { position: absolute; z-index: 3; inset: 0; overflow: hidden; pointer-events: none; --shield-opacity: .72; }
.if-battle-fx::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 34%, rgba(235,228,255,.2), transparent 25%), repeating-linear-gradient(0deg, transparent 0 7px, rgba(205,220,255,.025) 8px 9px); mix-blend-mode: screen; }
.if-shield { position: absolute; left: 50%; top: 34%; width: min(52vw, 760px); aspect-ratio: 1.5625; translate: -50% -50%; opacity: var(--shield-opacity); filter: drop-shadow(0 0 18px rgba(190,202,255,.72)); transition: opacity .5s ease, scale .6s ease, filter .5s ease; animation: ifShieldDrift 5s linear infinite; }
.if-shield-half { position: absolute; top: 0; width: 50.15%; height: 100%; background: url("assets/images/fx/if-extra-star-chart-shield-v1.svg?v=2") no-repeat; background-size: 200% 100%; transition: translate .75s cubic-bezier(.2,.75,.2,1), rotate .75s ease, opacity .5s ease, clip-path .55s ease, filter .5s ease; }
.if-shield-left { left: 0; background-position: left center; }
.if-shield-right { right: 0; background-position: right center; }
.if-reticle { position: absolute; left: 50%; top: 34%; width: 10vmin; aspect-ratio: 1; translate: -50% -50%; border: 1px solid rgba(242,235,255,.84); border-radius: 50%; box-shadow: 0 0 24px rgba(224,213,255,.74), inset 0 0 20px rgba(224,213,255,.35); }
.if-line { position: absolute; left: 50%; top: 34%; width: 1.5px; height: 72vmax; transform-origin: top; opacity: 0; filter: drop-shadow(0 0 8px currentColor); transition: opacity .45s ease; }
.if-line-green { color: #65e7a1; background: currentColor; rotate: 128deg; }
.if-line-blue { color: #6da9ff; background: currentColor; rotate: 232deg; }
.if-line-silver { color: #e8eeff; background: currentColor; rotate: 52deg; }
.if-line-orange { color: #ffad69; background: currentColor; rotate: 308deg; }
.if-line-white { color: #eee7ff; background: currentColor; rotate: 0deg; width: 2px; }
.if-battle-fx[data-state="shield-1"] { --shield-opacity: .58; }
.if-battle-fx[data-state="shield-2"] { --shield-opacity: .38; }
.if-battle-fx[data-state="shield-3"], .if-battle-fx[data-state="shield-unstable"] { --shield-opacity: .2; }
.if-battle-fx[data-state="boss-active"] .if-shield,
.if-battle-fx[data-state="shield-1"] .if-shield,
.if-battle-fx[data-state="shield-2"] .if-shield,
.if-battle-fx[data-state="shield-3"] .if-shield { animation: ifShieldDrift 8s linear infinite, ifShieldBreathe 3.4s ease-in-out infinite; }
.if-battle-fx[data-state="shield-unstable"] .if-shield { animation: ifShieldUnstable .42s steps(2,end) infinite; }
.if-battle-fx[data-state="shield-1"] .if-shield-right { clip-path: polygon(0 0,100% 0,100% 36%,91% 42%,100% 51%,100% 100%,0 100%); }
.if-battle-fx[data-state="shield-2"] .if-shield-left { clip-path: polygon(0 0,100% 0,100% 100%,0 100%,0 68%,12% 59%,0 49%); }
.if-battle-fx[data-state="shield-3"] .if-shield-half { filter: brightness(1.4) contrast(1.22); opacity: .76; }
.if-battle-fx[data-state="shield-open"] .if-shield, .if-battle-fx[data-state="four-lines"] .if-shield { opacity: .62; }
.if-battle-fx[data-state="shield-open"] .if-shield-left, .if-battle-fx[data-state="four-lines"] .if-shield-left { translate: -44% 0; rotate: -6deg; }
.if-battle-fx[data-state="shield-open"] .if-shield-right, .if-battle-fx[data-state="four-lines"] .if-shield-right { translate: 44% 0; rotate: 6deg; }
.if-battle-fx[data-state="four-lines"] .if-line:not(.if-line-white) { opacity: .9; animation: ifInputLine 1.25s ease-in-out infinite; }
.if-battle-fx[data-state="lines-disconnected"] .if-line:not(.if-line-white) { opacity: 0; animation: ifLineDisconnect .75s ease-out 1; }
.if-battle-fx[data-state="lines-disconnected"] .if-shield { opacity: .08; scale: 1.08; filter: blur(2px) drop-shadow(0 0 30px #fff); }
.if-battle-fx[data-state="lines-disconnected"] .if-reticle { opacity: 0; }
.if-battle-fx[data-state="fifth-line"] .if-line-white { opacity: .95; animation: ifInputLine .8s ease-in-out infinite; }
.if-battle-fx[data-state="fifth-line"] .if-shield { opacity: .12; }
.if-battle-fx[data-state="collapse"] { animation: ifBattleCollapse 1.5s ease-out 1 both; }
.if-battle-fx[data-state="collapse"] .if-shield { scale: 1.2; opacity: 0; filter: blur(7px) brightness(3); }
.if-battle-fx[data-state="collapse"] .if-shield-left { translate: -72% 20%; rotate: -18deg; }
.if-battle-fx[data-state="collapse"] .if-shield-right { translate: 72% -16%; rotate: 19deg; }
.if-battle-fx[data-state="collapse"] .if-reticle,
.if-battle-fx[data-state="collapse"] .if-line { opacity: 0; animation: none; }
.if-battle-fx[data-state="collapse"]::before { opacity: 0; }
.if-battle-fx[data-pulse="warning"] .if-reticle { animation: ifAttackWarning 1.35s ease-out 1; }
.if-battle-fx[data-pulse="beam"]::after { content: ""; position: absolute; left: -10%; top: 43%; width: 120%; height: 4px; rotate: -8deg; background: #f5f0ff; box-shadow: 0 0 18px 8px rgba(225,215,255,.8); animation: ifBeamSweep 1.15s ease-in 1 both; }
.if-battle-fx[data-pulse="shield-hit"] .if-shield { animation: ifShieldHit .75s ease-out 1; }
.if-battle-fx[data-pulse="disconnect"] { animation: ifDisconnectFlash .9s ease-out 1; }
.if-attack-label { position: absolute; left: 50%; top: 13%; translate: -50% 0; min-width: min(520px,72vw); padding: .5rem 1rem; border-block: 1px solid rgba(255,126,112,.7); color: #ffb0a5; background: linear-gradient(90deg,transparent,rgba(52,5,12,.78),transparent); text-align: center; font: 700 clamp(.62rem,1.2vw,.9rem)/1.4 ui-monospace,monospace; letter-spacing: .14em; opacity: 0; }
.if-battle-fx[data-pulse="warning"] .if-attack-label::after { content: "観測者保護 / OBSERVER PROTECTION"; }
.if-battle-fx[data-pulse="future"] .if-attack-label::after { content: "未来固定 / FUTURE LOCK"; }
.if-battle-fx[data-pulse="beam"] .if-attack-label::after { content: "収束光 / CONVERGENCE BEAM"; }
.if-battle-fx[data-pulse="shield-hit"] .if-attack-label::after { content: "結果補正 / RESULT CORRECTION"; }
.if-battle-fx[data-pulse="disconnect"] .if-attack-label::after { content: "選択者隔離 / SELECTOR ISOLATION"; }
.if-battle-fx[data-pulse] .if-attack-label { animation: ifAttackLabel 1.35s ease-out 1; }
.if-line-hud, .if-boss-status { position: absolute; top: 18%; padding: .65rem .75rem; border: 1px solid rgba(159,186,224,.3); background: rgba(2,10,24,.72); font: 600 clamp(.52rem,.85vw,.7rem)/1.65 ui-monospace,monospace; letter-spacing: .08em; opacity: .82; }
.if-line-hud { left: 2%; } .if-boss-status { right: 2%; }
.if-line-hud span, .if-boss-status span { display: flex; justify-content: space-between; gap: 1rem; min-width: 10.5rem; }
.if-line-hud .green { color:#65e7a1 }.if-line-hud .blue { color:#6da9ff }.if-line-hud .silver { color:#e8eeff }.if-line-hud .orange { color:#ffad69 }.if-line-hud .central { color:#eee7ff; border-top:1px solid rgba(255,255,255,.2); margin-top:.2rem; padding-top:.2rem; opacity:0 }
.if-line-hud b::after { content:"CONNECTED"; color:#c8d2e5; }
.if-battle-fx[data-state="four-lines"] .if-line-hud b::after { content:"READY"; }
.if-battle-fx[data-state="lines-disconnected"] .if-line-hud span:not(.central) b::after { content:"DISCONNECTED"; color:#ff9b90; }
.if-battle-fx[data-state="fifth-line"] .if-line-hud span:not(.central) b::after { content:"DISCONNECTED"; color:#77869b; }
.if-battle-fx[data-state="fifth-line"] .if-line-hud .central { opacity:1 }.if-battle-fx[data-state="fifth-line"] .if-line-hud .central b::after { content:"ACTIVE"; color:#fff; }
.if-boss-status span:nth-child(1) b::after { content:"MAXIMUM" }.if-boss-status span:nth-child(2) b::after { content:"LOCKED" }.if-boss-status span:nth-child(3) b::after { content:"04 CONNECTED" }.if-boss-status span:nth-child(4) b::after { content:"READY" }
.if-battle-fx[data-state^="shield-"] .if-boss-status span:nth-child(1) b::after { content:"DAMAGED"; color:#ffd18b }
.if-battle-fx[data-state="shield-open"] .if-boss-status span:nth-child(1) b::after,.if-battle-fx[data-state="four-lines"] .if-boss-status span:nth-child(1) b::after { content:"OPEN"; color:#ff9b90 }
.if-battle-fx[data-state="lines-disconnected"] .if-boss-status span:nth-child(3) b::after,.if-battle-fx[data-state="fifth-line"] .if-boss-status span:nth-child(3) b::after { content:"00 CONNECTED"; color:#ff9b90 }
.if-battle-fx[data-state="lines-disconnected"] .if-boss-status span:nth-child(4) b::after,.if-battle-fx[data-state="fifth-line"] .if-boss-status span:nth-child(4) b::after { content:"IMPOSSIBLE"; color:#ff9b90 }
@keyframes ifAttackLabel { 0% { opacity:0; translate:-50% -8px } 15%,72% { opacity:1; translate:-50% 0 } 100% { opacity:0 } }
@keyframes ifShieldDrift { to { rotate: 360deg; } }
@keyframes ifShieldBreathe { 0%, 100% { scale: .96; } 50% { scale: 1.02; } }
@keyframes ifShieldUnstable { 50% { scale: .84 1; opacity: .08; } }
@keyframes ifInputLine { 50% { opacity: .42; filter: drop-shadow(0 0 18px currentColor); } }
@keyframes ifLineDisconnect { 0% { opacity: 1; } 45% { opacity: 1; filter: brightness(4) drop-shadow(0 0 24px currentColor); } 100% { opacity: 0; scale: 1 .1; } }
@keyframes ifBattleCollapse { 45% { filter: brightness(2.2); } 100% { opacity: 0; } }
@keyframes ifAttackWarning { 0% { opacity: .15; scale: 1.8; } 35% { opacity: 1; scale: .72; } 55% { opacity: .35; } 100% { opacity: 1; scale: .38; } }
@keyframes ifBeamSweep { 0% { opacity: 0; translate: -35% -10vh; } 25% { opacity: 1; } 100% { opacity: 0; translate: 35% 18vh; } }
@keyframes ifShieldHit { 35% { filter: brightness(3) drop-shadow(0 0 35px #fff); scale: .92; } }
@keyframes ifDisconnectFlash { 35% { background: rgba(240,235,255,.5); } }
.backdrop[data-cg-scene="intentional-blank"]::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 42%, rgba(14,35,47,.08), rgba(2,7,15,.48)); }
.flash { position: absolute; z-index: 7; inset: 0; background: white; opacity: 0; pointer-events: none; }
.flash.is-flashing { animation: flash 1.3s ease-out; }
.flash.is-whiteout { animation: whiteout 4s ease-in forwards; }

/* IF EXTRA「閉じない正常系」Phase A battle effects. */
.game-screen[data-scene-effect^="if-"] .backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.game-screen[data-scene-effect="if-alert"] .backdrop::after {
  background: linear-gradient(115deg, rgba(72, 231, 150, .12), rgba(75, 153, 255, .18) 35%, rgba(233, 239, 255, .14) 58%, rgba(255, 154, 72, .16) 78%, rgba(225, 218, 255, .18));
  animation: ifAlertPulse 1.25s steps(2, end) infinite;
}
.game-screen[data-scene-effect^="if-reboot-"] .backdrop::after { background: radial-gradient(ellipse at 50% 92%, var(--if-reboot-color) 0 2%, transparent 43%); opacity: .9; filter: drop-shadow(0 0 18px var(--if-reboot-color)); animation: ifRebootRise .7s ease-out both; }
.game-screen[data-scene-effect="if-reboot-green"] { --if-reboot-color:rgba(74,238,144,.72) }
.game-screen[data-scene-effect="if-reboot-blue"] { --if-reboot-color:rgba(78,155,255,.78) }
.game-screen[data-scene-effect="if-reboot-silver"] { --if-reboot-color:rgba(224,235,255,.82) }
.game-screen[data-scene-effect="if-reboot-orange"] { --if-reboot-color:rgba(255,145,55,.8) }
.game-screen[data-scene-effect="if-reboot-white"] { --if-reboot-color:rgba(240,235,255,.9) }
@keyframes ifRebootRise { from { clip-path:inset(100% 0 0); opacity:.1 } to { clip-path:inset(0); opacity:.9 } }
.game-screen[data-scene-effect="if-chase"] .backdrop { animation: ifChaseShake .52s linear infinite; }
.game-screen[data-scene-effect="if-chase"] .backdrop::after {
  background: repeating-linear-gradient(102deg, transparent 0 13%, rgba(102, 188, 255, .13) 13.5% 14%, transparent 14.5% 27%);
  animation: ifCableSweep 1.1s linear infinite;
}
.game-screen[data-scene-effect="if-mimic-room"] .backdrop::after,
.game-screen[data-scene-effect="if-mimic"] .backdrop::after {
  background: repeating-linear-gradient(0deg, rgba(213, 229, 255, .04) 0 1px, transparent 1px 5px), linear-gradient(90deg, rgba(80, 235, 160, .09), rgba(80, 155, 255, .1), rgba(255, 174, 78, .09));
  mix-blend-mode: screen;
  animation: ifMimicNoise .34s steps(2, end) infinite;
}
.game-screen[data-scene-effect="if-mimic"] .backdrop::before {
  background: url("assets/images/fx/if-extra-mimic-observer-v1.png") 18% 46% / auto 76% no-repeat;
  opacity: .78;
  filter: drop-shadow(0 0 18px rgba(205, 220, 255, .48));
  animation: ifMimicObserver 2.4s steps(2, end) infinite;
}
.game-screen[data-scene-effect="if-ui-attack"] .speaker {
  animation: ifSpeakerGlitch 1.8s steps(2, end) infinite;
}
.game-screen[data-scene-effect="if-ui-attack"] .backdrop::before,
.game-screen[data-scene-effect="if-record-delete"] .backdrop::before {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: .2;
  mix-blend-mode: screen;
  mask-image: radial-gradient(ellipse at center, #000 15%, rgba(0,0,0,.82) 55%, transparent 92%);
  animation: ifAbnormalProjection 9.6s steps(1, end) infinite;
}
.game-screen[data-scene-effect="if-record-delete"] .speaker:empty::before {
  content: "▓▒░ ░▒▓";
  color: rgba(226, 235, 255, .9);
  letter-spacing: .18em;
  text-shadow: -5px 0 rgba(96, 211, 255, .5), 5px 0 rgba(255, 151, 92, .42);
  animation: ifRecordNameDelete .48s steps(4, end) both;
}
.standing-layer[data-effect="record-delete"] {
  opacity: 0;
  animation: ifRecordSpriteDelete .22s steps(4, end) both;
}
.standing-layer[data-effect="record-delete"] .standing-sprite { filter: grayscale(.8) contrast(1.8); }
.game-screen[data-scene-effect="if-ui-attack"] .choice-panel button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 5px, rgba(235, 244, 255, .1) 5px 7px);
  pointer-events: none;
}
.game-screen[data-scene-effect="if-selector-exclude"] .message-box {
  border-color: rgba(235, 237, 255, .72);
  box-shadow: 0 0 0 2px rgba(211, 216, 255, .18), 0 0 55px rgba(193, 204, 255, .34), var(--shadow);
  animation: ifSelectorExclude 2.2s ease-in-out 1 both;
}
.game-screen[data-scene-effect="if-boss"] .backdrop,
.game-screen[data-scene-effect="if-boss-climax"] .backdrop,
.game-screen[data-scene-effect="if-four-lines"] .backdrop,
.game-screen[data-scene-effect="if-fifth-line"] .backdrop {
  filter: brightness(.62) saturate(1.28) contrast(1.12) !important;
}
.game-screen[data-scene-effect="if-boss"] .backdrop::after,
.game-screen[data-scene-effect="if-boss-climax"] .backdrop::after {
  background:
    radial-gradient(circle at 50% 27%, rgba(232, 229, 255, .72) 0 1.2%, transparent 5%),
    conic-gradient(from 205deg at 50% 30%, rgba(89, 230, 153, .2), rgba(86, 159, 255, .22), rgba(226, 232, 255, .18), rgba(255, 160, 76, .22), rgba(89, 230, 153, .2));
  mask-image: radial-gradient(ellipse at 50% 35%, #000 0 31%, transparent 69%);
  animation: ifBossCore 2.2s ease-in-out infinite;
}
.game-screen[data-scene-effect="if-boss-climax"] { animation: ifBossImpact .42s linear 2; }
.game-screen[data-scene-effect="if-four-lines"] .backdrop::after {
  background: linear-gradient(110deg, transparent 19%, rgba(89, 230, 153, .72) 20%, transparent 21%), linear-gradient(70deg, transparent 39%, rgba(86, 159, 255, .72) 40%, transparent 41%), linear-gradient(110deg, transparent 59%, rgba(228, 235, 255, .8) 60%, transparent 61%), linear-gradient(70deg, transparent 79%, rgba(255, 160, 76, .76) 80%, transparent 81%);
  filter: drop-shadow(0 0 12px rgba(220, 230, 255, .55));
  animation: ifFourLines 1.5s ease-in-out infinite;
}
.game-screen[data-scene-effect="if-fifth-line"] .backdrop::after {
  background: linear-gradient(90deg, transparent 49.5%, rgba(231, 226, 255, .82) 50%, transparent 50.5%);
  filter: drop-shadow(0 0 18px rgba(224, 216, 255, .88));
}
.game-screen[data-scene-effect="if-manual-mode"] .backdrop { filter: none !important; }
.game-screen[data-scene-effect="if-manual-mode"] .backdrop::after {
  background: radial-gradient(circle at center, transparent 58%, rgba(0,0,0,.2));
}
.game-screen[data-scene-effect="if-aftermath"] .backdrop { filter: none !important; }
.game-screen[data-scene-effect="if-aftermath"] .backdrop::after { background: radial-gradient(circle at center, transparent 54%, rgba(0,0,0,.24)); }
.game-screen[data-scene-effect="if-blackout"] .backdrop { filter: brightness(0) !important; }
.if-extra-btn { border-color: rgba(255, 125, 104, .7) !important; box-shadow: inset 0 0 24px rgba(255, 92, 72, .08); }
.terminal-screen[data-theme="if-hostile"] { z-index: 6; --terminal-accent: #ff9b87; --terminal-glow: rgba(255, 73, 51, .26); }
.terminal-screen[data-theme="if-hostile"] .terminal-frame { background: linear-gradient(135deg, rgba(2, 10, 22, .98), rgba(11, 20, 34, .97)); }
@keyframes ifAlertPulse { 50% { opacity: .34; filter: hue-rotate(24deg); } }
@keyframes ifChaseShake { 25% { translate: -2px 1px; } 75% { translate: 2px -1px; } }
@keyframes ifCableSweep { to { background-position: 70vw 0; } }
@keyframes ifMimicNoise { 50% { translate: 2px -1px; opacity: .64; } }
@keyframes ifMimicObserver { 0%, 100% { translate: -3px 0; opacity: .7; } 50% { translate: 4px -1px; opacity: .86; } }
@keyframes ifSpeakerGlitch { 8%, 14% { opacity: .18; translate: 5px 0; } 16% { opacity: 1; translate: 0; } }
@keyframes ifRecordNameDelete {
  0% { opacity: 1; translate: 0; filter: blur(0); }
  55% { opacity: .85; translate: 7px 0; filter: blur(1px); }
  100% { opacity: 0; translate: -5px 0; filter: blur(4px); }
}
@keyframes ifRecordSpriteDelete {
  0% { opacity: 1; clip-path: inset(0); translate: 0; }
  45% { opacity: .7; clip-path: inset(14% 0 31% 0); translate: 7px 0; }
  75% { opacity: .34; clip-path: inset(42% 0 8% 0); translate: -5px 0; }
  100% { opacity: 0; clip-path: inset(50% 0); translate: 0; }
}
@keyframes ifAbnormalProjection {
  0%, 24.99% { background-image: url("assets/images/bg-clubroom-day.webp"); opacity: .18; filter: hue-rotate(8deg) saturate(.72); }
  25%, 49.99% { background-image: url("assets/images/bg-equipment-room.webp"); opacity: .22; filter: hue-rotate(178deg) saturate(.62); }
  50%, 74.99% { background-image: url("assets/images/bg-rooftop-dusk.webp"); opacity: .2; filter: saturate(.74); }
  75%, 100% { background-image: url("assets/images/bg-presentation-exhibit.webp"); opacity: .24; filter: hue-rotate(-8deg) saturate(.7); }
}
@keyframes ifSelectorExclude {
  0%, 18% { translate: 0 0; opacity: 1; }
  48% { translate: 0 52%; opacity: .32; }
  76%, 100% { translate: 0 0; opacity: 1; }
}
@keyframes ifBossCore { 50% { opacity: .55; scale: 1.025; } }
@keyframes ifBossImpact { 25% { translate: -5px 2px; } 75% { translate: 5px -2px; } }
@keyframes ifFourLines { 50% { opacity: .58; filter: drop-shadow(0 0 25px rgba(220, 230, 255, .82)); } }
@media (prefers-reduced-motion: reduce) {
  .game-screen.is-cinematic-slow .backdrop, .game-screen.is-cinematic-slow .event-cg, .game-screen.is-cinematic-slow .if-battle-fx { animation: none !important; filter: saturate(.82) !important; scale: 1 !important; }
  .game-screen[data-scene-effect^="if-"] *,
  .game-screen[data-scene-effect^="if-"] .backdrop,
  .game-screen[data-scene-effect^="if-"] .backdrop::after { animation: none !important; }
  .game-screen[data-scene-effect="if-chase"] .backdrop,
  .game-screen[data-scene-effect="if-mimic"] .backdrop::after,
  .game-screen[data-scene-effect="if-boss-climax"] { translate: none !important; }
  .game-screen[data-scene-effect="if-selector-exclude"] .message-box { translate: none !important; opacity: 1 !important; }
  .standing-layer[data-effect="record-delete"] { animation: none !important; opacity: 0 !important; }
  .game-screen[data-scene-effect="if-record-delete"] .speaker:empty::before { display: none; }
  .game-screen[data-scene-effect="if-ui-attack"] .backdrop::before { background-image: url("assets/images/bg-presentation-exhibit.webp"); opacity: .16; filter: saturate(.65); }
  .choice-panel.is-fake-choice button.is-erased { opacity: 0 !important; visibility: hidden !important; }
  .if-battle-fx[data-state] .if-shield { rotate: 0deg !important; transition: none !important; }
  .if-battle-fx[data-state="collapse"] { opacity: 0 !important; }
  .if-battle-fx[data-pulse="warning"] .if-reticle { opacity: .72; scale: 1; }
  .if-battle-fx[data-pulse="beam"]::after { opacity: .7; translate: none; box-shadow: 0 0 10px 3px rgba(225,215,255,.62); }
  .if-battle-fx[data-pulse="disconnect"] { box-shadow: inset 0 0 70px rgba(240,235,255,.2); }
  .flash.is-flashing,
  .flash.is-whiteout { opacity: 0 !important; }
}

@media (max-width: 700px) {
  .if-shield { width: min(68vw, 520px); opacity: calc(var(--shield-opacity) + .16); filter: contrast(1.18) brightness(1.08) drop-shadow(0 0 7px rgba(205,214,255,.76)); }
  .if-shield-half { filter: contrast(1.34) brightness(1.1); }
  .if-battle-fx[data-state="shield-3"] .if-shield-half { filter: contrast(1.48) brightness(1.24); }
  .if-line-hud, .if-boss-status { max-width: 47%; padding: .38rem .45rem; font-size: clamp(.43rem, 1.75vw, .58rem); line-height: 1.45; background: rgba(2,10,24,.62); }
  .if-line-hud span, .if-boss-status span { min-width: 0; gap: .35rem; }
  .if-boss-status { top: 35%; }
  .if-attack-label { top: 12%; min-width: 82vw; }
}

.chapter-card { position: absolute; z-index: 9; inset: 0; display: grid; place-items: center; background: rgba(2, 7, 18, .78); opacity: 0; pointer-events: none; font-size: clamp(1.5rem, 4vw, 3.5rem); letter-spacing: .18em; text-shadow: 0 4px 25px #000; }
.chapter-card .chapter-number { margin-right: .45em; }
.chapter-card.is-hidden { visibility: hidden; opacity: 0; animation: none; }
.chapter-card.is-visible { animation: chapter 2.4s ease both; }

.game-toolbar { position: absolute; z-index: 10; top: 0; right: 0; display: flex; gap: .18rem; margin: .65rem; padding: .28rem; border: 1px solid rgba(194,211,235,.16); background: rgba(4,11,23,.68); box-shadow: 0 8px 24px rgba(0,0,0,.28); backdrop-filter: blur(12px); }
.game-toolbar::before { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(233,202,131,.68), transparent); }
.game-toolbar button { padding: .42rem .68rem; border: 0; border-right: 1px solid rgba(194,211,235,.13); border-radius: 0; background: transparent; font: 600 .66rem/1 system-ui, sans-serif; letter-spacing: .08em; backdrop-filter: blur(8px); }
.game-toolbar button:last-child { border-right: 0; }
.game-toolbar button[aria-pressed="true"] { color: #172035; background: var(--gold); }
.message-box { position: absolute; z-index: 4; left: 50%; bottom: max(2.3vh, env(safe-area-inset-bottom)); width: min(1040px, 91vw); min-height: 180px; transform: translateX(-50%); padding: 2.15rem clamp(1.4rem, 4vw, 3.3rem) 1.5rem; border: 1px solid rgba(187,204,230,.32); border-top-color: var(--speaker-color); background: linear-gradient(112deg, rgba(3,10,24,.96), rgba(11,23,43,.91)); box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.03), 0 0 34px var(--speaker-glow); backdrop-filter: blur(12px); cursor: pointer; transition: border-color .35s ease, box-shadow .35s ease; }
.message-box::before, .message-box::after { content: ""; position: absolute; pointer-events: none; }
.message-box::before { inset: 8px; border: 1px solid rgba(199,216,240,.08); clip-path: polygon(0 0, 88px 0, 88px 1px, 1px 1px, 1px 42px, 0 42px, 0 0, 100% 0, 100% 100%, 0 100%); }
.message-box::after { top: -1px; right: 22px; width: 132px; height: 1px; background: linear-gradient(90deg, transparent, var(--speaker-color)); }
.speaker { position: absolute; top: -1rem; left: 2.2rem; min-width: 150px; padding: .45rem 1.4rem; border: 1px solid color-mix(in srgb, var(--speaker-color) 58%, transparent); background: linear-gradient(100deg, rgba(7,18,36,.98), rgba(20,31,50,.96)); color: var(--speaker-color); text-align: center; letter-spacing: .12em; box-shadow: 0 8px 20px rgba(0,0,0,.3), 0 0 18px var(--speaker-glow); }
.speaker:empty { display: none; }
.message { margin: 0; font-size: clamp(1rem, 1.55vw, 1.25rem); line-height: 2; letter-spacing: .04em; white-space: pre-wrap; text-shadow: 0 2px 8px #000; }
.next-indicator { position: absolute; right: 1.4rem; bottom: .8rem; width: .55rem; height: .55rem; color: transparent; border: 1px solid var(--speaker-color); transform: rotate(45deg); animation: blink 1s infinite; }
.message-box[data-speaker="チャッピー"] { --speaker-color: #a9d6a2; --speaker-glow: rgba(112,170,112,.2); }
.message-box[data-speaker="コデにゃん"] { --speaker-color: #9ec9ed; --speaker-glow: rgba(90,151,204,.2); }
.message-box[data-speaker="クロ"] { --speaker-color: #d7dbe8; --speaker-glow: rgba(196,202,220,.18); }
.message-box[data-speaker="ジェミくん"] { --speaker-color: #efb06f; --speaker-glow: rgba(221,139,68,.2); }
.message-box[data-speaker="部長"] { --speaker-color: #d8c8ee; --speaker-glow: rgba(175,143,209,.18); }
.choice-panel { position: absolute; z-index: 8; inset: 0; display: none; align-content: center; justify-items: center; gap: .75rem; padding: 8vh 5vw 26vh; background: rgba(1, 6, 16, .4); }
.choice-panel.is-visible { display: grid; }
.choice-panel { counter-reset: choice; }
.choice-panel button { counter-increment: choice; width: min(680px, 90vw); padding: 1rem 1.4rem 1rem 4.2rem; border-color: rgba(190,211,245,.38); background: linear-gradient(105deg, rgba(4,14,32,.96), rgba(15,29,51,.94)); box-shadow: 0 12px 35px rgba(0,0,0,.32); text-align: left; }
.choice-panel button::before { content: "0" counter(choice); position: absolute; left: 1.25rem; top: 50%; translate: 0 -50%; padding-right: .8rem; border-right: 1px solid rgba(233,202,131,.4); color: var(--gold); font: .72rem/1 system-ui,sans-serif; letter-spacing: .08em; }
.choice-panel button:focus { border-color: var(--gold); color: var(--gold); }
.choice-panel.is-fake-choice button:disabled { opacity: 1; color: #e8eef8; cursor: default; }
.choice-panel.is-fake-choice button.is-erased { animation: ifChoiceErase .55s ease-in forwards; pointer-events: none; }
.choice-panel .fake-choice-wait { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; counter-increment: none; border: 0; }
.choice-panel .fake-choice-wait::before { display: none; }
.choice-panel .fake-choice-wait:focus-visible { position: relative; width: min(520px, 84vw); height: auto; margin: .35rem 0 0; padding: .8rem 1.1rem; overflow: visible; clip: auto; clip-path: none; white-space: normal; border: 1px solid var(--gold); text-align: center; color: var(--gold); background: rgba(4,14,32,.96); }
@keyframes ifChoiceErase {
  0% { opacity: 1; filter: brightness(1); transform: scale(1); }
  45% { opacity: 1; filter: brightness(3) blur(1px); box-shadow: 0 0 34px rgba(255,255,255,.95); }
  100% { opacity: 0; filter: brightness(4) blur(8px); transform: scale(1.025); visibility: hidden; }
}

.ending-screen { align-items: center; justify-content: center; flex-direction: column; text-align: center; background: radial-gradient(circle at 50% 15%, #334f7b, #101e39 38%, #030815 80%); }
.ending-screen h2 { font-size: clamp(1.8rem, 4.5vw, 4rem); line-height: 1.5; font-weight: 500; }
.ending-message { width: min(650px, 86vw); min-height: 100px; margin: 1rem; padding: 1.4rem; border-block: 1px solid rgba(233,202,131,.38); color: #e7d9b5; line-height: 2; }
.ending-actions { display: flex; gap: .8rem; flex-wrap: wrap; justify-content: center; }

.modal { position: fixed; z-index: 100; inset: 0; display: none; place-items: center; }
.modal.is-visible { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 3, 10, .74); backdrop-filter: blur(6px); }
.modal-panel { position: relative; display: flex; flex-direction: column; width: min(780px, 92vw); height: min(720px, calc(100dvh - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)))); overflow: hidden; border: 1px solid rgba(195,218,255,.28); border-top-color: rgba(233,202,131,.58); background: linear-gradient(135deg, #071326, #0d1b31); box-shadow: var(--shadow), inset 0 0 0 8px rgba(255,255,255,.012); }
.modal-panel::after { content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); pointer-events: none; }
.modal-panel > header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-panel h2 { margin: 0; font-size: 1.1rem; letter-spacing: .15em; }
.close-btn { width: 2.2rem; height: 2.2rem; border: 0; background: transparent; font-size: 1.4rem; }
.modal-content { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 1.25rem 1.25rem calc(2.5rem + env(safe-area-inset-bottom)); scrollbar-gutter: stable; }
.settings-grid { display: grid; gap: 1.4rem; font-family: system-ui, sans-serif; }
.settings-grid label { display: grid; gap: .55rem; }
.settings-grid input[type="range"] { width: 100%; accent-color: var(--gold); }
.settings-grid select { padding: .65rem; color: var(--ink); border: 1px solid var(--line); background: #13213a; }
.check-row { display: flex !important; align-items: center; }
.settings-action-btn, .danger-btn { padding: .7rem; }
.danger-btn { border-color: #834f59; color: #efb8c0; }
.save-grid { display: grid; gap: .65rem; }
.save-slot { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: .8rem; padding: .8rem; border: 1px solid var(--line); border-left-color: rgba(233,202,131,.46); background: linear-gradient(90deg, rgba(233,202,131,.035), rgba(255,255,255,.018)); }
.save-slot strong { color: var(--gold); }
.save-slot small { color: var(--muted); font-family: system-ui, sans-serif; }
.save-slot button { padding: .55rem .8rem; }
.log-list { display: grid; gap: .7rem; }
.log-entry { padding-bottom: .65rem; border-bottom: 1px solid rgba(255,255,255,.08); line-height: 1.7; }
.log-entry strong { color: var(--gold); margin-right: .5rem; }
.credits { display: grid; gap: 1.15rem; line-height: 1.75; }
.credits section { padding-bottom: 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.credits h3 { margin: 0 0 .35rem; color: var(--gold); font-size: .95rem; letter-spacing: .12em; }
.credits p { margin: 0; color: var(--muted); }
.debug-start-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; font-family: system-ui, sans-serif; }
.debug-start-note, .debug-start-menu h3 { grid-column: 1 / -1; }
.debug-start-note { margin: 0 0 .35rem; color: var(--muted); line-height: 1.7; }
.debug-start-menu h3 { margin: .65rem 0 0; padding-bottom: .4rem; color: var(--gold); border-bottom: 1px solid var(--line); font-size: .92rem; letter-spacing: .12em; }
.debug-start-button { display: grid; gap: .3rem; padding: .8rem 1rem; text-align: left; }
.debug-start-button strong { color: var(--ink); }
.debug-start-button span { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.extra-start-menu { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; }
.extra-start-menu .debug-start-button { height: 4.5rem; align-items: center; }
.extra-start-menu .debug-start-button strong { line-height: 1.45; }
.debug-standing-button { grid-column: 1 / -1; border-color: rgba(233,202,131,.55); background: rgba(233,202,131,.06); }
.standing-review { display: grid; gap: 1rem; font-family: system-ui, sans-serif; }
.standing-review-group { display: grid; gap: .65rem; }
.standing-review-group h3 { margin: .55rem 0 0; padding-bottom: .4rem; color: var(--gold); border-bottom: 1px solid var(--line); font-size: .92rem; letter-spacing: .12em; }
.standing-review-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; }
.standing-review-card { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); background: rgba(255,255,255,.025); }
.standing-review-card img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: contain; object-position: center bottom; background: radial-gradient(circle at 50% 35%, rgba(97,131,177,.2), rgba(3,8,21,.75)); }
.standing-review-card figcaption { display: grid; gap: .2rem; padding: .55rem .65rem; }
.standing-review-card figcaption strong { color: var(--ink); font-size: .82rem; line-height: 1.4; }
.standing-review-card code { overflow-wrap: anywhere; color: var(--muted); font-size: .68rem; }
.standing-review-back { justify-self: stretch; margin-top: .5rem; }
@media (max-width: 600px) { .debug-start-menu { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .standing-review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.record-book { position: relative; width: min(760px, 88vw); max-height: min(68vh, 610px); overflow: hidden auto; margin: 8vh auto 0; padding: clamp(1.2rem, 3vw, 2.3rem); color: #273126; background: linear-gradient(90deg, #eee4c9 0 49.6%, #cfc3a6 50%, #f3ead3 50.4% 100%); border: 10px solid #314437; border-radius: 5px 14px 14px 5px; box-shadow: 0 24px 70px rgba(0,0,0,.62), inset 0 0 45px rgba(87,67,35,.14); font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; }
.record-book::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, transparent 0 31px, rgba(72,91,73,.11) 32px); mix-blend-mode: multiply; }
.record-book > * { position: relative; }
.record-book header { padding-bottom: 1rem; border-bottom: 2px solid rgba(47,72,53,.35); text-align: center; }
.record-book header small { color: #667064; letter-spacing: .18em; }
.record-book h3 { margin: .35rem 0 .2rem; color: #21352a; font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: .12em; }
.record-book header p { margin: 0; color: #596259; font-size: .85rem; }
.record-book-pages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 2rem; padding: 1.2rem .4rem; }
.record-book-pages section { opacity: 0; transform: translateY(8px); animation: record-line-in .45s ease forwards; animation-delay: calc(var(--record-index) * .13s); }
.record-book-pages strong { display: block; margin-bottom: .25rem; color: #386047; font-size: .76rem; letter-spacing: .14em; }
.record-book-pages p { margin: 0; line-height: 1.75; }
.record-book footer { padding-top: .75rem; border-top: 1px solid rgba(47,72,53,.32); color: #657065; font-size: .78rem; text-align: right; }
.record-book.is-letter { border-color: #513a32; background-color: #f2e4cf; }
.record-book.is-closed { filter: saturate(.55); }
.record-book.is-closed h3, .record-book.is-closed .record-book-pages strong { color: #4d5350; }
@keyframes record-line-in { to { opacity: 1; transform: translateY(0); } }
@media (max-width: 600px) {
  .record-book {
    box-sizing: border-box;
    width: min(92vw, 760px);
    max-height: 100%;
    margin: 0 auto;
    padding: .65rem .72rem;
    border-width: 5px;
  }
  .record-book header { padding-bottom: .42rem; }
  .record-book header small { font-size: .58rem; letter-spacing: .1em; }
  .record-book h3 { margin: .18rem 0 .08rem; font-size: 1.18rem; letter-spacing: .08em; }
  .record-book header p { font-size: .68rem; }
  .record-book-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .48rem .7rem; padding: .58rem .1rem; }
  .record-book-pages strong { margin-bottom: .12rem; font-size: .58rem; letter-spacing: .08em; }
  .record-book-pages p { font-size: .72rem; line-height: 1.45; }
  .record-book footer { padding-top: .42rem; font-size: .6rem; line-height: 1.4; }
}

@keyframes drift { to { background-position: 75px 40px, 128px 97px; } }
@keyframes meteor { 0%, 78% { opacity: 0; transform: translate(-20vw,-10vh) rotate(-18deg); } 82% { opacity: 1; } 100% { opacity: 0; transform: translate(25vw,20vh) rotate(-18deg); } }
@keyframes blink { 50% { opacity: .25; transform: translateY(2px) rotate(45deg); } }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: .95; } 100% { opacity: 0; } }
@keyframes whiteout { 0% { opacity: 0; } 62% { opacity: .92; } 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes chapter { 0% { opacity: 0; } 22%, 72% { opacity: 1; } 100% { opacity: 0; } }
@keyframes four-starfall {
  0%, 10% { opacity: 0; transform: translateY(-14%); }
  24% { opacity: .95; }
  76% { opacity: .95; }
  100% { opacity: 0; transform: translateY(14%); }
}

@media (max-width: 700px) {
  .app { min-height: 480px; }
  .game-toolbar { left: .35rem; right: .35rem; width: auto; justify-content: flex-end; margin: max(.35rem, env(safe-area-inset-top)) 0 0; padding: .22rem; }
  .game-toolbar button { padding: .36rem .45rem; font-size: .59rem; }
  /* REC／STANDBYはツールバー左側の空きへ収め、立ち絵の顔から離す。 */
  .camera-status { z-index: 11; top: max(.62rem, env(safe-area-inset-top)); left: .72rem; right: auto; gap: 5px; padding: .36rem .48rem; border-radius: 3px; }
  .camera-status span { width: 7px; height: 7px; }
  .camera-status strong { font-size: .57rem; letter-spacing: .08em; }
  /* 選択肢表示中は判断に不要な撮影状態を隠し、選択肢へ重ねない。 */
  .choice-panel.is-visible ~ .camera-status { opacity: 0; transform: translateY(-5px); }
  /* 端末自体に状態表示があるため、スマホではREC等のバッジを一時退避する。 */
  .game-screen.has-terminal .camera-status { opacity: 0; transform: translateY(-5px); }
  .message-box { bottom: max(.8rem, env(safe-area-inset-bottom)); width: 95vw; min-height: 36dvh; max-height: 46dvh; padding: 2rem 1.25rem 1.2rem; }
  .message { font-size: .98rem; line-height: 1.8; }
  .speaker { left: 1rem; min-width: 115px; }
  .message-box::before { inset: 5px; }
  /* 下端をメッセージ枠の奥へ入れ、半身立ち絵の裁ち落としを見せない。 */
  .standing-sprite { right: -7vw; bottom: 18dvh; height: 66dvh; max-width: 92vw; }
  .standing-sprite[data-character="コデにゃん"] { right: -4vw; }
  .standing-sprite[data-character="クロ"] { right: -2vw; }
  .game-screen[data-scene-effect="if-mimic"] .backdrop::before { background-position: 8% 39%; background-size: auto 58%; opacity: .72; }
  .event-cg { object-position: center; }
  .event-cg[data-scene="kuro"] { object-position: 58% center; }
  .event-cg[data-scene="code"] { object-position: 62% center; }
  .event-cg[data-scene="gemini"] { object-position: 65% center; }
  .event-cg[data-scene="if-hostile-observatory"] { object-position: center top; }
  .event-cg[data-scene="if-four-line-disconnect"] { object-fit: contain; object-position: center 12%; background: #020712; }
  .event-cg[data-scene="if-observatory-shutdown"] { object-position: center top; }
  .event-cg[data-scene="if-manual-terminal"] { inset: max(8dvh, 3.5rem) 5% auto; width: 90%; height: 48dvh; object-fit: contain; object-position: center top; }
  .event-cg[data-scene="if-manual-terminal"][data-variant="disassembled"] { inset: max(9dvh, 4rem) 1% auto; width: 98%; height: 43dvh; }
  /* CG-J01は顔が右寄り。中央cropだとスマホ縦画面で顔が切れる。 */
  .event-cg[data-scene="jemi-rain-shelter"] { object-position: 67% center; }
  .event-cg[data-scene="true-green-completion"] { object-position: 67% center; }
  .event-cg[data-scene="true-blue-completion"] { object-position: 72% center; }
  .event-cg[data-scene="true-silver-completion"] { object-position: 38% center; }
  .event-cg[data-scene="true-orange-completion"] { object-position: 78% center; }
  .event-cg[data-scene="romance-kuro-greenhouse"] { object-position: 65% center; }
  .event-cg[data-scene="romance-kuro-close"] { object-position: 72% center; }
  .event-cg[data-scene="romance-jemi-napkin"] { object-position: 68% center; }
  .event-cg[data-scene="romance-jemi-arm-link"] { object-position: 55% center; }
  .event-cg[data-scene="romance-chappy-bus-stop-hug"] { object-position: 62% center; }
  .event-cg[data-scene="true-ending-group"] { inset: 8dvh auto auto -15%; width: 130%; height: auto; object-fit: contain; object-position: center top; filter: drop-shadow(0 12px 24px rgba(0,0,0,.4)); }
  .event-cg[data-scene="extra-final-photo"] { inset: max(7dvh, 3.5rem) 0 auto; width: 100%; height: 52dvh; object-fit: contain; object-position: center top; background: rgba(3,8,18,.82); filter: drop-shadow(0 12px 24px rgba(0,0,0,.42)); }
  .event-cg[data-scene="sixth-observer"] { inset: auto 1% 24dvh auto; width: 34vw; height: 56dvh; object-fit: contain; object-position: right bottom; }
  .event-cg[data-scene="future-footage"],
  .event-cg[data-scene="route-choice"] {
    top: 7.5dvh;
    bottom: auto;
    height: 40dvh;
    object-fit: contain;
    object-position: center top;
  }
  .backdrop[data-cg-scene="starfall"] { background: #07101f url("assets/images/event-cg/05_first_starfall_v1.webp") center / cover no-repeat; filter: blur(9px) brightness(.58); transform: scale(1.04); }
  .backdrop[data-cg-scene="starfall"]::before { display: none; }
  .event-cg[data-scene="starfall"] { top: 10dvh; bottom: auto; width: 100%; height: auto; object-fit: contain; object-position: center top; filter: drop-shadow(0 10px 22px rgba(0,0,0,.48)); -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 7%, #000 91%, transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 7%, #000 91%, transparent 100%); }
  .chapter-card { padding: 0 1rem 22dvh; font-size: clamp(1.15rem, 5.5vw, 1.7rem); line-height: 1.7; letter-spacing: .1em; text-align: center; }
  .chapter-card .chapter-number, .chapter-card .chapter-title { display: block; }
  .chapter-card .chapter-number { margin-right: 0; margin-bottom: .15em; }
  .choice-panel { padding-bottom: 42dvh; }
  .choice-panel button { font-size: .9rem; padding: .8rem 1rem .8rem 3.35rem; }
  .choice-panel button::before { left: .9rem; min-width: 1.55rem; padding-right: .3rem; }
  .title-screen { background-position: 61% center; }
  .title-copy { width: min(92vw, 620px); margin: 0; padding: .25rem .5rem; }
  .title-logo { filter: drop-shadow(0 5px 16px #000); }
  .trial-label { margin: .35rem 0 0; padding: .2rem 1rem; font-size: .78rem; }
  .title-menu { width: min(78vw, 330px); gap: .35rem; margin-top: 1rem; }
  .title-menu button { padding: .55rem 1rem; }
  .title-note { bottom: max(4px, env(safe-area-inset-bottom)); margin: 0; font-size: .6rem; }
  .save-slot { grid-template-columns: 56px 1fr; }
  .save-slot button { grid-column: 1 / -1; }
}

@media (max-width: 700px) and (max-height: 700px) {
  .title-screen {
    justify-content: center;
    padding: max(.65rem, env(safe-area-inset-top)) 0 max(.65rem, env(safe-area-inset-bottom));
  }
  .title-copy { width: min(86vw, 520px); }
  .title-logo { max-height: 23dvh; object-fit: contain; }
  .trial-label { font-size: .7rem; letter-spacing: .25em; }
  .title-menu { gap: .25rem; margin-top: .65rem; }
  .title-menu button { padding-block: .43rem; }
  .title-note { display: none; }
}

/* 横長の星降りCGは、縦向きタブレットで cover のままだと左右が大きく欠ける。
   スマホと同じくCG全体を見せ、背面には同じ絵をぼかして敷く。 */
@media (orientation: portrait) and (min-width: 701px) {
  .event-cg[data-scene="extra-final-photo"] { inset: max(7dvh, 3.5rem) 0 auto; width: 100%; height: 52dvh; object-fit: contain; object-position: center top; background: rgba(3,8,18,.82); filter: drop-shadow(0 12px 24px rgba(0,0,0,.42)); }
  .event-cg[data-scene="future-footage"],
  .event-cg[data-scene="route-choice"] {
    top: 7.5dvh;
    bottom: auto;
    height: 40dvh;
    object-fit: contain;
    object-position: center top;
  }
  .backdrop[data-cg-scene="starfall"] { background: #07101f url("assets/images/event-cg/05_first_starfall_v1.webp") center / cover no-repeat; filter: blur(9px) brightness(.58); transform: scale(1.04); }
  .backdrop[data-cg-scene="starfall"]::before { display: none; }
  .event-cg[data-scene="starfall"] { top: 8dvh; bottom: auto; width: 100%; height: auto; object-fit: contain; object-position: center top; filter: drop-shadow(0 10px 22px rgba(0,0,0,.48)); -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 7%, #000 91%, transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 7%, #000 91%, transparent 100%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
