/* =========================================================
 *  야간 검문소: 전설의 고향 — 스타일
 * ========================================================= */
:root {
  --ink: #121316;
  --navy: #1B2232;
  --hanji: #E8DFC8;
  --hanji-dark: #d6caad;
  --seal: #B8292F;
  --lantern: #E69D45;
  --wisp: #38BDF8;
  --wood: #4a2f1d;
  --text-dark: #2a1f16;
  --f-display: 'Song Myung', 'Noto Serif KR', serif;
  --f-body: 'Gowun Batang', 'Noto Serif KR', serif;
  --f-doc: 'Noto Serif KR', 'Gowun Batang', serif;

  /* 한지 질감: 구김(조명) + 섬유 */
  --crumple: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.022' numOctaves='5' seed='7'/><feDiffuseLighting lighting-color='%23ffffff' surfaceScale='2.2'><feDistantLight azimuth='125' elevation='52'/></feDiffuseLighting></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  --fiber: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='0.9 0.08' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.36  0 0 0 0 0.22  0 0 0 0.35 0'/></filter><rect width='100%25' height='100%25' filter='url(%23f)'/></svg>");
  --woodgrain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='400'><filter id='w'><feTurbulence type='fractalNoise' baseFrequency='0.004 0.09' numOctaves='3' seed='11'/><feColorMatrix values='0.32 0 0 0 0.2  0.2 0 0 0 0.11  0.1 0 0 0 0.05  0 0 0 0 1'/></filter><rect width='100%25' height='100%25' filter='url(%23w)'/></svg>");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--hanji); font-family: var(--f-body); overflow: hidden; overscroll-behavior: none; }
button { font-family: inherit; cursor: pointer; }
b { font-weight: 700; }

#app { position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; animation: screenIn .6s ease; }
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 공통: 한지 ---------- */
.paper {
  background-color: var(--hanji);
  background-image: var(--fiber), var(--crumple);
  background-blend-mode: multiply, multiply;
  background-size: 200px 200px, 320px 320px;
  color: var(--text-dark);
}

/* ---------- 버튼 ---------- */
.btn {
  appearance: none; border: 1px solid rgba(232, 223, 200, .35); background: rgba(27, 34, 50, .7);
  color: var(--hanji); padding: .75em 1.4em; font-size: 1rem; border-radius: 4px; letter-spacing: .08em;
  transition: transform .15s, background .2s, box-shadow .2s; font-family: var(--f-body);
}
.btn:hover:not(:disabled) { background: rgba(230, 157, 69, .18); border-color: var(--lantern); box-shadow: 0 0 18px rgba(230, 157, 69, .25); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #c53a3f, var(--seal)); border-color: #e0676b; color: #fff6e6; box-shadow: 0 4px 0 #6d1418, 0 8px 24px rgba(184, 41, 47, .3); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #d7454a, #c22f35); }
.btn.ghost { background: transparent; }
.btn.big { font-size: 1.15rem; padding: .9em 2em; }
.btn small { opacity: .7; font-size: .8em; }
.icon-btn { background: transparent; border: 1px solid rgba(232, 223, 200, .2); color: var(--hanji); width: 34px; height: 34px; border-radius: 50%; font-size: 15px; display: inline-grid; place-items: center; padding: 0; }
.icon-btn:hover { border-color: var(--lantern); }
.icon-btn.off { opacity: .4; }

/* ---------- 밤하늘 공통 ---------- */
.night-sky, .scene-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 70% 0%, #26304a 0%, var(--navy) 40%, var(--ink) 100%); overflow: hidden; }
.stars { position: absolute; inset: 0; background-image:
  radial-gradient(1px 1px at 10% 20%, #fff8, transparent), radial-gradient(1px 1px at 30% 12%, #fff6, transparent),
  radial-gradient(1.5px 1.5px at 55% 25%, #fff9, transparent), radial-gradient(1px 1px at 72% 8%, #fff7, transparent),
  radial-gradient(1px 1px at 85% 30%, #fff5, transparent), radial-gradient(1px 1px at 20% 40%, #fff4, transparent),
  radial-gradient(1.5px 1.5px at 92% 15%, #fff8, transparent), radial-gradient(1px 1px at 45% 6%, #fff6, transparent);
  animation: twinkle 6s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .6; } to { opacity: 1; } }
.moon { position: absolute; top: 9%; right: 14%; width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fff7e0, #e9d9a8 60%, #c9b37a);
  box-shadow: 0 0 30px 8px rgba(255, 236, 180, .25), 0 0 80px 20px rgba(255, 236, 180, .1); }
.moon.big { width: 120px; height: 120px; top: 8%; right: 12%; }
#screen-intro[data-day="3"] .moon, .day3 .moon { background: radial-gradient(circle at 40% 40%, #ffe0c8, #e08a6a 60%, #a8452f); box-shadow: 0 0 40px 10px rgba(224, 110, 80, .35); }
.mountains { position: absolute; left: 0; bottom: 0; width: 100%; height: 55%; }
.title-mtn { height: 40%; }
.mist { position: absolute; left: -20%; right: -20%; bottom: 0; height: 40%; background: radial-gradient(ellipse at 30% 100%, rgba(200, 210, 230, .12), transparent 60%), radial-gradient(ellipse at 80% 100%, rgba(200, 210, 230, .09), transparent 60%); animation: mist 18s ease-in-out infinite alternate; pointer-events: none; }
@keyframes mist { from { transform: translateX(-4%); } to { transform: translateX(4%); } }

/* ---------- 청사초롱 ---------- */
.lantern, .title-lantern { position: absolute; transform-origin: top center; animation: sway 4s ease-in-out infinite; }
.lantern::before, .title-lantern::before { content: ''; position: absolute; left: 50%; top: -60px; width: 2px; height: 60px; background: #5a4630; }
.lantern-body { position: relative; width: 34px; height: 46px; border-radius: 40% 40% 40% 40% / 30% 30% 30% 30%;
  background: linear-gradient(180deg, #2b4f8a 0 22%, #c43a3a 22% 78%, #2b4f8a 78%);
  box-shadow: 0 0 24px 8px rgba(230, 157, 69, .45), inset 0 0 12px rgba(255, 220, 150, .8);
  display: grid; place-items: center; animation: lanternGlow 2.3s infinite; }
.lantern-body span { font-family: var(--f-display); color: #ffe7b0; font-size: 14px; text-shadow: 0 0 6px #ffb84d; }
.lantern-body::after { content: ''; position: absolute; bottom: -12px; left: 50%; width: 3px; height: 12px; margin-left: -1.5px; background: #c43a3a; }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes lanternGlow { 0%, 100% { box-shadow: 0 0 24px 8px rgba(230, 157, 69, .45), inset 0 0 12px rgba(255, 220, 150, .8); } 37% { box-shadow: 0 0 30px 12px rgba(230, 157, 69, .55), inset 0 0 16px rgba(255, 220, 150, .95); } 62% { box-shadow: 0 0 18px 6px rgba(230, 157, 69, .38), inset 0 0 10px rgba(255, 220, 150, .7); } }

/* ---------- 타이틀 ---------- */
#screen-title { align-items: center; justify-content: center; }
.title-wrap { position: relative; z-index: 2; text-align: center; padding: 20px; max-width: 560px; }
.title-lantern { position: relative; display: inline-block; margin: 40px 0 14px; }
.title-lantern .lantern-body { width: 54px; height: 72px; }
.title-lantern .lantern-body span { font-size: 22px; }
.title-kicker { font-family: var(--f-display); letter-spacing: .6em; color: var(--lantern); margin: 0; opacity: .85; }
.title-main { font-family: var(--f-display); font-weight: 400; font-size: clamp(3rem, 12vw, 5.5rem); margin: .1em 0 0; letter-spacing: .12em; color: #f3ead2;
  text-shadow: 0 0 20px rgba(230, 157, 69, .35), 0 4px 0 #000; }
.title-sub { font-family: var(--f-display); font-size: clamp(1.2rem, 4vw, 1.7rem); color: var(--seal); margin: .2em 0 1em; letter-spacing: .5em; text-shadow: 0 0 12px rgba(184, 41, 47, .6); }
.title-tag { opacity: .75; line-height: 1.8; margin-bottom: 28px; }
.title-menu { display: flex; flex-direction: column; gap: 10px; max-width: 280px; margin: 0 auto; }
.title-foot { margin-top: 26px; font-size: .78rem; opacity: .55; display: flex; gap: 10px; align-items: center; justify-content: center; }

/* ---------- 일차 소개 ---------- */
#screen-intro { align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, #1d2436, var(--ink) 70%); overflow-y: auto; }
.intro-wrap { max-width: 620px; width: 100%; padding: 32px 22px 40px; text-align: center; margin: auto; }
.intro-hanja { font-family: var(--f-display); font-size: clamp(3rem, 14vw, 6rem); color: var(--seal); opacity: .9; letter-spacing: .1em; text-shadow: 0 0 30px rgba(184, 41, 47, .4); animation: inkIn 1.4s ease; }
@keyframes inkIn { from { opacity: 0; filter: blur(8px); letter-spacing: .5em; } to { opacity: .9; filter: blur(0); } }
.intro-title { font-family: var(--f-display); font-weight: 400; font-size: 1.8rem; margin: 0; }
.intro-sub { color: var(--lantern); margin: .3em 0 1.4em; }
.intro-story p { line-height: 1.9; opacity: 0; animation: fadeUp .8s forwards; text-align: left; margin: 0 0 .9em; }
.intro-story p:nth-child(2) { animation-delay: .5s; } .intro-story p:nth-child(3) { animation-delay: 1s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: .9; transform: none; } }
.intro-events .event { text-align: left; border: 1px solid var(--lantern); background: rgba(230, 157, 69, .08); padding: 14px 16px; border-radius: 4px; margin: 14px 0; line-height: 1.75; }
.intro-events .event h4 { margin: 0 0 6px; color: var(--lantern); font-family: var(--f-display); font-weight: 400; font-size: 1.15rem; }
.intro-events .event .coins { color: #ffd77a; font-weight: 700; }
.bang { text-align: left; margin: 22px 0 26px; padding: 18px 20px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); transform: rotate(-.6deg); border: 1px solid #b9a982; }
.bang h3 { font-family: var(--f-display); font-weight: 400; margin: 0 0 4px; font-size: 1.4rem; display: flex; justify-content: space-between; align-items: baseline; }
.bang h3 small { font-family: var(--f-body); font-size: .8rem; opacity: .7; }

/* 규칙 목록 (방) */
.rules-list { list-style: none; padding: 0; margin: 8px 0 0; counter-reset: r; }
.rules-list li { position: relative; padding: 6px 0 6px 30px; border-top: 1px dashed rgba(90, 60, 30, .3); line-height: 1.55; font-size: .95rem; counter-increment: r; }
.rules-list li::before { content: counter(r); position: absolute; left: 2px; top: 7px; width: 20px; height: 20px; border: 1.5px solid var(--seal); color: var(--seal); border-radius: 2px; font-size: .75rem; display: grid; place-items: center; font-family: var(--f-doc); font-weight: 700; }
.rules-list li.new::after { content: '新'; position: absolute; right: 0; top: 4px; background: var(--seal); color: #fff; font-size: .7rem; padding: 1px 5px; border-radius: 2px; font-family: var(--f-display); }
.rules-list li.new { padding-right: 30px; }
.rules-list li.hint { opacity: .75; font-size: .88rem; }

/* ---------- 상단바 ---------- */
#screen-game { flex-direction: column; }
.topbar { flex: 0 0 46px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; padding-top: env(safe-area-inset-top); background: linear-gradient(180deg, #0d0e11, #15171d); border-bottom: 1px solid rgba(230, 157, 69, .2); gap: 8px; z-index: 20; }
.tb-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.tb-day { font-family: var(--f-display); font-size: 1.25rem; color: var(--lantern); white-space: nowrap; }
.tb-date { font-size: .8rem; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-mid { font-size: .85rem; opacity: .8; white-space: nowrap; }
.tb-right { display: flex; align-items: center; gap: 6px; }
.tb-stat { font-size: .9rem; margin-right: 4px; white-space: nowrap; }
.tb-stat b { color: #ffd77a; }
.tb-stat.warn b { color: #ff8a8a; }
.tb-stat.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.35); } }

.game-main { flex: 1; display: flex; min-height: 0; }

/* ---------- 검문창 ---------- */
.booth { position: relative; width: 35%; display: flex; flex-direction: column; background: var(--ink); border-right: 3px solid #2a1b10; min-height: 0; }
.scene { position: relative; flex: 0 0 46%; overflow: hidden; touch-action: none; border-bottom: 3px solid #2a1b10; }
.scene .lantern { top: 58px; left: 12%; z-index: 3; }
.gate-post { position: absolute; bottom: 0; width: 18px; height: 78%; background: linear-gradient(90deg, #2c1c10, #4a3220 45%, #24170d); z-index: 1; }
.gate-post.left { left: 4%; } .gate-post.right { right: 4%; }
.gate-beam { position: absolute; left: 2%; right: 2%; top: 22%; height: 12px; background: linear-gradient(180deg, #4a3220, #24170d); z-index: 1; }

.portrait-wrap { position: absolute; bottom: 0; left: 50%; height: 88%; aspect-ratio: 200 / 240; transform: translateX(-50%); z-index: 2; pointer-events: none; }
.portrait-wrap > svg, .portrait-wrap > img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 14px rgba(0, 0, 0, .6)); transform-origin: 50% 100%; animation: breathe 4s ease-in-out infinite; }
#portrait-human > svg, #portrait-human > img { filter: drop-shadow(0 0 14px rgba(0, 0, 0, .6)) brightness(.92) sepia(.12); }
.portrait-wrap.enter > * { animation: enter .8s cubic-bezier(.2, .8, .3, 1), breathe 4s ease-in-out .8s infinite; }
.portrait-wrap.exit > * { animation: exitWalk .9s ease-in forwards; }
.portrait-wrap.vanish > * { animation: vanish 1.6s ease-in forwards; }
.portrait-wrap.flee > * { animation: flee .6s ease-in forwards; }
.portrait-wrap.empty > * { opacity: 0; }
@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.012); } }
@keyframes enter { from { transform: translateX(-70%); opacity: 0; filter: blur(4px) brightness(.3); } to { transform: none; opacity: 1; } }
@keyframes exitWalk { to { transform: translateX(90%); opacity: 0; } }
@keyframes vanish { 0% { opacity: 1; filter: blur(0); } 100% { opacity: 0; filter: blur(14px) brightness(2); transform: translateY(-14%) scale(1.05); } }
@keyframes flee { to { transform: translateX(-120%) skewX(10deg); opacity: 0; } }

/* 청동거울 투영 */
.reveal { position: absolute; inset: 0; z-index: 4; clip-path: circle(0px at -200px -200px); pointer-events: none; }
.reveal.full { transition: clip-path 1.2s ease-in; }
.reveal-bg { position: absolute; inset: 0; background: radial-gradient(circle at 50% 55%, #1d3a40 0%, #0b1418 70%); }
.reveal-bg::after { content: ''; position: absolute; inset: 0; background: repeating-radial-gradient(circle at 50% 55%, rgba(56, 189, 248, .05) 0 2px, transparent 2px 9px); animation: ripple 3s linear infinite; }
@keyframes ripple { to { transform: scale(1.08); opacity: .6; } }
#portrait-true > svg, #portrait-true > img { filter: drop-shadow(0 0 12px rgba(56, 189, 248, .55)) sepia(.35) hue-rotate(-8deg) contrast(1.1); }
.reveal.yokai #portrait-true > * { animation: breathe 4s infinite, yokaiJitter .18s steps(2) infinite; }
@keyframes yokaiJitter { 50% { transform: translate(1px, -1px); } }

.lens { position: absolute; left: 0; top: 0; width: 140px; height: 140px; border-radius: 50%; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: none;
  box-shadow: 0 0 0 5px #a8803c, 0 0 0 9px #5d4118, 0 0 0 11px #2a1d0b, 0 6px 24px 10px rgba(0, 0, 0, .6), inset 0 0 26px rgba(56, 189, 248, .45), 0 0 40px rgba(56, 189, 248, .25); }
.lens::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .25), transparent 35%); }
.lens::after { content: ''; position: absolute; left: 50%; bottom: -34px; width: 14px; height: 30px; margin-left: -7px; background: linear-gradient(90deg, #5d4118, #a8803c, #5d4118); border-radius: 0 0 6px 6px; }
.booth.mirror-on .lens { display: block; }
.booth.mirror-on .scene { cursor: none; }
.lens-caption { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: .78rem; color: var(--wisp); text-shadow: 0 0 6px #000, 0 0 10px rgba(56, 189, 248, .8); font-family: var(--f-display); }
.lens.yokai { box-shadow: 0 0 0 5px #a8803c, 0 0 0 9px #5d4118, 0 0 0 11px #2a1d0b, inset 0 0 40px rgba(184, 41, 47, .7), 0 0 50px rgba(184, 41, 47, .55); animation: lensPulse .5s infinite alternate; }
@keyframes lensPulse { to { filter: brightness(1.3); } }

/* 촛불 일렁임 */
.candle-glow { position: absolute; inset: 0; z-index: 6; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle at 18% 30%, rgba(230, 157, 69, .32), transparent 50%), radial-gradient(ellipse at 50% 120%, rgba(230, 157, 69, .18), transparent 60%);
  animation: flicker 3.7s infinite; }
.candle-glow::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, .65) 100%); }
@keyframes flicker { 0%, 100% { opacity: .9; } 8% { opacity: .75; } 12% { opacity: 1; } 31% { opacity: .82; } 33% { opacity: .95; } 52% { opacity: .7; } 55% { opacity: .92; } 78% { opacity: .85; } 80% { opacity: 1; } }

.scene-caption { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 7; padding: 4px 12px; font-family: var(--f-display); font-size: .95rem; color: #fff; background: rgba(184, 41, 47, .85); border-radius: 2px; opacity: 0; transition: opacity .3s; white-space: nowrap; pointer-events: none; }
.scene-caption.show { opacity: 1; animation: shake .4s; }
.scene-caption.human { background: rgba(27, 34, 50, .9); color: var(--wisp); }

/* 말풍선 */
.speech { position: relative; margin: 10px 12px 6px; padding: 12px 16px 14px; min-height: 96px; border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); cursor: pointer; z-index: 8; transition: opacity .2s; }
.speech::before { content: ''; position: absolute; top: -10px; left: 40px; border: 10px solid transparent; border-top: 0; border-bottom-color: var(--hanji); }
.speech-name { font-family: var(--f-display); color: var(--seal); font-size: .95rem; margin-bottom: 4px; }
.speech-text { line-height: 1.65; font-size: 1rem; min-height: 3.3em; }
.speech-more { position: absolute; right: 10px; bottom: 4px; font-size: .7rem; color: var(--seal); opacity: 0; animation: bob 1s infinite; }
.speech.has-more .speech-more { opacity: 1; }
.speech.response .speech-text { font-weight: 700; }
@keyframes bob { 50% { transform: translateY(3px); } }

.booth-actions { display: flex; gap: 8px; padding: 4px 12px 8px; align-items: center; z-index: 8; }
.tool-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid #a8803c; background: linear-gradient(180deg, #3b2c17, #241a0c); color: #f0d9a0; padding: 7px 12px; border-radius: 20px; font-size: .9rem; }
.tool-btn .mirror-ico { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #9fe3ff, #2e6f86 60%, #133); box-shadow: 0 0 0 2px #a8803c; }
.tool-btn.active { background: linear-gradient(180deg, #0f4157, #082636); border-color: var(--wisp); color: #cdf2ff; box-shadow: 0 0 14px rgba(56, 189, 248, .5); }
.tool-btn.locked { opacity: .45; filter: grayscale(1); }
.tool-btn.pulse { animation: toolPulse 1.4s infinite; }
@keyframes toolPulse { 50% { box-shadow: 0 0 0 4px rgba(56, 189, 248, .35), 0 0 18px rgba(56, 189, 248, .6); } }
.question-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.question-list::-webkit-scrollbar { display: none; }
.q-chip { flex: 0 0 auto; border: 1px solid rgba(232, 223, 200, .3); background: rgba(232, 223, 200, .06); color: var(--hanji); padding: 7px 11px; border-radius: 16px; font-size: .82rem; white-space: nowrap; }
.q-chip:hover { border-color: var(--lantern); }
.q-chip.asked { opacity: .4; }

.rules-panel { flex: 1; margin: 4px 12px 12px; padding: 12px 14px; overflow-y: auto; border-radius: 3px; box-shadow: inset 0 0 30px rgba(120, 90, 40, .25), 0 4px 14px rgba(0, 0, 0, .4); min-height: 0; }
.rules-panel h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.2rem; display: flex; justify-content: space-between; align-items: baseline; }
.rules-panel h3 small { font-family: var(--f-body); font-size: .75rem; opacity: .7; }

/* ---------- 책상 ---------- */
.desk { position: relative; width: 65%; display: flex; flex-direction: column; min-height: 0; }
.desk-tabs { flex: 0 0 auto; display: flex; gap: 4px; padding: 6px 10px 0; background: #1a120b; overflow-x: auto; scrollbar-width: none; }
.desk-tabs::-webkit-scrollbar { display: none; }
.desk-tab { flex: 0 0 auto; border: 1px solid #4a3220; border-bottom: none; background: #2a1c11; color: #d8c49a; padding: 6px 14px; border-radius: 6px 6px 0 0; font-size: .85rem; }
.desk-tab.active { background: #5a3b22; color: #fff1d0; }
.desk-tab.mobile-only { display: none; }
.desk-surface { position: relative; flex: 1; overflow: hidden; min-height: 0;
  background-color: #5b3920; background-image: linear-gradient(180deg, rgba(0, 0, 0, .1), rgba(0, 0, 0, .35)), var(--woodgrain); background-size: auto, 600px 400px; box-shadow: inset 0 10px 30px rgba(0, 0, 0, .6); }
.desk-light { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 20% 0%, rgba(230, 157, 69, .28), transparent 60%); animation: flicker 4.3s infinite; z-index: 1; }
.desk-surface.thud { animation: thud .35s; }
@keyframes thud { 20% { transform: translateY(3px); } 50% { transform: translateY(-1px); } }
.desk-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); color: rgba(255, 240, 210, .5); font-size: .85rem; z-index: 1; pointer-events: none; white-space: nowrap; transition: opacity 1s; }
.desk-hint.hide { opacity: 0; }

/* 서류 공통 */
.doc { position: absolute; z-index: 10; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; transform: rotate(var(--rot, 0deg)); transition: transform .2s, box-shadow .2s; box-shadow: 0 6px 16px rgba(0, 0, 0, .5), 0 2px 4px rgba(0, 0, 0, .4); }
.doc.dragging { cursor: grabbing; transform: rotate(0deg) scale(1.03); box-shadow: 0 18px 34px rgba(0, 0, 0, .6); transition: box-shadow .2s; }
.doc.focus { animation: focusDoc .5s; }
@keyframes focusDoc { 40% { transform: rotate(0deg) scale(1.05); } }
.doc.slide-in { animation: docIn .55s cubic-bezier(.2, .8, .3, 1.2) both; }
.doc.slide-out { animation: docOut .45s ease-in forwards; pointer-events: none; }
@keyframes docIn { from { opacity: 0; transform: translateY(-60px) rotate(-8deg); } }
@keyframes docOut { to { opacity: 0; transform: translateY(-80px) rotate(10deg); } }
.doc .field { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(60, 40, 20, .2); }
.doc .lbl { font-size: .72rem; opacity: .7; white-space: nowrap; }
.doc .val { font-family: var(--f-doc); font-weight: 700; font-size: .95rem; text-align: right; }
.doc .hl { background: linear-gradient(transparent 60%, rgba(184, 41, 47, .25) 60%); }

/* 호패 */
.doc.hopae { width: 158px; padding: 30px 14px 16px; border-radius: 46px 46px 10px 10px; color: #2b1a0c;
  background: linear-gradient(90deg, rgba(0, 0, 0, .15), transparent 15%, transparent 85%, rgba(0, 0, 0, .2)), repeating-linear-gradient(92deg, #c79b62 0 3px, #bb8d55 3px 7px, #d0a56c 7px 9px), #c49860;
  border: 2px solid #8a5f30; }
.doc.hopae::before { content: ''; position: absolute; top: 9px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #3a2412; box-shadow: inset 0 2px 3px #000; }
.doc.hopae::after { content: ''; position: absolute; top: -26px; left: 50%; width: 3px; height: 34px; margin-left: -1.5px; background: linear-gradient(#b8292f, #7a1a1e); border-radius: 2px; z-index: -1; }
.hopae .doc-title { text-align: center; font-family: var(--f-display); font-size: 1.15rem; letter-spacing: .4em; margin-bottom: 6px; text-shadow: 0 1px 0 rgba(255, 230, 180, .5); }
.hopae .field { border-color: rgba(60, 30, 10, .3); flex-direction: column; align-items: flex-start; gap: 0; }
.hopae .val { text-align: left; text-shadow: 0 1px 0 rgba(255, 230, 180, .4); font-size: .92rem; }

/* 통행첩 */
.doc.permit { width: 250px; padding: 16px 18px 20px; border-radius: 2px; }
.doc.permit::before { content: ''; position: absolute; inset: 7px; border: 1.5px solid rgba(184, 41, 47, .5); outline: 1px solid rgba(184, 41, 47, .3); outline-offset: 2px; pointer-events: none; }
.permit .doc-title { text-align: center; font-family: var(--f-display); font-size: 1.3rem; letter-spacing: .2em; color: #3a2516; }
.permit .doc-sub { text-align: center; font-size: .72rem; opacity: .6; margin-bottom: 8px; }

/* 직인 */
.seal-mark { display: inline-grid; place-items: center; width: 46px; height: 46px; border: 2.5px solid var(--seal); color: var(--seal); font-family: var(--f-display); font-size: .78rem; line-height: 1.05; text-align: center; padding: 2px; opacity: .85; mix-blend-mode: multiply; transform: rotate(-6deg); border-radius: 3px; word-break: break-all; letter-spacing: .05em; }
.seal-row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; font-size: .72rem; opacity: .9; }
.hopae .seal-row { justify-content: center; }
.seal-none { color: #888; font-size: .72rem; border: 1px dashed #888; padding: 6px; }

/* 살생부 */
.doc.registry { width: 280px; padding: 14px 16px 16px 26px; border-radius: 2px 6px 6px 2px; background-color: #e2d6b8; }
.doc.registry::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: repeating-linear-gradient(180deg, #3a2516 0 4px, #e2d6b8 4px 24px); border-right: 2px solid #3a2516; }
.registry .doc-title { font-family: var(--f-display); font-size: 1.2rem; color: #4a1a14; display: flex; justify-content: space-between; align-items: baseline; }
.registry .doc-title small { font-family: var(--f-body); font-size: .7rem; opacity: .6; }
.reg-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .78rem; }
.reg-table th { text-align: left; font-weight: 400; opacity: .6; font-size: .68rem; border-bottom: 1.5px solid #4a1a14; padding: 3px 2px; }
.reg-table td { padding: 5px 2px; border-bottom: 1px dotted rgba(74, 26, 20, .35); vertical-align: top; }
.reg-table td.nm { font-family: var(--f-doc); font-weight: 900; color: #4a1a14; white-space: nowrap; }
.reg-table tr.fresh td { background: rgba(184, 41, 47, .08); }

/* 방 (모바일 서류) / 꾸러미 */
.doc.rules-doc { width: 250px; padding: 14px 16px; }
.rules-doc .doc-title { font-family: var(--f-display); font-size: 1.2rem; }
.doc.pouch { width: 120px; height: 120px; border-radius: 45% 45% 40% 40%; background: radial-gradient(circle at 40% 35%, #8b5a3a, #5a3420 70%); color: #ffe7b0; display: grid; place-items: center; text-align: center; font-size: .78rem; padding: 18px; box-shadow: 0 8px 18px rgba(0, 0, 0, .6), inset 0 -10px 20px rgba(0, 0, 0, .4); }
.doc.pouch::before { content: ''; position: absolute; top: 12px; left: 30%; right: 30%; height: 8px; background: #b8292f; border-radius: 4px; }
.pouch b { display: block; font-size: 1.3rem; color: #ffd77a; font-family: var(--f-display); }

/* 도장 자국 */
.stamp-mark { position: absolute; left: 50%; top: 52%; width: 104px; height: 104px; margin: -52px 0 0 -52px; display: grid; place-items: center; font-family: var(--f-display); font-size: 62px; color: var(--seal); border: 6px double var(--seal); border-radius: 6px; mix-blend-mode: multiply; pointer-events: none; z-index: 5;
  -webkit-mask-image: radial-gradient(circle at 30% 30%, #000 55%, rgba(0, 0, 0, .7) 70%, #000 85%), var(--fiber); mask-image: radial-gradient(circle at 30% 30%, #000 55%, rgba(0, 0, 0, .7) 70%, #000 85%);
  transform: rotate(var(--srot, -8deg)); animation: stampIn .5s cubic-bezier(.3, 1.6, .5, 1) both; text-shadow: 0 0 1px var(--seal); background: radial-gradient(circle, rgba(184, 41, 47, .08), transparent 70%); }
.stamp-mark.deny { border-radius: 50%; border-style: solid; }
@keyframes stampIn { 0% { transform: rotate(var(--srot)) scale(2.6); opacity: 0; filter: blur(3px); } 45% { transform: rotate(var(--srot)) scale(.88); opacity: 1; filter: blur(0); } 70% { transform: rotate(var(--srot)) scale(1.06); } 100% { transform: rotate(var(--srot)) scale(1); opacity: .92; } }

/* 도장 버튼 */
.stamp-bar { position: absolute; right: 18px; bottom: 18px; display: flex; gap: 16px; z-index: 50; }
.stamp-btn { position: relative; width: 96px; height: 110px; border: none; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; transition: transform .15s; }
.stamp-handle { position: absolute; top: 0; left: 50%; width: 42px; height: 50px; margin-left: -21px; border-radius: 20px 20px 8px 8px; background: linear-gradient(90deg, #3b2412, #7a5232 45%, #3b2412); box-shadow: 0 4px 8px rgba(0, 0, 0, .5); }
.stamp-handle::before { content: ''; position: absolute; top: -10px; left: 50%; width: 26px; height: 18px; margin-left: -13px; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #8a5f3a, #3b2412); }
.stamp-face { position: relative; width: 84px; height: 54px; margin-bottom: 4px; display: grid; place-items: center; font-family: var(--f-display); font-size: 34px; color: #fff4e0; background: linear-gradient(180deg, #c8363c, #8d1c21); border-radius: 6px; box-shadow: 0 6px 0 #4a0d10, 0 10px 16px rgba(0, 0, 0, .6); text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.stamp-btn.deny .stamp-face { background: linear-gradient(180deg, #3a3f52, #1d2232); box-shadow: 0 6px 0 #0c0f18, 0 10px 16px rgba(0, 0, 0, .6); color: #ffb3b3; }
.stamp-label { position: absolute; bottom: -18px; font-size: .78rem; color: #f0e0bf; text-shadow: 0 1px 2px #000; }
.stamp-btn:hover:not(:disabled) { transform: translateY(-4px); }
.stamp-btn:active:not(:disabled), .stamp-btn.pressed { transform: translateY(6px) scale(.96); }
.stamp-btn:disabled { opacity: .45; cursor: default; }

/* 경고장 */
.citation { position: absolute; top: 12px; right: 12px; z-index: 900; width: 230px; padding: 12px 14px; background: #f3d6d0; color: #4a1a14; border-left: 6px solid var(--seal); box-shadow: 0 8px 20px rgba(0, 0, 0, .5); font-size: .85rem; line-height: 1.5; animation: citeIn .5s cubic-bezier(.2, 1.4, .4, 1); }
.citation h4 { margin: 0 0 4px; font-family: var(--f-display); font-weight: 400; color: var(--seal); font-size: 1.1rem; }
.citation.out { animation: docOut .5s forwards; }
@keyframes citeIn { from { transform: translateY(-40px) rotate(6deg); opacity: 0; } }

/* ---------- 정산 ---------- */
#screen-settle { align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 20%, #1d2436, var(--ink) 70%); overflow-y: auto; padding: 20px; }
.settle-wrap { width: 100%; max-width: 520px; padding: 26px 26px 24px; box-shadow: 0 20px 50px rgba(0, 0, 0, .6); margin: auto; border: 1px solid #b9a982; }
.settle-title { font-family: var(--f-display); font-weight: 400; text-align: center; font-size: 1.8rem; margin: 0; color: #3a2516; }
.settle-sub { text-align: center; opacity: .65; margin: .3em 0 1em; font-size: .9rem; }
.ledger .row { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px dashed rgba(60, 40, 20, .3); opacity: 0; animation: fadeUp .4s forwards; }
.ledger .row .amt { font-family: var(--f-doc); font-weight: 700; }
.ledger .row.plus .amt { color: #2f6b3a; } .ledger .row.minus .amt { color: var(--seal); } .ledger .row.shady .amt { color: #8a6a1f; }
.ledger .row.shady .lbl::after { content: ' (뒷돈)'; font-size: .75em; opacity: .7; }
.settle-total { margin-top: 12px; padding-top: 10px; border-top: 2px solid #3a2516; display: flex; justify-content: space-between; align-items: baseline; font-family: var(--f-display); font-size: 1.3rem; opacity: 0; animation: fadeUp .5s forwards; }
.settle-total .coins { font-size: 1.7rem; color: #8a5a10; }
.settle-total .coins.neg { color: var(--seal); }
.epilogue { margin: 18px 0 20px; }
.epilogue h4 { font-family: var(--f-display); font-weight: 400; margin: 0 0 8px; font-size: 1.1rem; color: var(--seal); }
.epilogue p { margin: 0 0 8px; line-height: 1.7; font-size: .92rem; padding-left: 12px; border-left: 2px solid rgba(184, 41, 47, .4); opacity: 0; animation: fadeUp .6s forwards; }
.settle-wrap .btn { display: block; margin: 0 auto; }

/* ---------- 엔딩 ---------- */
#screen-ending { align-items: center; justify-content: center; overflow-y: auto; background: radial-gradient(ellipse at 50% 30%, #1d2436, var(--ink) 70%); }
#screen-ending.tone-blood { background: radial-gradient(ellipse at 50% 30%, #4a1014, #0d0607 70%); }
#screen-ending.tone-gold { background: radial-gradient(ellipse at 50% 30%, #3d2e10, #0d0a05 70%); }
#screen-ending.tone-spirit { background: radial-gradient(ellipse at 50% 30%, #12364a, #060d12 70%); }
.ending-wrap { max-width: 560px; width: 100%; padding: 36px 22px; text-align: center; margin: auto; }
.ending-seal { display: inline-grid; place-items: center; width: 120px; height: 120px; border: 8px double var(--seal); color: var(--seal); font-family: var(--f-display); font-size: 74px; border-radius: 8px; transform: rotate(-8deg); background: rgba(232, 223, 200, .92); --srot: -8deg; animation: stampIn .7s .3s cubic-bezier(.3, 1.6, .5, 1) both; }
.ending-kicker { letter-spacing: .5em; opacity: .6; margin: 22px 0 0; }
.ending-title { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 8vw, 3rem); margin: .1em 0 .6em; color: #f3ead2; text-shadow: 0 0 20px rgba(230, 157, 69, .35); }
.ending-text p { text-align: left; line-height: 1.9; opacity: 0; animation: fadeUp .8s forwards; }
.ending-stats { text-align: left; margin: 20px 0; padding: 14px 18px; font-size: .92rem; line-height: 1.8; }
.ending-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- 모달 ---------- */
.modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; background: rgba(5, 6, 9, .78); padding: 16px; backdrop-filter: blur(3px); }
.modal.open { display: flex; animation: screenIn .25s; }
.modal-box { position: relative; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; padding: 26px 24px; border-radius: 3px; box-shadow: 0 20px 60px rgba(0, 0, 0, .7); }
.modal-close { position: absolute; top: 8px; right: 10px; border: none; background: none; font-size: 1.3rem; color: #5a3a20; }
.modal-body h2 { font-family: var(--f-display); font-weight: 400; margin: 0 0 12px; color: #3a2516; }
.modal-body h3 { font-family: var(--f-display); font-weight: 400; color: var(--seal); margin: 18px 0 6px; }
.modal-body p, .modal-body li { line-height: 1.75; font-size: .95rem; }
.modal-body .menu-list { display: flex; flex-direction: column; gap: 8px; }
.modal-body .menu-list .btn { color: var(--hanji); }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.codex-card { border: 1px solid #b9a982; background: rgba(255, 255, 255, .25); padding: 14px 10px; text-align: center; cursor: pointer; border-radius: 3px; transition: transform .15s; color: var(--text-dark); font-family: var(--f-body); }
.codex-card:hover { transform: translateY(-2px); }
.codex-card .ico { font-family: var(--f-display); font-size: 2.2rem; color: var(--seal); }
.codex-card .nm { font-weight: 700; margin-top: 4px; font-size: .92rem; }
.codex-card .sb { font-size: .72rem; opacity: .6; }
.codex-card.locked { cursor: default; filter: grayscale(1); opacity: .55; }
.codex-card.locked .ico { color: #777; }
.lore-view .ico { font-family: var(--f-display); font-size: 3rem; color: var(--seal); text-align: center; }
.lore-view p { text-indent: 1em; }
.ending-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ending-chips span { border: 1px solid #b9a982; padding: 4px 10px; border-radius: 14px; font-size: .82rem; }
.ending-chips span.got { background: var(--seal); color: #fff; border-color: var(--seal); }

/* ---------- 토스트 & 효과 ---------- */
#toast-layer { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 1100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: rgba(18, 19, 22, .94); color: var(--hanji); border: 1px solid var(--lantern); padding: 10px 16px; border-radius: 3px; font-size: .9rem; line-height: 1.5; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); animation: toastIn .35s ease; text-align: center; }
.toast.good { border-color: #5aa36a; } .toast.bad { border-color: var(--seal); } .toast.lore { border-color: var(--wisp); color: #cdf2ff; }
.toast.out { animation: toastOut .4s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }
#fx-flash { position: fixed; inset: 0; pointer-events: none; z-index: 1050; opacity: 0; }
#fx-flash.blood { animation: flashBlood 2.4s ease forwards; }
#fx-flash.wisp { animation: flashWisp 1s ease forwards; }
@keyframes flashBlood { 0% { opacity: 0; background: #b8292f; } 10% { opacity: .75; } 30% { opacity: .2; } 45% { opacity: .65; } 100% { opacity: 0; background: #400; } }
@keyframes flashWisp { 0% { opacity: 0; background: radial-gradient(circle, #38bdf8, transparent 70%); } 20% { opacity: .7; } 100% { opacity: 0; background: radial-gradient(circle, #38bdf8, transparent 70%); } }
.shake { animation: shake .45s; }
@keyframes shake { 10%, 90% { transform: translate(-1px, 0); } 20%, 80% { transform: translate(3px, 1px); } 30%, 50%, 70% { transform: translate(-5px, -1px); } 40%, 60% { transform: translate(5px, 1px); } }
#app.quake { animation: shake .5s 3; }

/* =========================================================
 *  모바일 (세로) — max-width: 768px
 * ========================================================= */
@media (max-width: 768px) {
  .game-main { flex-direction: column; }
  .booth { width: 100%; height: 38%; flex: 0 0 38%; border-right: none; border-bottom: 3px solid #2a1b10; display: block; }
  .scene { position: absolute; inset: 0; border-bottom: none; }
  .scene .lantern { top: 40px; left: auto; right: 8%; }
  .scene .lantern .lantern-body { width: 24px; height: 32px; }
  .scene .lantern .lantern-body span { font-size: 10px; }
  .scene .moon { width: 30px; height: 30px; top: 8%; right: auto; left: 40%; }
  .portrait-wrap { left: 25%; height: 92%; }
  .gate-post.left { left: 2%; } .gate-post.right { right: 2%; width: 12px; }
  .speech { position: absolute; top: 8px; right: 8px; left: 48%; margin: 0; min-height: 0; max-height: calc(100% - 62px); overflow-y: auto; padding: 9px 11px 12px; }
  .speech::before { top: 22px; left: -10px; border: 10px solid transparent; border-left: 0; border-right-color: var(--hanji); }
  .speech-name { font-size: .82rem; margin-bottom: 2px; }
  .speech-text { font-size: .86rem; line-height: 1.55; min-height: 0; }
  .booth-actions { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
  .tool-btn { padding: 6px 10px; font-size: .82rem; }
  .q-chip { font-size: .76rem; padding: 6px 9px; }
  .rules-panel { display: none; }
  .booth.mirror-on .speech { opacity: .15; pointer-events: none; }
  .lens { width: 110px; height: 110px; }
  .scene-caption { top: auto; bottom: 50px; font-size: .85rem; }

  .desk { width: 100%; flex: 1; }
  .desk-tab { padding: 6px 11px; font-size: .8rem; }
  .desk-tab.mobile-only { display: block; }
  .stamp-bar { position: relative; right: auto; bottom: auto; flex: 0 0 auto; gap: 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: #1a120b; border-top: 2px solid #2a1b10; }
  .stamp-btn { flex: 1; width: auto; height: 62px; flex-direction: row; justify-content: center; gap: 10px; margin: 0 4px; border-radius: 8px; background: linear-gradient(180deg, #c8363c, #8d1c21); box-shadow: 0 5px 0 #4a0d10; }
  .stamp-btn.deny { background: linear-gradient(180deg, #3a3f52, #1d2232); box-shadow: 0 5px 0 #0c0f18; }
  .stamp-handle { display: none; }
  .stamp-face { width: auto; height: auto; margin: 0; background: none !important; box-shadow: none !important; font-size: 34px; }
  .stamp-label { position: static; font-size: 1.05rem; font-weight: 700; color: #fff4e0; letter-spacing: .2em; }
  .stamp-btn:hover:not(:disabled) { transform: none; }
  .stamp-btn:active:not(:disabled), .stamp-btn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 #4a0d10; }

  .doc.hopae { width: 136px; padding: 26px 11px 12px; }
  .doc.permit { width: 214px; padding: 13px 14px 16px; }
  .doc.registry { width: 252px; padding: 10px 12px 12px 22px; }
  .doc.rules-doc { width: 260px; }
  .doc .val { font-size: .86rem; }
  .stamp-mark { width: 86px; height: 86px; margin: -43px 0 0 -43px; font-size: 50px; }
  .citation { width: 200px; font-size: .78rem; }
  .desk-hint { font-size: .75rem; }
  .topbar { padding: 0 8px; }
  .tb-date, .tb-mid { display: none; }
  .tb-stat { font-size: .82rem; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }
}
@media (max-width: 768px) and (max-height: 620px) {
  .speech-text { font-size: .8rem; }
  .stamp-btn { height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* =========================================================
 *  일러스트 (assets/img) — 있으면 CSS 배경 대신 사용
 * ========================================================= */
#screen-title.has-img .night-sky { background: linear-gradient(180deg, rgba(10, 11, 15, .35), rgba(10, 11, 15, .55) 50%, rgba(10, 11, 15, .9)), var(--title-img) center / cover no-repeat; }
#screen-title.has-img .night-sky > *, #screen-title.has-img .title-mtn { display: none; }
#screen-title.has-img .title-lantern { display: none; }
#screen-title.has-img .title-main { margin-top: 0; }

.scene.has-img .scene-bg { background: var(--scene-img) center 70% / cover no-repeat; }
.scene.has-img .scene-bg > *:not(.mist) { display: none; }
.scene.has-img .candle-glow { background: radial-gradient(circle at 18% 28%, rgba(230, 157, 69, .28), transparent 45%), radial-gradient(ellipse at 50% 120%, rgba(230, 157, 69, .14), transparent 60%); }

.desk-surface.has-img { background-image: linear-gradient(180deg, rgba(0, 0, 0, .05), rgba(0, 0, 0, .35)), var(--desk-img); background-size: auto, cover; background-position: center; }

/* 일러스트 초상화 */
.portrait-wrap.img { aspect-ratio: 1 / 1; height: 94%; }
.portrait-wrap.img > img { object-fit: cover; user-select: none;
  -webkit-mask-image: radial-gradient(ellipse 60% 66% at 50% 48%, #000 62%, transparent 100%);
  mask-image: radial-gradient(ellipse 60% 66% at 50% 48%, #000 62%, transparent 100%); }
#portrait-human.img > img { filter: brightness(.95) contrast(1.03); }
#portrait-true.img > img { filter: drop-shadow(0 0 10px rgba(56, 189, 248, .5)) contrast(1.08); }
@media (max-width: 768px) {
  .portrait-wrap.img { height: 100%; left: 24%; }
}

/* 본모습 일러스트가 없을 때: 인간 일러스트를 요괴로 변조 */
#portrait-true.img > img.morph-wonhon { filter: grayscale(.85) sepia(.15) hue-rotate(170deg) saturate(1.8) contrast(1.25) brightness(1.08) drop-shadow(0 0 14px rgba(140, 200, 230, .7)); }
#portrait-true.img > img.morph-gumiho { filter: sepia(.6) saturate(2) hue-rotate(-12deg) contrast(1.2) drop-shadow(0 0 14px rgba(255, 200, 120, .8)); }
#portrait-true.img > img.morph-dokkaebi { filter: sepia(1) saturate(4) hue-rotate(-30deg) contrast(1.2) drop-shadow(0 0 14px rgba(56, 189, 248, .8)); }
.morph-fx { position: absolute; inset: 0; pointer-events: none; }
.morph-fx-wonhon {
  background:
    linear-gradient(180deg, rgba(150, 8, 18, .95), rgba(150, 8, 18, .75) 65%, transparent) 36.6% 50% / 1.3% 24% no-repeat,
    linear-gradient(180deg, rgba(150, 8, 18, .95), rgba(150, 8, 18, .75) 70%, transparent) 52% 52% / 1.3% 27% no-repeat,
    radial-gradient(circle at 37% 37%, rgba(0, 0, 0, .55) 0 2.4%, transparent 3.6%),
    radial-gradient(circle at 52% 37%, rgba(0, 0, 0, .55) 0 2.4%, transparent 3.6%),
    radial-gradient(ellipse 55% 62% at 50% 46%, transparent 45%, rgba(60, 120, 160, .45) 100%);
  animation: ghostFlicker 2.2s infinite;
}
@keyframes ghostFlicker { 0%, 100% { opacity: 1; } 47% { opacity: .85; } 50% { opacity: .5; } 53% { opacity: .95; } }

/* ---------- 음향 설정 패널 ---------- */
.sound-box { border: 1px solid #b9a982; background: rgba(42, 31, 22, .06); padding: 12px 14px; border-radius: 4px; margin-bottom: 14px; }
.sound-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: .92rem; }
.sound-row input[type="range"] { flex: 1; max-width: 240px; accent-color: var(--seal); cursor: pointer; }
.sound-test { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .82rem; }
.sound-test .sfx-demo { color: var(--text-dark); border-color: #9c8964; background: rgba(255, 255, 255, .45); }
.sound-test .sfx-demo:hover { border-color: var(--seal); background: rgba(184, 41, 47, .12); }

/* ---------- 살생부 다수 항목 스크롤 ---------- */
.reg-scroll { max-height: 290px; overflow-y: auto; padding-right: 4px; touch-action: pan-y; }
.reg-scroll::-webkit-scrollbar { width: 5px; }
.reg-scroll::-webkit-scrollbar-thumb { background: rgba(74, 26, 20, .35); border-radius: 3px; }
@media (max-width: 768px) {
  .reg-scroll { max-height: 210px; }
}
.settle-partner { margin-top: 14px; padding-top: 10px; border-top: 1px dashed rgba(74,26,20,.25); text-align: center; }
.settle-partner[hidden] { display: none; }
.settle-partner iframe { display: block; width: 100%; height: 75px; border: 0; border-radius: 6px; background: #fff; }
.partner-notice { margin: 5px 0 0; font-size: .7rem; color: #6b5a45; line-height: 1.3; }
