:root {
  --bg: #05060a;
  --accent: #b5121b;
  --accent-soft: #7a1016;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px;
  --space-1: 6px; --space-2: 10px; --space-3: 16px; --space-4: 24px; --space-5: 34px;
  --z-vignette: 5; --z-scan: 6; --z-hud: 10; --z-damage: 20; --z-map: 25; --z-screen: 30;
  --text: #cdd2d8;
  --text-dim: #a7adb5;
  --fuse: #3aa0ff;
  --key-col: #ffd24a;
  --exit-col: #18ff6a;
  --power-col: #ff5a4a;
  --panel: rgba(10, 12, 16, 0.78);
  --panel-border: rgba(130, 20, 24, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

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

html, body {
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

#game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  /* 숨는 중(--hide=1)엔 채도를 낮춰 '숨죽인' 분위기 */
  filter: saturate(calc(1 - var(--hide, 0) * 0.55)) brightness(calc(1 - var(--hide, 0) * 0.12));
  transition: filter 0.4s ease;
}

/* ---------- 분위기 오버레이 ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  /* 위험도(--danger 0~1)가 오르면 어두운 테두리가 안쪽으로 수축 */
  background:
    radial-gradient(ellipse at center,
      rgba(90,0,0,0) calc(55% - var(--danger, 0) * 30%),
      rgba(60,0,0,calc(var(--danger, 0) * 0.5)) calc(80% - var(--danger, 0) * 20%),
      rgba(30,0,0,calc(var(--danger, 0) * 0.65)) 100%),
    radial-gradient(ellipse at center,
      rgba(0,0,0,0) 38%,
      rgba(0,0,0,0.55) 78%,
      rgba(0,0,0,0.9) 100%);
  transition: background 0.12s linear;
}
#scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0.08;
  background: repeating-linear-gradient(
    to bottom, rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.04) 1px,
    rgba(0,0,0,0) 2px, rgba(0,0,0,0) 3px);
}
#damage-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 20;
  background: radial-gradient(ellipse at center, rgba(120,0,0,0) 40%, rgba(150,0,0,0.75) 100%);
  opacity: 0; transition: opacity 0.12s ease-out;
}
#damage-flash.on { opacity: 1; }

#blackout-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: #000; opacity: 0; transition: opacity 1.2s ease;
}

/* ---------- 경보 ---------- */
/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }

#crosshair {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 10px; height: 10px; transition: transform 0.15s ease;
}
#crosshair span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid rgba(235,235,235,0.75); box-shadow: 0 0 5px rgba(0,0,0,0.95);
  transition: border-color 0.15s, background 0.15s;
}
#crosshair span::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 2px; height: 2px; margin: -1px 0 0 -1px; border-radius: 50%;
  background: rgba(235,235,235,0.9);
}
/* 상호작용 가능할 때 초록으로 강조 + 살짝 확대 */
#crosshair.active { transform: translate(-50%,-50%) scale(1.35); }
#crosshair.active span { border-color: #6fd98a; box-shadow: 0 0 8px rgba(60,220,120,0.7); }
#crosshair.active span::after { background: #6fd98a; }

/* 지도 열기 안내 배지 */
#map-hint {
  position: absolute; top: 92px; left: 50%; transform: translateX(-50%);
  background: rgba(10,12,16,0.8); border: 1px solid var(--panel-border);
  padding: 5px 12px; border-radius: 20px; font-size: 13px; color: #e7eaee;
  pointer-events: none; box-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

/* 학교 지도 오버레이 */
#map-overlay {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(4,6,10,0.93); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.map-inner { max-width: 960px; width: 100%; text-align: center; animation: fadeUp 0.3s ease; }
.map-title { font-size: 28px; font-weight: 800; color: #e9ecef; letter-spacing: 0.04em; }
.map-sub { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
#map-floors { display: flex; gap: 18px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.map-floor {
  flex: 1 1 260px; max-width: 300px; background: rgba(16,20,28,0.9);
  border: 1px solid rgba(130,20,24,0.4); border-radius: 10px; padding: 14px;
}
.map-floor h3 { font-size: 15px; color: #ffd24a; letter-spacing: 0.1em; margin-bottom: 10px; }
.map-plan { display: flex; flex-direction: column; gap: 8px; }
.map-room {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(40,46,56,0.7); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px; padding: 8px 12px; font-size: 14px; color: #cdd2d8;
}
.map-room .rn { font-weight: 700; color: #e7eaee; }
.map-room .tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.map-room .tag.fuse { background: rgba(58,160,255,0.2); color: #7ac0ff; border: 1px solid var(--fuse); }
.map-room .tag.key  { background: rgba(255,210,74,0.2); color: var(--key-col); border: 1px solid var(--key-col); }
.map-room .tag.got  { background: rgba(60,200,100,0.15); color: #6fd98a; border: 1px solid #3aa060; }
.map-room .tag.none { color: var(--text-dim); }
.map-corridor { margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.map-breaker-hl {
  color: #ff5a4a; font-weight: 800;
  animation: breakerPulse 1.1s ease-in-out infinite;
  text-shadow: 0 0 8px rgba(255,60,40,0.6);
}
@keyframes breakerPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.map-guide {
  width: 100%; margin-top: 16px; text-align: center;
  background: rgba(255,210,74,0.12); border: 1px solid rgba(255,210,74,0.4);
  border-radius: 8px; padding: 10px 16px; font-size: 14px; color: #ffe9a8;
  font-weight: 600;
}
.map-guide b { color: #fff; }
.map-legend { margin-top: 20px; display: flex; gap: 20px; justify-content: center; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.sw-fuse { color: var(--fuse); }
.sw-key { color: var(--key-col); }
.sw-exit { color: var(--exit-col); }
.sw-power { color: var(--power-col); }

/* 초보자 튜토리얼 힌트 */
#tutorial {
  position: absolute; bottom: 13%; left: 50%; transform: translateX(-50%);
  background: rgba(8,10,14,0.92); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 11px 20px; max-width: 72vw; text-align: center;
  font-size: 14.5px; line-height: 1.5; color: #e7eaee;
  box-shadow: 0 6px 24px rgba(0,0,0,0.7); animation: fadeUp 0.4s ease;
}
#tutorial b { color: #ffd24a; }
#tutorial .tut-key {
  display: inline-block; background: #e7eaee; color: #111; font-weight: 700;
  border-radius: 4px; padding: 1px 7px; font-size: 13px; margin: 0 2px;
  box-shadow: 0 2px 0 #9aa0a6;
}

/* 경비원 추격 대사 자막 */
#guard-line {
  position: absolute; bottom: 16%; left: 50%; transform: translateX(-50%) scale(1);
  background: rgba(30,6,8,0.85); border: 1px solid rgba(220,40,40,0.5);
  border-radius: 8px; padding: 10px 24px; max-width: 76vw; text-align: center;
  font-size: 20px; font-weight: 800; letter-spacing: 0.02em; color: #ffdad2;
  text-shadow: 0 0 10px rgba(255,40,30,0.7); box-shadow: 0 6px 26px rgba(120,0,0,0.5);
  opacity: 0; transition: opacity 0.18s ease;
}
#guard-line.show { opacity: 1; animation: guardShake 0.4s ease; }
@keyframes guardShake {
  0% { transform: translateX(-50%) scale(1.15); }
  40% { transform: translateX(-52%) scale(1.02); }
  60% { transform: translateX(-48%) scale(1.02); }
  100% { transform: translateX(-50%) scale(1); }
}

/* 교내 방송(PA) 자막 — 스피커 안내 느낌(차분한 청록, 상단) */
#pa-line {
  position: absolute; top: 12%; left: 50%; transform: translateX(-50%);
  background: rgba(8,20,26,0.9); border: 1px solid rgba(90,200,220,0.5);
  border-radius: 8px; padding: 9px 22px; max-width: 78vw; text-align: center;
  font-size: 18px; font-weight: 700; letter-spacing: 0.02em; color: #cfeef5;
  text-shadow: 0 0 10px rgba(80,200,230,0.5); box-shadow: 0 6px 24px rgba(0,60,80,0.45);
  opacity: 0; transition: opacity 0.25s ease; z-index: 21;
}
#pa-line.show { opacity: 1; animation: paFlicker 0.5s ease; }
#pa-line.hidden { display: none; }
@keyframes paFlicker { 0%,20%{opacity:0.3;} 10%{opacity:0.9;} 30%{opacity:0.6;} 100%{opacity:1;} }
html.reduce-motion #pa-line.show { animation: none; }

/* 방송 중 발소리 엄폐 배지 — 지금이 이동 기회(초록 계열, 상단 중앙) */
#cover-badge {
  position: absolute; top: 20%; left: 50%; transform: translateX(-50%);
  background: rgba(10,30,18,0.9); border: 1px solid rgba(90,220,150,0.6);
  color: #b8f5d0; padding: 7px 16px; border-radius: 24px; font-size: 14px; font-weight: 700;
  box-shadow: 0 0 16px rgba(60,200,120,0.4); animation: badgePulse 0.8s infinite;
  white-space: nowrap; z-index: 20;
}
#cover-badge.hidden { display: none; }
html.reduce-motion #cover-badge { animation: none; }
html.colorblind #cover-badge { outline: 2px solid #fff; outline-offset: 1px; }

#hud-top {
  position: absolute; top: 18px; left: 18px; right: 18px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
#objective-box, #power-timer-box {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 10px 14px; backdrop-filter: blur(3px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.6);
}
#power-timer-box { text-align: right; min-width: 150px; }
.label { font-size: 11px; letter-spacing: 0.22em; color: var(--text-dim); text-transform: uppercase; }
#objective-text { font-size: 16px; font-weight: 600; margin-top: 3px; color: #e7eaee; }
#power-state { font-size: 12px; margin-top: 2px; color: var(--text-dim); }
#power-state.restored { color: #5fd27a; }

#hud-items {
  position: absolute; bottom: 20px; left: 20px; display: flex; gap: 12px;
}
.item-slot {
  background: var(--panel); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px; padding: 8px 10px; display: flex; align-items: center; gap: 8px;
  opacity: 0.45; transition: opacity 0.3s, border-color 0.3s, box-shadow 0.3s;
  min-width: 92px;
}
.item-slot .icon { font-size: 20px; filter: grayscale(1) brightness(0.7); }
.item-slot .cap { font-size: 12px; color: var(--text-dim); }
.item-slot.have { opacity: 1; border-color: var(--panel-border); box-shadow: 0 0 14px rgba(181,18,27,0.25); }
.item-slot.have .icon { filter: none; }
.item-slot.have .cap { color: var(--text); }
/* 획득 순간 펀치 + 글로우 */
.item-slot.pickup { animation: pickupPunch 0.45s ease; }
@keyframes pickupPunch {
  0% { transform: scale(1); }
  35% { transform: scale(1.28); box-shadow: 0 0 26px rgba(255,210,74,0.8); }
  100% { transform: scale(1); }
}

#interact-prompt {
  position: absolute; bottom: 24%; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-border);
  padding: 8px 16px; border-radius: 30px; font-size: 15px; color: #e7eaee;
  box-shadow: 0 4px 18px rgba(0,0,0,0.7);
}
#hide-indicator {
  position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%);
  background: rgba(10,12,16,0.85); border: 1px solid var(--panel-border);
  padding: 8px 16px; border-radius: 30px; font-size: 15px; color: #cfe8d0;
}
#hide-indicator.tense {
  background: rgba(40,6,8,0.9); border-color: rgba(255,80,70,0.7); color: #ffb4ad;
  font-weight: 700; animation: badgePulse 0.7s infinite;
}
/* 숨 게이지 바(남은 숨) — 숨는 중에만 표시 */
.breath-bar {
  margin-top: 6px; height: 6px; width: 160px; border-radius: 4px;
  background: rgba(255,255,255,0.14); overflow: hidden;
}
.breath-bar > span {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #5ad1e6, #8ae6c0);
  transition: width 0.12s linear;
}
.breath-bar.low > span { background: linear-gradient(90deg, #ff5a4a, #ff9060); }

/* 손전등 빛샘 경고(빛-소리 상충) — 손전등 켠 채 경비 가시거리 안일 때 */
#flash-warn {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  background: rgba(46,30,6,0.92); border: 1px solid rgba(255,200,70,0.7);
  color: #ffdf8a; padding: 7px 15px; border-radius: 24px; font-size: 14px; font-weight: 700;
  box-shadow: 0 0 16px rgba(255,180,50,0.4); animation: badgePulse 0.8s infinite;
  white-space: nowrap; z-index: 20;
}
#flash-warn.hidden { display: none; }
html.reduce-motion #flash-warn { animation: none; }
html.colorblind #flash-warn { outline: 2px solid #fff; outline-offset: 1px; }
html.reduce-motion .breath-bar > span { transition: none; }
.key {
  display: inline-block; background: #e7eaee; color: #111; font-weight: 700;
  border-radius: 4px; padding: 1px 7px; font-size: 13px; margin: 0 2px;
  box-shadow: 0 2px 0 #9aa0a6;
}

#toast {
  position: absolute; bottom: 34%; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(10,12,16,0.9); border-left: 3px solid var(--accent);
  padding: 10px 18px; border-radius: 4px; font-size: 14px; color: #e7eaee;
  opacity: 0; transition: opacity 0.3s, transform 0.3s; max-width: 70vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#sprint-bar-wrap {
  position: absolute; bottom: 22px; right: 22px; width: 140px; height: 6px;
  background: rgba(255,255,255,0.08); border-radius: 3px;
}
#sprint-bar-wrap .sb-label {
  position: absolute; bottom: 10px; right: 0; font-size: 11px; color: var(--text-dim);
  white-space: nowrap; letter-spacing: 0.03em;
}
#sprint-bar { width: 100%; height: 100%; background: linear-gradient(90deg,#b5121b,#ff6b4a); transition: width 0.1s linear; border-radius: 3px; }

/* ---------- 화면(start/pause/fail/clear) ---------- */
.screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0a0c10 0%, #000 100%);
  text-align: center; padding: 24px;
  overflow-y: auto;            /* 내용이 길면 스크롤 — 제목/하단 잘림 방지 */
  overflow-x: hidden;
}
/* 세로 공간이 부족하면 가운데정렬 대신 위에서부터(잘림 방지) */
@media (max-height: 760px) { .screen { align-items: flex-start; } }
.screen.hidden, .hidden { display: none !important; }
.screen-inner { max-width: 640px; width: 100%; margin: auto; animation: fadeUp 0.6s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px);} to { opacity: 1; transform: none; } }

.game-title {
  font-size: clamp(40px, 7.5vw, 76px); font-weight: 900; letter-spacing: 0.04em;
  color: #e9ecef; line-height: 1.02;
  text-shadow: 0 0 30px rgba(181,18,27,0.4), 0 6px 20px rgba(0,0,0,0.8);
  animation: titleFlicker 6s infinite;
}
.game-title .accent { color: var(--accent); text-shadow: 0 0 26px rgba(255,20,20,0.7); }
@keyframes titleFlicker {
  0%,19%,21%,100% { opacity: 1; }
  20% { opacity: 0.4; }
  55% { opacity: 1; }
  56% { opacity: 0.6; }
  57% { opacity: 1; }
}
.subtitle { margin-top: 8px; font-size: 13px; letter-spacing: 0.4em; color: var(--text-dim); }
.tagline { margin-top: 12px; font-size: 16px; color: #c6b0b0; font-style: italic; }

.horror-btn {
  margin-top: 18px; display: inline-block;
  background: linear-gradient(180deg, #1a1c22, #0c0d11);
  color: #ececec; border: 1px solid var(--accent-soft);
  padding: 14px 42px; font-size: 18px; font-weight: 700; letter-spacing: 0.08em;
  border-radius: 4px; cursor: pointer; pointer-events: auto;
  transition: transform 0.12s, box-shadow 0.25s, background 0.25s;
  box-shadow: 0 0 0 rgba(181,18,27,0);
  font-family: var(--font);
}
.horror-btn:hover {
  background: linear-gradient(180deg, #241417, #140a0c);
  box-shadow: 0 0 26px rgba(181,18,27,0.55); transform: translateY(-1px);
  border-color: var(--accent);
}
.horror-btn:active { transform: translateY(1px); }
.horror-btn.ghost { border-color: rgba(255,255,255,0.14); color: var(--text-dim); margin-left: 10px; }
.horror-btn.ghost:hover { box-shadow: none; background: #16181d; color: var(--text); }

.controls-guide { margin-top: 22px; }
.cg-grid {
  display: grid; grid-template-columns: repeat(4, auto); gap: 9px 18px;
  justify-content: center; align-items: center;
  font-size: 13.5px; color: var(--text); max-width: 540px; margin: 0 auto;
}
.cg-grid span { white-space: nowrap; }
.cg-grid b { color: #e7eaee; }
.hint { margin-top: 20px; font-size: 13px; color: var(--text-dim); line-height: 1.6; }

.scr-title { font-size: clamp(34px, 7vw, 64px); font-weight: 900; letter-spacing: 0.05em; }
.scr-title.fail { color: var(--accent); text-shadow: 0 0 28px rgba(181,18,27,0.6); }
.scr-title.clear { color: #6fd98a; text-shadow: 0 0 28px rgba(60,200,100,0.5); }
.scr-sub { margin-top: 14px; font-size: 17px; color: #c0c5cb; }

/* 로딩 */
.loader-text { font-size: 18px; letter-spacing: 0.1em; color: var(--text); margin-bottom: 18px; }
.loader-bar { width: 300px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin: 0 auto; }
#loader-fill { width: 0%; height: 100%; background: linear-gradient(90deg,#7a1016,#ff5a4d); transition: width 0.2s; }
.loader-tip {
  margin-top: 22px; font-size: 14px; color: #c6b0b0; font-style: italic;
  max-width: 460px; margin-left: auto; margin-right: auto; line-height: 1.5; min-height: 2.6em;
}
.loader-tip b { color: #ffd24a; font-style: normal; }

@media (max-width: 560px) {
  .cg-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ======================= UI/UX 개선 추가 스타일 ======================= */

/* 발각 순간 화면 흔들림 */
#game-root.shake { animation: screenShake 0.5s cubic-bezier(.36,.07,.19,.97); }
@keyframes screenShake {
  0%,100% { transform: translate(0,0); }
  10% { transform: translate(-6px,3px); }
  25% { transform: translate(7px,-4px); }
  40% { transform: translate(-5px,5px); }
  55% { transform: translate(6px,-3px); }
  70% { transform: translate(-4px,2px); }
  85% { transform: translate(3px,-2px); }
}

/* 시작화면 공략 4단계 스텝 카드 */
.steps {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 18px auto 4px; flex-wrap: wrap; max-width: 560px;
}
.step {
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: 3px; min-width: 82px; padding: 9px 10px 8px;
  background: rgba(16,20,28,0.9); border: 1px solid rgba(130,20,24,0.4);
  border-radius: 10px;
}
.step-ico { font-size: 23px; line-height: 1; }
.step-n {
  position: absolute; top: -9px; left: -9px; width: 20px; height: 20px;
  background: var(--accent); color: #fff; border-radius: 50%;
  font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 10px rgba(181,18,27,0.6);
}
.step-t { font-size: 13px; font-weight: 700; color: #e7eaee; }
.step-arrow { color: var(--accent); font-size: 18px; font-weight: 800; opacity: 0.8; }

/* 조작 안내 키캡(시작화면) — 간격만 보강(.key 기존 스타일 재사용) */
.cg-grid span { display: flex; align-items: center; gap: 4px; justify-content: center; }

/* 접이식 도움말 */
.help { margin-top: 22px; max-width: 560px; margin-left: auto; margin-right: auto; }
.help summary {
  cursor: pointer; font-size: 13px; color: var(--key-col); letter-spacing: 0.02em;
  list-style: none; text-align: center; padding: 6px;
}
.help summary::-webkit-details-marker { display: none; }
.help summary:hover { color: #ffe9a8; }
.help .hint { margin-top: 10px; text-align: left; }

/* 경비 상태 배지 */
#guard-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 19px; font-weight: 800; margin-top: 2px;
  padding: 2px 2px; letter-spacing: 0.01em; transition: color 0.2s;
}
#guard-badge .gb-dot {
  width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none;
}
#guard-badge.patrol { color: #aeb4bc; }
#guard-badge.patrol .gb-dot { background: #8b929b; border-radius: 50%; }
#guard-badge.suspect { color: #ffcf4a; }
#guard-badge.suspect .gb-dot { background: #ffcf4a; border-radius: 2px; box-shadow: 0 0 8px #ffcf4a; animation: badgePulse 1s infinite; }
#guard-badge.search { color: #ffb24a; }
#guard-badge.search .gb-dot { background: #ffb24a; border-radius: 2px; box-shadow: 0 0 6px #ffb24a; }
#guard-badge.chase { color: #ff5a4d; }
#guard-badge.chase .gb-dot { background: #ff5a4d; border-radius: 0; box-shadow: 0 0 12px #ff5a4d; animation: badgePulse 0.4s infinite; }
@keyframes badgePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* 스태미너 소진 경고 */
#sprint-bar-wrap.low #sprint-bar { background: #ff5a4d; animation: badgePulse 0.5s infinite; }

/* 상태화면 공통 통계 블록 */
.run-stats {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin: 22px auto 6px; max-width: 600px;
}
.run-stats .rs {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 84px; padding: 11px 10px;
  background: rgba(16,20,28,0.85); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}
.run-stats .rs-ico { font-size: 18px; }
.run-stats .rs b { font-size: 17px; color: #e7eaee; font-weight: 800; }
.run-stats .rs small { font-size: 11px; color: var(--text-dim); letter-spacing: 0.04em; }

/* 실패 격려 문구 */
.scr-encourage { margin-top: 14px; font-size: 15px; color: #d9b3b0; font-style: italic; }

/* 일시정지 조작 리마인더 */
.scr-hint-mini { margin-top: 16px; font-size: 13px; color: var(--text-dim); }

/* 클리어 등급 뱃지 */
.clear-grade {
  margin: 18px auto 4px; width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 900; line-height: 1;
  border: 3px solid; animation: gradePop 0.5s ease;
}
.clear-grade.s { color: #ffe066; border-color: #ffe066; text-shadow: 0 0 20px rgba(255,224,102,0.8); box-shadow: 0 0 30px rgba(255,224,102,0.4); }
.clear-grade.a { color: #6fd98a; border-color: #6fd98a; text-shadow: 0 0 16px rgba(111,217,138,0.6); }
.clear-grade.b { color: #7ac0ff; border-color: #7ac0ff; }
.clear-grade.c { color: #c0a0a0; border-color: #a07878; }
.clear-grade-note { text-align: center; margin: 2px 0 10px; font-size: 13px; color: #cbb; opacity: 0.9; }
@keyframes gradePop { 0% { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }

@media (max-width: 560px) {
  .steps { gap: 3px; }
  .step { min-width: 70px; padding: 9px 6px; }
  .step-arrow { font-size: 14px; }
  .run-stats .rs { min-width: 76px; padding: 10px; }
}

/* 접근성: 모션 민감 사용자를 위해 흔들림·강한 펄스 완화 */
@media (prefers-reduced-motion: reduce) {
  #game-root.shake { animation: none; }
  #guard-badge.chase .gb-dot,
  #guard-badge.suspect .gb-dot,
  #sprint-bar-wrap.low #sprint-bar { animation: none; }
  .clear-grade { animation: none; }
  .game-title { animation: none; }
}


/* ======================= 93점 폴리시 추가 ======================= */

/* 시작 버튼 그룹 + 최고기록 */
.start-btns { display: flex; gap: var(--space-2); justify-content: center; align-items: center; }
.start-best {
  margin-top: var(--space-3); font-size: 15px; color: var(--key-col); font-weight: 700;
  letter-spacing: 0.02em; text-shadow: 0 0 10px rgba(255,210,74,0.3);
}

/* 설정 화면 */
.scr-title.set { color: #c7d0da; text-shadow: 0 0 22px rgba(120,160,220,0.4); }
.settings {
  display: flex; flex-direction: column; gap: var(--space-1); 
  margin: var(--space-3) auto; max-width: 440px; text-align: left;
}
.set-row {
  display: grid; grid-template-columns: 130px 1fr 54px; align-items: center; gap: var(--space-2);
  background: rgba(16,20,28,0.85); border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius); padding: 9px 14px; font-size: 14px; color: #e7eaee;
}
.set-row.toggle { grid-template-columns: 1fr auto; }
.set-row .set-val { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.set-row input[type=range] {
  -webkit-appearance: none; appearance: none; height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #ff6b4a); outline: none; cursor: pointer;
}
.set-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px rgba(255,90,74,0.8); cursor: pointer;
}
.set-row input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px rgba(255,90,74,0.8); cursor: pointer;
}
.set-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

/* 포커스 링(키보드 접근성) — 공포 테마 적색 글로우 */
.horror-btn:focus-visible,
.help summary:focus-visible,
.set-controls summary:focus-visible,
.set-row input:focus-visible {
  outline: 2px solid #ff6b4a; outline-offset: 3px;
  box-shadow: 0 0 14px rgba(255,90,74,0.6);
}
.horror-btn:focus { outline: none; } /* 마우스 클릭 시엔 숨김(:focus-visible만) */

/* 목표 변경 전환 애니메이션 */
#objective-box.obj-change { animation: objFlash 0.6s ease; }
@keyframes objFlash {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(255,210,74,0); }
  30% { transform: scale(1.04); box-shadow: -4px 0 16px rgba(255,210,74,0.5); border-color: var(--key-col); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(255,210,74,0); }
}
#objective-text { transition: opacity 0.25s ease; }

/* 사용자 수동 '모션 줄이기' */
html.reduce-motion #game-root.shake { animation: none !important; }
html.reduce-motion #guard-badge .gb-dot,
html.reduce-motion #sprint-bar-wrap.low #sprint-bar,
html.reduce-motion #hide-indicator.tense,
html.reduce-motion .clear-grade,
html.reduce-motion #objective-box.obj-change,
html.reduce-motion .game-title { animation: none !important; }

@media (max-width: 560px) {
  .set-row { grid-template-columns: 100px 1fr 44px; font-size: 13px; }
  .start-btns { flex-direction: column; }
}


/* 설정 버튼 그룹 */
.set-btns { display: flex; gap: var(--space-2); justify-content: center; align-items: center; }

/* 설정 내 조작법 안내(접이식) */
.set-controls { max-width: 540px; margin: 4px auto 14px; text-align: center; }
.set-controls summary {
  cursor: pointer; color: var(--text-dim); font-size: 14px; padding: 6px;
  list-style: none; user-select: none;
}
.set-controls summary::-webkit-details-marker { display: none; }
.set-controls summary:hover { color: var(--text); }
.set-controls[open] summary { color: var(--text); margin-bottom: 8px; }
.set-controls .cg-grid { font-size: 13px; }

/* 시작화면 최고기록 빈 상태 */
.start-best.empty { color: var(--text-dim); font-weight: 500; text-shadow: none; }

/* 색약 보조 모드: 상태를 색 외에 고대비 테두리/밝기로 강하게 구분 */
html.colorblind #guard-badge .gb-dot { outline: 2px solid #fff; outline-offset: 1px; }
html.colorblind #guard-badge.patrol .gb-dot { background: #d8dde3; }
html.colorblind #guard-badge.chase .gb-dot { background: #fff; outline-color: #ff0; }
html.colorblind #crosshair.active span { border-color: #fff; box-shadow: 0 0 10px #fff; }
html.colorblind .map-room .tag.fuse { background: #10243a; color: #cfe6ff; border-color: #fff; }
html.colorblind .map-room .tag.key { background: #2a2410; color: #fff3c0; border-color: #fff; }
html.colorblind .sw-fuse, html.colorblind .sw-key,
html.colorblind .sw-exit, html.colorblind .sw-power { text-shadow: 0 0 2px #000, 0 0 1px #fff; }


/* ======================= 모바일/터치 조작 ======================= */
.touch-hint {
  margin-top: var(--space-2); font-size: 12.5px; color: var(--text-dim);
  line-height: 1.5; max-width: 440px; margin-left: auto; margin-right: auto;
}
#touch-controls {
  position: absolute; inset: 0; z-index: 30; pointer-events: none;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#touch-controls.hidden { display: none; }
/* 오른쪽 절반: 시점 드래그 영역(투명) */
#touch-look {
  position: absolute; right: 0; top: 0; width: 55%; height: 78%;
  pointer-events: auto;
}
/* 왼쪽 가상 조이스틱 */
#touch-joy {
  position: absolute; left: 22px; bottom: 90px; width: 120px; height: 120px;
  border-radius: 50%; background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.18); pointer-events: auto;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.4);
}
#touch-joy-knob {
  position: absolute; left: 50%; top: 50%; width: 50px; height: 50px;
  margin: -25px 0 0 -25px; border-radius: 50%;
  background: rgba(255,90,74,0.55); border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 0 14px rgba(255,90,74,0.5); transition: transform 0.03s linear;
}
/* 우하단 액션 버튼 */
#touch-btns {
  position: absolute; right: 18px; bottom: 26px;
  display: grid; grid-template-columns: repeat(2, 64px); gap: 12px; pointer-events: auto;
}
.touch-btn {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(16,20,28,0.78); border: 2px solid rgba(255,255,255,0.22);
  color: #f0ede6; font-size: 24px; line-height: 1; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn small { font-size: 9px; opacity: 0.7; margin-top: 1px; }
.touch-btn:active { background: rgba(255,90,74,0.45); transform: scale(0.94); }
.touch-btn.on { background: rgba(255,210,74,0.4); border-color: var(--key-col); }


/* ======================= 난이도 선택 ======================= */
.difficulty { margin: var(--space-3) auto 0; max-width: 440px; }
.diff-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 0.04em; }
.diff-opts { display: flex; gap: 8px; justify-content: center; }
.diff-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px; border-radius: var(--radius);
  background: rgba(16,20,28,0.8); border: 1.5px solid rgba(255,255,255,0.14);
  color: #d8dce2; font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.diff-btn .di { font-size: 20px; line-height: 1; }
.diff-btn:hover { border-color: rgba(255,120,90,0.6); }
.diff-btn.active {
  background: rgba(255,90,74,0.22); border-color: #ff6b4a;
  box-shadow: 0 0 14px rgba(255,90,74,0.35); color: #fff;
}
.diff-btn:focus-visible { outline: 2px solid #ff6b4a; outline-offset: 2px; }
.diff-desc { min-height: 1.2em; margin-top: 8px; font-size: 12.5px; color: var(--text-dim); text-align: center; }
html.colorblind .diff-btn.active { outline: 2px solid #fff; outline-offset: 1px; }
@media (max-width: 560px) {
  .diff-btn { font-size: 12px; padding: 8px 4px; }
}


/* ======================= 시네마틱(인트로·엔딩) ======================= */
#cinematic {
  position: fixed; inset: 0; z-index: 40; pointer-events: auto;
  background: #000;                 /* 3D를 가리는 암전 — 환경 무관 동일 연출 */
  display: flex; align-items: center; justify-content: center;
}
#cinematic.hidden { display: none !important; }
.cine-bar { display: none; }        /* 텍스트 시네마틱에선 레터박스 바 불필요 */
.cine-sub {
  position: static; transform: none; max-width: 78vw; text-align: center;
  color: #e8e2da; font-size: clamp(20px, 3vw, 30px); font-weight: 600;
  letter-spacing: 0.01em; line-height: 1.6; text-shadow: 0 2px 18px rgba(0,0,0,0.95);
  opacity: 0; transition: opacity 0.7s ease; padding: 0 20px;
}
.cine-sub.show { opacity: 1; }
.cine-sub b { color: #ff6b5a; }
.cine-skip {
  position: absolute; right: 18px; bottom: 18px; font-size: 12px; color: rgba(255,255,255,0.45);
  letter-spacing: 0.02em;
}
.cine-skip .key { font-size: 11px; }
html.reduce-motion .cine-sub { transition: none; }
