/* リセットと基本設定 */
:root {
    --vh: 1vh;
    /* 薄暗い倉庫：真っ黒より一段明るく、病んだ黄緑の蛍光灯色 */
    --bg-deep: #14161a;
    --bg-mid: #1c1f24;
    --bg-panel: #242830;
    --tint-sick: rgba(180, 200, 120, 0.06);
    --tint-amber: rgba(210, 160, 60, 0.08);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}

::selection {
    background: transparent;
    color: inherit;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    position: fixed;
}

body {
    font-family: 'Avenir Next Condensed', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    background: var(--bg-deep);
    color: #e8ebe6;
    width: 100vw;
    height: calc(var(--vh) * 100);
    height: -webkit-fill-available;
}

/* スクリーン管理（iOS safe-area対応） */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(var(--vh) * 100);
    display: none;
    z-index: 10;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* スタート画面 */
#startScreen {
    background: #0c1011;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

#startScreen::before {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg, rgba(0,0,0,.7), transparent 24%, transparent 76%, rgba(0,0,0,.76));
    pointer-events: none;
    z-index: 2;
}

.start-content {
    position: relative;
    z-index: 5;
    text-align: center;
    width: min(88vw, 560px);
    padding: max(36px, env(safe-area-inset-top)) 14px max(32px, env(safe-area-inset-bottom));
    animation: titleReveal 1.15s cubic-bezier(.2,.8,.2,1) both;
}

.title-glow {
    margin: 14px 0 0;
    color: #e8e7df;
    line-height: .9;
    text-shadow: 0 3px 0 #111, 0 12px 30px #000;
    transform: skewY(-2deg);
}

.title-small { display: block; font-size: clamp(23px, 6.7vw, 38px); font-weight: 800; letter-spacing: .2em; margin-left: .2em; }
.title-main { display: block; font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif; font-size: clamp(76px, 23vw, 132px); font-weight: 900; letter-spacing: .12em; margin-right: -.12em; color: #f2eee2; }
.title-main::first-letter { color: #d99b31; }
.title-en { margin-top: 17px; color: #c89b4b; font-size: 10px; font-weight: 800; letter-spacing: .36em; }
.case-number { color: #89908c; font-size: 10px; font-weight: 700; letter-spacing: .22em; }
.case-number b { color: #d49a36; font-size: 13px; }
.case-number span { opacity: .55; }
.title-rule { display: flex; align-items: center; gap: 8px; width: 72%; margin: 14px auto 16px; height: 5px; border-top: 1px solid rgba(221,204,166,.4); border-bottom: 1px solid rgba(221,204,166,.16); }
.title-rule span { width: 34%; height: 3px; margin: -1px auto 0; background: #bc8125; box-shadow: 0 0 16px rgba(213,147,42,.6); }

.warehouse-title-scene { position: absolute; inset: 0; z-index: 0; overflow: hidden; perspective: 450px; background: linear-gradient(#111719 0 56%, #080b0c 56%); }
.back-wall { position: absolute; left: 9%; right: 9%; top: 13%; height: 54%; background: linear-gradient(90deg, #121718, #293033 48%, #121718); border: 4px solid #080a0b; box-shadow: inset 0 0 90px #050606, 0 0 80px #000; }
.shutter-lines { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 12px, rgba(0,0,0,.55) 13px 15px, rgba(255,255,255,.035) 16px 17px); }
.door-seam { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: #070909; box-shadow: 0 0 15px #000; }
.warning-stripe { position: absolute; z-index: 2; left: 0; right: 0; bottom: 11%; height: 13px; opacity: .65; background: repeating-linear-gradient(135deg, #c88d25 0 14px, #17191a 14px 28px); }
.exit-sign { position: absolute; right: 7%; top: 9%; padding: 5px 9px; border: 1px solid rgba(210,153,53,.5); color: #d6a145; background: #14140f; font: 700 8px/1 monospace; letter-spacing: .16em; transform: rotate(1deg); }
.ceiling-beam { position: absolute; top: -8%; width: 17px; height: 61%; background: #090c0d; box-shadow: 0 0 0 2px #191e1f, 15px 0 35px #000; transform-origin: top; z-index: 1; }
.beam-left { left: 7%; transform: rotate(-27deg); } .beam-right { right: 7%; transform: rotate(27deg); }
.hanging-cable { position: absolute; z-index: 2; left: 50%; top: -2%; width: 2px; height: 19%; background: #030404; }
.warehouse-lamp { position: absolute; z-index: 3; left: calc(50% - 35px); top: 15%; width: 70px; height: 19px; background: #171b1a; border-radius: 50% 50% 12% 12%; box-shadow: 0 5px 10px #000; }
.warehouse-lamp span { position: absolute; left: 16px; right: 16px; bottom: -3px; height: 7px; border-radius: 50%; background: #e3bd72; box-shadow: 0 0 16px #d89a35, 0 0 45px rgba(216,154,53,.6); animation: lampFlicker 5s infinite; }
.light-cone { position: absolute; z-index: 1; left: 16%; right: 16%; top: 16%; height: 66%; background: linear-gradient(180deg, rgba(219,176,94,.16), rgba(188,141,57,.035) 70%, transparent); clip-path: polygon(45% 0,55% 0,100% 100%,0 100%); filter: blur(7px); animation: lampFlicker 5s infinite; }
.floor-grid { position: absolute; left: -30%; right: -30%; bottom: -10%; height: 48%; transform: rotateX(63deg); transform-origin: bottom; background: repeating-linear-gradient(90deg, transparent 0 44px, rgba(154,133,93,.11) 45px 47px), repeating-linear-gradient(0deg, transparent 0 39px, rgba(154,133,93,.1) 40px 42px); }
.crate { position: absolute; z-index: 2; bottom: 7%; width: 29%; max-width: 155px; aspect-ratio: 1.15; background: linear-gradient(135deg,#2a2118,#110e0b); border: 5px solid #33271b; box-shadow: inset 0 0 0 2px #100d0a, 0 18px 30px #000; opacity: .78; }
.crate::before,.crate::after { content:""; position:absolute; left:8%; right:8%; top:47%; height:8px; background:#453321; transform:rotate(32deg); box-shadow:0 2px 3px #000; }.crate::after { transform:rotate(-32deg); }
.crate-left { left:-6%; transform:rotate(-5deg); }.crate-right { right:-9%; bottom:13%; transform:rotate(7deg) scale(.8); }
.screen-grain { position:absolute; inset:-50%; z-index:6; pointer-events:none; opacity:.07; background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E"); animation: grain .25s steps(2) infinite; }
.start-vignette { position:absolute; inset:0; z-index:4; pointer-events:none; background:radial-gradient(ellipse at 50% 44%, transparent 18%, rgba(0,0,0,.25) 55%, #020303 100%); }
.dust { position:absolute; z-index:2; width:3px; height:3px; border-radius:50%; background:#e6c78e; box-shadow:0 0 6px #e6c78e; animation:dustFloat 7s linear infinite; }.dust-a{left:34%;top:35%}.dust-b{left:61%;top:29%;animation-delay:-2s}.dust-c{left:47%;top:55%;animation-delay:-4s}

.story-text {
    font-size: clamp(12px, 3.5vw, 15px); line-height: 1.9; letter-spacing: .08em; margin: 0 0 22px; color: #b9bbb6; text-shadow: 0 2px 5px #000;
}

.story-text b { color: #d6a34d; font-weight: 800; }

.btn-start,
.btn-retry,
.btn-restart,
.choice-btn,
.sound-toggle {
    min-height: 56px;
    cursor: pointer;
    transition: transform 0.08s ease, opacity 0.08s ease, filter 0.08s ease, background 0.08s ease, border-color 0.08s ease;
    will-change: transform;
    touch-action: manipulation;
}

.btn-start {
    position:relative; display:inline-flex; align-items:center; justify-content:center; gap:14px; min-width:min(76vw,320px); padding:16px 34px; font-size:15px; font-weight:800; letter-spacing:.22em; background:rgba(10,12,12,.88); color:#f1e9d7; border:1px solid #b67d25; border-radius:0; box-shadow:inset 0 0 0 3px #0c0e0e, inset 0 0 0 4px rgba(182,125,37,.3), 0 9px 30px #000; overflow:hidden;
}
.btn-start::before { content:""; position:absolute; inset:0; transform:translateX(-105%); background:linear-gradient(100deg,transparent,rgba(213,159,62,.24),transparent); animation:buttonSweep 3.2s 1.2s infinite; }
.button-mark { color:#d89c36; font-size:11px; }

.btn-start:hover {
    transform: translateY(-2px); filter:brightness(1.2); box-shadow:inset 0 0 0 3px #0c0e0e, inset 0 0 0 4px rgba(224,167,66,.6), 0 12px 35px #000;
}

.btn-start:active,
.btn-start.is-pressed,
.btn-retry:active,
.btn-retry.is-pressed,
.btn-restart:active,
.btn-restart.is-pressed,
.choice-btn:active,
.choice-btn.is-pressed,
.sound-toggle:active,
.sound-toggle.is-pressed {
    transform: scale(0.92);
    opacity: 0.88;
}

.start-footer { margin-top:18px; display:flex; align-items:center; justify-content:center; gap:9px; color:#646a67; font:700 8px/1 monospace; letter-spacing:.09em; }
.pulse-dot { width:4px; height:4px; border-radius:50%; background:#c98d2c; box-shadow:0 0 8px #c98d2c; animation:pulseDot 1.4s infinite; }

@keyframes titleReveal { from{opacity:0;transform:translateY(18px) scale(.98);filter:blur(8px)} to{opacity:1;transform:none;filter:none} }
@keyframes lampFlicker { 0%,18%,22%,24%,70%,100%{opacity:1} 20%,23%,72%{opacity:.45} }
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(2%,-1%)} 50%{transform:translate(-1%,2%)} 75%{transform:translate(1%,1%)} }
@keyframes dustFloat { from{transform:translateY(40px);opacity:0} 20%{opacity:.7} to{transform:translate(28px,-190px);opacity:0} }
@keyframes buttonSweep { 0%,50%{transform:translateX(-105%)} 75%,100%{transform:translateX(105%)} }
@keyframes pulseDot { 50%{opacity:.25;transform:scale(.7)} }

@media (max-height: 700px) {
    .start-content { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
    .case-number { font-size: 8px; }
    .title-glow { margin-top: 8px; }
    .title-small { font-size: clamp(18px, 5.4vw, 28px); }
    .title-main { font-size: clamp(58px, 18vw, 94px); }
    .title-en { margin-top: 10px; }
    .title-rule { margin-top: 9px; margin-bottom: 10px; }
    .story-text { line-height: 1.65; margin-bottom: 13px; }
    .btn-start { min-height: 50px; padding-top: 12px; padding-bottom: 12px; }
    .start-footer { margin-top: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    .start-content, .warehouse-lamp span, .light-cone, .screen-grain, .dust, .btn-start::before, .pulse-dot,
    .scene-light-flicker, .scene-dust, .scene-drip, .scene-shadow-breathe,
    .hero-back, .hero-flashlight, .hero-light-beam, .poison-burger, .escape-timer.critical { animation: none !important; }
    .effect-layer.ceiling-trap { animation: none !important; }
    .effect-layer.ceiling-trap::before { animation: none !important; top: 31%; transform: translateX(-50%) scale(1.1); }
    .effect-layer.ceiling-trap::after { animation: none !important; opacity: 1; }
    .effect-layer.transmission, .effect-layer.transmission::after { animation: none !important; }
}

/* ゲーム画面 */
#gameScreen {
    background: #111517;
}

.game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ステータスバー */
.status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, transparent 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

/* 5分脱出カウントダウン */
.escape-timer {
    position: absolute;
    z-index: 170;
    top: calc(66px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    min-width: 146px;
    padding: 6px 18px 8px;
    text-align: center;
    color: #d3a34f;
    background: rgba(6,8,8,.9);
    border: 1px solid #87672f;
    box-shadow: inset 0 0 0 3px #111515, 0 8px 24px rgba(0,0,0,.65), 0 0 22px rgba(197,137,42,.12);
    pointer-events: none;
}

.escape-timer > span {
    display: block;
    margin-bottom: 2px;
    color: #81745d;
    font: 700 7px/1 monospace;
    letter-spacing: .22em;
}

.escape-timer strong {
    display: block;
    font: 800 clamp(2rem, 10vw, 3.25rem)/.95 'Avenir Next Condensed', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: .08em;
    text-shadow: 0 0 16px rgba(213,156,56,.48);
}

.escape-timer.warning {
    color: #df6b3e;
    border-color: #a04c2d;
    box-shadow: inset 0 0 0 3px #160e0c, 0 0 25px rgba(201,67,29,.28);
}

.escape-timer.critical {
    color: #f04a37;
    border-color: #c43b2c;
    animation: timerCritical .55s steps(2) infinite;
}

@keyframes timerCritical {
    50% { opacity: .45; filter: brightness(1.5); }
}

.progress-info {
    font-size: 1.1em;
    font-weight: bold;
}

.stage-label {
    color: #ffd700;
    text-shadow: 0 2px 5px rgba(255, 215, 0, 0.5);
}

.life-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.life-label {
    font-size: 0.9em;
    color: #ddd;
}

.hearts {
    display: flex;
    gap: 5px;
}

.heart {
    font-size: 1.3em;
    transition: all 0.3s;
}

.heart.lost {
    filter: grayscale(100%);
    opacity: 0.3;
    transform: scale(0.8);
}

.heart {
    filter: saturate(0.6) brightness(0.85);
}

/* アイテムバッジ */
.status-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.item-badges {
    display: flex;
    gap: 4px;
    padding: 0;
    border: 0;
    color: inherit;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
}

.item-badge {
    font-size: clamp(.78rem, 3.5vw, 1.05rem);
    filter: grayscale(100%) brightness(0.4);
    opacity: 0.35;
    transition: all 0.4s ease;
}

.item-badge.acquired {
    filter: none;
    opacity: 1;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

/* 所持品パネル */
.inventory-panel { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: flex-end; justify-content: center; }
.inventory-panel[hidden] { display: none; }
.inventory-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(0,0,0,.74); opacity: 0; transition: opacity .18s ease; }
.inventory-sheet { position: relative; width: min(100%, 520px); padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(160deg,#171c1d,#080b0b); border-top: 1px solid #a37835; box-shadow: 0 -16px 45px #000; transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.inventory-panel.open .inventory-backdrop { opacity: 1; }
.inventory-panel.open .inventory-sheet { transform: translateY(0); }
.inventory-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.inventory-kicker { color: #876c3b; font: 700 7px/1 monospace; letter-spacing: .18em; }
.inventory-header h2 { margin-top: 5px; color: #e2d8c4; font: 800 1.25rem/1 'Yu Gothic',sans-serif; letter-spacing: .16em; }
.inventory-close { width: 44px; height: 44px; border: 1px solid #655537; border-radius: 1px; color: #d8bb82; background: #111515; font-size: 24px; touch-action: manipulation; }
.inventory-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inventory-item { min-width: 0; display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; padding: 10px; background: #0d1011; border: 1px solid #292e2d; border-left: 3px solid #343633; opacity: .48; filter: grayscale(1); }
.inventory-item > span { grid-row: 1 / 3; font-size: 1.4rem; text-align: center; }
.inventory-item div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.inventory-item b { color: #bdbdb5; font-size: .78rem; white-space: nowrap; }
.inventory-item small { color: #777c78; font-size: .6rem; line-height: 1.3; }
.inventory-item em { grid-column: 2; color: #747873; font: normal 700 7px/1 monospace; letter-spacing: .12em; }
.inventory-item.acquired { opacity: 1; filter: none; border-color: #4d493b; border-left-color: #b28135; background: linear-gradient(145deg,#1e2322,#111515); }
.inventory-item.acquired em { color: #c89542; }
.inventory-hint { margin-top: 13px; color: #78766e; text-align: center; font-size: .68rem; letter-spacing: .08em; }

@media (max-width: 370px) {
    .inventory-grid { grid-template-columns: 1fr; max-height: 58vh; overflow-y: auto; }
}

/* 気配インジケーター */
.presence-indicator {
    position: absolute;
    top: 10px;
    right: 16px;
    display: flex;
    gap: 5px;
    z-index: 50;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.5);
    transition: all 0.4s ease;
}

.presence-dot.lit {
    background: #b71c1c;
    box-shadow: 0 0 10px rgba(183, 28, 28, 0.9);
}

/* 部屋の背景（近距離の箱型ルーム） */
.warehouse-bg {
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    height: 42%;
    background:
        radial-gradient(ellipse at 50% 35%, var(--tint-amber), transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(0, 0, 0, 0.35), transparent 60%),
        #22272a;
    border-bottom: 2px solid #3a3f46;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scene-container {
    width: 100%;
    height: 100%;
}

.scene-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

.scene-light-flicker { animation: sceneCinematicFlicker 5.2s steps(1) infinite; }
.scene-dust { animation: sceneDustDrift 8s ease-in-out infinite alternate; transform-origin: center; }
.scene-drip { animation: sceneDrip 2.8s ease-in infinite; }
.scene-shadow-breathe { animation: shadowBreath 2.8s ease-in-out infinite; transform-origin: center bottom; }
.hero-back { animation: heroBreathing 3.4s ease-in-out infinite; transform-origin: 190px 300px; }
.hero-flashlight { animation: heroHandSway 4.2s ease-in-out infinite; transform-origin: 225px 251px; }
.hero-light-beam { animation: flashlightGlow 2.8s ease-in-out infinite; }

@keyframes sceneCinematicFlicker {
    0%, 18%, 22%, 25%, 69%, 73%, 100% { opacity: .92; }
    20%, 23%, 71% { opacity: .28; }
}

@keyframes sceneDustDrift {
    from { transform: translate(0, 5px); opacity: .2; }
    to { transform: translate(8px, -8px); opacity: .48; }
}

@keyframes sceneDrip {
    from { transform: translateY(0); opacity: 0; }
    20% { opacity: .6; }
    to { transform: translateY(80px); opacity: 0; }
}

@keyframes heroBreathing {
    0%, 100% { transform: translateY(0) scaleX(1); }
    50% { transform: translateY(1px) scaleX(1.008); }
}

@keyframes heroHandSway {
    0%, 100% { transform: rotate(-1deg); }
    50% { transform: rotate(1.5deg); }
}

.bulb-flicker {
    animation: bulbFlickerWeak 2.6s ease-in-out infinite;
}

.bulb-amber {
    animation: bulbFlickerAmber 1.4s ease-in-out infinite;
}

.flashlight-lens {
    animation: flashlightPulse 2.8s ease-in-out infinite;
}

.flashlight-glow {
    animation: flashlightGlow 2.8s ease-in-out infinite;
}

@keyframes flashlightPulse {
    0%, 100% { opacity: 0.85; }
    45% { opacity: 0.45; }
    55% { opacity: 1; }
}

@keyframes flashlightGlow {
    0%, 100% { opacity: 0.12; }
    50% { opacity: 0.22; }
}

.presence-shadow {
    animation: shadowBreath 2.4s ease-in-out infinite;
}

.noise-mote {
    animation: moteDrift 1.8s ease-in-out infinite alternate;
}

@keyframes shadowBreath {
    0%, 100% { opacity: 0.55; transform: translateY(0); }
    50% { opacity: 0.85; transform: translateY(1px); }
}

@keyframes moteDrift {
    from { opacity: 0.25; }
    to { opacity: 0.65; }
}

@keyframes bulbFlickerWeak {
    0%, 100% { opacity: 0.9; }
    38% { opacity: 0.3; }
    45% { opacity: 0.8; }
    60% { opacity: 0.35; }
    72% { opacity: 0.85; }
}

@keyframes bulbFlickerAmber {
    0%, 100% { opacity: 1; }
    20% { opacity: 0.5; }
    35% { opacity: 0.9; }
    55% { opacity: 0.4; }
    80% { opacity: 0.95; }
}

/* =========================================================
   ノベルUI：本文窓と選択肢をテイスト分離
   参考にした定石（ウェブ上のサウンドノベル／VN系）:
   1) 迷惑堂・HTMLサウンドノベル — 下部半透明テキスト帯＋上辺ライン
   2) アライコウ研究所 — メッセージ窓は主役ではなく物語を支える暗色窓
   3) kamioka（メッセージ枠研究）— ホラーは読みもの寄り・行間と行長で空気を作る
   4) Arcweave VN CSS — 選択肢は本文と別レイヤ／別形状で「操作」と明示
   5) Atrament / Narrat — 選択肢はラベル付きパネル、本文は叙事ボックス
   ========================================================= */

.quiz-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: 50%;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, transparent 0%, rgba(10, 12, 14, 0.55) 18%, var(--bg-deep) 42%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    max-height: none;
}

/* --- 本文：メッセージ窓（読む・浸る） --- */
.novel-window {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    flex: 0 0 auto;
    background: rgba(8, 10, 12, 0.72);
    border: none;
    border-radius: 0;
    box-shadow:
        inset 0 1px 0 rgba(200, 190, 150, 0.12),
        inset 0 -1px 0 rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    overflow: hidden;
}

.novel-window-bar {
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(180, 160, 90, 0.55) 20%,
        rgba(200, 180, 110, 0.85) 50%,
        rgba(180, 160, 90, 0.55) 80%,
        transparent 100%
    );
}

.novel-window-body {
    padding: 12px 14px 14px 16px;
    border-left: 3px solid rgba(160, 140, 70, 0.35);
    text-align: left;
}

.question-box {
    /* 旧クラス互換（他画面で未使用なら無害） */
    background: rgba(8, 10, 12, 0.72);
    padding: 12px 14px;
    border-radius: 0;
    border: none;
}

.question-text {
    font-size: 1.15em;
    line-height: 1.5;
    text-align: center;
    color: #fff;
}

.story-box {
    text-align: left;
}

.story-line {
    font-size: clamp(0.9rem, 3.6vw, 1.02rem);
    line-height: 1.7;
    letter-spacing: 0.06em;
    color: #d8d4c8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
    opacity: 0;
    transform: translateY(4px);
    margin-bottom: 0.35em;
    word-break: keep-all;
    line-break: strict;
    overflow-wrap: anywhere;
}

.story-line:last-child {
    margin-bottom: 0;
    color: #f2efe6;
    letter-spacing: 0.08em;
}

.story-line.line-in {
    animation: lineFadeIn 0.7s ease forwards;
}

@keyframes lineFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 選択肢：操作パネル（決める・押す） --- */
.answers-container,
.choices-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 auto;
    max-width: 800px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    align-content: stretch;
    counter-reset: novel-choice;
}

.choice-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-height: 72px;
    font-size: clamp(0.95rem, 4.5vw, 1.1rem);
    line-height: 1.4;
    letter-spacing: 0.02em;
    text-align: left;
    color: #e8ece4;
    white-space: normal;
    word-break: break-word;
    /* 倉庫パネル風：本文の半透明帯と対比 */
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 28%),
        linear-gradient(145deg, #2c333c 0%, #1a1e24 100%);
    border: 1px solid #5a6574;
    border-top-color: #7a8696;
    border-bottom-color: #2a3038;
    border-radius: 4px;
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: transform 0.08s ease, opacity 0.08s ease, filter 0.08s ease, border-color 0.08s ease, background 0.08s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.choice-btn:disabled {
    cursor: not-allowed;
    color: #777d7b;
    border-color: #343a40;
    background: linear-gradient(145deg, #20252a 0%, #15181b 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    opacity: 0.62;
    filter: grayscale(0.8);
}

.choice-btn:disabled::before {
    content: "×";
    color: #b5aca0;
    background: #3a3b39;
    border-color: #555651;
}

.choice-btn::before {
    counter-increment: novel-choice;
    content: counter(novel-choice, upper-alpha);
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55em;
    height: 1.55em;
    min-width: 28px;
    min-height: 28px;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0;
    color: #1a1610;
    background: linear-gradient(180deg, #d4c48a 0%, #9a8850 100%);
    border: 1px solid #e8d9a8;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.choice-btn:hover {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 30%),
        linear-gradient(145deg, #3a4450 0%, #242a32 100%);
    border-color: #8a9aaa;
    border-top-color: #a8b4c4;
}

.choice-btn:active,
.choice-btn.is-pressed {
    transform: scale(0.96);
    opacity: 0.9;
    filter: brightness(1.05);
    border-color: #c4b070;
}

.answer-btn {
    padding: 12px 15px;
    font-size: 0.95em;
    background: linear-gradient(135deg, #2a4a5a 0%, #1a3a4a 100%);
    color: white;
    border: 2px solid #3a5a6a;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

.answer-btn:hover {
    background: linear-gradient(135deg, #3a5a6a 0%, #2a4a5a 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(58, 90, 106, 0.4);
}

.answer-btn:active {
    transform: translateY(0);
}

.answer-btn.correct {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    border-color: #4caf50;
    animation: correct-pulse 0.5s ease;
}

.answer-btn.wrong {
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%);
    border-color: #f44336;
    animation: wrong-shake 0.5s ease;
}

.answer-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* フィードバックメッセージ */
.feedback-message {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    min-height: 30px;
    margin-top: 10px;
}

.feedback-message.correct {
    color: #4caf50;
    text-shadow: 0 0 20px rgba(76, 175, 80, 0.8);
}

.feedback-message.wrong {
    color: #f44336;
    text-shadow: 0 0 20px rgba(244, 67, 54, 0.8);
}

/* エフェクトレイヤー */
.effect-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 200;
}

.effect-layer.alarm {
    background: rgba(255, 0, 0, 0.1);
    animation: alarm-flash 0.5s ease 3;
}

.effect-layer.trap {
    background: rgba(150, 15, 9, .18);
    animation: trap-hit .42s ease 2;
}

.effect-layer.trap::after {
    content: "TRAP  /  DAMAGE -1";
    position: absolute;
    left: 50%;
    top: 36%;
    transform: translate(-50%, -50%);
    padding: 9px 14px;
    color: #f0c2b9;
    background: rgba(30, 4, 3, .9);
    border: 1px solid #a93629;
    box-shadow: inset 3px 0 #bd3b2c, 0 8px 25px #000;
    font: 800 12px/1 monospace;
    letter-spacing: .15em;
    white-space: nowrap;
}

.effect-layer.poison {
    background: rgba(82, 126, 36, .2);
    animation: poison-hit .7s ease 2;
}

.effect-layer.poison::after {
    content: "POISON  /  DAMAGE -1";
    position: absolute;
    left: 50%;
    top: 36%;
    transform: translate(-50%, -50%);
    padding: 9px 14px;
    color: #d9efb6;
    background: rgba(12, 27, 5, .92);
    border: 1px solid #6d9b38;
    box-shadow: inset 3px 0 #7eaf3f, 0 8px 25px #000;
    font: 800 12px/1 monospace;
    letter-spacing: .15em;
    white-space: nowrap;
}

/* 天井から人のようなものが落ちるジャンプスケア */
.effect-layer.ceiling-trap {
    overflow: hidden;
    background: rgba(118, 8, 5, .12);
    animation: ceilingTrapFlash .18s steps(2) 5;
}

.effect-layer.ceiling-trap::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -48%;
    width: 94px;
    height: 245px;
    transform: translateX(-50%) rotate(7deg);
    transform-origin: 50% 15%;
    background:
        radial-gradient(circle at 50% 16%, #050505 0 23px, transparent 24px),
        radial-gradient(ellipse at 50% 55%, #030303 0 38px, transparent 39px),
        linear-gradient(78deg, transparent 0 18%, #030303 19% 30%, transparent 31% 69%, #030303 70% 81%, transparent 82%);
    filter: drop-shadow(0 18px 15px #000);
    animation: humanoidDrop .72s cubic-bezier(.62,.01,.82,.45) forwards;
}

.effect-layer.ceiling-trap::after {
    content: "―― うえから来る ――";
    position: absolute;
    left: 50%;
    top: 28%;
    transform: translate(-50%, -50%);
    color: #e5d8cb;
    text-shadow: 0 2px 3px #000, 0 0 12px #a21710;
    font: 800 clamp(1rem, 5vw, 1.4rem)/1 'Yu Mincho', serif;
    letter-spacing: .14em;
    white-space: nowrap;
    opacity: 0;
    animation: scareText .9s .45s steps(2) forwards;
}

/* 正体不明の通信 */
.effect-layer.transmission {
    overflow: hidden;
    background: repeating-linear-gradient(0deg, rgba(132,164,124,.07) 0 2px, transparent 2px 7px);
    animation: transmissionGlitch .18s steps(2) 12;
}

.effect-layer.transmission::before {
    content: "UNKNOWN SIGNAL  /  CH. 014";
    position: absolute;
    left: 50%;
    top: 23%;
    transform: translateX(-50%);
    padding: 8px 13px;
    color: #afc99f;
    background: rgba(4,13,8,.88);
    border: 1px solid #59724f;
    box-shadow: 0 0 18px rgba(100,145,80,.22);
    font: 700 9px/1 monospace;
    letter-spacing: .15em;
    white-space: nowrap;
}

.effect-layer.transmission::after {
    content: "「じじ時、じじ時、おは、じじ」";
    position: absolute;
    left: 50%;
    top: 35%;
    width: min(88%, 420px);
    transform: translateX(-50%);
    padding: 16px 10px;
    color: #d7dfcd;
    text-align: center;
    background: rgba(2,8,5,.92);
    border-left: 3px solid #78936b;
    text-shadow: -2px 0 #6e261f, 2px 0 #265b4b;
    font: 800 clamp(.95rem, 4.5vw, 1.25rem)/1.5 'Yu Mincho', serif;
    letter-spacing: .1em;
    animation: transmissionText 3s steps(2) forwards;
}

@keyframes transmissionGlitch {
    0%, 100% { transform: translateX(0); opacity: .95; }
    35% { transform: translateX(-4px); opacity: .65; }
    70% { transform: translateX(3px); opacity: 1; }
}

@keyframes transmissionText {
    0% { opacity: 0; filter: blur(5px); }
    12%, 72% { opacity: 1; filter: none; }
    76% { transform: translateX(-48%); }
    82% { transform: translateX(-52%); color: #9e3d35; }
    100% { opacity: 0; transform: translateX(-50%); }
}

@keyframes humanoidDrop {
    0% { top: -48%; transform: translateX(-50%) rotate(7deg) scale(.75); }
    72% { top: 33%; transform: translateX(-50%) rotate(-5deg) scale(1.2); }
    88% { top: 29%; transform: translateX(-50%) rotate(3deg) scale(1.08); }
    100% { top: 31%; transform: translateX(-50%) rotate(0) scale(1.1); }
}

@keyframes ceilingTrapFlash {
    0%, 100% { background: rgba(118,8,5,.05); transform: translateX(0); }
    50% { background: rgba(180,18,10,.28); transform: translateX(5px); }
}

@keyframes scareText {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(1.7); }
    35%, 75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%,-50%) scale(1); }
}

.poison-burger { animation: burgerTemptation 2.4s ease-in-out infinite; transform-origin: 76px 240px; }

@keyframes poison-hit {
    0% { opacity: 0; filter: hue-rotate(0); }
    35% { opacity: 1; filter: hue-rotate(30deg); }
    100% { opacity: 0; filter: hue-rotate(-20deg); }
}

@keyframes burgerTemptation {
    0%, 100% { transform: translateY(0); filter: brightness(.9); }
    50% { transform: translateY(-1px); filter: brightness(1.15); }
}

@keyframes trap-hit {
    0% { opacity: 0; transform: translateX(0); }
    25% { opacity: 1; transform: translateX(-5px); }
    55% { transform: translateX(5px); }
    100% { opacity: 0; transform: translateX(0); }
}

.effect-layer.darkness {
    background: rgba(0, 0, 0, 0.7);
    animation: darkness-fade 2s ease;
}

/* ゲームオーバー画面（バッドエンド） */
#badEndScreen,
#gameOverScreen {
    background:
        radial-gradient(ellipse at 50% 40%, rgba(60, 20, 18, 0.55), transparent 55%),
        radial-gradient(ellipse at 50% 100%, rgba(20, 28, 18, 0.4), transparent 50%),
        #121214;
    overflow: hidden;
}

.badend-noise {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.07;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
    animation: noiseShift 0.35s steps(2) infinite;
    z-index: 1;
    mix-blend-mode: overlay;
}

.badend-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.72) 100%);
    z-index: 2;
}

.gameover-content {
    text-align: center;
    padding: 28px 22px;
    max-width: min(92vw, 360px);
    width: 100%;
    position: relative;
    z-index: 3;
}

.gameover-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15em;
    font-size: clamp(1.35rem, 6.2vw, 1.85rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #b71c1c;
    margin-bottom: 28px;
    line-height: 1.35;
    position: relative;
    word-break: keep-all;
    overflow-wrap: normal;
    /* 甘いネオンではなく、沈んだ血痕＋たまに色がずれる */
    text-shadow:
        0 0 1px rgba(0, 0, 0, 0.9),
        -1px 0 0 rgba(70, 100, 80, 0.35),
        1px 0 0 rgba(90, 20, 20, 0.45);
    animation:
        titleFlicker 4.5s ease-in-out infinite,
        titleJitter 3.2s steps(2) infinite,
        titleChroma 5.5s steps(1) infinite;
}

.gameover-title .title-line {
    display: block;
    white-space: nowrap;
}

.gameover-text {
    font-size: clamp(0.92rem, 3.8vw, 1.05rem);
    line-height: 1.85;
    margin-bottom: 32px;
    color: #c4c7be;
    text-align: left;
    letter-spacing: 0.04em;
}

.gameover-text p,
.clear-text p {
    margin-bottom: 0.85em;
    word-break: keep-all;
    line-break: strict;
    overflow-wrap: anywhere;
}

.gameover-text p:last-child,
.clear-text p:last-child {
    margin-bottom: 0;
}

.badend-line {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(0.4px);
}

.badend-line.line-reveal {
    animation: badLineIn 1.1s ease forwards;
    animation-delay: var(--delay, 0.3s);
}

.btn-retry {
    padding: 14px 28px;
    font-size: 1rem;
    letter-spacing: 0.08em;
    background: #2a1214;
    color: #d7cfc8;
    border: 1px solid #6e3030;
    border-radius: 4px;
    box-shadow: none;
    min-width: 70%;
}

.btn-retry:hover {
    background: #3a181a;
    border-color: #8a4040;
}

@keyframes titleFlicker {
    0%, 100% { opacity: 1; filter: brightness(1); }
    46% { opacity: 1; }
    48% { opacity: 0.55; filter: brightness(1.35); }
    50% { opacity: 0.9; }
    72% { opacity: 1; }
    73% { opacity: 0.4; }
    74% { opacity: 1; }
}

@keyframes titleJitter {
    0%, 90%, 100% { transform: translate(0, 0); }
    91% { transform: translate(-1px, 0.5px); }
    93% { transform: translate(1px, -0.5px); }
    95% { transform: translate(0.5px, 1px); }
}

@keyframes titleChroma {
    0%, 88%, 100% {
        text-shadow:
            0 0 1px rgba(0, 0, 0, 0.9),
            -1px 0 0 rgba(70, 100, 80, 0.3),
            1px 0 0 rgba(90, 20, 20, 0.4);
    }
    89% {
        text-shadow:
            0 0 1px rgba(0, 0, 0, 0.9),
            -3px 0 0 rgba(70, 100, 80, 0.55),
            3px 0 0 rgba(120, 20, 20, 0.55);
    }
    91% {
        text-shadow:
            0 0 1px rgba(0, 0, 0, 0.9),
            2px 1px 0 rgba(70, 100, 80, 0.4),
            -2px -1px 0 rgba(90, 20, 20, 0.5);
    }
}

@keyframes badLineIn {
    0% { opacity: 0; transform: translateY(8px); filter: blur(1.5px); }
    40% { opacity: 0.55; filter: blur(0.6px); }
    100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@keyframes noiseShift {
    0% { transform: translate(0, 0); }
    50% { transform: translate(-2%, 1%); }
    100% { transform: translate(1%, -1%); }
}

.score-display {
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    font-size: 1.2em;
}

/* クリア画面 */
#clearScreen {
    background: linear-gradient(135deg, #1a3a1a 0%, #0f2f0f 100%);
    overflow: hidden;
}

.clear-content {
    text-align: center;
    padding: 30px;
    max-width: 400px;
    position: relative;
    z-index: 10;
}

.clear-title {
    font-size: 2.5em;
    color: #4caf50;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(76, 175, 80, 0.8);
    animation: clear-bounce 1s ease infinite alternate;
}

.clear-text {
    font-size: 1.1em;
    line-height: 1.8;
    margin-bottom: 30px;
    color: #fff;
}

.final-score {
    background: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 30px;
    border: 2px solid #4caf50;
}

.score-label {
    font-size: 1.3em;
    color: #ffd700;
    margin-bottom: 15px;
}

.score-value {
    font-size: 1.2em;
    line-height: 1.8;
}

.btn-restart {
    padding: 15px 40px;
    font-size: 1.2em;
    background: linear-gradient(135deg, #4caf50, #45a049);
    color: white;
    border: none;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.3);
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.5);
}

/* 紙吹雪エフェクト */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd700;
    animation: confetti-fall 3s linear infinite;
}

/* =========================================================
   WORLD TREATMENT — INDUSTRIAL WAREHOUSE NOIR
   タイトル画面の黒鉄・琥珀・警告表示を全画面へ継承
   ========================================================= */
#gameScreen {
    background: #202629;
}

.game-container::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 180;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(20,25,25,.32), transparent 12%, transparent 88%, rgba(20,25,25,.36)),
        radial-gradient(ellipse at 50% 38%, transparent 42%, rgba(24,30,29,.3) 100%);
    box-shadow: inset 0 0 0 1px #252a29;
}

.game-container::after {
    content: "CASE 014  /  INTERNAL SURVEILLANCE";
    position: absolute;
    z-index: 181;
    pointer-events: none;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    color: rgba(188, 150, 80, .42);
    font: 700 7px/1 monospace;
    letter-spacing: .22em;
    white-space: nowrap;
}

.status-bar {
    min-height: 58px;
    padding: 13px 18px;
    background:
        repeating-linear-gradient(135deg, transparent 0 7px, rgba(211,151,47,.035) 7px 9px),
        linear-gradient(180deg, rgba(7,9,9,.98), rgba(10,13,13,.94));
    border-top: 1px solid #34312a;
    border-bottom: 1px solid #6a5430;
    box-shadow: 0 8px 24px rgba(0,0,0,.65), inset 0 -1px rgba(213,155,54,.14);
}

.progress-info {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-family: 'Avenir Next Condensed', 'Yu Gothic', sans-serif;
    letter-spacing: .08em;
}

.progress-info::before {
    content: "SECTOR";
    color: #7c807c;
    font: 700 7px/1 monospace;
    letter-spacing: .18em;
    margin-right: 3px;
}

.stage-label {
    color: #d6a048;
    text-shadow: 0 0 15px rgba(210,148,46,.45);
}

.total-label { color: #777b77; }
.status-right { padding: 5px 8px; border: 1px solid rgba(134,112,71,.2); background: rgba(0,0,0,.22); }
.item-badge { filter: grayscale(1) sepia(.35) brightness(.42); }
.item-badge.acquired { filter: sepia(.25) saturate(.8); text-shadow: 0 0 9px rgba(218,165,69,.55); }
.heart { filter: grayscale(.45) sepia(.15) brightness(.78); }
.presence-dot { border-radius: 1px; width: 7px; height: 7px; background: #272b2a; }
.presence-dot.lit { background: #b72b21; box-shadow: 0 0 10px rgba(197,42,28,.95); }

.warehouse-bg {
    top: 58px;
    background: #343c3d;
    border-bottom: 1px solid #625035;
    box-shadow: inset 0 -35px 55px rgba(0,0,0,.48);
}

.warehouse-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(218,164,72,.035), transparent 25%),
        repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 1px, transparent 1px 4px);
    mix-blend-mode: screen;
}

.scene-container svg {
    filter: saturate(.68) sepia(.08) contrast(1.02) brightness(1.18);
}

.quiz-area {
    background:
        linear-gradient(180deg, rgba(32,39,39,.12), #252c2d 14%, #1c2223 100%);
    border-top: 1px solid #2b3030;
}

.novel-window {
    background: rgba(31,37,37,.94);
    border: 1px solid #4a5351;
    box-shadow: inset 0 0 30px rgba(0,0,0,.55), 0 7px 22px rgba(0,0,0,.4);
}

.novel-window::before {
    content: "FIELD LOG";
    position: absolute;
    right: 12px;
    top: 8px;
    color: rgba(185,145,75,.35);
    font: 700 7px/1 monospace;
    letter-spacing: .2em;
}

.novel-window-bar { background: linear-gradient(90deg, #7c581d, #d3a14d 45%, #604419 72%, transparent); }
.novel-window-body { border-left-color: #9b7029; }
.story-line { color: #c7c5bc; text-shadow: 0 2px 3px #000; }
.story-line:last-child { color: #e5ddcb; }

.choice-btn {
    color: #d8d7cf;
    background:
        linear-gradient(180deg, rgba(213,167,85,.05), transparent 30%),
        repeating-linear-gradient(135deg, transparent 0 9px, rgba(255,255,255,.012) 9px 10px),
        linear-gradient(145deg, #3d4545, #293031);
    border-color: #596260;
    border-top-color: #6b685c;
    border-radius: 1px;
    box-shadow: inset 3px 0 #76551e, 0 3px 0 #030404;
}

.side-oni { animation: oni-peek 3.8s ease-in-out infinite; transform-origin: 90% 70%; }
.cute-watcher { animation: watcher-breathe 2.6s ease-in-out infinite; transform-origin: center bottom; }
.watcher-eye { animation: watcher-blink 5.2s steps(1) infinite; }
@keyframes oni-peek { 0%,70%,100%{transform:translateX(5px)} 78%,92%{transform:translateX(-5px)} }
@keyframes watcher-breathe { 0%,100%{transform:scaleY(1)} 50%{transform:scaleY(1.025)} }
@keyframes watcher-blink { 0%,93%,100%{transform:scaleY(1)} 95%,97%{transform:scaleY(.08)} }

.choice-btn::after {
    content: "SELECT";
    position: absolute;
    right: 8px;
    bottom: 6px;
    color: rgba(178,146,86,.25);
    font: 700 6px/1 monospace;
    letter-spacing: .14em;
}

.choice-btn::before {
    color: #15130f;
    background: linear-gradient(180deg, #d0aa61, #846325);
    border-color: #e0bd76;
    border-radius: 1px;
}

.choice-btn:hover {
    background: linear-gradient(145deg, #303534, #1b1f1f);
    border-color: #a07b3d;
    border-top-color: #c49647;
}

.choice-btn:disabled { background: #111415; border-color: #282d2c; box-shadow: inset 3px 0 #34332e; }
.effect-layer.alarm { background: rgba(174,22,13,.15); mix-blend-mode: screen; }

.sound-toggle {
    border-radius: 2px;
    background: linear-gradient(145deg, #222a2b, #101415);
    border: 1px solid #8b6b37;
    color: #d7ae64;
    box-shadow: inset 0 0 0 3px #111516, 0 5px 16px #000;
}
.sound-toggle.muted { background: #171a1a; border-color: #454845; filter: grayscale(1); }

#badEndScreen,
#gameOverScreen {
    background:
        repeating-linear-gradient(0deg, transparent 0 4px, rgba(255,255,255,.015) 4px 5px),
        radial-gradient(ellipse at 50% 38%, rgba(107,27,19,.42), transparent 52%),
        #080909;
}
.gameover-content { border-top: 1px solid #7d2d25; border-bottom: 1px solid #37201d; background: rgba(4,5,5,.55); }
.gameover-title { font-family: 'Hiragino Mincho ProN','Yu Mincho',serif; color: #a93429; }
.btn-retry { border-radius: 1px; background: #160e0e; border-color: #784038; box-shadow: inset 3px 0 #7d2b23; }

#clearScreen {
    background:
        linear-gradient(180deg, rgba(200,143,55,.14), transparent 42%),
        radial-gradient(ellipse at 50% 15%, rgba(225,180,96,.25), transparent 48%),
        repeating-linear-gradient(90deg, transparent 0 46px, rgba(198,155,80,.025) 47px 49px),
        #090c0c;
}

#clearScreen::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -10%;
    width: 90%;
    height: 75%;
    transform: translateX(-50%);
    clip-path: polygon(42% 0,58% 0,100% 100%,0 100%);
    background: linear-gradient(180deg, rgba(238,196,119,.19), transparent);
    filter: blur(8px);
}

.clear-content { width: min(90vw, 400px); background: rgba(7,9,9,.7); border-top: 1px solid #b08442; border-bottom: 1px solid #3b3428; }
.clear-title { font-family: 'Hiragino Mincho ProN','Yu Mincho',serif; color: #e0bd78; letter-spacing: .16em; text-shadow: 0 0 25px rgba(213,160,71,.45); animation: none; }
.clear-text { color: #c9c5b8; }
.final-score { border-radius: 1px; border: 1px solid #836936; background: rgba(202,154,67,.06); }
.score-label { color: #c8953d; font: 800 1rem/1 monospace; letter-spacing: .24em; }
.btn-restart { border-radius: 1px; background: #151918; border: 1px solid #a37935; color: #e3d8c2; box-shadow: inset 3px 0 #a37935, 0 5px 18px #000; }
.btn-restart:hover { box-shadow: inset 3px 0 #c99b4e, 0 8px 24px #000; }
.confetti { width: 4px; height: 12px; background: #b78b43; opacity: .6; }

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(255, 100, 100, 0.8),
                     0 0 40px rgba(255, 100, 100, 0.4);
    }
    50% {
        text-shadow: 0 0 30px rgba(255, 100, 100, 1),
                     0 0 60px rgba(255, 100, 100, 0.6);
    }
}

@keyframes light-pulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.2);
    }
}

@keyframes correct-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes wrong-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

@keyframes alarm-flash {
    0%, 100% {
        background: rgba(255, 0, 0, 0);
    }
    50% {
        background: rgba(255, 0, 0, 0.2);
    }
}

@keyframes darkness-fade {
    0% {
        background: rgba(0, 0, 0, 0);
    }
    50% {
        background: rgba(0, 0, 0, 0.7);
    }
    100% {
        background: rgba(0, 0, 0, 0);
    }
}

@keyframes clear-bounce {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    .title-glow {
        font-size: 2em;
    }
    
    .story-text {
        font-size: 1em;
    }
    
    .btn-start,
    .btn-retry,
    .btn-restart {
        font-size: 1.1em;
        padding: 12px 30px;
    }
    
    .question-text {
        font-size: 1.05em;
    }
    
    .answer-btn {
        font-size: 0.9em;
        padding: 10px 12px;
    }
    
    .door-container {
        width: 150px;
        height: 200px;
    }
    
    .warehouse-bg {
        height: 40%;
    }

    .quiz-area {
        height: 52%;
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 10px;
    }

    .status-bar {
        padding: 10px 15px;
    }
    
    .progress-info {
        font-size: 1em;
    }
    
    .heart {
        font-size: 1.1em;
    }
}

@media (max-width: 480px) {
    .title-glow {
        font-size: 1.8em;
    }
    
    .quiz-area {
        height: 52%;
        padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }
    
    .novel-window-body {
        padding: 10px 12px 12px 12px;
    }
    
    .story-line {
        font-size: 0.88em;
        line-height: 1.55;
        letter-spacing: 0.04em;
    }
    
    .answers-container,
    .choices-container {
        grid-template-columns: 1fr 1fr;
        gap: 7px;
    }
    
    .choice-btn {
        padding: 8px 8px 8px 8px;
        font-size: 0.8em;
        min-height: 52px;
        gap: 8px;
    }

    .choice-btn::before {
        width: 1.4em;
        height: 1.4em;
        min-width: 24px;
        min-height: 24px;
        font-size: 0.72em;
    }
    
    .door-container {
        width: 120px;
        height: 160px;
    }
}

/* 音声コントロールボタン */
.sound-toggle {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    width: 50px;
    height: 50px;
    min-height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3a4a52 0%, #2a3840 100%);
    border: 2px solid #4a5a62;
    color: white;
    font-size: 1.5em;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.sound-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 15px rgba(58, 90, 106, 0.6);
}

.sound-toggle.muted {
    background: linear-gradient(135deg, #666 0%, #444 100%);
    border-color: #555;
}

/* 音声アイコンの表示制御 */
.sound-on, .sound-off {
    position: absolute;
}

/* タッチデバイス用の調整 */
@media (hover: none) {
    .answer-btn:hover {
        background: linear-gradient(135deg, #2a4a5a 0%, #1a3a4a 100%);
        transform: none;
    }

    .choice-btn:hover {
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 28%),
            linear-gradient(145deg, #2c333c 0%, #1a1e24 100%);
        transform: none;
    }

    .btn-start:hover,
    .btn-retry:hover,
    .btn-restart:hover {
        transform: none;
    }
}

/* 横向き対応 */
@media (orientation: landscape) and (max-height: 500px) {
    .warehouse-bg {
        height: 36%;
    }
    
    .door-container {
        width: 120px;
        height: 140px;
        margin: 10px auto;
    }
    
    .quiz-area {
        height: 56%;
        padding: 6px 14px calc(8px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }
    
    .novel-window-body {
        padding: 8px 12px;
    }
    
    .answers-container,
    .choices-container {
        gap: 6px;
        grid-template-columns: 1fr 1fr;
    }
    
    .choice-btn {
        padding: 6px 8px;
        font-size: 0.78em;
        min-height: 48px;
        gap: 7px;
    }
    
    .answer-btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }
}

/* 後方互換スタイルより後に置き、iOSでも工業ノワール配色を固定 */
.sound-toggle {
    border-radius: 2px;
    background: linear-gradient(145deg, #222a2b, #101415);
    border: 1px solid #8b6b37;
    color: #d7ae64;
    box-shadow: inset 0 0 0 3px #111516, 0 5px 16px #000;
}

.sound-toggle:hover {
    box-shadow: inset 0 0 0 3px #111516, 0 6px 20px rgba(180,128,44,.25);
}

.sound-toggle.muted {
    background: #171a1a;
    border-color: #454845;
    filter: grayscale(1);
}

@media (hover: none) {
    .choice-btn:hover {
        background:
            linear-gradient(180deg, rgba(213,167,85,.05), transparent 30%),
            repeating-linear-gradient(135deg, transparent 0 9px, rgba(255,255,255,.012) 9px 10px),
            linear-gradient(145deg, #2a3031, #191d1e);
        border-color: #454c4b;
        border-top-color: #6b685c;
    }
}
