/* 二〇四 — スタイル(画像素材なし: CSSグラデーション/影/ノイズで全表現)
 * 将来画像追加時は #scene-bg に background-image が流し込まれ、CSS表現の上に重なる。
 */

:root {
  --font-scale: 1;
  --c-bg: #050507;
  --c-panel: #0d0d12;
  --c-text: #c9c4b8;
  --c-dim: #6e6a60;
  --c-accent: #8a9b6e;     /* 非常灯の緑 */
  --c-danger: #9b3c30;
  --c-line: #26262e;

  /* 明度調整(PC既定。スマホは @media で上書きしてさらに明るく) */
  --bg-bright: 1.12;       /* 背景画像の明度: PCはホラーの暗さを保ちつつ +12% */
  --bg-contrast: 1.03;     /* コントラストは上げすぎない */
  --act3-bright: .99;      /* Act3背景は暗くしすぎない(色味で不穏さを出す) */
  --dark-center: .18;      /* 視点中央(ライト核)の暗幕係数: 小さいほど中央が明るい(従来0.25) */
  --dark-mid: .90;         /* 暗闇マスク中間の濃さ(小さいほど明るい) */
  --dark-edge: .95;        /* 暗闇マスク外周の濃さ(外周は不穏さを残す) */
  --light-r: 33vmax;       /* ライト半径(点灯時) */
  --light-off-r: 15vmax;   /* ライト半径(消灯時) */
  --noise-op: .10;         /* Act3ノイズ濃度 */
  --noise-op-reduced: .07; /* Act3ノイズ濃度(演出控えめ) */
  --vvh: 100dvh;           /* iOS SafariではJSがvisualViewport.heightで上書きする */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-bottom-gap: max(var(--safe-bottom), 14px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: calc(16px * var(--font-scale));
  line-height: 1.7;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
button:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
a { color: inherit; }
.site-info-link { text-decoration: none; }

/* ============ 画面切替 ============ */
.screen { display: none; height: 100vh; height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ============ タイトル ============ */
#screen-title { align-items: center; justify-content: center; position: relative; }
.title-inner { text-align: center; max-width: 640px; padding: 24px; position: relative; z-index: 2; }
.title-noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .05; z-index: 1;
  background: repeating-linear-gradient(0deg, #fff 0 1px, transparent 1px 3px);
  animation: scan 8s linear infinite;
}
.game-title { font-weight: 400; letter-spacing: .1em; }
.t-kanji {
  display: block; font-size: 4.2em; letter-spacing: .25em; padding-left: .25em;
  text-shadow: 0 0 18px rgba(138,155,110,.25), 0 0 2px rgba(255,255,255,.3);
  animation: titleFlicker 7s infinite;
}
.t-sub { display: block; font-size: .95em; color: var(--c-dim); margin-top: 8px; letter-spacing: .3em; }
.title-tagline { margin: 22px 0 30px; color: var(--c-text); }
.title-menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
#screen-title .title-menu { width: min(320px, 72vw); margin-inline: auto; }
#screen-title .title-menu .menu-btn {
  width: 100%; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  text-align: center;
}
.menu-btn {
  min-width: 220px; padding: 10px 28px;
  border: 1px solid var(--c-line); background: rgba(20,20,26,.7);
  letter-spacing: .2em; transition: border-color .3s, background .3s;
}
.menu-btn:hover { border-color: var(--c-accent); background: rgba(30,32,26,.8); }
.menu-btn.small { min-width: 0; padding: 6px 16px; letter-spacing: .1em; }
.menu-btn.danger { border-color: #4a2520; color: #c08070; }
.content-warning { margin-top: 34px; font-size: .8em; color: var(--c-dim); }
.title-endings { margin-top: 10px; font-size: .8em; color: var(--c-accent); min-height: 1.4em; }

@keyframes titleFlicker {
  0%, 91%, 94%, 100% { opacity: 1; }
  92%, 93% { opacity: .55; }
}
@keyframes scan { from { background-position-y: 0; } to { background-position-y: 100px; } }
.flash-reduce .t-kanji, .reduced .t-kanji { animation: none; }
.flash-reduce .title-noise { animation: none; }

/* ============ プロローグ ============ */
#screen-prologue {
  position: relative; align-items: center; justify-content: center;
  background: #030305; cursor: pointer; overflow: hidden;
}
#prologue-bg {
  position: absolute; inset: 0; z-index: 0;
  background-color: #07070b; background-size: cover; background-position: center 42%;
  opacity: .3; filter: brightness(.72) saturate(.9);
}
#prologue-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 120% 92% at 50% 45%, rgba(3,3,5,.45) 0%, rgba(3,3,5,.84) 100%);
}
#prologue-inner { position: relative; z-index: 2; max-width: 640px; padding: 30px 26px; text-align: center; }
#prologue-text {
  font-size: 1.15em; line-height: 2; letter-spacing: .12em; color: #d9d4c8;
  min-height: 4.2em; text-shadow: 0 0 8px #000, 0 0 2px #000;
}
#prologue-text.p-in { animation: descIn 1.1s ease-out; }
#prologue-choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }
.prologue-choice.used { opacity: .4; }
#prologue-proceed { margin-top: 22px; }
.prologue-advance {
  margin-top: 26px; color: var(--c-dim); font-size: .82em; letter-spacing: .22em;
  animation: pBlink 2.2s ease-in-out infinite;
}
@keyframes pBlink { 0%,100% { opacity: .3; } 50% { opacity: .85; } }
.reduced .prologue-advance, .flash-reduce .prologue-advance { animation: none; opacity: .6; }
#prologue-skip {
  position: absolute; top: 14px; right: 16px; z-index: 3;
  color: var(--c-dim); font-size: .82em; letter-spacing: .12em;
  padding: 8px 12px; border: 1px solid var(--c-line); border-radius: 4px;
  background: rgba(10,10,14,.6); white-space: nowrap;
}
#prologue-skip:hover { border-color: var(--c-accent); color: var(--c-text); }
#screen-prologue.p-fade { opacity: 0; transition: opacity .9s ease; }
.reduced #screen-prologue.p-fade, .flash-reduce #screen-prologue.p-fade { transition: opacity .12s ease; }

/* ============ ゲーム画面レイアウト ============ */
#screen-game { width: min(100vw, 1280px); max-width: 1280px; margin-inline: auto; }
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--c-line);
  background: var(--c-panel); font-size: .9em; letter-spacing: .15em;
}
#room-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#act-indicator { color: var(--c-danger); font-size: .85em; }
#clock-display { color: var(--c-dim); font-variant-numeric: tabular-nums; }
#clock-display.saved-blink { color: var(--c-accent); }
body.act3 #clock-display { color: var(--c-danger); animation: clockJitter 3s infinite; }
@keyframes clockJitter { 0%,96%,100%{transform:none} 97%{transform:translateX(1px)} 98%{transform:translateX(-1px)} }
.shake-reduce #clock-display { animation: none !important; }

#scene-wrap {
  position: relative; flex: 1; min-height: 0;
  width: 100%; max-width: 1280px; margin-inline: auto; overflow: hidden;
  background: #020203;
}
/* シーンは16:9固定ステージ(サイズはJSが算出)。背景画像と%座標が常に一致する */
#scene {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 100%; height: 100%; max-width: 100%; max-height: 100%; aspect-ratio: 16 / 9;
  overflow: hidden; background: #030305;
  --lx: 50%; --ly: 55%; --px: 50; --py: 50;
}

/* ---- 部屋ごとのCSS背景(visualKeyで切替・画像が来たら #scene-bg / #scene-bg-act3 に流し込み) ---- */
/* 2.5D微パララックス: 背景層だけがライト位置に弱く追従(±0.6%・ゆっくり)。
   scale(1.05)+inset拡張で端は見切れない。reduce系設定では固定。 */
/* ステージと画像は共に16:9のため 100%/100% で1:1描画(ホットスポット座標と厳密一致)。
   パララックス余白は scale(1.02) の最小限に留める(拡大しすぎると座標がズレる)。 */
#scene-bg, #scene-bg-act3 {
  position: absolute; inset: 0; z-index: 0;
  background-size: 100% 100%; background-position: center;
  /* 画像そのものは加工せず、表示時のフィルタだけで明度/コントラストを底上げする */
  filter: brightness(var(--bg-bright)) contrast(var(--bg-contrast));
  transform: scale(1.02)
    translate(calc((50 - var(--px, 50)) * 0.012%), calc((50 - var(--py, 50)) * 0.009%));
  transition: transform .8s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
}
#scene-bg-act3 {
  opacity: 0;
  transition: opacity 2.8s ease, transform .8s cubic-bezier(.22, .61, .36, 1);
}
body.act3 #scene-bg-act3 { opacity: 1; }                 /* 通常→Act3差分のクロスフェード */
body.act3 #scene-bg { filter: hue-rotate(-10deg) saturate(1.15) brightness(var(--act3-bright)) contrast(var(--bg-contrast)); }
.shake-reduce #scene-bg, .shake-reduce #scene-bg-act3,
.reduced #scene-bg, .reduced #scene-bg-act3 {
  transform: none; transition: opacity 2.8s ease;  /* パララックス無効(酔い対策・1:1描画) */
}
/* 画像がある部屋: CSSグラデーションは薄いカラーグレードとして上に残す */
#scene.has-bg::before { opacity: .22; }
#scene::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
}
#scene[data-visual="room_apartment"]::before {
  background:
    linear-gradient(180deg, #14141c 0%, #1a1a20 45%, #101014 100%),
    radial-gradient(ellipse at 65% 20%, rgba(80,90,120,.12), transparent 60%);
  background-blend-mode: screen;
}
#scene[data-visual="room_corridor"]::before {
  background:
    linear-gradient(90deg, #08080c 0%, #0e0e14 30%, #0a0a10 70%, #06060a 100%),
    radial-gradient(ellipse at 8% 16%, rgba(110,160,110,.16), transparent 30%),
    linear-gradient(180deg, transparent 75%, #050507 100%);
}
#scene[data-visual="room_neighbor"]::before {
  background:
    linear-gradient(180deg, #131318 0%, #18161c 45%, #0e0d12 100%),
    radial-gradient(ellipse at 35% 20%, rgba(90,80,110,.10), transparent 60%);
}
#scene[data-visual="room_stairs"]::before {
  background:
    linear-gradient(165deg, #0a0c10 0%, #0e1116 40%, #07080c 100%),
    repeating-linear-gradient(170deg, transparent 0 46px, rgba(255,255,255,.025) 46px 48px);
}
#scene[data-visual="room_entrance"]::before {
  background:
    linear-gradient(180deg, #0b0b10 0%, #121117 50%, #0a0a0e 100%),
    radial-gradient(ellipse at 46% 45%, rgba(150,160,200,.05), transparent 45%);
}
#scene[data-visual="room_office"]::before {
  background:
    linear-gradient(180deg, #0a0d12 0%, #10131a 50%, #090b0f 100%),
    radial-gradient(ellipse at 18% 30%, rgba(90,140,190,.14), transparent 40%);
}
#scene[data-visual="room_rooftop"]::before {
  background:
    linear-gradient(180deg, #06070d 0%, #0a0b14 55%, #0d0d12 78%, #131316 100%);
}
/* Act3: 全部屋の色味が静かに腐る */
body.act3 #scene::before { filter: hue-rotate(-12deg) saturate(1.25) brightness(.92); }

/* ---- 部屋デコ層(画像がある時の追加演出) ---- */
#scene-deco { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
/* 廊下: 周辺減光で奥行きを強調し、突き当たりの非常口灯がゆっくり脈動する */
#scene.has-bg[data-visual="room_corridor"] #scene-deco {
  background:
    radial-gradient(ellipse 7% 10% at 48.5% 44%, rgba(120, 220, 150, .15), transparent 70%),
    radial-gradient(ellipse 130% 95% at 50% 48%, transparent 52%, rgba(2, 3, 2, .58) 100%);
  animation: exitPulse 7s ease-in-out infinite;
}
@keyframes exitPulse { 0%, 100% { opacity: .85; } 45% { opacity: 1; } 58% { opacity: .68; } }
.flash-reduce #scene.has-bg[data-visual="room_corridor"] #scene-deco,
.reduced #scene.has-bg[data-visual="room_corridor"] #scene-deco { animation: none; }
/* 204: 画像があるときは窓側にごく薄い夜光を足す */
#scene.has-bg[data-visual="room_apartment"] #scene-deco {
  background: radial-gradient(ellipse 22% 26% at 66% 40%, rgba(90, 110, 150, .08), transparent 75%);
}
/* 管理人室: モニター群(右)の青光がゆっくり呼吸する。監視の「稼働中」感 */
#scene.has-bg[data-visual="room_office"] #scene-deco {
  background:
    radial-gradient(ellipse 28% 34% at 82% 50%, rgba(110, 160, 200, .10), transparent 75%),
    radial-gradient(ellipse 130% 100% at 50% 50%, transparent 55%, rgba(2, 2, 3, .5) 100%);
  animation: monitorBreath 9s ease-in-out infinite;
}
@keyframes monitorBreath { 0%, 100% { opacity: .8; } 50% { opacity: 1; } }
/* 203号室: 204より一段冷えた緑被り+周辺減光。「同じ部屋の冷たい写し」 */
#scene.has-bg[data-visual="room_neighbor"] #scene-deco {
  background:
    linear-gradient(180deg, rgba(60, 90, 70, .07), rgba(40, 60, 50, .10)),
    radial-gradient(ellipse 130% 100% at 50% 48%, transparent 50%, rgba(3, 5, 4, .45) 100%);
}
/* 非常階段: 青緑の冷気+強めの周辺減光。濡れた踊り場の反射だけが浮く */
#scene.has-bg[data-visual="room_stairs"] #scene-deco {
  background:
    linear-gradient(180deg, rgba(50, 80, 90, .08), rgba(30, 50, 60, .12)),
    radial-gradient(ellipse 110% 85% at 50% 55%, transparent 42%, rgba(1, 3, 4, .62) 100%);
}
/* 屋上: 電話ボックスの灯りだけが残る孤独な減光。空は重く沈む */
#scene.has-bg[data-visual="room_rooftop"] #scene-deco {
  background:
    radial-gradient(ellipse 10% 22% at 41% 48%, rgba(190, 200, 170, .09), transparent 75%),
    linear-gradient(180deg, rgba(0, 0, 0, .25) 0%, transparent 30%),
    radial-gradient(ellipse 125% 95% at 50% 55%, transparent 48%, rgba(1, 2, 3, .55) 100%);
}
.flash-reduce #scene.has-bg[data-visual="room_office"] #scene-deco,
.reduced #scene.has-bg[data-visual="room_office"] #scene-deco { animation: none; }

/* ---- 小物オーバーレイ層(背景と同一のパララックス変形を受ける) ----
 * 背景がライト位置に追従して動くとき、小物も同じだけ動いて「貼り付いた」ままになる。 */
#props-layer {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  transform: scale(1.02)
    translate(calc((50 - var(--px, 50)) * 0.012%), calc((50 - var(--py, 50)) * 0.009%));
  transition: transform .8s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
}
.shake-reduce #props-layer, .reduced #props-layer { transform: none; transition: none; }

/* ---- 壁掛け時計オーバーレイ(204号室 / SVG描画・画像なし環境でも表示) ----
 * 左壁面に掛かって見えるよう、左端を支点に奥(右)へ倒すパースを付ける。
 * 色味は室内の緑がかった蛍光灯光に合わせて沈め、UI素材の白さ・浮き感を消す。
 * 3:04 の読み取りやすさは rotateY 26度 + 補助の傾きまでに留めて維持。 */
#clock-prop {
  position: absolute; left: 4.2%; top: 18.5%; width: 6.2%; height: 11%;
  z-index: 2; pointer-events: none;
  transform-origin: 0% 50%;
  transform: perspective(600px) rotateY(26deg) rotateZ(-2deg) skewY(-2deg);
  filter: brightness(.5) contrast(.9) sepia(.3) hue-rotate(40deg) saturate(.85)
          drop-shadow(-2px 3px 3px rgba(0, 0, 0, .5));
  opacity: .9;
}
#clock-prop svg { width: 100%; height: 100%; display: block; }
body.act3 #clock-prop {
  filter: brightness(.42) contrast(.95) sepia(.25) hue-rotate(12deg) saturate(1.1)
          drop-shadow(-2px 3px 3px rgba(0, 0, 0, .6));
}
/* Act3: 秒針だけが逆向きに動き出す(調査文「秒針が逆向きに動いている」と一致) */
body.act3 #clock-prop .clock-sec { animation: clockSecReverse 75s linear infinite; }
@keyframes clockSecReverse { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }
.reduced #clock-prop .clock-sec,
.flash-reduce #clock-prop .clock-sec,
.shake-reduce #clock-prop .clock-sec { animation: none; }

/* ---- 開発用: ?debugHotspots=1 のときだけ有効(本番では出ない) ---- */
body.debug-hotspots .hotspot {
  border-color: rgba(255, 120, 120, .8) !important;
  background: rgba(255, 120, 120, .07);
}
body.debug-hotspots .hotspot .hs-label {
  opacity: 1; background: rgba(0, 0, 0, .6); padding: 1px 4px; border-radius: 2px;
}
body.debug-hotspots.mobile-ui .hotspot .hs-label { font-size: .66em; }
body.debug-hotspots .hotspot::after {
  content: attr(data-coords);
  position: absolute; left: 2px; top: 2px;
  font-size: 10px; line-height: 1.2; letter-spacing: 0;
  color: #ffb0a0; background: rgba(0, 0, 0, .65);
  padding: 0 3px; white-space: nowrap; pointer-events: none;
}
#debug-readout {
  position: fixed; left: 8px; bottom: 8px; z-index: 99;
  background: rgba(0, 0, 0, .8); color: #9fe0b0;
  font: 12px/1.6 Consolas, monospace;
  padding: 4px 10px; border: 1px solid #333; pointer-events: none;
}

/* ---- 常設ノイズオーバーレイ(overlay_noise / 画像なし時はCSS走査線) ---- */
#noise-overlay {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  opacity: 0; transition: opacity 1.6s ease;
  background-repeat: repeat; background-size: 256px 256px;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
}
body.act3 #noise-overlay { opacity: var(--noise-op); animation: noiseJitter .5s steps(2) infinite; }
body.act3.reduced #noise-overlay { opacity: var(--noise-op-reduced); }
@keyframes noiseJitter {
  0% { background-position: 0 0; }
  50% { background-position: -7px 4px; }
  100% { background-position: 5px -6px; }
}
.flash-reduce #noise-overlay { animation: none !important; }

/* 鏡像の部屋: 構造ごと左右反転(ラベルは再反転して可読に) */
#scene.mirrored-room #hotspots { transform: scaleX(-1); }
#scene.mirrored-room .hs-label { transform: translateX(-50%) scaleX(-1); }

/* ---- ホットスポット ---- */
#hotspots { position: absolute; inset: 0; z-index: 3; }
.hotspot {
  position: absolute;
  border: 1px solid rgba(200,196,180,.0);
  border-radius: 4px;
  transition: border-color .4s, background .4s;
}
/* 通常公開表示では枠を出さない。矩形確認は body.debug-hotspots 限定。 */
.hotspot.lit { border-color: transparent; background: transparent; }
.hotspot:hover.lit, .hotspot:focus { border-color: transparent; }
.hs-label {
  position: absolute; left: 50%; bottom: -1.5em; transform: translateX(-50%);
  white-space: nowrap; font-size: .72em; letter-spacing: .15em; color: var(--c-text);
  opacity: 0; transition: opacity .4s; pointer-events: none;
  text-shadow: 0 0 6px #000, 0 0 2px #000;
}
.hotspot.lit .hs-label { opacity: 0; }

/* ---- 暗闇とライト(radial-gradientのマスク) ---- */
#darkness {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  --ambient: 0.5;
  background: radial-gradient(
    circle var(--light-r) at var(--lx) var(--ly),
    rgba(5,5,7, calc(var(--dark-center) * (1 - var(--ambient)))) 0%,
    rgba(5,5,7, calc(var(--dark-mid) - var(--ambient) * 0.85)) 60%,
    rgba(5,5,7, calc(var(--dark-edge) - var(--ambient) * 0.75)) 100%
  );
  transition: background .6s;
}
body.light-off #darkness {
  background: radial-gradient(
    circle var(--light-off-r) at var(--lx) var(--ly),
    rgba(5,5,7,.40) 0%,
    rgba(5,5,7,.95) 55%,
    rgba(5,5,7,.99) 100%
  );
}

/* ---- 視覚エフェクト層 ---- */
#fx-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
#fx-layer.fx-flicker { animation: fxFlicker .7s steps(2) both; background: rgba(220,225,200,.06); }
@keyframes fxFlicker { 0%,40%,80% {opacity: 1;} 20%,60%,100% {opacity: 0;} }
#fx-layer.fx-dim { background: rgba(0,0,0,.45); transition: background .2s; }
#fx-layer.fx-shadow {
  background: linear-gradient(100deg, transparent 30%, rgba(0,0,0,.7) 46%, rgba(0,0,0,.75) 52%, transparent 68%);
  animation: fxShadow .7s ease-in both;
}
@keyframes fxShadow { from { transform: translateX(-60%); } to { transform: translateX(80%); } }
#fx-layer.fx-smear { backdrop-filter: blur(1.5px); background: rgba(10,8,14,.2); }
#fx-layer.fx-mirror { background: rgba(200,210,230,.07); }
#fx-layer.fx-warp { animation: fxWarp 1.6s ease-in-out both; }
@keyframes fxWarp {
  0%,100% { transform: none; }
  40% { transform: perspective(600px) rotateY(1.6deg) scale(1.012); }
  70% { transform: perspective(600px) rotateY(-1.2deg) scale(1.008); }
}
#fx-layer.fx-noise {
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 1px, transparent 1px 3px);
  animation: fxNoise .12s steps(3) infinite;
}
@keyframes fxNoise { 0%{background-position-y:0} 100%{background-position-y:9px} }
#fx-layer.fx-eye {
  background:
    radial-gradient(circle 9vmax at 50% 44%, rgba(220,215,200,.16) 0%, rgba(190,185,170,.10) 35%, transparent 60%),
    radial-gradient(circle 3.2vmax at 50% 44%, rgba(8,8,10,.9) 0%, rgba(8,8,10,.55) 60%, transparent 100%),
    rgba(0,0,0,.45);
  animation: fxEye .85s ease-out both;
}
@keyframes fxEye { 0% {opacity: 0;} 12% {opacity: 1;} 80% {opacity: 1;} 100% {opacity: 0;} }
.shake-reduce #fx-layer.fx-warp { animation: none; background: rgba(0,0,0,.3); }
.flash-reduce #fx-layer.fx-flicker { animation: none; background: rgba(0,0,0,.25); }
.flash-reduce #fx-layer.fx-noise { animation: none; opacity: .4; }

/* ---- 字幕 ---- */
#subtitle {
  position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%);
  max-width: 86%; padding: 6px 18px;
  background: rgba(5,5,7,.86); border: 1px solid var(--c-line);
  font-size: .9em; letter-spacing: .1em; color: #e6e1d4;
  text-shadow: 0 0 4px #000;   /* 明るくなった背景の上でも字幕が確実に読める */
  opacity: 0; transition: opacity .5s; pointer-events: none; text-align: center;
  z-index: 6;
}
#subtitle.show { opacity: 1; }

/* スマホ用の固定HUD。PCでは使わず、パンするシーン領域にも入れない。 */
#mobile-hud-layer { display: none; }
.mobile-hud-card {
  background: rgba(5,5,7,.92); border: 1px solid var(--c-line);
  color: #e8e3d6; text-align: center;
  text-shadow: 0 0 4px #000;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.mobile-hud-title { color: #d7b0a8; font-size: .82em; letter-spacing: .16em; }
.mobile-hud-text { margin-top: 2px; font-size: .88em; line-height: 1.55; }
.mobile-hud-action {
  margin-top: 8px; min-height: 40px; padding: 6px 18px;
  border: 1px solid #4a2520; background: rgba(45,18,18,.78);
  color: #ead8d2; letter-spacing: .12em;
}
.mobile-hud-action:hover { border-color: var(--c-danger); }

/* ---- 階段操作 ---- */
#stairs-controls {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 14px; z-index: 7;
}
#stairs-controls[hidden] { display: none; } /* display:flex が hidden属性を打ち消さないように */
.stairs-btn {
  padding: 14px 22px; border: 1px solid var(--c-line);
  background: rgba(13,13,18,.85); letter-spacing: .2em;
}
.stairs-btn:hover { border-color: var(--c-accent); }

/* ============ 調査文パネル ============ */
#desc-panel {
  border-top: 1px solid var(--c-line);
  background: #111119;            /* var(--c-panel) より僅かに明るく(本文の可読性) */
  padding: 10px 18px;
  min-height: 7.5em; max-height: 26vh; overflow-y: auto;
}
#desc-title { color: var(--c-dim); font-size: .8em; letter-spacing: .25em; }
#desc-text { white-space: pre-line; color: #d3cec1; }   /* 本文のコントラストを少し上げる */
.desc-anim { animation: descIn .5s ease-out; }
@keyframes descIn { from { opacity: 0; } to { opacity: 1; } }
.mirror-text { transform: scaleX(-1); display: inline-block; }
body.act3 #desc-text { text-shadow: 0 0 1px rgba(155,60,48,.4); }

/* ============ 下部バー ============ */
#bottombar {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 10px; border-top: 1px solid var(--c-line);
  background: #0a0a0e;
}
.bar-btn {
  padding: 7px 12px; border: 1px solid var(--c-line); border-radius: 3px;
  font-size: .85em; letter-spacing: .08em; position: relative;
  background: rgba(20,20,26,.6);
}
.bar-btn:hover { border-color: var(--c-accent); }
.bar-btn.ringing { animation: ringPulse 1.2s infinite; border-color: var(--c-danger); }
@keyframes ringPulse { 0%,100% { background: rgba(20,20,26,.6); } 50% { background: rgba(80,30,26,.5); } }
.flash-reduce .bar-btn.ringing { animation: none; background: rgba(80,30,26,.5); }
.badge {
  position: absolute; top: -7px; right: -7px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--c-danger); color: #eee;
  font-size: 11px; line-height: 18px; text-align: center;
}
/* 調べるボタンはスマホ専用。メニューは説明ページへの導線も含むためPCにも表示する */
#bottombar .bar-mobile { display: none; }

/* 調べる一覧 / メニュー シート */
.explore-list, .menu-sheet { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.explore-item, .sheet-item { width: 100%; min-height: 44px; text-align: left; letter-spacing: .12em; }

/* 固定の「移動」アクションパネル(上る/下りる・振り返って戻る扉)。
   背景の横パンに追従しないよう #scene-wrap の外に置き、PCでも終盤の戻り導線として表示する。 */
#mobile-move-bar {
  display: none; width: 100%; max-width: 1280px; margin-inline: auto;
}
#mobile-move-bar.has-actions {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  padding: 10px 12px; border-top: 1px solid var(--c-line);
  background: rgba(10,10,16,.92);
}
.move-btn {
  flex: 0 1 220px; min-width: 160px; min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 12px; border: 1px solid var(--c-line); border-radius: 6px;
  background: rgba(16,16,22,.92); font-size: .86em; letter-spacing: .04em;
  white-space: nowrap;
}
.move-btn:hover { border-color: var(--c-accent); }

/* ============ モーダル ============ */
#modal-root { position: fixed; inset: 0; z-index: 50; }
#modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
#modal-root.sheet-root #modal-backdrop { background: rgba(0,0,0,.5); }
#modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, 92vw); max-height: 84vh; overflow-y: auto;
  background: var(--c-panel); border: 1px solid var(--c-line);
  padding: 20px 22px;
  box-shadow: 0 0 40px rgba(0,0,0,.8);
}
#modal.wide { width: min(640px, 94vw); }
#modal-title { letter-spacing: .25em; color: var(--c-dim); font-size: .85em; margin-bottom: 12px; }
#modal-body { margin-bottom: 16px; }
#modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-text { white-space: pre-line; }
.dim-text { color: var(--c-dim); font-size: .85em; }

input[type="text"], textarea, select {
  width: 100%; margin-top: 10px; padding: 8px 10px;
  background: #07070a; color: var(--c-text);
  border: 1px solid var(--c-line); font-family: inherit; font-size: 1em;
  letter-spacing: .2em;
}
textarea { letter-spacing: normal; resize: vertical; }
input[type="range"] { width: 60%; }
select { width: auto; }

.lock-desc { font-size: .9em; color: var(--c-dim); }
.lock-result { margin-top: 12px; white-space: pre-line; min-height: 1.5em; color: #b08a80; }
.lock-result.ok { color: var(--c-accent); }

/* 留守録 */
.msg-list { display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow-y: auto; }
.msg-item {
  display: flex; justify-content: space-between; align-items: center;
  text-align: left; padding: 8px 12px; border: 1px solid var(--c-line);
}
.msg-item:hover { border-color: var(--c-accent); }
.msg-item.unheard { border-color: #5b4a40; }
.msg-new { font-size: .7em; color: var(--c-danger); letter-spacing: .15em; }
.msg-play { margin-top: 14px; position: relative; }
.msg-context { margin-bottom: 6px; color: var(--c-dim); font-size: .82rem; letter-spacing: .06em; }
.msg-title { margin-bottom: 6px; font-weight: 700; letter-spacing: .08em; }
.play-noise {
  position: absolute; inset: 0; pointer-events: none;
  opacity: .12; background-repeat: repeat; background-size: 256px 256px;
  mix-blend-mode: screen;
}
.reduced .play-noise { opacity: .07; }
.msg-playing { color: var(--c-accent); font-size: .8em; letter-spacing: .2em; }
.msg-text { white-space: pre-line; margin-top: 8px; font-size: .95em; }
/* 留守録の再生操作(再生/停止)。スマホでも押しやすいよう44px以上を確保 */
.msg-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; position: relative; z-index: 1; }
.msg-ctl {
  flex: 1 1 auto; min-width: 96px; min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--c-line); background: transparent; color: var(--c-text);
  letter-spacing: .08em; cursor: pointer;
}
.msg-ctl:hover { border-color: var(--c-accent); color: var(--c-accent); }
.msg-ctl:active { background: rgba(255, 255, 255, .04); }
.waveform { display: flex; align-items: flex-end; gap: 3px; height: 50px; margin-top: 12px; }
.waveform i { width: 9px; background: var(--c-accent); opacity: .75; }
.wave-note { font-size: .75em; color: var(--c-dim); margin-top: 4px; }

/* メモ */
.ghost-notes { margin-top: 14px; border-top: 1px dashed #3a2a2a; padding-top: 10px; }
.ghost-label { font-size: .75em; color: var(--c-danger); letter-spacing: .15em; }
.ghost-line {
  color: #b89a92; letter-spacing: .35em; margin-top: 6px;
  text-shadow: 0 0 4px rgba(155,60,48,.5);
}

/* 記録 */
.rec-table { width: 100%; border-collapse: collapse; }
.rec-table th, .rec-table td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--c-line);
  font-weight: normal; font-size: .9em;
}
.rec-table th { color: var(--c-dim); width: 11em; }
.rec-key td { color: var(--c-accent); }
.rec-note { margin-top: 12px; }

/* ログ */
.log-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.log-line { font-size: .88em; border-left: 2px solid var(--c-line); padding-left: 10px; }
.log-clue { border-left-color: var(--c-accent); }
.log-event { border-left-color: #5b4a40; }
.log-story { border-left-color: #3a3f55; }
.log-item { border-left-color: #6e6535; }
.log-phone { border-left-color: #4a5a6a; }
.log-system { color: var(--c-dim); }
.log-ghost { color: #b89a92; letter-spacing: .4em; border-left-color: var(--c-danger); }

/* ヒント */
.hint-block { border-top: 1px solid var(--c-line); padding: 12px 0; }
.hint-line { font-size: .9em; color: #b8b2a4; margin: 6px 0; }
.hint-block .menu-btn { margin-top: 6px; }

/* モニター */
.monitor-wrap { position: relative; }
.monitor-noise {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  opacity: .22; background-repeat: repeat; background-size: 256px 256px;
  background-image: repeating-linear-gradient(0deg, rgba(160,220,255,.06) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
  animation: noiseJitter .4s steps(2) infinite;
}
.reduced .monitor-noise { opacity: .15; }
.flash-reduce .monitor-noise { animation: none; }
.monitor-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.monitor-row {
  text-align: left; padding: 7px 12px;
  border: 1px solid #1d2a33; background: #060a0d;
  color: #7fa8b8; font-size: .85em; letter-spacing: .1em;
  font-family: "MS Gothic", "Yu Gothic", monospace;
}
.monitor-row:hover { border-color: #7fa8b8; }
.monitor-row:disabled { opacity: .4; }
body.act3 .monitor-row { color: #b87f7f; border-color: #331d1d; }

/* 持ち物 */
.item-row { border-top: 1px solid var(--c-line); padding: 10px 0; }
.item-row p { font-size: .88em; color: #a8a294; margin-top: 4px; }

/* 設定 */
.set-row { margin: 12px 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.set-row label { display: flex; align-items: center; gap: 8px; }
hr { border: none; border-top: 1px solid var(--c-line); margin: 14px 0; }

/* ============ トースト ============ */
#toast {
  position: fixed; top: 52px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: rgba(13,13,18,.92); border: 1px solid var(--c-line);
  padding: 8px 20px; font-size: .85em; letter-spacing: .1em;
  opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none; z-index: 60;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ エンディング ============ */
#screen-ending { align-items: center; justify-content: center; overflow-y: auto; position: relative; }
/* エンディング一枚絵: 本文の朗読中にゆっくり滲み出す(余韻重視・操作を奪わない) */
#ending-art {
  position: fixed; inset: 0; pointer-events: none;
  background-size: cover; background-position: center 38%;
  opacity: 0; transition: opacity 7s ease;
}
#ending-art.show { opacity: .5; }
.reduced #ending-art { transition: opacity .8s ease; }
.reduced #ending-art.show { opacity: .38; }
/* 一枚絵の上でも本文が読めるよう、上下を暗幕・中央もやや沈める */
#ending-art::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5,5,7,.62) 0%, rgba(5,5,7,.42) 42%, rgba(5,5,7,.74) 100%);
}

/* END C「記録完了」: 監視映像/記録映像としての提示(顔・怪物演出はしない) */
#ending-rec { display: none; }
body.ending-bad #ending-art.show { opacity: .58; }
body.ending-bad #ending-art::after {
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.16) 3px, rgba(0,0,0,0) 4px),
    radial-gradient(120% 90% at 50% 45%, rgba(5,5,7,.18) 0%, rgba(5,5,7,.5) 62%, rgba(5,5,7,.82) 100%);
}
body.ending-bad #ending-rec {
  display: flex; align-items: center; gap: 8px;
  position: fixed; top: 18px; right: 20px; z-index: 3;
  font-family: ui-monospace, "Courier New", monospace;
  font-size: .82em; letter-spacing: .18em; color: rgba(220,224,228,.82);
  text-shadow: 0 0 6px rgba(0,0,0,.8); pointer-events: none;
}
body.ending-bad #ending-rec .rec-dot { color: var(--c-danger); animation: recBlink 1.4s steps(1) infinite; }
body.ending-bad #ending-rec .rec-time { color: rgba(220,224,228,.6); letter-spacing: .12em; }
@keyframes recBlink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .15; } }
body.reduced.ending-bad #ending-rec .rec-dot { animation: none; }
@media (prefers-reduced-motion: reduce) { #ending-rec .rec-dot { animation: none; } }
/* スマホ: 画面いっぱいの一枚絵に本文が埋もれないよう、絵を少し沈めREC表示も縮める */
@media (max-width: 700px) {
  #ending-art.show { opacity: .42; }
  body.ending-bad #ending-art.show { opacity: .5; }
  #ending-rec { top: 12px; right: 12px; font-size: .74em; }
}
.ending-inner { max-width: 620px; padding: 40px 24px; position: relative; z-index: 2; }
#ending-title { font-weight: 400; letter-spacing: .3em; margin-bottom: 28px; color: var(--c-dim); }
body.ending-true #ending-title { color: var(--c-accent); }
body.ending-bad #ending-title { color: var(--c-danger); }
.ending-para { margin-bottom: 16px; animation: descIn 1.2s ease-out; }
.ending-after { margin-top: 30px; color: var(--c-dim); font-size: .85em; border-top: 1px solid var(--c-line); padding-top: 16px; }
.ending-award { color: var(--c-accent); letter-spacing: .15em; margin: 18px 0; min-height: 1.5em; }
#screen-ending .title-menu {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: min(92vw, 420px); margin: 10px auto 0;
}
#screen-ending .title-menu .menu-btn {
  width: 100%; min-height: 56px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  text-align: center;
}
#screen-ending .title-menu .menu-btn.small {
  padding: 10px 28px; letter-spacing: .2em;
}

/* ============ Act3 全体の変質 ============ */
body.act3 { --c-line: #2e2228; }
body.act3 #topbar { border-bottom-color: #2e2228; }

/* ============ スマホ縦 専用レイアウト ============ */
@media (max-width: 700px) {
  /* --- 明度: スマホはPCより明るくして背景・対象・本文を見やすく(暗所/ライト演出は維持) --- */
  :root {
    --bg-bright: 1.27;       /* 背景(PCの+12%よりさらに明るい) */
    --bg-contrast: 1.05;
    --act3-bright: 1.10;     /* Act3も暗くしすぎない(不穏さは色味/ノイズで担保) */
    --dark-center: .11;      /* 視点中央はさらに明るく(見えてしまう怖さ) */
    --dark-mid: .82;         /* 暗闇マスクを薄く(中央の探索対象が潰れない) */
    --dark-edge: .88;        /* 外周は不穏さを残す */
    --light-r: 42vmax;       /* ライト半径を広げる */
    --light-off-r: 19vmax;   /* 消灯時もやや広げ最低視認性を確保(手がかりの暗所演出は維持) */
    --noise-op: .06;         /* ノイズ/走査線を弱める(文字・背景の潰れ防止) */
    --noise-op-reduced: .04;
  }
  html, body {
    height: var(--vvh);
    min-height: var(--vvh);
    min-height: 100svh;
    overflow: hidden;
  }
  .screen {
    height: var(--vvh);
    min-height: var(--vvh);
    min-height: 100svh;
  }
  /* プロローグ: 縦画面で読みやすく・タップしやすく */
  #prologue-inner { padding: 24px 20px; max-width: 100vw; }
  #prologue-text { font-size: max(17px, 1.06em); line-height: 1.95; }
  #prologue-choices .menu-btn.small { min-height: 44px; }
  #prologue-skip { top: 10px; right: 10px; min-height: 40px; }
  #screen-title {
    width: 100vw;
    max-width: 100vw;
    justify-content: flex-start;
    align-items: center;
    overflow: hidden;
    padding: clamp(28px, 6vh, 52px) 18px calc(16px + var(--mobile-bottom-gap));
  }
  #screen-title .title-inner {
    width: 100%;
    max-width: 420px;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  #screen-title .title-noise { opacity: .035; }
  .game-title { letter-spacing: 0; }
  .t-kanji {
    font-size: clamp(2.05em, 15vw, 2.35em);
    letter-spacing: .16em;
    padding-left: .16em;
    line-height: 1.05;
  }
  .t-sub {
    margin-top: 6px;
    font-size: .82em;
    letter-spacing: .14em;
    color: #8b8678;
  }
  .title-tagline {
    width: min(calc(100vw - 56px), 320px);
    margin: 18px 0 22px;
    font-size: .92em;
    line-height: 1.72;
    color: #d0cabd;
  }
  #screen-title .title-menu {
    width: min(88vw, 360px);
    gap: 10px;
    margin: auto;
  }
  #screen-title .menu-btn {
    width: 100%;
    min-height: 50px;
    padding: 10px 16px;
    font-size: .96em;
    letter-spacing: .16em;
  }
  .content-warning {
    width: min(calc(100vw - 56px), 320px);
    margin-top: 18px;
    font-size: .82em;
    line-height: 1.7;
    color: #8f897c;
  }
  .title-endings { margin-top: 8px; font-size: .76em; }
  .menu-btn { min-width: 0; width: 100%; }
  #screen-game {
    width: 100vw; max-width: 100vw;
    height: var(--vvh); min-height: var(--vvh); min-height: 100svh; max-height: var(--vvh);
    overflow: hidden;
  }
  #topbar, #scene-wrap, #mobile-hud-layer, #desc-panel, #mobile-move-bar, #bottombar {
    width: 100vw; max-width: 100vw;
  }

  /* --- シーンは拡大した16:9ステージを横に見回す覗き窓にする --- */
  #scene-wrap {
    flex: 0 0 auto; min-width: 0; min-height: 0;
    height: 90vw;
    overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-x;
  }
  #scene-wrap::-webkit-scrollbar { display: none; }
  body.sheet-open {
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.sheet-open #screen-game {
    overflow: hidden;
    touch-action: none;
  }
  body.sheet-open #scene-wrap {
    overflow: hidden;
    pointer-events: none;
    touch-action: none;
  }
  body.sheet-open #modal-root,
  body.sheet-open #modal.sheet {
    pointer-events: auto;
  }
  #scene {
    position: relative; left: auto; top: auto; transform: none;
    width: 160vw; max-width: none; height: 90vw;
    aspect-ratio: 16 / 9; margin: 0;
  }
  #subtitle { display: none; }
  #mobile-hud-layer {
    flex: 0 0 auto;
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 6px 12px 0;
    pointer-events: none;
    z-index: 20;
  }
  body.mobile-ui.mobile-hud-active #mobile-hud-layer { display: flex; }
  .mobile-hud-card {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 7px 12px;
    border-radius: 6px;
    pointer-events: auto;
  }
  .mobile-event-subtitle {
    display: none;
    font-size: .9em;
    line-height: 1.6;
    letter-spacing: .04em;
  }
  .mobile-event-subtitle.show { display: block; }
  .mobile-ring-alert { border-color: #4a2520; }
  .mobile-ring-alert .mobile-hud-action { min-height: 44px; }
  /* ヘッダーをコンパクトに */
  #topbar { padding: 5px 12px; font-size: .8em; }

  /* --- 本文パネル: 残りを埋めて読みやすく(16px相当・行間確保・内部スクロール) --- */
  #desc-panel {
    flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto;
    font-size: max(16px, calc(16px * var(--font-scale)));
    line-height: 1.75; padding: 12px 16px calc(14px + var(--mobile-bottom-gap));
    scroll-padding-bottom: var(--mobile-bottom-gap);
    background: #16161f;          /* スマホはさらに少し明るい本文背景でコントラスト確保 */
  }
  #desc-text { color: #dcd7ca; }  /* スマホ本文の文字を一段明るく */
  #desc-title { font-size: .72em; }

  /* --- 下部ツールバー: 主要+調べる+メニューの1行に圧縮(タップ44px・safe-area対応) --- */
  #bottombar {
    flex: 0 0 auto;
    display: grid; grid-template-columns: repeat(5, minmax(44px, 15vw));
    justify-content: start;
    gap: 4px; padding: 7px 5px;
    padding-bottom: calc(9px + var(--mobile-bottom-gap));
  }
  #bottombar .bar-secondary { display: none; }     /* メモ/記録/ヒント/ログ/設定 → メニュー内へ */
  #bottombar .bar-mobile { display: inline-flex; } /* 調べるを表示 */
  .bar-btn {
    width: 100%; min-width: 0; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 1px; padding: 5px 1px; font-size: .7em; letter-spacing: 0;
    border-radius: 6px; text-align: center; line-height: 1.2;
    white-space: normal; overflow: visible;   /* 留守録の未読バッジを角からはみ出して見せる(見切れ防止) */
  }
  /* 未読バッジはボタン上端からはみ出すので、ツールバー上端に少し余白を確保して切れないようにする */
  #bottombar { padding-top: calc(7px + 8px); }
  .badge {
    top: -6px; right: -4px; min-width: 16px; height: 16px;
    line-height: 16px; font-size: 10px; z-index: 3;
    box-shadow: 0 0 0 1px #0a0a0e;
  }
  #btn-menu { color: transparent; font-size: 0; }
  #btn-menu::before {
    content: "☰\Aメニュー";
    white-space: pre;
    color: var(--c-text);
    font-size: 10px;
    line-height: 1.1;
  }

  /* --- ホットスポット: 通常は枠・ラベル常時表示なし。薄い点だけがライトに反応する --- */
  .mobile-ui:not(.debug-hotspots) .hotspot {
    border-color: transparent;
    background: transparent;
    min-width: 28px; min-height: 28px;
  }
  .mobile-ui:not(.debug-hotspots) .hotspot.lit {
    border-color: transparent;
    background: transparent;
  }
  .mobile-ui:not(.debug-hotspots) .hotspot.lit::before {
    content: "";
    position: absolute; left: 50%; top: 50%;
    width: 7px; height: 7px; border-radius: 50%;
    transform: translate(-50%, -50%);
    background: rgba(210, 220, 185, .5);
    box-shadow: 0 0 12px rgba(180, 210, 150, .25);
    animation: hsPulse 2.8s ease-in-out infinite;
    pointer-events: none;
  }
  .mobile-ui:not(.debug-hotspots) .hotspot .hs-label { opacity: 0 !important; }
  .mobile-ui:not(.debug-hotspots) .hotspot:focus .hs-label,
  .mobile-ui:not(.debug-hotspots) .hotspot:active .hs-label {
    opacity: .95 !important;
    background: rgba(0,0,0,.62); padding: 2px 5px; border-radius: 3px;
  }
  .mobile-ui.debug-hotspots .hotspot { min-width: 0; min-height: 0; }
  .hs-label { font-size: .72em; }
  @keyframes hsPulse { 0%, 100% { opacity: .35; } 50% { opacity: .8; } }
  body.reduced.mobile-ui:not(.debug-hotspots) .hotspot.lit::before,
  body.flash-reduce.mobile-ui:not(.debug-hotspots) .hotspot.lit::before { animation: none; opacity: .55; }

  /* 字幕は本文と被らないよう上め・幅広に */
  #toast {
    top: calc(38px + env(safe-area-inset-top, 0px));
    width: min(92vw, 420px);
    padding: 8px 14px;
    font-size: .82em;
    line-height: 1.45;
    text-align: center;
  }

  /* 上下移動・戻る扉は固定の「移動」パネルへ集約し、背景の横パンに追従させない。
     シーン内(#scene-wrap 内)の #stairs-controls はスマホでは使わず隠す。 */
  #stairs-controls { display: none; }
  #mobile-move-bar.has-actions {
    display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 8px;
    flex-shrink: 0; justify-content: flex-start;
    padding: 7px 10px 10px;
    border-top: 1px solid var(--c-line);
    background: #0a0a0e;
  }
  #mobile-move-bar .move-btn {
    flex: 1 1 40%; min-width: 40%; min-height: 44px;
    padding: 9px 8px;
  }

  /* モーダルは画面いっぱい近くに。調べる/メニューはbottom sheetとして下から出す */
  #modal { width: min(440px, 94vw); padding: 16px 16px; }
  #modal.wide { width: 94vw; }
  #modal.sheet {
    left: 0; right: 0; bottom: var(--mobile-bottom-gap); top: auto; transform: none;
    width: 100vw; max-height: min(calc(var(--vvh) - 20px - var(--mobile-bottom-gap)), 620px);
    display: flex; flex-direction: column; overflow: hidden;
    border-left: none; border-right: none; border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 16px 16px calc(16px + var(--mobile-bottom-gap));
    box-shadow: 0 -18px 44px rgba(0,0,0,.75);
  }
  #modal.sheet #modal-title { flex: 0 0 auto; }
  #modal.sheet #modal-body {
    flex: 1 1 auto; min-height: 0; max-height: none;
    overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; touch-action: pan-y;
  }
  #modal.sheet #modal-actions { flex: 0 0 auto; }
  #modal.sheet .explore-list,
  #modal.sheet .menu-sheet { overflow: visible; }
  #modal-actions .menu-btn { min-height: 44px; }
}

/* OSのreduce motion設定を尊重 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}
