/* 시체에게 속삭이다 — 장면 방 (플레이어·GM 공용) */
:root {
  --ink: #e9e4dc; --dim: #8d867c; --blood: #c0262d; --blood-soft: #ff6b6b33;
  --panel: rgba(8, 6, 6, .78); --line: rgba(255, 255, 255, .12);
  --serif: "Noto Serif KR", "Nanum Myeongjo", serif; --sans: "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--ink); font-family: var(--serif); }
button { font: inherit; cursor: pointer; }
a { color: #e8b4b4; }

/* ── 플레이어 화면 ── */
/* overflow: clip — hidden 이면 노이즈 층(inset -50%) 때문에 화면이 스크롤돼 타이머가 위로 밀렸다 */
.stage { position: fixed; inset: 0; overflow: clip; background: #000; }
.bg { position: absolute; inset: -4%; background: center/cover no-repeat; filter: brightness(.6) contrast(1.15) saturate(.6); transition: opacity 1.2s; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,.85) 100%); }
.grain { position: absolute; inset: -50%; pointer-events: none; opacity: .09; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); animation: grain 1s steps(6) infinite; }
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-5%,3%)} 50%{transform:translate(4%,-4%)} 75%{transform:translate(-3%,-2%)} 100%{transform:translate(2%,4%)} }

/* tv 장면: 주사선·노이즈·색 번짐 */
.tv-layer { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .6s; mix-blend-mode: screen;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 1px, transparent 1px 3px); }
.mode-tv .tv-layer { opacity: 1; animation: roll 7s linear infinite; }
.mode-tv .bg { filter: brightness(.35) contrast(1.4) saturate(.2) hue-rotate(160deg); animation: jitter .18s steps(2) infinite; }
.mode-tv .text { text-shadow: 1.5px 0 rgba(255,0,60,.35), -1.5px 0 rgba(0,200,255,.3); }
@keyframes roll { from { background-position: 0 0; } to { background-position: 0 300px; } }
@keyframes jitter { 0% { transform: translate(0,0); } 50% { transform: translate(1px,-1px); } }

/* flicker 장면: 불규칙 깜빡임 */
.mode-flicker .bg { animation: flick 5s infinite; }
@keyframes flick { 0%,18%,22%,60%,63%,100% { opacity: 1; } 20% { opacity: .25; } 61% { opacity: .45; } 62% { opacity: .1; } }

/* 장면 전환: 꺼졌다 켜짐 */
.blackout { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.blackout.on { animation: out .9s ease-out; }
@keyframes out { 0% { opacity: 0; } 15% { opacity: 1; } 45% { opacity: 1; } 55% { opacity: .3; } 62% { opacity: 1; } 100% { opacity: 0; } }

/* 충격 */
.redflash { position: absolute; inset: 0; background: radial-gradient(circle, rgba(200,0,20,.25), rgba(120,0,0,.75)); opacity: 0; pointer-events: none; }
.shake { animation: shake .5s; }
.shake .redflash { animation: red .7s; }
@keyframes shake { 10%,90% { transform: translate(-3px,2px); } 20%,80% { transform: translate(6px,-4px); } 30%,50%,70% { transform: translate(-9px,5px); } 40%,60% { transform: translate(9px,-3px); } }
@keyframes red { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }

/* 글 상자 */
.box { position: absolute; left: 50%; bottom: 7vh; transform: translateX(-50%); width: min(880px, calc(100% - 32px)); max-height: 64vh;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 0 60px rgba(0,0,0,.9), inset 0 0 40px rgba(120,0,0,.12); }
.scene-title { font-family: var(--serif); letter-spacing: .3em; color: var(--blood); font-size: .95rem; padding: 14px 22px 0; text-shadow: 0 0 8px rgba(192,38,45,.6); }
.text { overflow-y: auto; padding: 10px 22px 20px; font-size: clamp(16px, 2.1vw, 19px); line-height: 1.95; }
.text p { margin: 0 0 1em; }
.text p.k-rule { font-family: var(--sans); font-size: .82em; color: var(--dim); line-height: 1.7; border-left: 2px solid #5a1d1d; padding-left: 10px; }
.text p.k-ghost { color: #ff9a9a; text-shadow: 0 0 10px rgba(200,0,20,.8), 0 0 2px #f00; animation: tremble .12s infinite; font-size: 1.08em; }
@keyframes tremble { 0% { transform: translate(0,0); } 33% { transform: translate(.6px,-.4px); } 66% { transform: translate(-.5px,.5px); } }
.text .color1 { color: #d86a6a; }
.caret::after { content: "▌"; color: var(--blood); animation: blink .8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.waiting { color: var(--dim); font-style: italic; letter-spacing: .1em; }

/* 위·아래 칸 */
.hud { position: absolute; top: 14px; right: 16px; font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 1.15rem; letter-spacing: .08em;
  padding: 6px 12px; background: rgba(0,0,0,.55); border: 1px solid var(--line); border-radius: 3px; }
.hud.low { color: #ff5a5a; border-color: #7a1d1d; animation: pulse 1s infinite; }
.hud.off { opacity: .5; }
@keyframes pulse { 50% { box-shadow: 0 0 14px rgba(255,40,40,.5); } }
.tools { position: absolute; left: 16px; bottom: 14px; display: flex; gap: 8px; z-index: 3; }
.tools button, .btn { background: rgba(0,0,0,.6); color: var(--ink); border: 1px solid var(--line); border-radius: 3px; padding: 6px 12px; font-family: var(--sans); font-size: .85rem; }
.tools button:hover, .btn:hover { border-color: #7a2a2a; }

/* 지난 장면 */
.drawer { position: absolute; inset: 0; background: rgba(0,0,0,.92); z-index: 5; overflow-y: auto; padding: 40px 16px; }
.drawer .inner { max-width: 760px; margin: 0 auto; line-height: 1.9; }
.drawer h3 { color: var(--blood); letter-spacing: .25em; font-weight: 500; margin: 2em 0 .6em; }
.drawer p.k-rule { font-family: var(--sans); color: var(--dim); font-size: .85em; }
.drawer p.k-ghost { color: #ff9a9a; }

/* 입장 */
.gate { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: #000; text-align: center; }
.gate h1 { font-weight: 300; letter-spacing: .35em; font-size: clamp(22px, 4vw, 38px); margin: 0 0 .4em; color: #ddd; }
.gate p { color: var(--dim); font-family: var(--sans); font-size: .9rem; margin: .4em 0; }
.gate button { margin-top: 22px; background: transparent; color: var(--ink); border: 1px solid #6b1d1d; padding: 12px 30px; letter-spacing: .3em; font-family: var(--serif); }
.gate button:hover { background: #1a0505; }
.gate .sub { margin-top: 14px; background: none; border: 0; color: var(--dim); letter-spacing: 0; font-family: var(--sans); text-decoration: underline; padding: 4px; }
.err { color: #ff7a7a; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  .box { bottom: 60px; max-height: 70vh; }
  .text { padding: 8px 14px 14px; }
  .scene-title { padding: 12px 14px 0; }
}
