/* =====================================================================
   비밀의 방 — UI 스타일
   · 따뜻한 파스텔(노란 벽 · 분홍 지붕) 톤
   · 모바일 가로(844×390 · 844×344) · 세로(390×844) · 데스크톱(1440×900)
   · HUD는 위, 터치 조작은 아래 — 겹침 0px
   ===================================================================== */
:root {
  --cream: #fff8ea;
  --paper: #fffdf7;
  --paper2: #fff2da;
  --ink: #4b382b;
  --ink2: #6d5546;
  --dim: #9b8271;
  --line: rgba(139, 106, 78, .22);
  --line2: rgba(139, 106, 78, .42);
  --pink: #f28aa6;
  --pinkDark: #d96d8c;
  --pinkLight: #ffd6e2;
  --mint: #7fd3b6;
  --mintDark: #4fae90;
  --mintLight: #d6f4e9;
  --gold: #f3bf5e;
  --goldDark: #d79f3c;
  --sky: #a7d9f2;
  --wood: #b8845c;
  --shadow: 0 10px 28px rgba(94, 62, 38, .18);
  --shadow2: 0 4px 14px rgba(94, 62, 38, .14);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: #f6e7cd; color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; overflow: hidden; background: #bfe9f7; }

#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(255,250,235,0) 55%, rgba(96, 62, 34, .28) 100%);
}
#flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255, 248, 205, .62), rgba(255, 224, 140, 0) 62%);
  transition: opacity .2s ease-out;
}
#damage {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 120, 150, 0) 40%, rgba(240, 92, 128, .45) 100%);
  transition: opacity .16s ease-out;
}

.hidden { display: none !important; }

/* ============================ 버튼 공통 ============================ */
.btn {
  font-family: var(--font);
  font-size: 14px; font-weight: 700; color: var(--ink);
  background: linear-gradient(180deg, #fffdf8, #ffeecf);
  border: 2px solid var(--line2);
  border-radius: 14px;
  padding: 9px 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(150, 112, 78, .22);
  transition: transform .08s ease, box-shadow .08s ease, background .15s;
  min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: linear-gradient(180deg, #fffefb, #ffe6bd); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(150, 112, 78, .22); }
.btn.primary {
  color: #fff; border-color: #d76d8b;
  background: linear-gradient(180deg, #ffa8be, #ef7f9d);
  box-shadow: 0 4px 0 #c9607d, 0 8px 18px rgba(217, 109, 140, .28);
}
.btn.primary:hover { background: linear-gradient(180deg, #ffb6c9, #f28aa6); }
.btn.primary:disabled { opacity: .5; cursor: default; transform: none; }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--line); color: var(--ink2); }
/* 타이틀 「▶ 이어서 하기」 */
.btn.continue { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 6px auto 0; padding: 9px 24px; font-size: 14px; border-radius: 12px; background: #e9f9f1; border-color: #6cc0a4; color: #1f6b52; }
.btn.continue small { font-size: 10.5px; font-weight: 800; color: #2f8f71; }
.btn.small { font-size: 12px; padding: 6px 10px; min-height: 34px; }
.btn.big { font-size: 18px; padding: 13px 30px; border-radius: 18px; min-height: 52px; letter-spacing: .02em; }
.btn.icon {
  padding: 0; width: 36px; min-width: 36px; height: 36px; min-height: 36px;
  border-radius: 11px; font-size: 15px; box-shadow: 0 2px 0 rgba(150, 112, 78, .2);
}
.btn.icon.bgm { font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.btn.icon.fs { width: auto; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn.icon[aria-pressed="true"].fs { background: linear-gradient(180deg, #fff3c1, #ffe08a); border-color: var(--goldDark); }
kbd {
  font-family: var(--font); font-size: 10px; font-weight: 800;
  background: rgba(75, 56, 43, .1); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; color: var(--ink2);
}

/* ============================ HUD ============================ */
#hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; font-size: 13px; }
.hud-top {
  display: flex; align-items: flex-start; gap: 7px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(9px + env(safe-area-inset-right, 0px)) 0 calc(9px + env(safe-area-inset-left, 0px));
}
.hud-card {
  background: linear-gradient(165deg, rgba(255, 252, 244, .95), rgba(255, 240, 214, .93));
  border: 2px solid rgba(196, 152, 108, .45);
  border-radius: 12px;
  padding: 5px 9px;
  box-shadow: var(--shadow2);
}
.hud-card .row { display: flex; align-items: center; gap: 6px; }
.room-block { min-width: 168px; }
.room-badge { font-size: 13px; }
.room-name { font-size: 13px; font-weight: 800; color: var(--ink); }
.room-frag { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--ink2); }
.bar { position: relative; height: 7px; margin-top: 4px; background: rgba(120, 88, 60, .16); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--mint), var(--gold)); transition: width .25s ease-out; }
.bar.thin { height: 5px; margin-top: 4px; }
.keys-row { display: flex; gap: 3px; margin-top: 3px; }
.key-dot {
  width: 17px; height: 17px; border-radius: 5px; font-size: 10px; line-height: 15px; text-align: center;
  background: rgba(120, 88, 60, .1); border: 1px solid rgba(120, 88, 60, .2); color: var(--dim);
  display: inline-flex; align-items: center; justify-content: center;
}
.key-dot.on { background: linear-gradient(180deg, #fff2b8, #f7cd67); border-color: var(--goldDark); color: #7a5312; font-size: 11px; }

.hud-notice { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 1px; }
.hint, .toast {
  max-width: min(560px, 100%);
  padding: 4px 12px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1.35; color: #6a4a1c;
  background: rgba(255, 247, 205, .95); border: 1.5px solid rgba(215, 159, 60, .5);
  box-shadow: 0 2px 8px rgba(150, 110, 60, .18);
  opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.toast { background: rgba(255, 252, 242, .96); border-color: rgba(196, 152, 108, .45); color: var(--ink); }
.hint.show, .toast.show { opacity: 1; transform: translateY(0); }

.time-block { min-width: 108px; display: flex; flex-direction: column; gap: 2px; }
.time-block .row { gap: 4px; }
.clock-ico { font-size: 12px; }
.timer { font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--ink); }
.timer.low { color: #d23f63; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.hearts { display: flex; gap: 1px; font-size: 12px; line-height: 1; }
.heart { color: rgba(190, 120, 140, .35); }
.heart.on { color: #ec5d85; text-shadow: 0 1px 0 rgba(255, 255, 255, .6); }

.hud-actions { display: flex; gap: 4px; pointer-events: auto; flex-wrap: nowrap; }
.hud-sub {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px 0 calc(10px + env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.item-chips { display: flex; gap: 4px; flex-wrap: wrap; max-width: 70%; }
.hud-sub { padding-right: calc(10px + env(safe-area-inset-right, 0px)); }
.chip {
  font-size: 10.5px; font-weight: 700; color: var(--ink2);
  background: rgba(255, 252, 244, .92); border: 1.5px solid rgba(196, 152, 108, .4);
  border-radius: 999px; padding: 2px 8px;
  display: inline-flex; align-items: center; gap: 2px; white-space: nowrap;
}
.chip i { font-style: normal; font-size: 8.5px; opacity: .7; margin-left: 1px; }
.chip.hot { background: #ffe6c4; border-color: #e9a95c; }
.chip.cool { background: #dff1ff; border-color: #8cc4e6; }
/* 바닥 아이템 효과 칩 — 종류별 색으로 구분 */
.chip.eff { color: #fff; border-color: rgba(255, 255, 255, .7); box-shadow: 0 1px 3px rgba(90, 60, 40, .22); }
.chip.candy { background: linear-gradient(135deg, #ff9ecb, #ffbe6f); }
.chip.cloak { background: linear-gradient(135deg, #c4bcff, #9f9ae0); }
.chip.orb { background: linear-gradient(135deg, #b89cff, #8f7ae0); }
.chip.shield { background: linear-gradient(135deg, #8fe0c0, #5cc0a0); color: #fff; border-color: rgba(255, 255, 255, .7); }
.chip.eff i, .chip.shield i { opacity: .85; }
.score-chip {
  margin-left: auto; font-size: 11px; font-weight: 700; color: #7a5312;
  background: rgba(255, 247, 205, .95); border: 1.5px solid rgba(215, 159, 60, .5);
  border-radius: 999px; padding: 2px 9px;
}

/* 조사 버튼(안내 겸용) — 손가락이 주 입력인 기기에서만 오른쪽 조사 버튼이 그 역할을 한다.
   터치스크린이 달렸어도 마우스·키보드로 하는 노트북(pointer: fine, hover 가능)에서는
   「○○ 조사  E」 안내를 그대로 보여 준다 — 안 보이면 조사 지점을 지나쳐도 알 수 없다. */
.touch-primary .prompt { display: none; }
/* 터치 조작부(조이스틱·버튼)가 함께 떠 있는 화면에서는 안내를 그 위로 올려 겹치지 않게 */
.touch-device:not(.touch-primary) .prompt { bottom: calc(134px + env(safe-area-inset-bottom, 0px)); }
.prompt {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-size: 13.5px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #8fd9bd, #59b795);
  border: 2px solid #3f9b7c; border-radius: 999px;
  padding: 9px 16px; cursor: pointer; pointer-events: auto;
  box-shadow: 0 4px 0 #3f9b7c, 0 10px 22px rgba(63, 155, 124, .3);
  animation: prompt-in .18s ease-out;
  max-width: 70vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prompt:hover { filter: brightness(1.05); }
.prompt kbd { background: rgba(255, 255, 255, .28); border-color: rgba(255, 255, 255, .45); color: #fff; }
@keyframes prompt-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================ 터치 조작 ============================ */
.touchpad { position: absolute; inset: 0; pointer-events: none; }
.joy {
  position: absolute; left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: 108px; height: 108px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 251, 240, .62), rgba(255, 240, 210, .38));
  border: 2px solid rgba(255, 253, 245, .75);
  box-shadow: 0 6px 18px rgba(80, 50, 30, .18);
  pointer-events: auto; touch-action: none;
}
.joy-base { position: absolute; inset: 0; }
.joy-dir { position: absolute; font-size: 9px; color: rgba(90, 62, 40, .5); }
.d-up { left: 50%; top: 4px; transform: translateX(-50%); }
.d-down { left: 50%; bottom: 4px; transform: translateX(-50%); }
.d-left { left: 4px; top: 50%; transform: translateY(-50%); }
.d-right { right: 4px; top: 50%; transform: translateY(-50%); }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%; background: linear-gradient(180deg, #fffdf6, #ffe6bd);
  border: 2px solid rgba(180, 138, 94, .65); box-shadow: 0 3px 8px rgba(90, 60, 35, .25);
  transition: transform .04s linear;
}
.tp-buttons {
  position: absolute; right: calc(12px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: flex-end; gap: 9px; pointer-events: none;
}
.tbtn {
  pointer-events: auto;
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-family: var(--font); font-size: 10.5px; font-weight: 800; color: var(--ink);
  background: linear-gradient(180deg, #fffdf6, #ffe8c2);
  border: 2px solid rgba(180, 138, 94, .6);
  box-shadow: 0 4px 0 rgba(150, 108, 68, .35), 0 8px 18px rgba(90, 60, 35, .18);
  touch-action: none;
}
.tbtn .tb-ico { font-size: 22px; line-height: 1; }
.tbtn.interact .tb-label { font-size: 10px; white-space: nowrap; }
.tbtn.interact { color: #fff; background: linear-gradient(180deg, #9fe3c9, #5dbd9c); border-color: #3f9b7c; box-shadow: 0 4px 0 #3f9b7c, 0 8px 18px rgba(63, 155, 124, .28); width: 72px; height: 72px; }
.tbtn:active { transform: translateY(2px); }
.tbtn.hide { display: none; }

/* ============================ 오버레이 · 패널 ============================ */
.overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(63, 43, 28, .42);
  padding: 10px;
}
.panel {
  position: relative; width: min(720px, 96vw); max-height: calc(100% - 12px);
  background: linear-gradient(170deg, var(--paper), var(--paper2));
  border: 3px solid #efd7b2;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(70, 45, 25, .35), inset 0 0 0 2px rgba(255, 255, 255, .6);
  padding: 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel.narrow { width: min(460px, 94vw); }
.panel.wide { width: min(760px, 96vw); }
.panel-title { margin: 0 0 6px; font-size: 20px; font-weight: 900; color: var(--ink); letter-spacing: -.01em; }
.panel-sub { margin: 0 0 12px; font-size: 13px; color: var(--ink2); line-height: 1.5; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-head .panel-title { margin: 0; }
.nb-progress { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--mintDark); }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

/* 타이틀 화면에서 연 조작법·옵션 패널이 타이틀 카드(z-index:40) 뒤로 깔리지 않도록 위로 올린다 */
#help, #options { z-index: 60; }

/* ============================ 타이틀 ============================ */
.title-screen {
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 240, 210, .35), rgba(90, 60, 35, .35) 100%);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  z-index: 40;
}
.title-inner {
  width: min(600px, 94vw); text-align: center; padding: 22px 26px 20px;
  background: linear-gradient(170deg, rgba(255, 252, 242, .96), rgba(255, 240, 214, .94));
  border: 3px solid #f0d7ae; border-radius: 28px;
  box-shadow: 0 22px 60px rgba(60, 38, 20, .4), inset 0 0 0 2px rgba(255, 255, 255, .7);
}
.eyebrow { margin: 0 0 6px; font-size: 11.5px; letter-spacing: .16em; font-weight: 800; color: #b07a5c; }
.game-title {
  margin: 0; font-size: clamp(34px, 6.4vh, 58px); line-height: 1.06; font-weight: 900; letter-spacing: -.03em;
  color: #5a3c2a; text-shadow: 0 3px 0 #ffe3b0, 0 7px 14px rgba(140, 90, 50, .2);
}
.game-title span { color: var(--pinkDark); }
.title-en { margin: 2px 0 8px; font-size: 11px; letter-spacing: .3em; font-weight: 800; color: #c39a78; }
.title-screen .sub { margin: 0 auto 12px; font-size: 13px; color: #7c5b45; line-height: 1.5; max-width: 480px; }
.settings { margin: 0 auto 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.setting-row { display: flex; align-items: center; gap: 9px; }
.setting-label { font-size: 12px; font-weight: 800; color: #7c5b45; }
.segmented { display: inline-flex; background: rgba(255, 255, 255, .65); border: 2px solid rgba(180, 138, 94, .45); border-radius: 999px; padding: 2px; gap: 2px; }
.segmented button {
  font-family: var(--font); font-size: 12.5px; font-weight: 800; color: #8a6a52;
  background: transparent; border: 0; border-radius: 999px; padding: 5px 13px; cursor: pointer; min-height: 30px;
}
.segmented button.active { background: linear-gradient(180deg, #ffc2d0, #f28aa6); color: #fff; box-shadow: 0 2px 6px rgba(217, 109, 140, .3); }
.segmented.tiny button { font-size: 11px; padding: 3px 9px; min-height: 26px; }
.diff-hint { margin: 0; font-size: 11px; color: #9b7a5f; }
.status { margin: 6px 0 0; font-size: 11.5px; color: #8a6a52; }
.status.best { color: #b07a2c; font-weight: 700; }
.title-actions { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* ---- 타이틀 학번·이름 (2026-11-25) ---- */
.student-box {
  margin: 0 auto 10px; padding: 8px 12px 6px;
  width: min(470px, 100%); text-align: center;
  background: rgba(255, 253, 246, .94);
  border: 2px dashed rgba(180, 138, 94, .5); border-radius: 16px;
}
.student-head { margin: 0 0 6px; font-size: 12.5px; font-weight: 900; color: #7c5b45; }
.student-fields { display: flex; gap: 8px; justify-content: center; align-items: stretch; }
.sf { display: flex; align-items: center; gap: 6px; flex: 1 1 0; min-width: 0; }
.sf-label { flex: 0 0 auto; font-size: 12px; font-weight: 800; color: #8a6a52; }
.sf input {
  flex: 1 1 auto; min-width: 0; width: 100%;
  font-family: var(--font);
  /* iOS·iPadOS는 16px 미만 입력란에 포커스하면 화면을 저절로 확대한다 — 16px 고정 */
  font-size: 16px; font-weight: 700; color: var(--ink);
  background: #fffdf8; border: 2px solid rgba(180, 138, 94, .5); border-radius: 10px;
  padding: 7px 10px; min-height: 40px;
  -webkit-user-select: text; user-select: text; touch-action: manipulation;
  -webkit-touch-callout: default; caret-color: var(--pinkDark);
}
.sf input::placeholder { color: #c2a992; font-weight: 600; }
.sf input:focus {
  outline: 3px solid rgba(242, 138, 166, .45); outline-offset: 1px;
  border-color: var(--pinkDark); background: #fff;
}
.student-box.bad .sf input { border-color: #d9534f; background: #fff6f5; }
.student-msg { margin: 5px 0 0; font-size: 12px; font-weight: 800; color: #c0392b; line-height: 1.35; }
.student-msg:empty { display: none; }
.student-note { margin: 3px 0 0; font-size: 10.5px; color: #9b7a5f; }

/* ============================ 퀴즈 ============================ */
.quiz-panel { width: min(760px, 97vw); }
.quiz-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #9fe0c8, #5fbd9d);
  border-radius: 999px; padding: 3px 10px;
}
.quiz-reason { font-size: 11.5px; font-weight: 700; color: var(--ink2); }
.quiz-hearts { margin-left: auto; display: flex; gap: 1px; font-size: 13px; }
.quiz-hearts .heart { color: rgba(190, 120, 140, .35); }
.quiz-hearts .heart.on { color: #ec5d85; }
#quizQuestion { margin: 8px 0 8px; font-size: 19px; line-height: 1.38; font-weight: 800; color: var(--ink); }
.quiz-guard { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
.qg-track { flex: 1; height: 6px; border-radius: 999px; background: rgba(150, 110, 70, .18); overflow: hidden; }
.qg-track i { display: block; height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, var(--gold), var(--pink)); }
.qg-label { font-size: 10.5px; font-weight: 700; color: var(--dim); white-space: nowrap; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 9px; text-align: left;
  font-family: var(--font); font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.35;
  background: linear-gradient(180deg, #fffdf8, #fff3df);
  border: 2px solid rgba(180, 138, 94, .45); border-radius: 14px;
  padding: 9px 12px; cursor: pointer; min-height: 52px;
  box-shadow: 0 3px 0 rgba(180, 138, 94, .22);
  transition: background .12s, border-color .12s, transform .08s;
}
.choice:hover:not(:disabled) { background: #fff8e6; border-color: var(--mint); }
.choice:active:not(:disabled) { transform: translateY(2px); }
.choice:disabled { cursor: default; }
.choice .num {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; color: #8a6a52;
  background: rgba(180, 138, 94, .16); border: 1px solid rgba(180, 138, 94, .25);
}
.choice .label { flex: 1; }
.choice.correct { background: #dff6e8; border-color: #4fae90; box-shadow: 0 3px 0 #4fae90; }
.choice.correct .num { background: #4fae90; color: #fff; border-color: #4fae90; }
.choice.wrong { background: #ffe3e9; border-color: #e06487; box-shadow: 0 3px 0 #e06487; }
.choice.wrong .num { background: #e06487; color: #fff; border-color: #e06487; }
.choice.dim { opacity: .55; }
.feedback { margin-top: 10px; padding: 9px 11px; border-radius: 13px; background: rgba(255, 249, 226, .95); border: 2px solid rgba(215, 159, 60, .45); }
.feedback.ok { border-color: #6cc0a4; background: #e9f9f1; }
.feedback.no { border-color: #e8a2b4; background: #fff0f3; }
.fb-title { font-size: 14px; font-weight: 900; margin-bottom: 2px; color: var(--ink); }
.fb-title.ok { color: #2f8f71; }
.fb-title.no { color: #c8536f; }
.feedback p { margin: 0 0 8px; font-size: 15px; line-height: 1.5; color: var(--ink2); }
.feedback .btn { font-size: 14px; }

/* 수첩 — 다시 조사할 곳 */
.nb-go {
  margin: 8px 0 2px; padding: 8px 10px; border-radius: 10px; font-size: 12px; font-weight: 900;
  color: #8a5a12; background: linear-gradient(180deg, #fff6d6, #ffe9b0); border: 2px solid #f0c96a;
  animation: nbGoPulse 1.6s ease-in-out infinite;
}
@keyframes nbGoPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240, 201, 106, 0); } 50% { box-shadow: 0 0 0 4px rgba(240, 201, 106, .35); } }
.nb-retry { display: flex; flex-wrap: wrap; gap: 5px; }
.nb-retry-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 9px; font-size: 11.5px; font-weight: 800; color: #a53b5c; background: #fff0f3; border: 1px solid #f0bccb; }
.nb-retry-chip i { font-style: normal; font-size: 10px; font-weight: 700; color: #b06a80; }

/* ============================ 단서 카드 ============================ */
.clue-panel { width: min(520px, 95vw); text-align: center; }
.clue-zone { margin: 0 0 4px; font-size: 11.5px; font-weight: 800; letter-spacing: .06em; color: var(--mintDark); }
.clue-title { margin: 0 0 10px; font-size: 21px; font-weight: 900; color: var(--ink); }
.clue-paper {
  position: relative; margin: 0 auto 10px; padding: 16px 16px 18px;
  background: repeating-linear-gradient(180deg, #fffdf3, #fffdf3 23px, #f4e8cf 24px);
  border: 2px dashed #d8b98a; border-radius: 12px;
  transform: rotate(-1.2deg);
  box-shadow: 0 8px 18px rgba(120, 85, 50, .14);
}
.clue-digit {
  width: 74px; height: 74px; margin: 0 auto 8px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 900; color: #8a5a16;
  background: radial-gradient(circle at 35% 30%, #fff4c2, #f7cd67);
  border: 3px solid #d79f3c; box-shadow: 0 6px 14px rgba(190, 140, 50, .28);
}
.clue-text { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink2); }
.clue-guide { margin: 0 0 12px; font-size: 12px; color: var(--dim); }

/* ============================ 단서 수첩 ============================ */
.notebook-panel { width: min(660px, 96vw); text-align: left; display: flex; flex-direction: column; overflow: hidden; }
.notebook-panel .panel-head { flex: none; }
.notebook-panel > .btn { flex: none; display: flex; margin: 10px auto 0; }
/* 내용만 스크롤 — 제목과 「수첩 닫기」 버튼은 항상 보인다 */
.nb-body { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; margin-top: 4px; padding-right: 2px; }
.nb-rooms { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.nb-room {
  background: rgba(255, 253, 246, .95); border: 2px solid rgba(180, 138, 94, .35);
  border-radius: 13px; padding: 8px 10px;
}
.nb-room.done { border-color: var(--mint); background: #f0fbf6; }
.nb-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 13px; }
.nb-head b { color: var(--ink); }
.nb-head span { font-size: 10.5px; font-weight: 800; color: var(--dim); }
.nb-room.done .nb-head span { color: var(--mintDark); }
.nb-meta { margin-top: 4px; font-size: 11px; line-height: 1.45; color: var(--ink2); }
.nb-digit {
  display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center;
  border-radius: 50%; background: #ffe9a8; border: 1.5px solid #d79f3c; color: #7a5312; font-size: 12px;
}
.nb-sub { margin: 12px 0 5px; font-size: 13px; font-weight: 900; color: var(--ink); }
.nb-sub-n { margin-left: 5px; font-size: 11px; font-weight: 800; color: var(--mintDark); }
.nb-items { display: flex; gap: 5px; flex-wrap: wrap; }
.nb-empty { font-size: 11.5px; color: var(--dim); }
/* 바닥 아이템 도감 — 아이콘·이름·효과를 한 줄씩 */
.nb-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.nb-pick {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--dim); line-height: 1.35;
  background: rgba(255, 253, 246, .9); border: 1.5px solid rgba(180, 138, 94, .22);
  border-radius: 9px; padding: 3px 7px; min-width: 0;
}
.nb-pick.got { color: var(--ink2); background: #f4fbf7; border-color: rgba(79, 174, 144, .45); }
.nb-pick .ico { font-size: 13px; flex: none; }
.nb-pick b { font-size: 11px; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-pick .eff { margin-left: auto; font-size: 9.5px; color: var(--dim); white-space: nowrap; flex: none; }
.nb-pick.got .eff { color: var(--mintDark); font-weight: 700; }
.nb-pick .n {
  flex: none; font-size: 9px; font-weight: 800; color: #fff; background: var(--mintDark);
  border-radius: 999px; padding: 0 4px; line-height: 13px;
}
.nb-tip { margin: 10px 0 0; font-size: 11.5px; line-height: 1.55; color: var(--ink2); background: rgba(255, 247, 205, .8); border: 1.5px solid rgba(215, 159, 60, .35); border-radius: 11px; padding: 7px 10px; }

/* ============================ 자물쇠 ============================ */
.keypad-panel { width: min(400px, 94vw); text-align: center; }
.keypad-panel.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.kp-sub { margin: 0 0 10px; font-size: 12px; color: var(--ink2); }
.kp-slots { display: flex; justify-content: center; gap: 9px; margin: 4px 0 10px; }
.kp-slot {
  width: 54px; height: 64px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 900; color: var(--ink);
  background: #fffdf5; border: 2.5px solid rgba(180, 138, 94, .45);
  box-shadow: inset 0 -3px 0 rgba(180, 138, 94, .18);
}
.kp-slot.filled { background: #fff4c9; border-color: var(--goldDark); color: #7a5312; }
.kp-hint { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 11px; color: var(--ink2); }
.kp-hint-item b { color: var(--mintDark); }
.kp-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; max-width: 300px; margin: 0 auto; }
.kp-pad button {
  font-family: var(--font); font-size: 21px; font-weight: 900; color: var(--ink);
  background: linear-gradient(180deg, #fffdf7, #ffeecf); border: 2px solid rgba(180, 138, 94, .4);
  border-radius: 12px; padding: 8px 0; cursor: pointer; min-height: 46px;
  box-shadow: 0 3px 0 rgba(180, 138, 94, .22);
}
.kp-pad button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(180, 138, 94, .22); }
.kp-pad .kp-ok { font-size: 15px; color: #fff; background: linear-gradient(180deg, #9fe0c8, #4fae90); border-color: #3f9b7c; box-shadow: 0 3px 0 #3f9b7c; }
.kp-msg { min-height: 16px; margin: 8px 0 0; font-size: 11.5px; font-weight: 700; color: #c8536f; }

/* ============================ 인트로 ============================ */
#intro { position: absolute; inset: 0; z-index: 50; }
.intro-veil { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(45, 30, 18, .45), rgba(45, 30, 18, .68)); }
.intro-stage { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 12px; }
.intro-dialogbox {
  width: min(760px, 96vw);
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(170deg, #fffdf7, #fff0d8);
  border: 3px solid #f0d7ae; border-radius: 22px;
  padding: 14px 16px; box-shadow: 0 18px 44px rgba(30, 18, 8, .4);
  cursor: pointer;
}
.intro-dialogbox.in { animation: intro-in .28s ease-out; }
@keyframes intro-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.intro-portrait {
  flex: 0 0 66px; width: 66px; height: 66px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center; font-size: 38px;
  background: radial-gradient(circle at 35% 30%, #fff6d6, #ffe0b0);
  border: 2.5px solid #f0d0a0;
}
.intro-copy { flex: 1; min-width: 0; }
.intro-speaker { margin: 0 0 3px; font-size: 12.5px; font-weight: 900; color: #b0722f; }
.intro-line { margin: 0; font-size: 16px; line-height: 1.5; font-weight: 700; color: var(--ink); }
.intro-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 9px; }
.intro-choice {
  display: flex; align-items: center; gap: 8px; text-align: left;
  font-family: var(--font); font-size: 14px; font-weight: 800; color: var(--ink);
  background: #fffdf7; border: 2px solid rgba(180, 138, 94, .4); border-radius: 12px;
  padding: 8px 11px; cursor: pointer; min-height: 46px;
}
.intro-choice:hover { border-color: var(--mint); background: #f4fdf8; }
.intro-choice .ic { font-size: 19px; }
.intro-choice .lb { flex: 1; }
.intro-choice .tip { font-size: 10.5px; color: var(--mintDark); white-space: nowrap; }
.intro-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.intro-dots { display: flex; gap: 4px; }
.intro-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(150, 110, 70, .25); }
.intro-dots i.on { background: var(--pinkDark); }
.intro-next {
  font-family: var(--font); font-size: 12.5px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #ffb0c4, #ef7f9d); border: 2px solid #d76d8b;
  border-radius: 999px; padding: 6px 14px; cursor: pointer; min-height: 32px;
}
.intro-tap { margin: 8px 0 0; font-size: 10.5px; color: rgba(255, 250, 240, .8); }

/* ============================ 엔딩 스토리 ============================ */
#ending { position: absolute; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; padding: 8px; }
.ending-veil {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(52, 34, 20, .52), rgba(34, 21, 12, .84));
}
.ending-stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.ending-card {
  position: relative; width: min(600px, 94vw); max-height: 100%;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: linear-gradient(170deg, #fffdf7, #fff0d8);
  border: 3px solid #f0d7ae; border-radius: 26px;
  padding: 16px 22px 12px;
  box-shadow: 0 22px 60px rgba(18, 10, 5, .55), inset 0 0 0 2px rgba(255, 255, 255, .65);
  cursor: pointer;
}
.ending-card.in { animation: ending-in .38s ease-out; }
@keyframes ending-in { from { transform: translateY(12px); } to { transform: none; } }
.ending-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.ending-chapter { font-size: 10.5px; font-weight: 900; letter-spacing: .16em; color: #b0722f; }
.ending-dots { display: flex; gap: 5px; }
.ending-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(150, 110, 70, .25); }
.ending-dots i.on { background: var(--pinkDark); }
.ending-art {
  width: 64px; height: 64px; margin: 8px 0 4px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 34px; line-height: 1;
  background: radial-gradient(circle at 35% 30%, #fff7d8, #ffe0b0);
  border: 2.5px solid #f0d0a0; box-shadow: 0 6px 16px rgba(170, 120, 60, .22);
}
.ending-kicker { margin: 0; font-size: 11px; font-weight: 900; letter-spacing: .12em; color: var(--mintDark); }
.ending-title {
  margin: 2px 0 8px; font-size: 23px; font-weight: 900; line-height: 1.2;
  color: #5a3c2a; letter-spacing: -.02em; text-shadow: 0 2px 0 #ffe3b0;
}
.ending-line { margin: 0 0 5px; font-size: 14.5px; line-height: 1.6; color: var(--ink2); word-break: keep-all; }
.ending-line.sub { margin-bottom: 0; color: var(--ink); font-weight: 700; }
.ending-tap { margin: 9px 0 0; font-size: 11px; font-weight: 700; color: var(--dim); }
.ending-tap kbd { margin: 0 1px; }

/* ============================ 일시정지 · 옵션 ============================ */
.stat-row { display: flex; gap: 7px; margin: 10px 0 2px; }
.pause-extra { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.pause-extra .btn.fs { display: inline-flex; align-items: center; gap: 5px; }
.pause-tip { margin: 0; font-size: 11px; font-weight: 700; color: var(--dim); }
.pause-tip kbd { font-size: 10px; }
.mini-stat {
  flex: 1; background: rgba(255, 253, 246, .95); border: 2px solid rgba(180, 138, 94, .32);
  border-radius: 12px; padding: 7px 4px; text-align: center;
}
.mini-stat span { display: block; font-size: 10.5px; color: var(--dim); }
.mini-stat b { font-size: 15px; color: var(--ink); }
.opt-list { display: flex; flex-direction: column; gap: 9px; }
.opt-row { display: flex; align-items: center; gap: 10px; }
.opt-label { flex: 0 0 84px; font-size: 12.5px; font-weight: 700; color: var(--ink2); }
.opt-row input[type="range"] { flex: 1; accent-color: var(--pink); height: 20px; }
.opt-val { flex: 0 0 30px; text-align: right; font-size: 12px; color: var(--ink2); }
.toggle {
  font-family: var(--font); font-size: 12px; font-weight: 800; color: var(--ink2);
  background: rgba(180, 138, 94, .16); border: 2px solid rgba(180, 138, 94, .35);
  border-radius: 999px; padding: 5px 14px; cursor: pointer; min-height: 32px;
}
.toggle.on { background: linear-gradient(180deg, #b6f0d8, #6cc9a9); border-color: #4fae90; color: #fff; }

/* ============================ 조작법 ============================ */
.help-panel { width: min(820px, 97vw); display: flex; flex-direction: column; }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.help-head .panel-title { margin: 0; }
.help-body { overflow-y: auto; margin-top: 8px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.help-card { background: rgba(255, 253, 246, .95); border: 2px solid rgba(180, 138, 94, .3); border-radius: 13px; padding: 9px 11px; }
.help-card h3 { margin: 0 0 5px; font-size: 13px; color: var(--ink); }
.help-card ul { margin: 0; padding-left: 15px; }
.help-card li { font-size: 11.5px; line-height: 1.55; color: var(--ink2); margin-bottom: 2px; }
.help-card b { color: var(--ink); }
.help-map { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.map-row { display: flex; gap: 7px; align-items: center; font-size: 11.5px; color: var(--ink2); flex-wrap: wrap; }
.map-row b { color: #b0722f; }
.map-row span { background: #fff9e8; border: 1.5px solid rgba(215, 159, 60, .35); border-radius: 999px; padding: 2px 8px; }
.help-foot { display: flex; justify-content: center; margin-top: 10px; }

/* ============================ 결과 ============================ */
.result-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 40%, rgba(255, 236, 170, .5), rgba(255, 220, 170, 0) 60%);
}
.result-panel { text-align: center; max-height: calc(100% - 16px); }
.result-title { margin: 2px 0 6px; font-size: clamp(34px, 6vh, 54px); font-weight: 900; color: #e06487; letter-spacing: -.02em; text-shadow: 0 3px 0 #ffe0b0; }
#result.lost .result-title { color: #8a6a52; text-shadow: 0 3px 0 #e8d6bd; }

/* 결과 화면의 학번·이름 — 멀리서도 읽히게 크고 진하게 */
.result-student {
  display: inline-flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  margin: 2px auto 9px; padding: 7px 18px;
  background: #fffaea; border: 2px solid rgba(215, 159, 60, .6); border-radius: 14px;
  box-shadow: 0 2px 0 rgba(215, 159, 60, .22), inset 0 0 0 2px rgba(255, 255, 255, .6);
}
.result-student .rs-item { display: inline-flex; align-items: baseline; gap: 7px; }
.result-student i { font-style: normal; font-size: 11.5px; font-weight: 800; color: #9b7a5f; letter-spacing: .05em; }
.result-student b { font-size: clamp(21px, 3.4vh, 28px); font-weight: 900; color: #40291a; letter-spacing: -.01em; }
#result.lost .result-student { background: rgba(255, 253, 246, .96); border-color: rgba(150, 120, 90, .5); }
#result.lost .result-student b { color: #5a3c2a; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 4px; }
.stat { background: rgba(255, 253, 246, .95); border: 2px solid rgba(180, 138, 94, .28); border-radius: 12px; padding: 6px 4px; }
.stat.hi { border-color: rgba(215, 159, 60, .55); background: #fffaea; }
.stat-label { display: block; font-size: 10px; color: var(--dim); margin-bottom: 1px; }
.stat b { font-size: 14px; color: var(--ink); }
.result-hint { margin: 10px 0 0; font-size: 11.5px; color: var(--dim); }

/* ============================ 작은 화면 ============================ */
@media (max-height: 560px) {
  .panel { padding: 10px 12px; border-radius: 18px; }
  .panel-title { font-size: 17px; }
  .nb-sub { margin: 7px 0 4px; font-size: 12px; }
  .nb-tip { font-size: 10.5px; padding: 5px 8px; margin-top: 6px; line-height: 1.45; }
  .notebook-panel > .btn { margin-top: 8px; }
  .choice { min-height: 46px; padding: 6px 10px; font-size: 16px; }
  #quizQuestion { font-size: 19px; margin: 6px 0; }
  .feedback { margin-top: 6px; padding: 6px 9px; }
  .feedback p { font-size: 15px; line-height: 1.4; margin-bottom: 5px; }
  .intro-line { font-size: 14px; }
  .intro-portrait { flex-basis: 52px; width: 52px; height: 52px; font-size: 30px; border-radius: 16px; }
  .ending-card { padding: 12px 16px 10px; border-radius: 20px; }
  .ending-art { width: 48px; height: 48px; margin: 6px 0 3px; font-size: 26px; }
  .ending-title { font-size: 19px; margin: 1px 0 6px; }
  .ending-line { font-size: 13px; line-height: 1.5; margin-bottom: 4px; }
  .ending-tap { margin-top: 6px; font-size: 10px; }
  .nb-rooms { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .game-title { font-size: clamp(30px, 8vh, 44px); }
  .title-screen .sub { font-size: 11.5px; margin-bottom: 8px; }
  .settings { margin-bottom: 8px; }
  .student-box { margin-bottom: 6px; padding: 5px 9px 4px; }
  .student-head { font-size: 11.5px; margin-bottom: 4px; }
  .student-note { display: none; }
  .sf input { min-height: 34px; padding: 4px 8px; }
  .result-student { margin: 1px auto 6px; padding: 4px 12px; gap: 10px; }
  .result-student b { font-size: 20px; }
  .result-student i { font-size: 10px; }
  .title-actions { margin-top: 8px; }
  .kv, .kv * { font-size: 11px; }
}

@media (max-height: 560px) and (min-width: 700px) {
  /* 가로로 눕힌 화면에서는 4구역을 한 줄로 — 단서 수첩이 한 화면에 들어온다 */
  .nb-rooms { grid-template-columns: repeat(4, 1fr); }
  .nb-pick { font-size: 10px; padding: 2px 6px; }
  .nb-pick b { font-size: 10px; }
  .nb-pick .eff { font-size: 9px; }
}

@media (max-height: 400px) {
  .hud-top { padding-top: calc(4px + env(safe-area-inset-top, 0px)); gap: 5px; }
  .hud-card { padding: 3px 7px; border-radius: 9px; }
  .room-block { min-width: 132px; }
  .room-name, .timer { font-size: 12px; }
  .time-block { min-width: 84px; }
  .hearts { font-size: 10.5px; }
  .keys-row { display: none; }
  .btn.icon { width: 30px; min-width: 30px; height: 30px; min-height: 30px; font-size: 13px; border-radius: 9px; }
  .btn.icon.fs { width: auto; padding: 0 7px; font-size: 10.5px; }
  .btn.icon.bgm { font-size: 8.5px; }
  .hud-sub { padding-top: 2px; }
  .chip { font-size: 9.5px; padding: 1px 6px; }
  .chip i { font-size: 8px; }
  .score-chip { font-size: 10px; }
  .joy { width: 88px; height: 88px; }
  .joy-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  .tbtn { width: 56px; height: 56px; }
  .tbtn .tb-ico { font-size: 18px; }
  .tbtn.interact { width: 62px; height: 62px; }
  .prompt { font-size: 11.5px; padding: 6px 12px; bottom: 8px; }
  .panel { padding: 8px 11px; border-radius: 14px; }
  #quizQuestion { font-size: 19px; line-height: 1.25; margin: 4px 0; }
  .choice { min-height: 38px; padding: 4px 9px; font-size: 16px; border-radius: 10px; }
  .choice .num { flex-basis: 20px; width: 20px; height: 20px; font-size: 10.5px; }
  .choices { gap: 6px; }
  .quiz-guard { margin: 0 0 5px; }
  .qg-track { height: 4px; }
  .feedback { margin-top: 5px; padding: 5px 8px; }
  .fb-title { font-size: 12.5px; }
  .feedback p { font-size: 15px; margin-bottom: 4px; line-height: 1.3; }
  .feedback .btn { min-height: 32px; padding: 5px 12px; font-size: 12px; }
  .intro-dialogbox { padding: 8px 11px; gap: 9px; border-radius: 14px; }
  .intro-line { font-size: 12.5px; }
  .intro-speaker { font-size: 11px; }
  .intro-choice { min-height: 34px; padding: 4px 9px; font-size: 11.5px; }
  .intro-choice .ic { font-size: 15px; }
  .intro-tap { display: none; }
  .ending-card { width: min(660px, 95vw); padding: 10px 16px 9px; border-radius: 16px; }
  .ending-head { margin-bottom: 0; }
  .ending-chapter { font-size: 9.5px; }
  .ending-dots i { width: 5px; height: 5px; }
  .ending-art { width: 40px; height: 40px; margin: 4px 0 2px; font-size: 22px; border-width: 2px; }
  .ending-kicker { font-size: 10.5px; }
  .ending-title { font-size: 18px; margin: 1px 0 5px; }
  .ending-line { font-size: 12.5px; line-height: 1.45; margin-bottom: 3px; }
  .ending-tap { margin-top: 5px; font-size: 10px; }
  .stat-grid { gap: 4px; margin: 5px 0 2px; }
  .stat { padding: 3px 2px; border-radius: 8px; }
  .stat-label { font-size: 8.5px; }
  .stat b { font-size: 11px; }
  .result-title { font-size: 30px; margin: 0 0 3px; }
  .student-head { display: none; }
  .student-box { padding: 4px 8px 3px; margin-bottom: 5px; border-radius: 12px; }
  .sf-label { font-size: 11px; }
  .sf input { min-height: 30px; padding: 3px 7px; border-radius: 8px; }
  .student-msg { margin-top: 3px; font-size: 11px; }
  .result-student { padding: 3px 10px; margin-bottom: 5px; }
  .result-student b { font-size: 18px; }
  .result-hint { margin-top: 6px; font-size: 10px; }
  .panel-actions { margin-top: 8px; }
  .btn { min-height: 32px; padding: 5px 11px; font-size: 12px; }
  .btn.primary.big { font-size: 15px; padding: 9px 22px; min-height: 42px; }
  .help-card li { font-size: 10.5px; line-height: 1.45; }
  .nb-rooms { gap: 5px; }
  .nb-room { padding: 5px 7px; }
  .nb-meta { font-size: 10px; }
  .nb-pick { font-size: 10px; padding: 2px 6px; }
  .nb-pick b { font-size: 10px; }
  .nb-pick .eff { font-size: 9px; }
  .kp-slot { width: 44px; height: 50px; font-size: 24px; }
  .kp-pad button { min-height: 36px; font-size: 17px; padding: 4px 0; }
  .kp-hint { margin-bottom: 5px; font-size: 10px; }
}

@media (max-width: 380px) {
  .student-fields { flex-direction: column; gap: 6px; }
  .sf input { min-height: 38px; }
}

@media (max-width: 640px) {
  .hud-top { flex-wrap: wrap; }
  .room-block { min-width: 140px; flex: 1 1 auto; }
  .hud-notice { position: absolute; top: auto; bottom: calc(104px + env(safe-area-inset-bottom, 0px)); left: 8px; right: 8px; padding: 0; }
  .hud-actions #btnSound, .hud-actions #btnBgm { display: none; }
  .hint, .toast { font-size: 10.5px; white-space: normal; max-width: 100%; }
  .hud-actions { gap: 3px; }
  .hud-actions .btn.icon { width: 32px; min-width: 32px; height: 32px; min-height: 32px; font-size: 13px; }
  .hud-actions .btn.icon.fs { width: auto; padding: 0 6px; font-size: 10px; }
  .hud-actions .btn.icon.bgm { font-size: 8.5px; }
  .time-block { min-width: 96px; }
  .item-chips { max-width: 100%; }
  .choices { grid-template-columns: 1fr; }
  .ending-card { width: min(360px, 94vw); padding-left: 15px; padding-right: 15px; }
  .ending-line { font-size: 13px; }
  .nb-rooms { grid-template-columns: 1fr; }
  .nb-picks { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .help-grid { grid-template-columns: 1fr; }
  .panel { padding: 12px 12px; }
  .joy { width: 96px; height: 96px; }
  .tbtn { width: 58px; height: 58px; }
  .tbtn.interact { width: 66px; height: 66px; }
}

@media (orientation: portrait) and (min-width: 400px) {
  .joy { width: 112px; height: 112px; }
  .tbtn { width: 66px; height: 66px; }
  .tbtn.interact { width: 74px; height: 74px; }
}

/* 키보드 접근성 */
button:focus-visible { outline: 3px solid rgba(79, 174, 144, .65); outline-offset: 2px; }

/* ==========================================================================
   [TB-CSS-BLOCK] 모바일 꾹누르기·드래그 차단 (2026-11-22)
   · 조이스틱·버튼을 꾹 누를 때 생기는 텍스트 선택(파란 하이라이트)을 없앤다
   · iOS 길게 누르기 메뉴(-webkit-touch-callout)와 이미지 끌기를 막는다
   · 문서 전체 overscroll(당겨서 새로고침·바운스)과 확대 제스처를 막는다
   · 스크롤이 필요한 모달은 위쪽 .overlay / .panel 규칙의 touch-action: pan-y 유지
   ========================================================================== */
*,
*::before,
*::after {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
    /* V33(2026-11-27) — none → manipulation. 구버전 삼성인터넷에서 body 전체 touch-action: none 이
     버튼·입력란의 탭(click)까지 삼켜 터치가 안 먹히는 증상이 있었다.
     두 번 탭 확대는 계속 막히고, 확대 제스처는 캔버스·조이스틱(touch-action: none)과
     두 손가락·gesture* 차단이 맡는다. */
  touch-action: manipulation;
  -ms-touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 게임 표면(캔버스)과 조이스틱은 손가락 제스처를 브라우저에 넘기지 않는다 */
#scene,
canvas,
#joy,
#joyKnob,
.joy,
.joy-base,
.joy-knob {
  touch-action: none;
  -ms-touch-action: none;
  -webkit-user-drag: none;
}

/* 입력 요소(볼륨 슬라이더·글자 입력)는 손가락 드래그가 살아 있어야 조작된다 */
input,
textarea,
select,
[contenteditable="true"] {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}
