:root {
  --bg1: #1b1612; --bg2: #0e0b09; --panel: #261f1a; --panel2: #31281f; --line: rgba(245, 215, 160, 0.14);
  --text: #f3e9da; --dim: #c4b49f; --accent: #f2a93b; --accent2: #ffd28a; --ok: #5ad08a; --bad: #f2665a;
  --me: #3a5a8c; --them: #2f2620; --r: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 70% at 50% -10%, #3a2b1c 0%, transparent 60%), linear-gradient(180deg, var(--bg1), var(--bg2));
  background-color: var(--bg2);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
[hidden] { display: none !important; }
h2, h3, h4 { margin: 0; }
p { margin: 4px 0; line-height: 1.5; }
.dim { color: var(--dim); }
.small { font-size: 0.84rem; }
.ok { color: var(--ok); } .bad { color: var(--bad); }

.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: rgba(242, 169, 59, 0.12); border: 1px solid rgba(242, 169, 59, 0.35); color: var(--accent2);
  text-decoration: none; font-size: 0.85rem; font-weight: 700;
}
.ai-chip { margin-left: auto; font-size: 0.78rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.ai-chip.on { color: var(--ok); border-color: rgba(90, 208, 138, 0.4); }
.ai-chip.off { color: #f5cf5b; border-color: rgba(245, 207, 91, 0.4); }
.mini { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-weight: 800; }

.screen { flex: 1; overflow-y: auto; padding: 4px 16px 32px; }
.screen > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h3 { margin-bottom: 6px; font-size: 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-weight: 800; text-decoration: none; }
.btn.go { background: var(--accent); color: #2a1a06; border-color: var(--accent); }
.btn.small { padding: 7px 10px; font-size: 0.85rem; }
.btn.wide { width: 100%; padding: 14px; font-size: 1.05rem; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row > .btn { flex: 1; }
.chip { font-style: normal; font-size: 0.7rem; padding: 1px 7px; border-radius: 999px; background: var(--panel2); color: var(--accent2); border: 1px solid var(--line); }

.tabs { display: grid; gap: 6px; }
.tab { padding: 8px 2px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.on { background: var(--accent); color: #2a1a06; border-color: var(--accent); }

/* ── 메뉴 ── */
.logo { text-align: center; margin: 4px auto 16px; }
.logo-lamp { position: relative; font-size: 3.2rem; line-height: 1; padding-top: 34px; }
.lamp-cone {
  position: absolute; left: 50%; top: 0; width: 150px; height: 90px; transform: translateX(-50%);
  background: radial-gradient(60% 100% at 50% 0%, rgba(255, 210, 138, 0.35), transparent 70%);
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%); animation: flicker 4s infinite; pointer-events: none;
}
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: 1; } 48% { opacity: 0.55; } 50% { opacity: 1; } 72% { opacity: 0.85; } }
h1 { margin: 8px 0 4px; font-size: 1.8rem; letter-spacing: 0.02em; }
h1 span { color: var(--accent); }
.tagline { margin: 0; color: var(--dim); font-size: 0.9rem; }
.continue, .big-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; margin-bottom: 10px;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--panel);
}
.continue { border-color: rgba(242, 169, 59, 0.55); background: linear-gradient(90deg, rgba(242, 169, 59, 0.16), var(--panel)); }
.continue .ci { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #2a1a06; }
.big-btn .bi { font-size: 1.8rem; width: 40px; text-align: center; flex: none; }
.continue b, .big-btn b { display: block; font-size: 1.02rem; }
.continue small, .big-btn small { color: var(--dim); font-size: 0.8rem; }
.big-btn.done { opacity: 0.7; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 4px; }
.stats b { display: block; font-size: 1.3rem; color: var(--accent2); }
.stats small { color: var(--dim); font-size: 0.72rem; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.recent li:first-child { border-top: 0; }
.recent .ok { color: var(--accent); letter-spacing: 1px; }
.note { border-color: rgba(245, 207, 91, 0.35); }

/* ── 사건 파일 ── */
.case-head { display: flex; gap: 12px; align-items: center; margin: 4px auto 12px; }
.case-emoji { font-size: 2.6rem; width: 64px; height: 64px; flex: none; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.case-head h2 { font-size: 1.3rem; margin: 2px 0; }
.incident { background: linear-gradient(135deg, #3a2a1a, var(--panel)); border-color: rgba(242, 169, 59, 0.35); }
.incident p { font-size: 1rem; }
.sec { font-size: 0.95rem; color: var(--accent2); margin: 16px auto 8px; }
.ev { display: block; width: 100%; text-align: left; background: #f1e6cf; color: #2a2017; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; border: 0; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.ev p { font-size: 0.85rem; color: #5a4a38; margin: 2px 0 0; }
.ev.pickable:hover { outline: 2px solid var(--accent); }
.sus { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.face { width: 48px; height: 48px; flex: none; position: relative; }
.face .portrait { width: 100%; height: 100%; display: block; }
.portrait { display: block; }
.sus-t { min-width: 0; }
.sus-t p { font-size: 0.86rem; margin-top: 4px; }
.lbl { display: inline-block; font-size: 0.7rem; color: var(--dim); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-right: 4px; }
.claim { color: var(--accent2); }
.rules ul { margin: 6px 0 0; padding-left: 18px; }
.rules li { margin: 3px 0; }

/* ── 심문 ── */
#room { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; max-width: 640px; margin: 0 auto; padding: 0 10px; padding-bottom: env(safe-area-inset-bottom); }
#room.shake { animation: shake 0.45s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.r-head { display: flex; align-items: center; gap: 6px; padding: 4px 0 8px; }
.r-count { margin: 0 auto; font-size: 0.9rem; color: var(--dim); white-space: nowrap; }
.r-count b { color: var(--accent2); font-size: 1.1rem; display: inline-block; }
.r-count.pop b { animation: pop 0.4s; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.5); color: var(--bad); } 100% { transform: scale(1); } }
.r-count b.warn { color: var(--bad); }
#rNote { position: relative; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-style: normal; font-size: 0.7rem; display: grid; place-items: center; }
.sus-tabs { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 6px; }
.sus-tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); position: relative; min-width: 0; }
.sus-tab .portrait { width: 40px; height: 40px; }
.sus-tab b { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sus-tab.on { border-color: var(--accent); background: linear-gradient(180deg, rgba(242, 169, 59, 0.22), var(--panel)); }
.sus-tab .st { position: absolute; top: 4px; right: 6px; font-style: normal; font-size: 0.72rem; font-weight: 800; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
.sus-tab .st.ok { background: var(--ok); color: #06240f; }
.sus-tab .st.bad { background: var(--bad); color: #fff; }
.sus-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-top: 8px; border-radius: 14px; background: linear-gradient(90deg, rgba(242, 169, 59, 0.1), var(--panel)); border: 1px solid var(--line); }
.sus-card .portrait.big { width: 64px; height: 64px; flex: none; }
.sc-face { flex: none; }
.sc-face[data-mood="angry"], .sc-face[data-mood="shocked"] { animation: pop 0.35s; }
.sus-card .sc-t b { font-size: 1.05rem; }
.sus-card p { margin: 3px 0 0; }
.chat { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 2px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; font-size: 0.95rem; line-height: 1.5; }
.msg.me { align-self: flex-end; background: var(--me); padding: 8px 12px; border-radius: 16px 16px 4px 16px; }
.msg.me.contra { background: #6b3a1f; border: 1px solid rgba(242, 169, 59, 0.5); }
.btn.zap { background: linear-gradient(180deg, #5a3a12, var(--panel2)); border-color: rgba(242, 169, 59, 0.5); color: var(--accent2); }
.type-tag { color: var(--accent2); }
.evt { color: var(--accent2); font-size: 0.9rem; }
.chip.key { color: #ffd28a; border-color: rgba(255, 210, 138, 0.5); }
.layout { margin: 0; padding-left: 18px; font-size: 0.88rem; }
.layout li { margin: 4px 0; line-height: 1.5; }
.layout i { font-style: normal; }
.layout i.scene { color: var(--bad); font-weight: 800; }
.nb-tabs { grid-template-columns: repeat(4, 1fr); margin-bottom: 10px; }
.nb li.retracted { text-decoration: line-through; opacity: 0.55; }
.sum-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.sum-row:first-child { border-top: 0; }
.sum-row .face { width: 40px; height: 40px; }
.sum-row p { margin: 2px 0; }
.warn { color: #f5cf5b; }
.sheet .sticky { background: linear-gradient(180deg, transparent, var(--bg1) 30%); }
.msg.them { align-self: flex-start; display: flex; gap: 6px; align-items: flex-end; }
.msg.them .who { width: 30px; height: 30px; flex: none; }
.msg.them .who .portrait { width: 30px; height: 30px; }
.msg.sys.hint { color: #ffe9b3; border-color: rgba(255, 233, 179, 0.5); }
.msg.sys.hit { color: #ffd28a; background: rgba(242, 102, 90, 0.16); border-color: rgba(242, 102, 90, 0.6); font-weight: 700; }
.msg.sys.miss { color: var(--dim); }
.msg.them .bub { background: var(--them); border: 1px solid var(--line); padding: 8px 12px; border-radius: 16px 16px 16px 4px; }
.msg.sys { align-self: center; max-width: 94%; font-size: 0.8rem; color: var(--accent2); background: rgba(242, 169, 59, 0.1); border: 1px dashed rgba(242, 169, 59, 0.4); padding: 6px 10px; border-radius: 10px; }
.ev-tag { display: block; font-size: 0.75rem; background: #f1e6cf; color: #2a2017; border-radius: 6px; padding: 1px 6px; margin-bottom: 4px; width: fit-content; }
.off { font-style: normal; color: #f5cf5b; margin-left: 4px; }
.typing i { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--dim); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 100% { opacity: 0.3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.quick { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.qchip { flex: none; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 0.8rem; color: var(--dim); }
.out { font-size: 0.85rem; color: var(--accent2); padding: 4px 2px; }
.ask { display: flex; gap: 6px; padding: 6px 0 10px; }
.ask input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: #120e0b; color: var(--text); font: inherit; font-size: 16px; }
.ask input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ev-btn { padding: 10px; white-space: nowrap; }

/* ── 지목 ── */
.acc-h { margin: 6px auto 2px; font-size: 1.3rem; }
.acc-sus { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 8px; }
.acc-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); }
.acc-pick .face { width: 56px; height: 56px; }
.acc-pick small { color: var(--dim); font-size: 0.72rem; text-align: center; }
.acc-pick.on { border-color: var(--bad); background: linear-gradient(180deg, rgba(242, 102, 90, 0.2), var(--panel)); }
.acc-basis { display: flex; flex-direction: column; gap: 6px; }
.basis { text-align: left; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); font-size: 0.86rem; line-height: 1.45; }
.basis .k { font-style: normal; font-size: 0.68rem; font-weight: 800; color: var(--accent2); margin-right: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
.basis.on { border-color: var(--accent); background: linear-gradient(90deg, rgba(242, 169, 59, 0.18), var(--panel)); }
.sticky { position: sticky; bottom: 0; padding: 10px 0; background: linear-gradient(180deg, transparent, var(--bg2) 30%); }

/* ── 결과 ── */
.verdict { text-align: center; padding: 18px 12px; border-radius: var(--r); margin: 6px auto 12px; border: 1px solid var(--line); }
.verdict.ok { background: linear-gradient(180deg, rgba(90, 208, 138, 0.18), var(--panel)); }
.verdict.bad { background: linear-gradient(180deg, rgba(242, 102, 90, 0.18), var(--panel)); }
.v-face { display: flex; justify-content: center; }
.v-face .portrait.big { width: 84px; height: 84px; }
.verdict h2 { font-size: 1.35rem; margin: 6px 0; }
.v-stars { font-size: 1.8rem; color: var(--accent); letter-spacing: 4px; }
.keys { list-style: none; margin: 0; padding: 0; font-size: 0.86rem; }
.keys li { padding: 4px 0; color: var(--dim); }
.keys li.got { color: var(--ok); }

/* ── 겹침 창·토스트·오류 ── */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { width: 100%; max-width: 640px; max-height: 82vh; display: flex; flex-direction: column; background: var(--bg1); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-body { overflow-y: auto; padding: 12px 16px 18px; }
.nb-h { margin: 12px 0 6px; color: var(--accent2); font-size: 0.92rem; }
.nb-h:first-child { margin-top: 0; }
.nb { margin: 0; padding-left: 18px; font-size: 0.88rem; }
.nb li { margin: 4px 0; line-height: 1.45; }
.help { padding-left: 20px; margin: 0 0 10px; }
.help li { margin: 6px 0; line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #000c; color: #fff; padding: 9px 14px; border-radius: 12px; font-size: 0.86rem; z-index: 30; max-width: 90vw; text-align: center; }
.fatal { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg2); z-index: 40; padding: 16px; }
.fatal .card { max-width: 360px; text-align: center; }
.fatal .btn { margin: 6px 4px 0; }

@media (max-width: 480px) {
  .sus-tab .portrait { width: 34px; height: 34px; }
  .sus-tab b { font-size: 0.74rem; }
  .sus-card .portrait.big { width: 52px; height: 52px; }
}
@media (max-width: 380px) {
  .back-txt { display: none; }
}

/* ── 도장 ── */
.stamp { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%) rotate(-12deg); font-size: 2.6rem; font-weight: 900; letter-spacing: 0.1em; padding: 6px 22px; border: 5px solid; border-radius: 12px; z-index: 35; pointer-events: none; animation: stampIn 1.1s forwards; }
.stamp.hit { color: #ff5a4a; border-color: #ff5a4a; background: rgba(20, 8, 4, 0.6); }
.stamp.miss { color: #9aa; border-color: #9aa; background: rgba(0, 0, 0, 0.5); }
@keyframes stampIn { 0% { transform: translate(-50%, -50%) rotate(-12deg) scale(2.2); opacity: 0; } 15% { transform: translate(-50%, -50%) rotate(-12deg) scale(1); opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ── 평면도 ── */
.plan-card { padding: 8px; }
.plan { width: 100%; height: auto; display: block; }
.pl-hall { fill: #4a3a2a; }
.pl-hall-t { fill: #d8c7a8; font-size: 8px; font-weight: 700; }
.pl-link { stroke: rgba(245, 215, 160, 0.35); stroke-width: 1.5; }
.pl-room { fill: #2f2620; stroke: rgba(245, 215, 160, 0.3); }
.pl-aux { fill: #27211c; stroke: rgba(245, 215, 160, 0.18); }
.pl-scene { fill: #5a1f1a; stroke: #f2665a; stroke-width: 1.5; }
.pl-exit { fill: #2a3a4a; stroke: #7cc4ff; }
.pl-conn { fill: #3a3a3a; stroke: rgba(245, 215, 160, 0.3); }
.pl-t { fill: #f3e9da; font-size: 7.5px; font-weight: 700; }
.pl-scene-t { fill: #ffd4cf; }
.pl-mark { fill: #f2a93b; font-size: 7px; font-weight: 800; }
.pl-path { fill: none; stroke: #ff5a4a; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw 2.2s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.pl-dot { fill: #ff5a4a; }
.pl-hit { fill: none; stroke: #ff5a4a; stroke-width: 2; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { r: 5; opacity: 1; } 50% { r: 9; opacity: 0.4; } }
.ev-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.ev-row .ev { flex: 0 0 min(78%, 300px); scroll-snap-align: start; margin-bottom: 0; }

/* ── 타임라인 ── */
.tl-wrap { overflow-x: auto; }
.timeline { min-width: 340px; width: 100%; height: auto; display: block; }
.tl-win { fill: rgba(242, 102, 90, 0.14); }
.tl-grid { stroke: rgba(245, 215, 160, 0.12); }
.tl-time { fill: var(--dim); font-size: 7px; }
.tl-crime { fill: #ff8a7a; font-weight: 800; }
.tl-name { fill: var(--text); font-size: 9px; font-weight: 800; }
.tl-status { fill: var(--dim); font-size: 7px; }
.tl-claim { fill: rgba(242, 169, 59, 0.22); stroke: rgba(242, 169, 59, 0.5); }
.tl-claim.lie { stroke-dasharray: 3 2; }
.tl-claim-t { fill: #ffd28a; font-size: 6.5px; }
.tl-absent { fill: rgba(242, 102, 90, 0.25); stroke: #f2665a; stroke-dasharray: 2 2; }
.tl-ok { fill: var(--ok); }
.tl-bad { fill: var(--bad); }
.tl-x line { stroke: var(--bad); stroke-width: 2.2; }
.nb-tabs { grid-template-columns: repeat(5, 1fr); }
.zap-mini { margin-left: 4px; padding: 0 6px; border-radius: 8px; border: 1px solid rgba(242, 169, 59, 0.5); background: rgba(242, 169, 59, 0.12); font-size: 0.75rem; vertical-align: middle; }
