/* 旧第三病棟 — 画面全体に WebGL、四隅にビデオカメラ風 HUD、タイトルは病棟の掲示板のような縦書き */
:root {
  --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: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gut-l: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}
* { 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-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, 2.8vw, 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(--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 { 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: 0; display: grid; place-items: center; pointer-events: none; font-family: var(--f-display); font-weight: 800; font-size: clamp(44px, 13vw, 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, 4vw, 56px); pointer-events: none;
  padding-block: calc(var(--safe-t) + clamp(56px, 9vh, 90px)) calc(var(--safe-b) + clamp(40px, 7vh, 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, 2vw, 22px); writing-mode: vertical-rl; margin-right: clamp(0px, 3vw, 40px); }
.mast h1 { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: clamp(50px, 11.5vh, 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, 1.9vh, 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, 4vw, 48px); }
.lede { margin: 0; font-family: var(--f-display); font-weight: 500; font-size: clamp(20px, 3.2vh, 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; background: #000; display: grid; place-content: center; justify-items: center; gap: 30px; text-align: center; padding-block: 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, 5.4vw, 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-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-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, 7.2vh, 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); }
}
@media (prefers-reduced-motion: reduce) {
  .hud.glitch { animation: none; }
}
