/* 旧第三病棟 脱出 — 画面全体に WebGL、四隅にビデオカメラ風 HUD、タイトルは病棟の掲示板のような縦書き */
:root {
  --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px);
  --vw: 1vw; --vh: 1vh;
  --void: #050606;
  --bone: #d6d0bf;
  --dim: #8a8e86;
  --blood: #8f1d15;
  --rec: #d43b2b;
  --f-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif;
  --f-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
  --f-hud: "DotGothic16", "Osaka-Mono", "MS Gothic", ui-monospace, monospace;
  --safe-t: var(--sa-t);
  --safe-b: var(--sa-b);
  --gut-l: max(16px, var(--sa-l));
  --gut-r: max(16px, var(--sa-r));
  color-scheme: dark;
}
@supports (width: 1svmin) { :root { --vw: 1svw; --vh: 1svh; } }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--void); color: var(--bone); font-family: var(--f-body); overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; background: var(--void); }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; font-family: var(--f-hud); color: var(--bone); font-size: clamp(12px, calc(2.8 * var(--vw)), 16px); letter-spacing: .08em; text-shadow: 0 0 6px rgba(0,0,0,.85); font-variant-numeric: tabular-nums; }
.hud > div { position: absolute; display: flex; align-items: center; gap: .7em; }
.hud-tl { top: calc(var(--safe-t) + 14px); left: var(--gut-l); }
.hud-tr { top: calc(var(--safe-t) + 14px); right: var(--gut-r); }
.hud-bl { bottom: calc(var(--safe-b) + 14px); left: var(--gut-l); }
.hud-br { bottom: calc(var(--safe-b) + 14px); right: var(--gut-r); color: var(--bone); flex-direction: column; align-items: flex-end !important; gap: .45em !important; text-align: right; max-width: 46vw; }
.hud-bl { flex-direction: column; align-items: flex-start !important; gap: .3em !important; }
#loc { color: var(--dim); }
#inv { display: flex; gap: .5em; flex-wrap: wrap; justify-content: flex-end; }
#inv span { border: 1px solid rgba(214,208,191,.45); padding: 2px 7px; font-size: .85em; background: rgba(5,6,6,.5); }
#objective::before { content: "目的　"; color: var(--dim); }
.rec { display: inline-flex; align-items: center; gap: .5em; }
.rec-dot { width: .72em; height: .72em; border-radius: 50%; background: var(--rec); box-shadow: 0 0 8px var(--rec); animation: blink 1.1s steps(2) infinite; }
.bat-wrap { display: inline-flex; align-items: center; gap: .55em; }
.bat { width: 2.7em; height: 1.05em; border: 1.5px solid var(--bone); position: relative; padding: 2px; }
.bat::after { content: ""; position: absolute; right: -5px; top: 28%; width: 3px; height: 44%; background: var(--bone); }
.bat i { display: block; height: 100%; width: 34%; background: var(--bone); }
.bat.low i { background: var(--rec); }
.bat.low { animation: blink .7s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }
.hud.glitch { animation: hudjit .07s steps(2) infinite; }
@keyframes hudjit { 0% { transform: translate(4px,-3px); } 50% { transform: translate(-5px,2px); } 100% { transform: none; } }

#hub, .chip { pointer-events: auto; font-family: var(--f-hud); font-size: 13px; letter-spacing: .08em; color: var(--bone); text-decoration: none; padding: 6px 10px; border: 1px solid rgba(214,208,191,.45); background: rgba(5,6,6,.55); border-radius: 0; cursor: pointer; }
#hub:hover, .chip:hover { border-color: var(--bone); background: rgba(143,29,21,.55); }
#hub:focus-visible, .chip:focus-visible, .btn:focus-visible { outline: 2px solid var(--rec); outline-offset: 3px; }

/* モードごとの出し分け */
body:not([data-mode="demo"]) #hub, body:not([data-mode="demo"]) #demo-tag { display: none; }
body[data-mode="demo"] .rec, body[data-mode="demo"] #abort, body[data-mode="demo"] .hud-br, body[data-mode="demo"] #loc { display: none; }
body:not([data-mode="play"]) #msg, body:not([data-mode="play"]) #prompt, body:not([data-mode="play"]) #stam, body:not([data-mode="play"]) #breath, body:not([data-mode="play"]) #tbtns, body:not([data-mode="play"]) #noise, body:not([data-mode="play"]) #map { display: none !important; }
body[data-mode="end"] #sense, body[data-mode="end"] #pulse, body[data-mode="loading"] #sense, body[data-mode="loading"] #pulse { display: none; }
body:not(.touch) #abort { display: none; }
body[data-mode="end"] .hud, body[data-mode="loading"] .hud { display: none; }
body:not([data-mode="end"]) #end { display: none; }
body:not([data-mode="loading"]) #loading { display: none; }

/* ---------- デモ表示（小さく） ---------- */
#demo-tag { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 18px); transform: translateX(-50%); display: flex; align-items: center; gap: .6em; font-family: var(--f-hud); font-size: 14px; letter-spacing: .2em; color: var(--bone); text-shadow: 0 0 6px #000; pointer-events: none; white-space: nowrap; }
#demo-tag i { width: .6em; height: .6em; background: var(--bone); clip-path: polygon(0 0, 100% 50%, 0 100%); }
#demo-tag em { font-style: normal; animation: blink 1.4s steps(2) infinite; }
body.touch #demo-tag .pc, body:not(.touch) #demo-tag .tc { display: none; }

/* ---------- 演出の文字 ---------- */
#cue { position: fixed; inset: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l); display: grid; place-items: center; pointer-events: none; font-family: var(--f-display); font-weight: 800; font-size: clamp(44px, calc(13 * var(--vw)), 128px); letter-spacing: .32em; padding-left: .32em; color: var(--blood); text-shadow: 0 0 22px rgba(143,29,21,.7), 2px 0 0 rgba(30,80,90,.4); opacity: 0; }
#cue.on { animation: cue 3.6s linear forwards; }
@keyframes cue { 0% { opacity: 0; } 5% { opacity: .85; } 7% { opacity: 0; } 10% { opacity: 1; transform: translateX(-4px); } 12% { transform: none; } 38% { opacity: .9; } 40% { opacity: .05; } 43% { opacity: 1; } 74% { opacity: 1; } 76% { opacity: 0; } 79% { opacity: .6; } 100% { opacity: 0; } }

#joy { position: fixed; width: 112px; height: 112px; margin: -56px 0 0 -56px; border: 1.5px solid rgba(214,208,191,.32); border-radius: 50%; pointer-events: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(214,208,191,.22); }

/* ---------- プレイ開始直後のタイトル ---------- */
#intro { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: clamp(14px, calc(4 * var(--vw)), 56px); pointer-events: none;
  padding-block: calc(var(--safe-t) + clamp(56px, calc(9 * var(--vh)), 90px)) calc(var(--safe-b) + clamp(40px, calc(7 * var(--vh)), 70px));
  padding-left: var(--gut-l); padding-right: var(--gut-r);
  background: linear-gradient(90deg, rgba(5,6,6,.82) 0%, rgba(5,6,6,.45) 46%, rgba(5,6,6,0) 68%, rgba(5,6,6,.55) 100%);
  opacity: 0; visibility: hidden; transition: opacity 1.4s ease, visibility 0s linear 1.4s; }
#intro.on { opacity: 1; visibility: visible; transition: opacity .6s ease; }
.mast { grid-column: 2; grid-row: 1; align-self: start; display: flex; flex-direction: column; gap: clamp(10px, calc(2 * var(--vw)), 22px); writing-mode: vertical-rl; margin-right: clamp(0px, calc(3 * var(--vw)), 40px); }
.mast h1 { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: clamp(50px, calc(11.5 * var(--vh)), 124px); line-height: 1.1; letter-spacing: .16em; white-space: nowrap; color: var(--bone); text-shadow: 0 0 30px rgba(0,0,0,.9); }
.mast p { margin: 0; font-family: var(--f-display); font-weight: 500; font-size: clamp(12px, calc(1.9 * var(--vh)), 15px); line-height: 1.4; letter-spacing: .42em; white-space: nowrap; color: var(--dim); padding-top: .6em; }
.mast p b { color: var(--blood); font-weight: 500; }
.info { grid-column: 1; grid-row: 1; align-self: end; max-width: 36ch; min-width: 0; display: flex; flex-direction: column; gap: 18px; margin-left: clamp(0px, calc(4 * var(--vw)), 48px); }
.lede { margin: 0; font-family: var(--f-display); font-weight: 500; font-size: clamp(20px, calc(3.2 * var(--vh)), 28px); line-height: 1.5; letter-spacing: .08em; text-wrap: balance; text-shadow: 0 0 12px #000; }
.notes { margin: 0; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 10px 14px; font-size: 13.5px; line-height: 1.65; text-shadow: 0 0 8px #000; }
.notes dt { font-family: var(--f-hud); color: var(--dim); letter-spacing: .12em; padding-top: 1px; }
.notes dd { margin: 0; }
.notes dd.warn { color: #e6b3aa; }
body.touch .desk, body:not(.touch) .tch { display: none; }

/* ---------- 終わり ---------- */
#end { position: fixed; inset: 0; overflow-y: auto; background: #000; display: grid; place-content: center; align-content: safe center; justify-items: center; gap: 30px; text-align: center; padding-block: calc(var(--sa-t) + 40px) calc(var(--sa-b) + 40px); padding-left: var(--gut-l); padding-right: var(--gut-r); opacity: 0; transition: opacity 2.4s ease; }
#end.in { opacity: 1; }
#end .stamp { font-family: var(--f-hud); color: var(--dim); letter-spacing: .14em; font-size: 14px; }
#end h2 { margin: 0; font-family: var(--f-display); font-weight: 500; font-size: clamp(22px, calc(5.4 * var(--vw)), 40px); line-height: 1.7; letter-spacing: .22em; text-wrap: balance; }
#end .sub { margin: 0; color: var(--dim); font-size: 14px; line-height: 1.8; }
#end .end-hint { margin: 0; max-width: 34ch; font-family: var(--f-hud); font-size: 13px; line-height: 1.8; letter-spacing: .08em; color: #c9a59e; border-top: 1px solid rgba(214,208,191,.18); padding-top: 14px; }
#end.clear { background: radial-gradient(120% 90% at 50% 100%, #3b4756 0%, #141b23 55%, #06080b 100%); }
#end.clear .stamp { color: #a9b6c2; }
.end-btns { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.btn { appearance: none; display: inline-flex; align-items: center; gap: .9em; font-family: var(--f-display); font-weight: 800; font-size: 20px; letter-spacing: .4em; padding: 13px 20px 13px 26px; color: var(--bone); background: transparent; border: 1px solid var(--bone); border-radius: 0; cursor: pointer; transition: background .25s, border-color .25s; }
.btn::before { content: ""; width: .5em; height: .5em; background: var(--rec); border-radius: 50%; box-shadow: 0 0 10px var(--rec); }
.btn.ghost { font-size: 15px; letter-spacing: .2em; border-color: rgba(214,208,191,.4); color: var(--dim); }
.btn.ghost::before { display: none; }
.btn:hover { background: var(--blood); border-color: var(--blood); color: var(--bone); }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--void); font-family: var(--f-hud); color: var(--dim); letter-spacing: .14em; padding-block: var(--sa-t) var(--sa-b); padding-left: var(--gut-l); padding-right: var(--gut-r); text-align: center; }

@media (max-width: 640px) {
  #intro { grid-template-columns: minmax(0,1fr); grid-template-rows: auto 1fr; background: linear-gradient(180deg, rgba(5,6,6,.5) 0%, rgba(5,6,6,0) 40%, rgba(5,6,6,.85) 100%); }
  .mast { grid-column: 1; grid-row: 1; justify-self: end; margin-right: 0; }
  .mast h1 { font-size: clamp(40px, calc(7.2 * var(--vh)), 84px); }
  .info { grid-column: 1; grid-row: 2; margin-left: 0; max-width: none; gap: 14px; }
  .notes { font-size: 12.5px; }
  #demo-tag { bottom: calc(var(--safe-b) + 46px); }
}
/* 短い横画面では縦書きと注意書きを、HUD の上下の間に収める。 */
@media (max-height: 500px) and (orientation: landscape) {
  #intro { padding-block: calc(var(--sa-t) + 40px) calc(var(--sa-b) + 28px); }
  .mast h1 { font-size: clamp(28px, calc(11.5 * var(--vh)), 50px); }
  .info { gap: 12px; }
  .notes { font-size: 12px; gap: 6px 10px; line-height: 1.55; }
  #end { gap: 14px; padding-block: calc(var(--sa-t) + 24px) calc(var(--sa-b) + 24px); }
  #end h2 { font-size: clamp(22px, calc(5.4 * var(--vw)), 30px); }
  #end .end-hint { max-width: 50ch; }
}
@media (prefers-reduced-motion: reduce) {
  .hud.glitch { animation: none; }
}

/* ---------- 脱出編の HUD：短い文・調べる・スタミナ・息・物音・案内図・タッチのボタン ---------- */
#msg { position: fixed; left: 50%; top: calc(var(--safe-t) + 17%); transform: translateX(-50%); max-width: min(88vw, 40em); text-align: center; font-family: var(--f-display); font-weight: 500; font-size: clamp(15px, calc(2.2 * var(--vh) + 6px), 21px); line-height: 1.6; letter-spacing: .08em; color: var(--bone); text-shadow: 0 0 10px #000, 0 0 3px #000; pointer-events: none; opacity: 0; transition: opacity .5s; }
#msg.on { opacity: 1; transition: opacity .15s; }
#prompt { position: fixed; left: 50%; top: 58%; transform: translateX(-50%); font-family: var(--f-hud); font-size: 15px; letter-spacing: .12em; color: var(--bone); text-shadow: 0 0 6px #000; pointer-events: none; opacity: 0; transition: opacity .15s; white-space: nowrap; display: flex; align-items: center; gap: .6em; }
#prompt.on { opacity: .92; }
#prompt kbd { font-family: var(--f-hud); border: 1px solid var(--bone); padding: 1px 7px; font-size: 13px; }
body.touch #prompt { display: none; }
#stam { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 54px); width: min(220px, 40vw); height: 4px; transform: translateX(-50%); background: rgba(214,208,191,.18); opacity: 0; transition: opacity .4s; pointer-events: none; }
#stam.on { opacity: 1; }
#stam i { display: block; height: 100%; width: 100%; background: var(--bone); }
#stam.tired i { background: var(--rec); }
#breath { position: fixed; left: 50%; top: calc(var(--safe-t) + 9%); transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 8px; font-family: var(--f-hud); font-size: 13px; letter-spacing: .12em; color: var(--dim); text-shadow: 0 0 6px #000; pointer-events: none; }
#breath.on { display: flex; }
#breath.hold { color: var(--bone); }
#breath b { display: block; width: min(180px, 40vw); height: 4px; background: rgba(214,208,191,.18); }
#breath i { display: block; height: 100%; background: #9fb8bd; }
body.touch #breath .pc, body:not(.touch) #breath .tc { display: none; }
#noise { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 64px); width: 40px; height: 40px; margin-left: -20px; border-radius: 50%; border: 1.5px solid rgba(214,208,191,.6); opacity: 0; pointer-events: none; }
#noise.on { animation: noise .6s ease-out forwards; }
@keyframes noise { 0% { opacity: .8; transform: scale(.4); } 100% { opacity: 0; transform: scale(calc(.8 + var(--s, .5) * 3)); } }

#map { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(3,4,4,.78); padding-block: calc(var(--sa-t) + 12px) calc(var(--sa-b) + 12px); padding-left: var(--gut-l); padding-right: var(--gut-r); z-index: 5; }
.map-box { width: min(980px, 100%); max-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 260px); grid-template-rows: auto minmax(0, 1fr); gap: 10px 16px; background: rgba(12,14,14,.92); border: 1px solid rgba(214,208,191,.3); padding: 14px; }
.map-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-family: var(--f-hud); letter-spacing: .1em; }
#mapCv { width: 100%; height: min(66vh, 62vw); min-height: 0; }
#mapList { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; line-height: 1.5; color: var(--dim); }
#mapList li.done { text-decoration: line-through; opacity: .55; }
#mapList li.now { color: var(--bone); }
#mapList li span { display: block; font-size: 12px; color: var(--dim); }
@media (max-width: 720px) {
  .map-box { grid-template-columns: minmax(0, 1fr); }
  #mapList { font-size: 12px; gap: 4px; }
  #mapList li:not(.now) { display: none; }
  #mapCv { height: 52vh; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .map-box { padding: 10px; grid-template-columns: minmax(0, 1fr) minmax(150px, 210px); }
  #mapCv { height: calc(var(--vh) * 100 - 96px - var(--sa-t) - var(--sa-b)); }
  #mapList { font-size: 12px; gap: 6px; }
}

#tbtns { display: none; }
body.touch #tbtns { display: grid; position: fixed; right: max(12px, var(--sa-r)); bottom: calc(var(--safe-b) + 44px); grid-template-columns: repeat(3, auto); gap: 8px; justify-items: end; align-items: end; pointer-events: none; }
.tb { pointer-events: auto; appearance: none; font-family: var(--f-hud); font-size: 13px; letter-spacing: .06em; color: var(--bone); background: rgba(5,6,6,.45); border: 1.5px solid rgba(214,208,191,.42); border-radius: 50%; width: 62px; height: 62px; padding: 0; touch-action: none; -webkit-user-select: none; user-select: none; line-height: 1.15; }
.tb.small { width: 50px; height: 50px; font-size: 11px; }
.tb.big { grid-column: 2 / span 2; width: 132px; height: 64px; border-radius: 32px; font-size: 14px; }
.tb.dim { opacity: .5; }
.tb.press { background: rgba(143,29,21,.6); border-color: var(--bone); }
#bBreath { display: none; }
body[data-hide]:not([data-hide=""]) #bBreath { display: block; }
body[data-hide]:not([data-hide=""]) #bRun, body[data-hide]:not([data-hide=""]) #bCrouch { visibility: hidden; }
body.touch .hud-br { bottom: calc(var(--safe-b) + 14px); right: auto; left: 50%; transform: translateX(-50%); align-items: center !important; text-align: center; max-width: 60vw; font-size: 12px; }
body.touch .hud-bl { display: none; }

/* タイトルの「脱出」は、病棟名の左に赤い小さな列で */
.mast h1 .ex { display: block; font-size: .5em; color: var(--blood); padding-top: 3.2em; letter-spacing: .3em; text-shadow: 0 0 18px rgba(143,29,21,.5); }

/* ---------- 音なしでも「彼女」の位置がわかる表示 ---------- */
#sense { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#senseMark { --c: 226 230 236; position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; will-change: transform, opacity; }
#senseMark i { position: absolute; left: 0; top: 0; width: var(--sz, 30vmin); height: var(--sz, 30vmin); transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(closest-side, rgb(var(--c) / .55), rgb(var(--c) / .18) 55%, rgb(var(--c) / 0) 100%); }
#senseMark b { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); font-family: var(--f-display); font-weight: 800; font-size: clamp(28px, 7vmin, 54px); color: rgb(var(--c)); text-shadow: 0 0 10px rgb(var(--c) / .8), 0 0 3px #000; }
#senseMark.far b { filter: blur(1.5px); }
#pulse { position: fixed; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 12vmin 3vmin rgba(150,12,8,.85); }
#breath em { display: none; font-style: normal; font-size: 15px; font-weight: 700; color: #ff9b8f; animation: blink .5s steps(2) infinite; }
#breath.warn em { display: block; }
#breath.warn .pc, #breath.warn .tc { display: none; }
#breath u { display: none; width: min(180px, 40vw); height: 3px; background: rgba(214,208,191,.12); }
#breath.warn u, #breath.sus u { display: block; }
#breath u i { display: block; height: 100%; width: 0; background: #d43b2b; }
@media (prefers-reduced-motion: reduce) { #breath em { animation: none; } }
