/* style.css - 일본풍 공포 UI 스타일 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&display=swap');

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

:root {
  --red:    #c0392b;
  --red2:   #8b0000;
  --gold:   #c8a951;
  --white:  #f0e8d8;
  --dark:   #0a0505;
  --panel:  rgba(10,5,5,0.88);
}

body {
  background: #000;
  font-family: 'Noto Serif JP', serif;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

/* ─── 타이틀 ─── */
#title-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.title-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, #1a0000 0%, #000 70%);
}
/* 스캔라인 */
.title-bg::before {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.1) 2px,
    rgba(0,0,0,0.1) 4px
  );
  pointer-events: none;
}
.title-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='4' height='4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1' height='1' fill='%23300' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.45;
}
.title-content {
  position: relative; z-index: 2;
  text-align: center;
  animation: fadeIn 2s ease;
}
.title-jp {
  font-size: clamp(3rem, 10vw, 6rem);
  color: var(--red);
  text-shadow: 0 0 40px #c0392b88, 0 0 80px #c0392b44;
  letter-spacing: 0.3em;
  margin-bottom: 0.2em;
}
.title-en {
  font-size: clamp(1.2rem, 4vw, 2rem);
  color: var(--white);
  letter-spacing: 0.6em;
  opacity: 0.85;
  margin-bottom: 0.5em;
}
.title-sub {
  font-size: clamp(0.8rem, 2vw, 1rem);
  color: var(--gold);
  letter-spacing: 0.3em;
  margin-bottom: 2.5em;
  opacity: 0.7;
}

/* ─── 버튼 ─── */
.jp-btn {
  display: inline-block;
  padding: 0.7em 2.2em;
  border: 1px solid var(--red);
  background: var(--panel);
  color: var(--white);
  font-family: 'Noto Serif JP', serif;
  font-size: 1rem;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  margin: 0.4em;
  backdrop-filter: blur(4px);
}
.jp-btn:hover { background: var(--red2); box-shadow: 0 0 18px rgba(192,57,43,0.55); }
.jp-btn.secondary { border-color: #444; color: #999; }
.jp-btn.secondary:hover { background: #1a0808; box-shadow: none; }

/* ─── 게임 캔버스 ─── */
#game-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

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

#hud-fragments {
  position: absolute; top: 18px; left: 18px;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--red2);
  padding: 6px 14px;
  color: var(--white);
  letter-spacing: 0.15em;
  backdrop-filter: blur(6px);
}
#hud-battery {
  position: absolute; top: 18px; right: 18px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid #3a2020;
  padding: 6px 12px;
  color: var(--white);
  backdrop-filter: blur(6px);
}
#hud-stamina {
  position: absolute; top: 58px; right: 18px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid rgba(200,169,81,0.28);
  padding: 6px 12px;
  color: var(--white);
  backdrop-filter: blur(6px);
}
#hud-sanity {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--red2);
  padding: 6px 18px;
  color: var(--white);
  letter-spacing: 0.15em;
  backdrop-filter: blur(6px);
}
.hud-label { font-size: 0.7rem; opacity: 0.6; letter-spacing: 0.12em; }

/* 파편 점 */
.frag-dots { display: flex; gap: 7px; align-items: center; }
.frag-dot {
  color: #2a0808;
  font-size: 0.82rem;
  transition: color 0.5s, text-shadow 0.5s;
}
.frag-dot.collected {
  color: var(--red);
  text-shadow: 0 0 8px rgba(192,57,43,0.9), 0 0 22px rgba(192,57,43,0.35);
}

.gauge-wrap {
  width: 80px; height: 6px;
  background: #180808;
  border: 1px solid #3a1818;
}
.gauge-wrap.wide { width: 150px; }
.gauge-fill {
  height: 100%;
  transition: width 0.4s ease;
}
.battery-fill {
  background: linear-gradient(90deg, #b07608, #f1c40f);
  box-shadow: 0 0 5px rgba(241,196,15,0.4);
}
.sanity-fill {
  background: linear-gradient(90deg, var(--red2), var(--red));
  box-shadow: 0 0 5px rgba(192,57,43,0.5);
}
.stamina-fill {
  background: linear-gradient(90deg, #356b4b, #88c070);
  box-shadow: 0 0 5px rgba(136,192,112,0.35);
}
#battery-text, #sanity-text, #stamina-text {
  font-size: 0.72rem;
  opacity: 0.8;
  min-width: 2.4em;
  text-align: right;
}

/* ─── 디버그 좌표 표시 ─── */
#debug-pos {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  color: #0f0;
  font-family: monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  pointer-events: none;
}

/* ─── 방 이름 표시 ─── */
#room-name {
  position: absolute; bottom: 28px; right: 20px;
  color: rgba(192,57,43,0.38);
  font-size: 0.66rem;
  letter-spacing: 0.45em;
  pointer-events: none;
  transition: color 0.8s;
}

/* ─── 조준점 (십자) ─── */
#crosshair {
  position: absolute; top: 50%; left: 50%;
  width: 20px; height: 20px;
  transform: translate(-50%, -50%);
}
#crosshair::before {
  content: ''; position: absolute;
  width: 100%; height: 1px;
  top: 50%; left: 0;
  background: rgba(255,255,255,0.48);
  transform: translateY(-50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.95);
}
#crosshair::after {
  content: ''; position: absolute;
  width: 1px; height: 100%;
  left: 50%; top: 0;
  background: rgba(255,255,255,0.48);
  transform: translateX(-50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.95);
}

/* ─── 조준점 active (상호작용 대상 바라볼 때) ─── */
#crosshair.active {
  width: 28px; height: 28px;
}
#crosshair.active::before {
  height: 2px;
  background: rgba(200,169,81,0.92);
  box-shadow: 0 0 8px rgba(200,169,81,0.7);
}
#crosshair.active::after {
  width: 2px;
  background: rgba(200,169,81,0.92);
  box-shadow: 0 0 8px rgba(200,169,81,0.7);
}

/* ─── 포인터락 클릭 안내 ─── */
#pointer-lock-hint {
  position: absolute; top: 43%; left: 50%;
  transform: translateX(-50%);
  background: rgba(10,5,5,0.82);
  border: 1px solid rgba(200,169,81,0.35);
  color: rgba(200,169,81,0.9);
  padding: 10px 24px;
  font-size: 0.82rem;
  letter-spacing: 0.2em;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(6px);
  animation: pulse 1.8s ease-in-out infinite;
  white-space: nowrap;
}

/* ─── 상호작용 힌트 ─── */
#interact-hint {
  position: absolute; top: 56%; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(200,169,81,0.5);
  color: var(--gold);
  padding: 5px 16px;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  animation: pulse 1.2s infinite;
  backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 8px;
}
#interact-hint kbd {
  display: inline-block;
  background: rgba(200,169,81,0.12);
  border: 1px solid rgba(200,169,81,0.6);
  color: var(--gold);
  padding: 1px 7px;
  font-size: 0.75rem;
  font-family: monospace;
  border-radius: 2px;
  line-height: 1.5;
}

/* ─── 정신력 이상 효과 ─── */
#sanity-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 9;
  background: radial-gradient(ellipse at center, transparent 50%, transparent 100%);
  transition: background 1s;
}
#sanity-vignette.low {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(140,0,0,0.45) 100%);
}
#sanity-vignette.critical {
  background: radial-gradient(ellipse at center, transparent 20%, rgba(140,0,0,0.75) 100%);
  animation: shake 0.15s infinite;
}
body.reduce-shake #sanity-vignette.critical {
  animation: none;
}
#sanity-noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 8;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px;
  animation: noise 0.05s steps(1) infinite;
}

/* ─── 몹 근접 경보 ─── */
#mob-warning {
  position: fixed; inset: 0; pointer-events: none; z-index: 9;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(160,0,0,0.6) 100%);
  opacity: 0;
}
#mob-warning.near  { animation: warnPulse 1.8s ease-in-out infinite; }
#mob-warning.close { animation: warnPulse 0.55s ease-in-out infinite; }
@keyframes warnPulse {
  0%,100% { opacity: 0; }
  50%     { opacity: 1; }
}

/* ─── 점프스케어 이모지 (img 위에 겹쳐 표시) ─── */
#jumpscare-emoji {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 35vmin;
  line-height: 1;
  background: #000;
  z-index: 201;
}
#jumpscare-emoji.visible { display: flex; }

/* ─── 점프스케어 ─── */
#jumpscare-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: #000;
  animation: flickerIn 0.05s ease;
}
#jumpscare-face {
  width: 100vw; height: 100vh;
  object-fit: cover;
  filter: contrast(130%) brightness(0.85);
  animation: scaleIn 0.08s ease;
}
.figure-distraction {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 190;
  opacity: 0.92;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 230, 190, 0.18), transparent 20%),
    radial-gradient(ellipse at center, transparent 38%, rgba(120, 0, 0, 0.62) 100%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.75'/%3E%3C/svg%3E");
  background-size: auto, auto, 160px 160px;
  mix-blend-mode: screen;
  animation: figureDistraction 0.12s steps(2) infinite;
  transition: opacity 0.42s ease;
}
.figure-distraction.fade-out { opacity: 0; }
body.reduce-shake .figure-distraction { animation: none; }
@keyframes figureDistraction {
  0%   { filter: contrast(150%) brightness(1.7); transform: translate3d(-1px, 0, 0); }
  50%  { filter: contrast(190%) brightness(0.72); transform: translate3d(1px, -1px, 0); }
  100% { filter: contrast(150%) brightness(1.4); transform: translate3d(0, 1px, 0); }
}
@keyframes scaleIn {
  from { transform: scale(0.5); }
  to   { transform: scale(1); }
}
@keyframes flickerIn {
  0%,50% { opacity: 0; }
  100%   { opacity: 1; }
}

/* ─── 쪽지 모달 ─── */
#note-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(2px);
}
.note-box {
  background: #f0e8d0;
  border: 1px solid #8b7355;
  box-shadow: 0 0 40px rgba(0,0,0,0.7), inset 0 0 20px rgba(180,155,100,0.15);
  max-width: 360px;
  min-width: 280px;
}
.note-title {
  color: #3a2208 !important;
  text-shadow: none !important;
  border-bottom: 1px solid rgba(139,115,85,0.35);
  padding-bottom: 0.5em;
  margin-bottom: 0.8em;
}
.note-text {
  color: #2a1a08;
  font-size: 0.88rem;
  line-height: 2.0;
  letter-spacing: 0.1em;
  white-space: pre-wrap;
  text-align: center;
  padding: 0 0 0.8em;
  min-height: 4em;
}

/* ─── 퍼즐 모달 ─── */
#puzzle-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(2px);
}
.modal-box {
  background: #0a0303;
  border: 1px solid var(--red2);
  box-shadow: 0 0 40px rgba(192,57,43,0.25), inset 0 0 30px rgba(0,0,0,0.6);
  padding: 2rem 2.5rem;
  min-width: 320px; max-width: 460px;
  text-align: center;
}
.modal-title {
  color: var(--red);
  font-size: 1.2rem;
  letter-spacing: 0.4em;
  margin-bottom: 0.5em;
  text-shadow: 0 0 14px rgba(192,57,43,0.5);
}
.modal-hint {
  color: var(--gold);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  margin-bottom: 1.5em;
  opacity: 0.75;
  line-height: 1.7;
}
.puzzle-section { margin-bottom: 1.2em; }
.puzzle-input {
  background: #120606;
  border: 1px solid #3a1010;
  border-bottom: 2px solid var(--red);
  color: var(--white);
  font-family: 'Noto Serif JP', serif;
  font-size: 1.8rem;
  text-align: center;
  letter-spacing: 0.5em;
  width: 8rem;
  padding: 0.4em 0.6em;
}
.puzzle-input:focus { outline: none; border-color: var(--red); }
.sequence-wrap {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap; margin-bottom: 1em;
}
.seq-item {
  background: #120606;
  border: 1px solid #444;
  color: var(--white);
  padding: 0.5em 1.1em;
  cursor: pointer;
  font-size: 0.88rem;
  letter-spacing: 0.1em;
  transition: border-color 0.15s, background 0.15s;
}
.seq-item:hover  { border-color: var(--gold); background: #1a0808; }
.seq-item.chosen { border-color: var(--red); background: #220808; }
.sequence-result {
  color: var(--gold);
  font-size: 0.8rem;
  min-height: 1.4em;
  letter-spacing: 0.15em;
  opacity: 0.8;
}
.puzzle-feedback {
  margin-top: 0.8em;
  min-height: 1.2em;
  font-size: 0.88rem;
  letter-spacing: 0.1em;
}
.puzzle-feedback.ok  { color: #27ae60; }
.puzzle-feedback.err { color: var(--red); }
.modal-btns { display: flex; justify-content: center; gap: 0.5em; margin-top: 1em; }

/* ─── 게임오버 / 클리어 ─── */
#gameover-screen, #clear-screen {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 1.5s ease;
}
#gameover-screen {
  background: radial-gradient(ellipse at center, #0e0000 0%, #000 75%);
}
#clear-screen {
  background: radial-gradient(ellipse at center, #0a0806 0%, #000 75%);
}
.end-content { text-align: center; }
.end-text {
  font-size: clamp(1.5rem, 5vw, 3rem);
  color: var(--white);
  letter-spacing: 0.3em;
  margin-bottom: 0.4em;
  text-shadow: 0 0 30px rgba(255,255,255,0.15);
}
.end-jp {
  color: var(--red);
  font-size: clamp(0.9rem, 2.5vw, 1.3rem);
  letter-spacing: 0.5em;
  margin-bottom: 2.5em;
  opacity: 0.55;
}
.clear .end-text { color: #fff8e7; text-shadow: 0 0 30px rgba(200,169,81,0.2); }
.clear .end-jp   { color: var(--gold); }

/* ─── 토스트 ─── */
#toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(200,169,81,0.35);
  color: var(--gold);
  padding: 8px 22px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  z-index: 30;
  animation: toastIn 0.3s ease;
  backdrop-filter: blur(6px);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── 효과음 자막 ─── */
#subtitle {
  position: fixed;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  z-index: 31;
  max-width: min(520px, calc(100vw - 36px));
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(200,169,81,0.28);
  color: rgba(240,232,216,0.9);
  padding: 7px 18px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-align: center;
  backdrop-filter: blur(5px);
  pointer-events: none;
  animation: subtitleIn 0.18s ease;
}
@keyframes subtitleIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── 공통 애니메이션 ─── */
@keyframes noise {
  0%  { background-position: 0 0; }
  20% { background-position: -5px -10px; }
  40% { background-position: -10px 5px; }
  60% { background-position: 5px -5px; }
  80% { background-position: -5px 10px; }
  100%{ background-position: 0 0; }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@keyframes shake {
  0%  { transform: translate(0,0); }
  25% { transform: translate(-2px,1px); }
  50% { transform: translate(2px,-1px); }
  75% { transform: translate(-1px,2px); }
  100%{ transform: translate(0,0); }
}

/* ─── 설정 패널 ─── */
#settings-panel {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.settings-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(6px);
}
.settings-box {
  position: relative; z-index: 1;
  background: #0a0303;
  border: 1px solid var(--red2);
  box-shadow: 0 0 50px rgba(192,57,43,0.2);
  padding: 2.5rem 3rem;
  min-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  animation: fadeIn 0.2s ease;
}
@media (max-width: 600px) {
  .settings-box {
    padding: 1.5rem 1rem;
    min-width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }
  .setting-label { min-width: 68px; font-size: 0.76rem; }
}
.settings-title {
  color: var(--red);
  font-size: 1.6rem;
  letter-spacing: 0.5em;
  margin-bottom: 2rem;
  text-shadow: 0 0 14px rgba(192,57,43,0.4);
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 1.6rem;
}
.setting-label {
  color: var(--white);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  min-width: 80px;
  text-align: left;
  opacity: 0.85;
}
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex: 1;
}
.slider-wrap input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: #3a1010;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.slider-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--red);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(192,57,43,0.7);
  cursor: pointer;
}
.slider-wrap input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--red);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.slider-wrap span {
  color: var(--gold);
  font-size: 0.78rem;
  min-width: 3.2em;
  text-align: right;
  opacity: 0.9;
}
.setting-toggle {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--red2);
  color: var(--white);
  font-family: 'Noto Serif JP', serif;
  font-size: 0.82rem;
  letter-spacing: 0.15em;
  padding: 0.45em 1em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.setting-toggle:hover { background: var(--red2); box-shadow: 0 0 12px rgba(192,57,43,0.4); }
.setting-toggle.active { background: var(--red2); border-color: var(--red); box-shadow: 0 0 12px rgba(192,57,43,0.5); }
.setting-select {
  flex: 1;
  background: #120606;
  border: 1px solid #3a1010;
  color: var(--white);
  font-family: 'Noto Serif JP', serif;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  padding: 0.45em 0.7em;
  cursor: pointer;
  outline: none;
}
.setting-select option { background: #0a0303; }

/* ─── 일시정지 메뉴 ─── */
#pause-menu {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
}
.pause-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
}
.pause-content {
  position: relative; z-index: 1;
  text-align: center;
  animation: fadeIn 0.2s ease;
}
.pause-title {
  color: var(--red);
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: 0.5em;
  text-shadow: 0 0 24px rgba(192,57,43,0.4);
  margin-bottom: 0.2em;
}
.pause-sub {
  color: var(--white);
  font-size: 0.82rem;
  letter-spacing: 0.4em;
  opacity: 0.45;
  margin-bottom: 2.2rem;
}
.pause-content .jp-btn {
  display: block;
  width: 200px;
  margin: 0.45em auto;
}

/* ─── 목표 HUD ─── */
#hud-objective {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(192,57,43,0.28);
  padding: 4px 16px;
  color: rgba(240,232,216,0.72);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  pointer-events: none;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) {
  #hud-objective { top: auto; bottom: 68px; font-size: 0.65rem; }
}

/* ─── 쪽지 로그 모달 ─── */
#note-log-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(2px);
}
.note-log-box {
  background: #f0e8d0;
  border: 1px solid #8b7355;
  box-shadow: 0 0 40px rgba(0,0,0,0.7), inset 0 0 20px rgba(180,155,100,0.15);
  width: min(520px, 92vw);
  min-width: 300px;
  max-height: 70vh;
  display: flex; flex-direction: column;
}
.note-log-title {
  color: #3a2208 !important;
  text-shadow: none !important;
  border-bottom: 1px solid rgba(139,115,85,0.35);
  padding-bottom: 0.5em;
  margin-bottom: 0.6em;
}
.note-log-view {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: stretch;
  gap: 0.7em;
  min-height: 230px;
}
.note-log-arrow {
  border: 1px solid rgba(139,115,85,0.45);
  background: rgba(70,40,15,0.08);
  color: #5c3710;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.note-log-arrow:hover:not(:disabled) {
  background: rgba(139,115,85,0.18);
}
.note-log-arrow:disabled {
  opacity: 0.28;
  cursor: default;
}
.note-log-page {
  min-width: 0;
  border: 1px solid rgba(139,115,85,0.22);
  background: rgba(255,248,220,0.28);
  padding: 0.9em 1em;
  overflow-y: auto;
}
.note-log-count {
  color: #8b7355;
  font-size: 0.72rem;
  text-align: center;
  opacity: 0.75;
  margin-bottom: 0.65em;
}
.note-log-text {
  color: #2a1a08; font-size: 0.82rem;
  line-height: 1.8; letter-spacing: 0.06em;
  white-space: pre-line;
}
.note-log-empty {
  color: #8b7355; font-size: 0.8rem;
  text-align: center; padding: 1.2em 0;
  opacity: 0.65;
}

/* ─── 엔딩 통계 ─── */
.end-stats {
  color: rgba(240,232,216,0.5);
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  margin-bottom: 2rem;
}
.clear .end-stats { color: rgba(200,169,81,0.55); }

/* ─── 인트로 로딩 퍼센트 ─── */
#intro-load-pct {
  position: absolute;
  bottom: 82px;
  font-size: 0.66rem;
  color: rgba(200,169,81,0.5);
  letter-spacing: 0.25em;
}

/* ─── 조작 안내 모달 ─── */
#help-modal {
  position: fixed; inset: 0; z-index: 210;
  display: flex; align-items: center; justify-content: center;
}
.help-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(6px);
}
.help-box {
  position: relative; z-index: 1;
  background: #0a0303;
  border: 1px solid var(--red2);
  box-shadow: 0 0 50px rgba(192,57,43,0.2);
  padding: 2.2rem 2.8rem;
  min-width: 320px;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  animation: fadeIn 0.2s ease;
}
@media (max-width: 480px) {
  .help-box { padding: 1.5rem 1.2rem; min-width: calc(100vw - 32px); }
}
.help-title {
  color: var(--red);
  font-size: 1.4rem;
  letter-spacing: 0.5em;
  margin-bottom: 1.6rem;
  text-shadow: 0 0 14px rgba(192,57,43,0.4);
}
.help-keybinds { margin-bottom: 1.6rem; text-align: left; }
.help-key-row {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.5em 0;
  border-bottom: 1px solid rgba(200,169,81,0.1);
  color: var(--white);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
}
.help-key-row:last-child { border-bottom: none; }
.help-key-row kbd {
  background: rgba(200,169,81,0.1);
  border: 1px solid rgba(200,169,81,0.5);
  color: var(--gold);
  padding: 2px 10px;
  font-family: monospace;
  font-size: 0.82rem;
  border-radius: 2px;
  min-width: 82px;
  text-align: center;
  letter-spacing: 0.05em;
}

/* ─── 진행 방식 모달 ─── */
#howto-modal {
  position: fixed; inset: 0; z-index: 210;
  display: flex; align-items: center; justify-content: center;
}
.howto-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(6px);
}
.howto-body {
  text-align: left;
  margin-bottom: 1.6rem;
  color: var(--white);
  font-size: 0.84rem;
  line-height: 1.6;
  letter-spacing: 0.03em;
}
.howto-body h4 {
  color: var(--gold);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  margin: 1.1rem 0 0.5rem;
  border-bottom: 1px solid rgba(200,169,81,0.2);
  padding-bottom: 0.3em;
}
.howto-body h4:first-child { margin-top: 0; }
.howto-body ul {
  margin: 0; padding-left: 1.2rem;
  list-style: disc;
}
.howto-body ul ul { margin-top: 0.3em; list-style: circle; }
.howto-body li { margin: 0.3em 0; }

/* ─── 인트로 에러 UI ─── */
#intro-error {
  position: absolute;
  bottom: 100px;
  text-align: center;
}
#intro-error-msg {
  color: rgba(192,57,43,0.85);
  font-size: 0.82rem;
  letter-spacing: 0.15em;
  margin-bottom: 1.2em;
  line-height: 1.8;
}
.intro-error-btns { display: flex; gap: 0.6em; justify-content: center; }

/* ─── 스토리 인트로 로딩 화면 ─── */
#intro-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#intro-text {
  color: var(--white);
  font-family: 'Noto Serif JP', serif;
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  text-align: center;
  line-height: 2;
  letter-spacing: 0.12em;
  white-space: pre-wrap;
  opacity: 0;
  transition: opacity 1.2s ease;
  max-width: 560px;
  padding: 0 2rem;
}
#intro-text.visible { opacity: 1; }
#intro-text.big {
  font-size: clamp(2.4rem, 6vw, 4rem);
  letter-spacing: 0.3em;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(200,169,81,0.35);
}
#intro-bar-wrap {
  position: absolute;
  bottom: 72px;
  left: 12%;
  right: 12%;
  height: 1px;
  background: rgba(255,255,255,0.12);
}
#intro-bar {
  height: 100%;
  width: 0%;
  background: rgba(200,169,81,0.6);
  transition: width 0.5s ease;
}
#intro-skip {
  position: absolute;
  bottom: 44px;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.22);
  letter-spacing: 0.25em;
}

/* ─── 필름 그레인 오버레이 ─── */
#grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9990;
  opacity: 0;
  transition: opacity 1.2s ease;
  background-size: 512px 512px;
  animation: grain-shift 0.09s steps(1) infinite;
}
#grain-overlay.visible {
  opacity: 0.1;
}

@keyframes grain-shift {
  0%   { background-position:   0px   0px; }
  13%  { background-position: -55px -32px; }
  26%  { background-position:  22px -68px; }
  39%  { background-position: -80px  44px; }
  52%  { background-position:  64px -18px; }
  65%  { background-position: -24px  78px; }
  78%  { background-position:  72px  52px; }
  91%  { background-position: -42px -74px; }
}
