:root {
  --ink: #1d1d22;
  --paper: #f7f3ea;
  --red: #e0383e;
  --gold: #f2c14e;
  --orange: #f2a14a;
  --font: 'Galmuri11', 'Galmuri9', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: none; user-select: none; }
button { font-family: inherit; }
.hidden { display: none !important; }

#viewport { position: fixed; inset: 0; }
/* 이미지 확대·축소: 원본(1024~1536px)을 화면 크기에 맞춰 줄여서 보여 주므로 부드럽게(auto) 줄인다.
   픽셀 그대로(pixelated) 줄이면 점이 불규칙하게 빠져 화질이 깨져 보인다. 탐색 맵은 정수 배율일 때만 pixelated. */
#stage {
  position: absolute; width: 1280px; height: 720px; transform-origin: 0 0;
  overflow: hidden; background: #111;
}
#bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: var(--pix, auto); }

/* ---------- 전환 / 효과 ---------- */
#fade { position: absolute; inset: 0; z-index: 88; background: #000; opacity: 0; pointer-events: none; transition: opacity .45s; }
#fade.on { opacity: 1; }
#flash { position: absolute; inset: 0; z-index: 87; opacity: 0; pointer-events: none; }
#flash.go { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
#stage.quake > :not(#fade):not(#flash) { animation: quake .38s linear; }
@keyframes quake { 0%,100% { translate: 0 0; } 20% { translate: -14px 6px; } 40% { translate: 12px -8px; } 60% { translate: -8px 4px; } 80% { translate: 6px -2px; } }
.bg-old { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: var(--pix, auto); animation: fadeout .35s forwards; pointer-events: none; }
@keyframes fadeout { to { opacity: 0; } }
.cutv.flying { box-shadow: 0 0 0 4px var(--gold); }

/* ---------- 캐릭터 ---------- */
#chars { position: absolute; inset: 0; pointer-events: none; }
.char {
  position: absolute; bottom: 92px; height: 610px; width: auto;
  transform: translateX(-50%); transition: left .3s, filter .2s, opacity .3s, transform .3s;
  image-rendering: var(--pix, auto);
  /* 이미지 가장자리에서 잘린 팔·몸이 네모로 끊겨 보이지 않게 양옆과 아래를 흐린다 */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent), linear-gradient(#000 72%, transparent 97%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent), linear-gradient(#000 72%, transparent 97%);
  mask-composite: intersect;
}
.char.enter { opacity: 0; transform: translateX(-50%) translateY(20px); }
.char[data-pos="left"] { left: 25%; }
.char[data-pos="center"] { left: 50%; }
.char[data-pos="right"] { left: 75%; }
.char[data-pos="farleft"] { left: 14%; }
.char[data-pos="farright"] { left: 86%; }
.char.dim { filter: brightness(.55); }
.char.leave { opacity: 0; transform: translateX(-50%) translateY(16px); }
.char.hop { animation: hop .28s ease-out; }
@keyframes hop { 40% { translate: 0 -10px; } }
.char.shake { animation: shake .3s linear 2; }
@keyframes shake { 0%,100% { margin-left: 0; } 25% { margin-left: -8px; } 75% { margin-left: 8px; } }

/* ---------- 대사창 ---------- */
#textbox {
  position: absolute; left: 40px; right: 40px; bottom: 24px; height: 170px; z-index: 20;
  background: rgba(247, 243, 234, .96); border: 4px solid var(--ink);
  box-shadow: 0 6px 22px rgba(0,0,0,.35);
  padding: 34px 34px 20px; cursor: pointer;
}
#textbox.narr { background: rgba(20, 20, 26, .92); color: #eee; border-color: #888; }
#tb-name {
  position: absolute; top: -26px; left: 24px; padding: 6px 18px;
  color: #fff; font-size: 24px; border: 4px solid var(--ink);
}
#tb-name:empty { display: none; }
#tb-text { font-size: calc(27px * var(--tb-scale, 1)); line-height: 1.55; white-space: pre-wrap; }
#tb-next { position: absolute; right: 22px; bottom: 12px; font-size: 20px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 선택지 / 행동 ---------- */
#choices {
  position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.ch-prompt { color: #fff; font-size: 26px; margin-bottom: 10px; text-shadow: 2px 2px 0 #000; }
.ch-btn {
  width: 640px; padding: 18px 24px; font-size: 26px; text-align: left;
  background: var(--paper); border: 4px solid var(--ink); box-shadow: 0 6px 22px rgba(0,0,0,.35); cursor: pointer;
}
.ch-btn:hover { background: var(--gold); transform: translateX(8px); }

#actions {
  position: absolute; left: 40px; right: 40px; bottom: 204px; z-index: 21;
  display: flex; justify-content: center; gap: 14px;
}
.act-btn {
  padding: 14px 26px; font-size: 24px; cursor: pointer;
  background: var(--paper); border: 4px solid var(--ink); box-shadow: 0 6px 22px rgba(0,0,0,.35);
}
.act-btn:hover:not(:disabled) { background: var(--btn-hi, #2e3250); color: var(--txt, #eee); transform: translateY(-3px); }
.act-btn:disabled { opacity: .4; cursor: default; }
.act-btn.objection { background: var(--red); color: #fff; font-size: 28px; font-weight: bold; }
.act-btn.objection:hover { background: #ff4f55; }
.act-btn.press { background: #3b6fd0; color: #fff; }
.act-btn.koharu { background: var(--orange); }
.act-btn.small { font-size: 20px; padding: 12px 18px; }

/* ---------- 목표 / HUD ---------- */
#goal {
  position: absolute; top: 16px; left: 16px; right: 170px; z-index: 25;
  background: rgba(20,20,26,.88); color: #fff; border-left: 8px solid var(--gold);
  padding: 12px 18px; font-size: 22px; line-height: 1.4;
}
#goal b { color: var(--gold); margin-right: 10px; }
#hud { position: absolute; top: 16px; right: 16px; z-index: 26; display: flex; gap: 8px; align-items: flex-start; }
.hud-btn {
  padding: 12px 22px; font-size: 22px; cursor: pointer;
  background: var(--paper); border: 4px solid var(--ink); box-shadow: 0 6px 22px rgba(0,0,0,.35);
}
.hud-btn.small { padding: 8px 10px; font-size: 16px; border-width: 3px; box-shadow: 0 6px 22px rgba(0,0,0,.35); background: rgba(247,243,234,.85); }
.hud-btn.on { background: var(--gold); }
#btn-note.pulse { animation: pulse .5s ease-out; }
@keyframes pulse { 40% { transform: scale(1.18); background: var(--gold); } }
#goal { right: 372px; font-size: 20px; }

/* ---------- 배너 ---------- */
#banner {
  position: absolute; inset: 0; z-index: 60; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75); color: #fff;
  animation: fadein .3s;
}
.bn-main { font-size: 64px; font-weight: bold; text-shadow: 4px 4px 0 #000; }
.bn-sub { font-size: 28px; margin-top: 14px; color: #ccc; }
#banner.objection { background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(224,56,62,.9) 0 3deg, rgba(20,0,0,.9) 3deg 10deg); }
#banner.objection .bn-main { font-size: 110px; color: #fff; -webkit-text-stroke: 4px #000; animation: slam .4s ease-out; }
#banner.objection .bn-sub { font-size: 34px; color: #fff; background: #000; padding: 8px 18px; }
@keyframes slam { 0% { transform: scale(2.5) rotate(-6deg); opacity: 0; } 100% { transform: scale(1) rotate(-3deg); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } }

#toast {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: #fff; border: 3px solid #fff; padding: 12px 22px; font-size: 22px;
}

/* ---------- 모달 ---------- */
#modal {
  position: absolute; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
}
.md-box {
  width: 1120px; max-height: 660px; overflow: auto;
  background: var(--paper); border: 5px solid var(--ink); box-shadow: 0 6px 22px rgba(0,0,0,.35);
  padding: 26px 30px;
}
.md-title { font-size: 32px; font-weight: bold; }
.md-title.gain { color: #5a3ea8; }
.md-sub { font-size: 21px; color: #555; margin: 6px 0 16px; }
.md-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; max-height: 452px; overflow-y: auto; padding: 4px 8px 4px 4px; }
#modal.pick .md-grid .cutv { min-width: 0; }
.md-one { display: flex; justify-content: center; }
.md-one .cutv { width: 440px; }
.md-lines { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.md-empty { color: #888; font-size: 20px; padding: 10px; }
.md-cancel, .md-ok {
  margin-top: 18px; padding: 12px 30px; font-size: 22px; cursor: pointer;
  background: var(--ink); color: #fff; border: none; box-shadow: 0 6px 22px rgba(0,0,0,.35);
}
#modal.gain .md-box { width: 640px; text-align: center; }
.line-btn {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 12px 16px; font-size: 22px; cursor: pointer;
  background: #fff; border: 3px solid var(--ink);
}
.line-btn small { font-size: 16px; color: #666; }
.line-btn:hover:not(.static) { background: var(--gold); }

/* ---------- 컷 ---------- */
.cutv {
  --owner: #555;
  position: relative; background: #fff; color: var(--ink); border: 4px solid var(--ink);
  display: flex; flex-direction: column; aspect-ratio: 4 / 3.4;
}
.cutv-head {
  display: flex; justify-content: space-between; gap: 6px;
  background: var(--owner); color: #fff; font-size: 16px; padding: 4px 8px;
  border-bottom: 3px solid var(--ink);
}
.cutv-body {
  flex: 1; position: relative; overflow: hidden auto;
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 8px; padding: 10px;
  background-color: #fff;
  background-image: radial-gradient(#cfc9bc 1.4px, transparent 1.6px); background-size: 7px 7px;
}
.cutv-body.has-img { padding: 0; background: #111; }
.cutv.has-bubble .cutv-body:not(.has-img) { padding-top: 58px; }
.cutv-zoom {
  position: absolute; right: 6px; bottom: 6px; z-index: 2;
  font-size: 18px; padding: 2px 6px; cursor: zoom-in;
  background: rgba(255,255,255,.9); border: 2px solid var(--ink);
}
.zoom {
  position: absolute; inset: 0; z-index: 95; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.zoom-box { width: 1040px; background: var(--paper); border: 5px solid var(--ink); padding: 14px; text-align: center; }
.zoom-head { font-size: 22px; font-weight: bold; text-align: left; margin-bottom: 8px; }
.zoom-box img { width: 100%; max-height: 540px; object-fit: contain; background: #111; display: block; }
.zoom-cap { font-size: 20px; margin: 10px 0; text-align: left; }
.zoom-box button { font-size: 20px; padding: 8px 26px; background: var(--ink); color: #fff; border: none; cursor: pointer; }
.cutv-cap { font-size: 14px; line-height: 1.35; padding: 4px 8px; border-top: 3px solid var(--ink); background: #fff; }
.cutv-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; user-select: none; }
.cutv-sfx { font-size: 38px; font-weight: bold; text-shadow: 3px 3px 0 #fff; }
.cutv-desc { font-size: 18px; line-height: 1.45; background: rgba(255,255,255,.92); padding: 6px 8px; border: 2px solid var(--ink); }
.cutv-dist { position: absolute; bottom: 6px; left: 6px; font-size: 14px; color: #888; }
.dist-tag { position: absolute; top: 34px; right: 6px; background: var(--red); color: #fff; font-size: 15px; padding: 2px 8px; z-index: 2; }
.cutv.pickable { cursor: pointer; transition: transform .1s; }
.cutv.pickable:hover { transform: translateY(-6px); box-shadow: 0 0 0 5px var(--gold); }
.cutv.dist-낙서 .cutv-body:not(.has-img) { background-image: repeating-linear-gradient(35deg, transparent 0 8px, rgba(200,30,30,.55) 8px 11px), repeating-linear-gradient(-50deg, transparent 0 12px, rgba(0,0,0,.4) 12px 15px); background-size: auto; }
.cutv.dist-미화 .cutv-body:not(.has-img) { background-image: radial-gradient(circle, #f5a3d3 4px, transparent 4.5px); background-size: 26px 26px; }
.cutv.dist-크레용 .cutv-body:not(.has-img) { background-image: repeating-linear-gradient(80deg, #ffe8a8 0 5px, #ffd6e6 5px 9px, #d8f0ff 9px 14px); background-size: auto; }
.cutv.dist-생략 .cutv-body:not(.has-img)::after { content: '(여백)'; position: absolute; right: 4px; top: 4px; width: 22%; height: 26%; opacity: .85; background: #fff; border: 3px dashed #bbb; color: #bbb; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.cutv.dist-과장 .cutv-desc { font-size: 26px; font-weight: bold; }

.bubble {
  position: absolute; top: 40px; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 10px 14px; font-size: 20px; font-weight: bold; white-space: nowrap;
  background: var(--ink);
  clip-path: polygon(0% 15%, 12% 0%, 25% 12%, 40% 0%, 55% 10%, 70% 0%, 85% 12%, 100% 5%, 92% 35%, 100% 60%, 90% 80%, 100% 100%, 75% 90%, 55% 100%, 40% 88%, 22% 100%, 10% 85%, 0% 95%, 6% 55%);
}
.bubble > span { display: block; background: #fff; padding: 4px 10px; }
.bubble.empty > span { color: #999; min-width: 60px; text-align: center; }

/* ---------- 탐색 ---------- */
#explore { position: absolute; right: 40px; top: 90px; z-index: 15; width: 420px; }
.ex-head { display: inline-block; background: rgba(14,16,30,.85); color: var(--txt); border-left: 3px solid var(--accent); font-size: 22px; padding: 6px 16px; }
.ex-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; max-height: 560px; overflow-y: auto; }
.ex-btn { text-align: left; padding: 12px 18px; font-size: 21px; cursor: pointer; background: var(--btn); color: var(--txt); border: 2px solid var(--btn-edge); border-radius: 4px; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 2px 0 var(--btn-edge); }
.ex-btn:hover { background: var(--btn-hi); box-shadow: inset 3px 0 0 var(--accent), 0 2px 0 var(--btn-edge); }
.ex-btn.seen { opacity: .6; }
.ex-btn.seen::after { content: ' ✓'; }
.ex-btn.haunt { animation: haunt 2.4s steps(4) infinite; }
.ex-btn.haunt::after { content: ' …누군가 있다'; color: #8a7fb8; font-size: 18px; }
@keyframes haunt { 0%, 100% { box-shadow: 0 6px 22px rgba(0,0,0,.35); } 50% { box-shadow: 0 0 0 4px #b8aee0, 0 6px 22px rgba(0,0,0,.35); } }

/* ---------- 심문 ---------- */
#trial { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.tr-gauge {
  position: absolute; top: 90px; left: 16px; z-index: 11;
  background: rgba(20,20,26,.88); color: #fff; padding: 10px 16px; font-size: 20px;
  display: flex; align-items: center; gap: 12px;
}
#tr-ink { display: flex; gap: 8px; }
.ink-b { width: 22px; height: 30px; border: 3px solid #fff; border-top-width: 7px; background: linear-gradient(to top, #3b6fd0 75%, transparent 75%); }
.ink-b.empty { background: transparent; opacity: .35; }
.tr-panel { position: absolute; right: 30px; top: 84px; width: 500px; pointer-events: auto; }
.tr-panel .cutv { aspect-ratio: auto; }
.tr-panel .cutv-body { aspect-ratio: 3 / 2; flex: none; }
#actions.trial { right: 560px; justify-content: flex-start; flex-wrap: wrap; }
.tr-panel .cutv { box-shadow: 0 6px 22px rgba(0,0,0,.35); }
.tr-panel .tr-label { background: var(--ink); color: #fff; font-size: 18px; padding: 4px 10px; display: inline-block; margin-bottom: 6px; }
.tr-panel .peeled .cutv-body { animation: peel .7s ease-out; }
@keyframes peel { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }
.tr-dots { display: flex; gap: 8px; margin-top: 8px; }
.tr-dot { width: 64px; height: 10px; background: rgba(255,255,255,.3); }
.tr-dot.on { background: var(--gold); }
.tr-dot.hint { background: var(--orange); box-shadow: 0 0 10px var(--orange); }

/* ---------- 퍼즐 ---------- */
#puzzle {
  position: absolute; inset: 0; z-index: 15; background: #2b2d35;
  display: flex; flex-direction: column; padding: 90px 30px 20px;
}
.pz-main { flex: 1; display: flex; gap: 24px; min-height: 0; }
.pz-paper {
  flex: 1; background: var(--paper); border: 3px solid #000; box-shadow: 0 6px 22px rgba(0,0,0,.35);
  padding: 24px; display: grid; gap: 18px; grid-auto-rows: 1fr; min-height: 0;
  outline: 3px dashed #9db6d6; outline-offset: -12px;
}
.pz-slot { position: relative; border: 4px dashed #b9b2a3; min-height: 0; display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 20px; cursor: pointer; }
.pz-slot.filled { border: none; }
.pz-slot .cutv { width: 100%; height: 100%; aspect-ratio: auto; }
.pz-num { position: absolute; top: -14px; left: -12px; z-index: 4; background: var(--ink); color: #fff; font-size: 18px; padding: 2px 10px; }
.pz-slot.bad-right::after, .pz-slot.bad-left::before {
  content: ''; position: absolute; top: -8px; bottom: -8px; width: 12px; z-index: 5;
  background: repeating-linear-gradient(180deg, var(--red) 0 10px, transparent 10px 18px);
  animation: shake .3s linear 3;
}
.pz-slot.bad-right::after { right: -15px; }
.pz-slot.bad-left::before { left: -15px; }
.pz-slot.decoy { outline: 5px solid var(--red); }
.pz-tray { width: 330px; background: #363944; border: 3px solid #111; padding: 14px; overflow: auto; color: #ddd; }
.pz-tray h3 { margin: 0 0 10px; font-size: 20px; color: #bbb; }
.pz-tray .cutv { margin-bottom: 14px; cursor: pointer; }
.pz-tray .cutv:hover { box-shadow: 0 0 0 5px var(--gold); }
.pz-tray .cutv-desc { font-size: 16px; }
.pz-bar { display: flex; gap: 14px; align-items: center; margin-top: 16px; }
.pz-say { flex: 1; color: #fff; font-size: 22px; background: rgba(0,0,0,.4); padding: 12px 16px; border-left: 6px solid #6fdc6f; min-height: 52px; }
.pz-paper .cutv-desc { font-size: 15px; }
.pz-paper .cutv-sfx { font-size: 28px; }
.pz-slot .bubble { cursor: pointer; }
.pz-paper.reading .pz-slot { opacity: .2; transition: opacity .3s; }
.pz-paper.reading .pz-slot.lit { opacity: 1; }

/* ---------- 타이틀 ---------- */
.title-screen { position: absolute; inset: 0; z-index: 90; color: #fff; overflow: hidden; background: #0b0d1a; transition: opacity .45s; }
.title-screen.leaving { opacity: 0; }
.ts-bg { position: absolute; inset: 0; background-size: cover; background-position: center; image-rendering: var(--pix, auto); }
@keyframes ts-pan { from { transform: scale(1.04) translateX(-1.5%); } to { transform: scale(1.1) translateX(1.5%); } }
.ts-shade { position: absolute; inset: 0; background:
  linear-gradient(90deg, rgba(8,9,20,.92) 0%, rgba(8,9,20,.72) 38%, rgba(8,9,20,.15) 62%, rgba(8,9,20,.35) 100%),
  linear-gradient(0deg, rgba(8,9,20,.85), transparent 35%); }

.ts-char { position: absolute; bottom: -40px; height: 660px; image-rendering: var(--pix, auto);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent), linear-gradient(#000 70%, transparent 96%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent), linear-gradient(#000 70%, transparent 96%);
  mask-composite: intersect; animation: ts-in .9s ease-out both; }
.ts-rei { right: 130px; height: 620px; animation-delay: .15s; }
.ts-koharu { right: -60px; height: 600px; filter: brightness(.7) saturate(.9); }
@keyframes ts-in { from { opacity: 0; transform: translateY(24px); } }

.title-screen.has-key .ts-char { display: none; }
.title-screen.has-key .ts-shade { background: linear-gradient(90deg, rgba(8,9,20,.78) 0%, rgba(8,9,20,.45) 30%, transparent 50%), linear-gradient(0deg, rgba(8,9,20,.6), transparent 30%); }

.ts-logo { position: absolute; left: 80px; top: 48px; animation: ts-in .8s ease-out both; }
.ts-chapter { display: inline-block; padding: 6px 14px; font-size: 20px; letter-spacing: 3px; color: #1d1d22; background: var(--gold); box-shadow: 0 6px 22px rgba(0,0,0,.35); }
.ts-logo h1 { margin: 18px 0 0; font-size: 84px; line-height: 1.08; letter-spacing: 2px; display: flex; flex-direction: column;
  text-shadow: 0 0 0 #000, 5px 5px 0 #000, 9px 9px 0 rgba(224,56,62,.85); }
.ts-logo .ts-l2 { margin-left: 120px; }
.ts-tag { margin-top: 20px; font-size: 22px; color: #c9cbe0; letter-spacing: 1px; padding-left: 4px; border-left: 4px solid var(--red); padding: 2px 0 2px 12px; }

.ts-menu { position: absolute; left: 80px; bottom: 70px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.ts-btn { position: relative; display: block; min-width: 260px; padding: 9px 24px; font-size: 23px; text-align: left; color: #fff; text-decoration: none;
  background: rgba(16,18,34,.82); border: 3px solid #f7f3ea; box-shadow: 0 6px 22px rgba(0,0,0,.35); cursor: pointer; transition: transform .12s, background .12s; }
.ts-btn::before { content: '▶'; position: absolute; left: -30px; top: 50%; transform: translateY(-50%); font-size: 20px; color: var(--gold); opacity: 0; transition: opacity .12s; }
.ts-btn:hover, .ts-btn:focus-visible { transform: translateX(10px); background: rgba(40,44,80,.9); outline: none; }
.ts-btn:hover::before, .ts-btn:focus-visible::before { opacity: 1; }
.ts-btn.primary { color: #1d1d22; background: var(--paper); border-color: #000; }
.ts-btn small { display: block; font-size: 15px; color: #666; margin-top: 2px; }
.ts-btn.primary:hover { background: #fff; }
.ts-btn.small { min-width: 0; padding: 8px 18px; font-size: 18px; border-width: 2px; box-shadow: 0 6px 22px rgba(0,0,0,.35); color: #c9cbe0; }

.ts-scenes { position: absolute; left: 390px; bottom: 40px; width: 470px; z-index: 2; background: rgba(12,13,26,.96); border: 3px solid #f7f3ea; box-shadow: 0 6px 22px rgba(0,0,0,.35); animation: ts-in .25s ease-out both; }
.ts-scenes-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; font-size: 22px; background: var(--paper); color: #1d1d22; }
.ts-close { background: none; border: 0; font-size: 22px; cursor: pointer; }
.ts-scenes ol { list-style: none; margin: 0; padding: 8px 0; max-height: 520px; overflow: auto; }
.ts-scenes li button { display: flex; gap: 16px; width: 100%; padding: 8px 20px; font-size: 21px; color: #e6e6f0; text-align: left; background: none; border: 0; cursor: pointer; }
.ts-scenes li button b { color: var(--gold); font-weight: normal; }
.ts-scenes li button:hover { background: rgba(242,193,78,.16); color: #fff; }

.ts-hint { position: absolute; left: 80px; bottom: 34px; font-size: 16px; color: #8a8ca8; letter-spacing: 1px; }

/* ---------- 대사 기록 / 설정 ---------- */
.log-list { max-height: 470px; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 8px; }
.log-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; font-size: 21px; line-height: 1.5; }
.log-row b { text-align: right; }
.log-row.narr span { grid-column: 1 / -1; color: #666; font-style: italic; }
#modal.settings .md-box { width: 760px; }
.set-grid { display: grid; grid-template-columns: 190px 1fr; gap: 22px 20px; align-items: center; font-size: 22px; margin: 18px 0; }
.set-seg { display: flex; gap: 8px; }
.set-seg button { flex: 1; padding: 10px; font-size: 19px; background: #fff; border: 3px solid var(--ink); cursor: pointer; }
.set-seg button.on { background: var(--ink); color: #fff; }
.set-grid input[type=range] { width: 100%; accent-color: var(--ink); }
.set-help { font-size: 17px; color: #666; }

/* ---------- 이벤트 CG ---------- */
#cg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: var(--pix, auto); z-index: 16; opacity: 0; pointer-events: none; transition: opacity .6s; }
#cg.on { opacity: 1; }

/* ---------- UI 스킨 (assets/ui/ 이미지가 있을 때만, ui.js가 skin-* 클래스를 붙인다) ---------- */
#stage.skin-textbox #textbox:not(.narr) { background: none; border: 24px solid transparent; border-image: var(--ui-textbox) 24 fill / 24px stretch; box-shadow: none; padding: 14px 16px 0; }
#stage.skin-textbox_dark #textbox.narr { background: none; border: 24px solid transparent; border-image: var(--ui-textbox_dark) 24 fill / 24px stretch; box-shadow: none; padding: 14px 16px 0; }
#stage.skin-textbox #tb-name { top: -46px; left: 0; }
#stage.skin-name #tb-name { background: none !important; color: var(--ink); border: 12px solid transparent; border-image: var(--ui-name) 12 fill / 12px stretch; padding: 0 8px; }
#stage.skin-name #tb-name::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; background: var(--name-accent, var(--gold)); }
#stage.skin-button :is(.act-btn, .ch-btn, .md-ok, .md-cancel, .hud-btn) { background: none; border: 12px solid transparent; border-image: var(--ui-button) 12 fill / 12px stretch; box-shadow: none; color: var(--ink); }
#stage.skin-button_hot :is(.act-btn:hover:not(:disabled), .ch-btn:hover, .md-ok:hover, .md-cancel:hover, .hud-btn:hover, .hud-btn.on) { border-image: var(--ui-button_hot) 12 fill / 12px stretch; }
#stage.skin-button_red .act-btn.objection { border-image: var(--ui-button_red) 12 fill / 12px stretch; color: #fff; }
#stage.skin-panel .md-box { background: none; border: 36px solid transparent; border-image: var(--ui-panel) 36 fill / 36px stretch; box-shadow: none; padding: 0 6px; }
#stage.skin-icons .hud-btn { position: relative; font-size: 0; width: 60px; height: 60px; padding: 0; }
#stage.skin-icons .hud-btn::after { content: ''; position: absolute; inset: 2px; background: var(--ui-icons) no-repeat; background-size: 800% 100%; image-rendering: var(--pix, auto); }
#stage.skin-icons .hud-btn { border-width: 4px; }
#stage.skin-icons #btn-note::after { background-position: 0.0% 0; }
#stage.skin-icons #btn-log::after { background-position: 14.286% 0; }
#stage.skin-icons #btn-auto::after { background-position: 28.571% 0; }
#stage.skin-icons #btn-skip::after { background-position: 42.857% 0; }
#stage.skin-icons #btn-set::after { background-position: 57.143% 0; }
#stage.skin-icons #btn-save::after { background-position: 85.714% 0; }
#stage.skin-objection #banner.objection { background: var(--ui-objection) center / cover no-repeat, #000; image-rendering: var(--pix, auto); }

/* ---------- 결론 / 수첩 ---------- */
.md-grid.few { grid-template-columns: repeat(3, 1fr); gap: 22px; }
.md-grid.few .cutv-cap { font-size: 16px; }
.nb-tabs { display: flex; gap: 8px; margin: 12px 0 16px; border-bottom: 4px solid var(--ink); }
.nb-tabs button { padding: 8px 20px; font-size: 20px; background: #e8e2d4; border: 3px solid var(--ink); border-bottom: none; cursor: pointer; }
.nb-tabs button.on { background: var(--ink); color: #fff; }
.nb-page { max-height: 440px; overflow: auto; }
.line-btn.used { opacity: .6; }
.nb-people { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.nb-person { display: flex; gap: 14px; align-items: center; background: #fff; border: 3px solid var(--ink); padding: 10px; }
.nb-person img { width: 88px; height: 88px; object-fit: cover; object-position: 50% 12%; image-rendering: var(--pix, auto); background: #2b2d35; border: 2px solid var(--ink); }
.nb-person b { font-size: 22px; }
.nb-person p { margin: 4px 0 0; font-size: 17px; line-height: 1.4; color: #444; }

/* ---------- 퍼즐 끌어 놓기 ---------- */
.pz-ghost { position: absolute; z-index: 99; width: 230px; pointer-events: none; opacity: .9; transform: rotate(-3deg); box-shadow: 0 6px 22px rgba(0,0,0,.35); }
.pz-slot.drop { outline: 5px solid var(--gold); outline-offset: 2px; }
.pz-dragging { opacity: .35; }

/* 여백 컷: 아무것도 없는 하얀 칸 */
.cutv.blank .cutv-body { background: #fff; background-image: none; }
.cutv-whisper { font-size: 15px; color: #c8c4ba; text-align: center; padding: 0 18px; line-height: 1.5; }


/* ---------- UI 테마: 반투명 패널 (크림색 상자 + 검은 그림자 스타일 대체) ---------- */
:root { --glass: rgba(14, 16, 30, .82); --glass-2: rgba(28, 31, 54, .9); --line: rgba(255, 255, 255, .16); --txt: #eef0f8; --sub: #a9adc6; }
#textbox {
  left: 50%; right: auto; width: min(1120px, calc(100% - 80px)); transform: translateX(-50%);
  bottom: 16px; height: 156px; padding: 30px 40px 18px;
  background: linear-gradient(180deg, rgba(14,16,30,.78), rgba(14,16,30,.92));
  border: 1px solid var(--line); border-radius: 12px; color: var(--txt);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
#textbox.narr { background: linear-gradient(180deg, rgba(8,9,16,.7), rgba(8,9,16,.88)); border-color: rgba(255,255,255,.1); color: #d9dbe8; }
#textbox.narr #tb-text { font-style: normal; color: #cfd2e2; }
#tb-name { top: -18px; left: 30px; padding: 5px 18px; font-size: 21px; border: none; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
#tb-text { font-size: 25px; line-height: 1.6; }
#tb-next { color: var(--gold); font-size: 16px; right: 24px; bottom: 14px; }

.ch-btn, .act-btn, .md-ok, .md-cancel, .hud-btn {
  border: 1px solid var(--line); border-radius: 8px; background: var(--glass); color: var(--txt);
  box-shadow: 0 6px 18px rgba(0,0,0,.3); transition: background .15s, transform .15s, border-color .15s;
}
.ch-btn:hover, .act-btn:hover:not(:disabled), .md-ok:hover, .md-cancel:hover, .hud-btn:hover { background: var(--glass-2); border-color: rgba(242,193,78,.6); }
.ch-btn { width: 680px; font-size: 24px; padding: 16px 24px; }
.ch-btn:hover { transform: translateX(6px); }
.ch-prompt { text-shadow: 0 2px 8px #000; }
.act-btn { font-size: 22px; padding: 12px 24px; }
.act-btn.small { font-size: 18px; padding: 10px 16px; }
.act-btn.objection { background: linear-gradient(180deg, #e8474d, #b92a30); border-color: rgba(255,255,255,.35); font-size: 26px; }
.act-btn.objection:hover { background: linear-gradient(180deg, #ff5a60, #c9353b); }
.act-btn.press { background: linear-gradient(180deg, #4a7fe0, #2f5cb4); border-color: rgba(255,255,255,.3); }
.act-btn.koharu { background: linear-gradient(180deg, #f2a14a, #d27f2a); color: #1d1d22; }
#actions { bottom: 206px; }

#hud { gap: 6px; }
.hud-btn, .hud-btn.small { padding: 7px 12px; font-size: 15px; background: rgba(14,16,30,.6); }
#btn-note { font-size: 17px; padding: 7px 16px; }
.hud-btn.on { background: rgba(242,193,78,.85); color: #1d1d22; }
#goal { top: 14px; left: 14px; right: 330px; border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; background: rgba(14,16,30,.72); font-size: 19px; padding: 9px 16px; }

.md-box { border: 1px solid rgba(0,0,0,.12); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.md-ok, .md-cancel { font-size: 20px; padding: 10px 28px; }
.tr-gauge, .tr-panel .tr-label { border-radius: 6px; background: rgba(14,16,30,.72); }
.ink-b { border-width: 2px; border-top-width: 5px; border-radius: 3px; }
#toast { border: 1px solid var(--line); border-radius: 8px; background: rgba(14,16,30,.9); }
.ts-btn { border: 1px solid rgba(255,255,255,.28); border-radius: 8px; background: rgba(14,16,30,.62); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.ts-btn.primary { background: rgba(247,243,234,.92); border-color: transparent; }
.ts-chapter { box-shadow: none; border-radius: 4px; }
.ts-scenes { border: 1px solid rgba(255,255,255,.2); border-radius: 12px; overflow: hidden; }

/* ---------- UI 정리 (사용자 피드백 15개) ---------- */
body { word-break: keep-all; overflow-wrap: normal; }
:root { --accent: #c9a24a; --btn: #23263c; --btn-hi: #2e3250; --btn-edge: #0b0c16; }

/* 상반신: 위쪽 기준으로 세워 얼굴이 대사창에 안 가리게, 도트는 픽셀 그대로 */
.char { top: 6px; bottom: auto; image-rendering: pixelated; }

/* 대사창: 낮게 (한두 줄) */
#textbox { height: 112px; padding: 22px 36px 12px; }
#tb-text { font-size: 24px; line-height: 1.55; }
#tb-name { top: -16px; left: 26px; background: var(--btn) !important; color: var(--txt); border: 1px solid var(--line); border-bottom: 2px solid var(--name-accent, var(--accent)); font-size: 19px; padding: 3px 14px; }

/* 심문 버튼: 대사창 안 오른쪽 아래에 작게 */
#textbox #actions { position: absolute; left: auto; right: 14px; bottom: 10px; top: auto; z-index: 2; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
#textbox #actions.hidden { display: none !important; }
#stage.in-trial #textbox { height: 132px; }
#stage.in-trial #tb-text { padding-right: 0; }
#textbox .act-btn, #textbox .act-btn.small { font-size: 16px; padding: 6px 12px; }
#textbox .act-btn.objection { font-size: 17px; }

/* 버튼 질감: 한 가지 모양 (도트 테두리 + 1px 그림자 + 눌림) */
.act-btn, .ch-btn, .md-ok, .md-cancel, .hud-btn, .hud-btn.small, #btn-note {
  background: var(--btn); color: var(--txt); border: 2px solid var(--btn-edge); border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 2px 0 var(--btn-edge); transition: none;
}
.act-btn:hover:not(:disabled), .ch-btn:hover, .md-ok:hover, .md-cancel:hover, .hud-btn:hover { background: var(--btn-hi); border-color: var(--btn-edge); transform: none; }
.act-btn:active:not(:disabled), .ch-btn:active, .md-ok:active, .md-cancel:active, .hud-btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.act-btn.press, .act-btn.koharu { background: var(--btn); color: var(--txt); }
.act-btn.objection { background: var(--accent); color: #111; border-color: var(--btn-edge); }
.act-btn.objection:hover { background: var(--accent); filter: brightness(1.12); }
.ch-btn:hover { transform: none; box-shadow: inset 3px 0 0 var(--accent), 0 2px 0 var(--btn-edge); }

/* 오른쪽 위: 모두 같은 모양, 수첩만 색으로 구분. 심문 중엔 자동·빨리 숨김 */
.hud-btn, .hud-btn.small, #btn-note { font-size: 15px; padding: 6px 12px; }
#btn-note { border-bottom-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent), 0 2px 0 var(--btn-edge); }
.hud-btn.on { background: var(--accent); color: #111; }
#stage.in-trial #btn-auto, #stage.in-trial #btn-skip { display: none; }

/* 목표: 한 줄, 강조색 하나 */
#goal { white-space: normal; word-break: keep-all; border-left-color: var(--accent); }
#goal b { color: var(--accent); }

/* 심문 정보 */
.tr-gauge { top: 66px; font-size: 18px; gap: 10px; }
.tr-gauge small { display: block; font-size: 12px; color: var(--sub); }
.ink-b { border-color: #cfd2e2; background: linear-gradient(to top, var(--accent) 75%, transparent 75%); }
.tr-panel { top: calc(var(--goal-h, 44px) + 24px); }
.tr-dot { background: rgba(255,255,255,.22); height: 6px; }
.tr-dot.on { background: var(--accent); }
.tr-dot.hint { background: rgba(255,255,255,.22); box-shadow: none; outline: 2px solid var(--accent); outline-offset: 1px; }

/* 돋보기: 컷 머리띠 안 */
.cutv-head .cutv-zoom { position: static; margin-left: auto; padding: 0 6px; font-size: 13px; line-height: 1.2; border: 1px solid rgba(255,255,255,.6); background: rgba(0,0,0,.25); color: #fff; }
.cutv-head { align-items: center; }

.tr-gauge { display: none; }
.tr-dots { align-items: center; }
.tr-mind { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--txt); background: rgba(14,16,30,.72); padding: 4px 10px; border-radius: 4px; }
.tr-mind small { font-size: 12px; color: var(--sub); }
.tr-mind .ink-b { width: 14px; height: 20px; }

/* 퍼즐 칸 번호가 컷 제목(시점 이름)을 가리지 않게 */
.pz-slot .cutv-head { padding-left: 34px; }

/* 상반신: 크게, 불투명하게 (가장자리 흐림 제거, v3 그림은 여백이 있어 필요 없음) */
.char { top: 0; -webkit-mask-image: none; mask-image: none; }
.char.dim { filter: brightness(.72); }
#textbox { background: linear-gradient(180deg, rgba(14,16,30,.94), rgba(10,11,22,.97)); }
#textbox.narr { background: linear-gradient(180deg, rgba(8,9,16,.92), rgba(6,7,12,.96)); }
.char[data-pos="left"] { left: 27%; }
.char[data-pos="right"] { left: 73%; }

/* 상반신은 창 크기와 상관없이 같은 크기(가슴 위가 대사창 위에 오게). 도트는 픽셀 그대로 키운다 */
.char { height: 860px; top: 0; }

/* 원고 평가 / 장면 선택의 장 제목 */
#modal.rank .md-box { width: 520px; background: #12142a; color: var(--txt); border: 1px solid var(--line); text-align: center; }
.rank-head { font-size: 22px; color: var(--sub); }
.rank-letter { font-size: 120px; line-height: 1.1; margin: 24px 0 12px; position: relative; z-index: 0; color: var(--accent); text-shadow: 0 6px 0 #000; }
.rank-rows { display: grid; gap: 6px; margin: 10px auto 6px; width: 320px; font-size: 19px; }
.rank-rows div { display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(255,255,255,.12); padding: 4px 0; }
.ts-scenes li.ts-ch { padding: 10px 20px 4px; color: var(--gold); font-size: 17px; }

/* 물증 카드 / 단어 조각 / 짚기 */
.cutv.item .cutv-body { background: #f3eedf; background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(80,90,140,.18) 27px 28px); }
.cutv-memo { font-size: 16px; line-height: 1.6; padding: 10px 12px; color: #2a2a33; }
.nb-words { display: flex; flex-wrap: wrap; gap: 8px; }
.word-chip { padding: 6px 12px; border-radius: 4px; background: #e8e2d4; border: 2px solid #1d1d22; font-size: 18px; }
.word-chip.cat-person { background: #f2dfe4; } .word-chip.cat-place { background: #dfe9f2; } .word-chip.cat-time { background: #efe6cf; } .word-chip.cat-thing { background: #e3efdf; } .word-chip.cat-act { background: #ece3f2; }
#modal.spot .md-box { width: 1000px; }
.spot-wrap img { width: 100%; cursor: crosshair; display: block; image-rendering: auto; }
.spot-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.tr-hold { background: var(--red); color: #fff; padding: 0 8px; border-radius: 3px; margin-left: 6px; font-size: 14px; }
.tr-dot.broken { background: rgba(255,255,255,.55); }

.zoom-img { position: relative; }
.zoom-head small { font-size: 15px; color: #8a6d1e; margin-left: 12px; font-weight: normal; }
.spot-mark { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 3px solid var(--gold); border-radius: 50%; pointer-events: none; animation: pulse .5s ease-out; }
.spot-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.spot-chips button { font-size: 13px; padding: 3px 8px; border: 1px dashed #777; background: rgba(255,255,255,.85); cursor: pointer; }
.spot-chips button.got { border-style: solid; border-color: var(--gold); }

/* ---------- 네임 (가설 문장) ---------- */
.name-screen { position: absolute; inset: 0; z-index: 45; background: rgba(6,7,14,.78); display: flex; align-items: center; justify-content: center; }
.name-box { position: relative; width: min(1060px, calc(100% - 80px)); background: rgba(14,16,30,.94); color: var(--txt); border: 1px solid var(--line); border-radius: 10px; padding: 26px 34px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
  background-image: repeating-linear-gradient(0deg, transparent 0 47px, rgba(80,100,160,.16) 47px 48px); }
.name-head { font-size: 24px; margin-bottom: 14px; }
.name-head b { background: var(--accent); color: #111; padding: 2px 10px; border-radius: 3px; margin-right: 8px; font-weight: normal; }
.name-head small { display: block; font-size: 16px; color: var(--sub); margin-top: 6px; }
.name-text { font-size: 26px; line-height: 2.05; }
.name-blank { font: inherit; font-size: 23px; min-width: 110px; padding: 0 12px; margin: 0 4px; border: none; border-bottom: 3px dashed var(--sub); background: rgba(255,255,255,.06); color: var(--sub); cursor: pointer; }
.name-blank.set { color: #fff; border-bottom-style: solid; border-bottom-color: var(--accent); background: rgba(255,255,255,.12); }
.name-say { margin-top: 16px; font-size: 18px; color: var(--sub); min-height: 26px; }
.name-bar { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.name-pop { position: absolute; z-index: 3; min-width: 180px; max-width: 420px; display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: #12142a; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.name-pop-head { width: 100%; font-size: 14px; color: var(--sub); }
.name-pop button { font-size: 18px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--btn); color: var(--txt); cursor: pointer; }
.name-pop button:hover { background: var(--btn-hi); }

/* 컷 배열: 칸 안의 자리(.pz-half). 동시 칸은 두 자리가 나란히, 두 칸 너비 */
.pz-slot { border: none; gap: 8px; align-items: stretch; }
.pz-half { flex: 1; min-width: 0; position: relative; border: 4px dashed #b9b2a3; display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 20px; }
.pz-half.filled { border: none; }
.pz-half .cutv { width: 100%; height: 100%; aspect-ratio: auto; }
.pz-slot.sim { grid-column: span 2; }
.pz-slot.sim .pz-half:not(.filled) { border-color: var(--accent, #c9961a); }
.pz-half.drop { outline: 5px solid var(--gold); outline-offset: 2px; }
.pz-slot.sim { background: rgba(201,150,26,.12); outline: 3px solid #c9961a; outline-offset: 5px; border-radius: 2px; }
.pz-slot.sim .pz-half + .pz-half { border-left: 3px dotted #c9961a; padding-left: 8px; }
.pz-slot.sim .pz-half.filled + .pz-half.filled { border-left: 3px dotted #c9961a; }

/* ---------- 연출 효과 (fx.js) ---------- */
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
#fade { display: none; } /* 장면 전환은 fx-top의 디더로 */

/* 큰 흔들림, 반전 프레임, 흑백, 고스트, 글리치 — 계단식으로 움직여 도트 느낌 */
#stage.quake-big > :not(.fx-canvas):not(#flash) { animation: quake-big .5s steps(10) both; }
@keyframes quake-big { 0%,100% { translate: 0 0; } 10% { translate: -24px 10px; } 20% { translate: 22px -14px; } 30% { translate: -18px 8px; } 45% { translate: 14px -6px; } 60% { translate: -8px 4px; } 80% { translate: 4px -2px; } }
#stage.fx-invert > #bg, #stage.fx-invert > #chars, #stage.fx-invert > #cg, #stage.fx-invert > #trial, #stage.fx-invert > #puzzle { filter: invert(1) grayscale(1) contrast(2); }
#stage.fx-mono > #bg, #stage.fx-mono > #chars, #stage.fx-mono > #explore { filter: grayscale(1) contrast(1.15); }
#stage.fx-ghost > #bg, #stage.fx-ghost > #chars { animation: fx-ghost .7s steps(7); }
@keyframes fx-ghost { 0%,100% { filter: none; } 20% { filter: drop-shadow(6px 0 0 rgba(255,60,120,.6)) drop-shadow(-6px 0 0 rgba(60,220,255,.6)); } 50% { filter: drop-shadow(-4px 0 0 rgba(255,60,120,.5)) drop-shadow(4px 0 0 rgba(60,220,255,.5)) brightness(1.2); } 80% { filter: drop-shadow(2px 0 0 rgba(255,60,120,.4)) drop-shadow(-2px 0 0 rgba(60,220,255,.4)); } }
#stage.fx-glitch > #bg, #stage.fx-glitch > #chars { animation: fx-glitch .7s steps(1) both; }
@keyframes fx-glitch {
  0% { clip-path: inset(10% 0 70% 0); translate: 30px 0; filter: hue-rotate(90deg); }
  15% { clip-path: inset(50% 0 20% 0); translate: -40px 0; }
  30% { clip-path: inset(0 0 85% 0); translate: 20px 0; filter: invert(1); }
  45% { clip-path: inset(70% 0 5% 0); translate: -16px 0; filter: none; }
  60% { clip-path: inset(30% 0 40% 0); translate: 50px 0; filter: hue-rotate(200deg); }
  80% { clip-path: inset(0); translate: -6px 0; filter: none; }
  100% { clip-path: inset(0); translate: 0 0; }
}
#stage.fx-pulse::after { content: ''; position: absolute; inset: 0; z-index: 85; pointer-events: none; animation: fx-pulse 1.2s steps(12); }
@keyframes fx-pulse {
  0%, 30%, 60%, 100% { box-shadow: inset 0 0 0 0 rgba(170,20,40,0); }
  10%, 45% { box-shadow: inset 0 0 0 26px rgba(170,20,40,.55), inset 0 0 0 60px rgba(170,20,40,.25); }
}

/* 의성어 도장 */
.fx-stamp { position: absolute; left: 50%; top: 42%; z-index: 87; pointer-events: none; transform: translate(-50%, -50%) rotate(-6deg);
  font-family: 'Galmuri11', sans-serif; font-weight: bold; font-size: 132px; color: #fff; letter-spacing: 4px;
  text-shadow: 6px 0 #111, -6px 0 #111, 0 6px #111, 0 -6px #111, 6px 6px #111, -6px -6px #111, 6px -6px #111, -6px 6px #111, 12px 12px 0 var(--red, #c33);
  animation: fx-stamp 1.1s steps(1) both; }
@keyframes fx-stamp { 0% { transform: translate(-50%, -50%) rotate(-6deg) scale(2.2); opacity: 0; } 8% { transform: translate(-50%, -50%) rotate(-6deg) scale(1.3); opacity: 1; } 16%, 75% { transform: translate(-50%, -50%) rotate(-6deg) scale(1); opacity: 1; } 88% { opacity: .5; } 100% { opacity: 0; } }
.fx-stamp.big { font-size: 180px; }

/* 반박 컷인 */
.fx-cutin { position: absolute; inset: 0; z-index: 84; pointer-events: none; overflow: hidden; }
.fx-band { position: absolute; left: -10%; right: -10%; top: 36%; height: 170px; transform: rotate(-4deg); overflow: hidden;
  background: repeating-linear-gradient(90deg, #111 0 40px, #1b1b22 40px 44px); border-top: 8px solid var(--c); border-bottom: 8px solid var(--c);
  animation: fx-band-in .22s steps(4) both, fx-band-run .3s steps(3) infinite; }
.fx-band img { position: absolute; left: 14%; top: -120px; height: 560px; image-rendering: pixelated; }
.fx-band b { position: absolute; left: 40%; top: 50%; transform: translateY(-50%); font-family: 'Galmuri11', sans-serif; font-size: 76px; color: #fff; white-space: nowrap;
  text-shadow: 5px 5px 0 var(--c), -3px -3px 0 #000; animation: fx-word-in .3s steps(3) .12s both; }
.fx-cutin.out .fx-band { animation: fx-band-out .18s steps(3) both; }
@keyframes fx-band-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes fx-band-out { from { clip-path: inset(0); } to { clip-path: inset(0 0 0 100%); } }
@keyframes fx-band-run { to { background-position: -44px 0; } }
@keyframes fx-word-in { from { translate: 120px 0; opacity: 0; } to { translate: 0 0; opacity: 1; } }

/* 증언 컷 찢기 */
.fx-tear { position: absolute !important; z-index: 83; pointer-events: none; margin: 0 !important; animation: fx-tear-a .85s steps(9) both; }
.fx-tear-a { clip-path: polygon(0 0, 54% 0, 46% 18%, 56% 36%, 44% 55%, 55% 74%, 47% 100%, 0 100%); }
.fx-tear-b { clip-path: polygon(54% 0, 100% 0, 100% 100%, 47% 100%, 55% 74%, 44% 55%, 56% 36%, 46% 18%); animation-name: fx-tear-b; }
@keyframes fx-tear-a { 0% { transform: none; } 20% { transform: translate(-8px, 0) rotate(-2deg); } 100% { transform: translate(-120px, 420px) rotate(-24deg); opacity: 0; } }
@keyframes fx-tear-b { 0% { transform: none; } 20% { transform: translate(8px, 0) rotate(2deg); } 100% { transform: translate(140px, 460px) rotate(28deg); opacity: 0; } }

/* 화면 당기기 */
#stage > #bg, #stage > #chars { transition: transform .5s steps(6); transform-origin: 50% 40%; }
#stage[data-zoom=left] > #bg, #stage[data-zoom=left] > #chars { transform: scale(1.18); transform-origin: 22% 30%; }
#stage[data-zoom=right] > #bg, #stage[data-zoom=right] > #chars { transform: scale(1.18); transform-origin: 78% 30%; }
#stage[data-zoom=center] > #bg, #stage[data-zoom=center] > #chars { transform: scale(1.14); transform-origin: 50% 30%; }

/* 표정이 바뀔 때의 반응 */
.char.re-shake { animation: shake .3s steps(4) 2; }
.char.re-jump { animation: re-jump .4s steps(5); }
.char.re-sink { animation: re-sink .7s steps(6) both; }
@keyframes re-jump { 30% { translate: 0 -28px; } 60% { translate: 0 4px; } }
@keyframes re-sink { 0% { translate: 0 0; } 40%, 100% { translate: 0 16px; } }

/* 외치는 대사 */
#textbox.jolt { animation: quake .3s steps(5); }
#textbox.jolt #tb-text { font-size: 1.22em; }
.fx-stamp.hold { font-size: 96px; top: 30%; left: 72%; color: #ffdede; text-shadow: 5px 0 #8a1020, -5px 0 #8a1020, 0 5px #8a1020, 0 -5px #8a1020, 8px 8px 0 #111; }
.rank-letter { animation: fx-rank .7s steps(5) both; }
@keyframes fx-rank { 0% { transform: scale(3) rotate(-12deg); opacity: 0; } 40% { transform: scale(.9) rotate(-4deg); opacity: 1; } 100% { transform: scale(1) rotate(-4deg); } }

/* ---------- 연출 2 ---------- */
/* 대사: 강조어, 전화, 속마음 */
#tb-text em { font-style: normal; color: var(--gold, #f2c14e); }
#textbox.phone #tb-text { color: #cfe8ff; }
#textbox.phone::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(160,200,255,.07) 0 2px, transparent 2px 4px); }
#textbox.phone #tb-name::after { content: ' · 전화'; font-size: .75em; opacity: .8; }
#textbox.thought #tb-text { color: #b9bccb; }

/* 배경이 바뀌면 살짝 다가오며 자리 잡는다 */
#bg.settle { animation: bg-settle 1.1s steps(8) both; }
@keyframes bg-settle { from { transform: scale(1.05); } to { transform: scale(1); } }

/* 선택지: 시간이 멈춘 듯 가라앉는다 */
#stage.fx-choice > #bg, #stage.fx-choice > #chars, #stage.fx-choice > #fx-back { filter: grayscale(.7) brightness(.6); transition: filter .3s steps(3); }

/* CG: 위아래 검은 띠 + 천천히 다가감 */
#stage.cg-on::before, #stage.cg-on::after { content: ''; position: absolute; left: 0; right: 0; height: 54px; background: #000; z-index: 17; animation: bar-in .3s steps(4) both; }
#stage.cg-on::before { top: 0; } #stage.cg-on::after { bottom: 0; }
@keyframes bar-in { from { height: 0; } }
#cg.on { animation: cg-pan 9s steps(30) both; }
@keyframes cg-pan { from { transform: scale(1); } to { transform: scale(1.06); } }

/* 형광등 깜빡임 */
#stage.fx-dim > #bg, #stage.fx-dim > #chars { filter: brightness(.55); }

/* 회상 */
#stage.fx-memory > #bg, #stage.fx-memory > #chars, #stage.fx-memory > #cg { filter: grayscale(1) sepia(.55) contrast(1.1) brightness(.9); }

/* 증인이 무너진다 */
.char.fx-break { animation: fx-break 1s steps(10) both; }
@keyframes fx-break { 0%, 20%, 40% { filter: brightness(4) grayscale(1); translate: -10px 0; } 10%, 30%, 50% { filter: invert(1); translate: 10px 0; } 70% { filter: grayscale(1) brightness(.6); translate: 0 14px; } 100% { filter: none; translate: 0 0; } }

/* 장 제목 카드 */
.fx-title { position: absolute; inset: 0; z-index: 91; background: #08080c; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; animation: fadein .2s steps(3); }
.fx-title.out { animation: fadeout .4s steps(4) forwards; }
.ft-panels { position: absolute; inset: 60px 120px; }
.ft-panels i { position: absolute; border: 6px solid #f7f3ea; animation: ft-draw .5s steps(5) both; }
.ft-panels i:nth-child(1) { left: 0; top: 0; width: 38%; height: 46%; }
.ft-panels i:nth-child(2) { right: 0; top: 0; width: 58%; height: 46%; animation-delay: .15s; }
.ft-panels i:nth-child(3) { left: 0; right: 0; bottom: 0; height: 50%; animation-delay: .3s; }
@keyframes ft-draw { from { clip-path: inset(0 100% 100% 0); } to { clip-path: inset(0); } }
.ft-top { position: relative; font-size: 30px; letter-spacing: 8px; color: var(--gold, #f2c14e); }
.ft-main { position: relative; font-size: 84px; min-height: 100px; text-shadow: 6px 6px 0 #000; }
.ft-sub { position: relative; font-size: 22px; color: #b9bccb; opacity: 0; }
.fx-title.done .ft-sub { animation: fadein .4s steps(4) forwards; opacity: 1; }
.fx-title.done .ft-main { animation: ft-stamp .3s steps(3); }
@keyframes ft-stamp { from { transform: scale(1.25); } }
/* 제목은 아래 넓은 칸 안에 */
.fx-title { justify-content: flex-end; padding-bottom: 108px; }
.ft-panels i:nth-child(1), .ft-panels i:nth-child(2) { height: 40%; }
.ft-panels i:nth-child(3) { height: 52%; }
.ft-panels i { overflow: hidden; }
.ft-panels img { position: absolute; left: 0; width: 100%; top: -8%; height: auto; image-rendering: pixelated; filter: grayscale(1) contrast(1.3) brightness(.9); animation: ft-face 2.4s steps(12) both; }
@keyframes ft-face { from { transform: translateY(18px); } }
.ft-panels img { width: auto; height: 240%; left: 50%; top: -40%; translate: -50% 0; }

/* 겹쳐 보기 */
.fx-overlay { position: absolute; inset: 0; z-index: 84; background: rgba(6,7,14,.82); animation: fadein .2s steps(3); }
.fx-overlay.out { animation: fadeout .25s steps(3) forwards; }
.fx-ov-head { position: absolute; top: 70px; left: 0; right: 0; text-align: center; font-size: 34px; color: var(--gold, #f2c14e); letter-spacing: 6px; }
.fx-overlay .cutv { position: absolute; top: 150px; width: 560px; left: 50%; transition: transform .6s steps(6), opacity .6s steps(6); }
.fx-ov-l { transform: translateX(-590px) rotate(-2deg); }
.fx-ov-r { transform: translateX(30px) rotate(2deg); }
.fx-overlay.merge .fx-ov-l { transform: translateX(-280px); }
.fx-overlay.merge .fx-ov-r { transform: translateX(-280px); opacity: .55; mix-blend-mode: screen; }
/* 파기 칸 */
.pz-slot.discard { grid-column: span 2; background: rgba(160,30,40,.12); outline: 3px dashed #b03040; outline-offset: 5px; }
.pz-slot.discard .pz-num { background: #b03040; }
.pz-slot.discard .pz-half.filled .cutv { filter: grayscale(1) brightness(.75); }

/* 시각표 */
.tl-paper { flex: 1; display: grid; grid-auto-rows: 34px; gap: 10px; background: #f4efe2; border: 4px solid #111; padding: 16px; align-content: start; }
.tl-paper { grid-template-rows: 34px; grid-auto-rows: 1fr; }
.tl-corner, .tl-time { font-size: 20px; color: #333; display: flex; align-items: center; justify-content: center; border-bottom: 3px solid #1d1d22; }
.tl-time { font-family: 'Galmuri11', monospace; letter-spacing: 2px; }
.tl-who { font-size: 22px; color: #1d1d22; display: flex; align-items: center; justify-content: center; background: #e6dfcd; border-left: 6px solid #38a3a5; }
.tl-who.bad { background: #f2c4c4; border-left-color: #b03040; animation: shake .3s steps(4); }
.tl-cell { position: relative; border: 3px dashed #b9b2a3; display: flex; align-items: center; justify-content: center; cursor: pointer; min-height: 0; }
.tl-cell.filled { border: none; }
.tl-cell .cutv { width: 100%; height: 100%; aspect-ratio: auto; }
.tl-cell.locked { outline: 3px solid var(--gold, #f2c14e); }
.tl-empty { color: #c9c2b0; font-size: 22px; }
.pz-tray .cutv.picked { box-shadow: 0 0 0 5px var(--gold, #f2c14e); transform: translateX(-6px); }
.tl-paper.reading .tl-cell { opacity: .25; }
.tl-paper.reading .tl-cell.lit { opacity: 1; }

/* ---------- 모바일 ---------- */
/* 조작 패드는 게임 화면(#stage) 밖, 실제 화면 구석에 손가락 크기로 */
/* 컷 끌기: 브라우저가 스크롤로 가로채지 않게 (예전 #pad 규칙을 지울 때 선택자가 깨져 있던 것 복구) */
#puzzle .cutv { touch-action: none; }
/* 묶음 안의 컷은 세로로 밀면 묶음이 스크롤되고, 옆(원고 쪽)으로 끌면 컷이 끌린다 */
#puzzle .pz-tray .cutv { touch-action: pan-y; }
/* 세로 화면에선 글씨가 너무 작아진다: 가로로 돌리라고 안내 */
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; text-align: center; padding: 24px;
    background: #0b0d1a; color: #f7f3ea; font-size: 20px; line-height: 1.6; }
  #rotate::before { content: '⟳'; display: block; font-size: 56px; color: var(--gold, #f2c14e); margin-bottom: 12px; }
  #rotate { flex-direction: column; }
}

/* 말하는 사람 얼굴 (상반신이 화면에 없을 때) */
#tb-face { display: none; position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 128px; height: 128px;
  background-color: rgba(255,255,255,.06); background-repeat: no-repeat; background-size: 205% auto; image-rendering: pixelated;
  border: 3px solid var(--name-accent, rgba(255,255,255,.4)); border-radius: 6px; }
#textbox.has-face #tb-face { display: block; animation: fadein .15s steps(2); }
#textbox.has-face #tb-text { padding-left: 150px; }
#textbox.has-face #tb-name { left: 170px; }
.pz-face { display: inline-block; vertical-align: middle; width: 56px; height: 56px; margin: -6px 12px -6px 0; border-radius: 4px;
  background-repeat: no-repeat; background-size: 205% auto; image-rendering: pixelated; border: 2px solid rgba(255,255,255,.4); background-color: rgba(255,255,255,.06); }
#tb-face { width: 104px; height: 104px; left: 16px; }
#textbox.has-face #tb-text { padding-left: 122px; }
#textbox.has-face #tb-name { left: 140px; }

/* 4·5장 */
.cutv.eroded .cutv-body { filter: blur(3px) grayscale(1) contrast(.7); }
.cutv.eroded::after { content: '흐려짐'; position: absolute; left: 6px; bottom: 6px; background: #444; color: #ddd; font-size: 14px; padding: 2px 6px; }
.pz-pagebreak { text-align: center; color: #8a8478; font-size: 18px; letter-spacing: 6px; border-top: 3px dashed #b9b2a3; padding-top: 2px; height: 22px; }
.tl-cell { min-width: 0; overflow: hidden; }

/* 멀리 선 인물(창밖·길 건너), 원격 인물(모니터 창) */
.char.far { height: 420px; top: 150px; opacity: .5; filter: brightness(.75) saturate(.6); }
.char.far.dim { filter: brightness(.6) saturate(.5); }
.char.remote { height: 400px; top: 70px; filter: drop-shadow(0 0 14px rgba(90, 255, 160, .35)); animation: remote-on .3s steps(3); }
.char.remote.dim { filter: brightness(.7) drop-shadow(0 0 8px rgba(90, 255, 160, .2)); }
@keyframes remote-on { 0% { clip-path: inset(48% 0 48% 0); } 50% { clip-path: inset(20% 0 20% 0); } 100% { clip-path: inset(0); } }

/* 조작 안내(도움말) 대사창 */
#textbox.tip { border-left: 4px solid #8fa0c8; }
#textbox.tip #tb-text { font-size: 21px; color: #d6dcf0; }

/* 반박하는 동안: 증언 패널을 치우고 레이를 앞으로 */
#stage.rebutting #trial { opacity: 0; pointer-events: none; transition: opacity .15s; }
#stage.rebutting .char[data-char="rei"] { z-index: 3; }
#stage.rebutting .char:not([data-char="rei"]) { filter: brightness(.45); }

/* 컷 고르기: 많으면 작게 */
.md-grid.many { gap: 10px; }
.md-grid.many .cutv-cap { font-size: 14px; }
.md-grid.many .cutv-head { font-size: 14px; }

/* 컷 묶음: 두 줄로 놓아 여러 장을 한눈에 비교 */
.pz-tray { width: 430px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.pz-tray h3 { grid-column: 1 / -1; margin-bottom: 0; }
.pz-tray .cutv { margin-bottom: 0; }
.pz-tray .cutv-cap, .pz-tray .cutv-desc { font-size: 13px; }
/* 알림은 대사창 바로 위 가운데: 증언 패널 제목을 가리지 않게 */
#toast { top: auto; bottom: 150px; }
/* 퍼즐·컷 칸 안의 컷 그림은 칸을 꽉 채운다(양옆 검은 띠 없이) */
.pz-slot .cutv-img, .pz-tray .cutv-img, .tl-cell .cutv-img, .md-grid .cutv-img { object-fit: cover; }

@media (pointer: coarse) { .ts-hint { display: none; } }
.pz-tray .cutv-head { font-size: 12px; white-space: nowrap; overflow: hidden; }

/* 조사 목록: 말 걸기 / 살펴보기 */
.ex-group { font-size: 15px; color: var(--sub, #aab); margin: 6px 0 -2px; letter-spacing: .1em; }
.ex-btn.talk { display: flex; align-items: center; gap: 12px; }
.ex-face { flex: none; width: 44px; height: 44px; border-radius: 4px; background: #222 no-repeat; background-size: 240%; border: 2px solid var(--btn-edge, #111);
  display: inline-flex; align-items: center; justify-content: center; color: #889; font-size: 20px; }

/* ---------- 결론 몽타주 ---------- */
.montage { position: absolute; inset: 0; z-index: 45; background: rgba(6,7,12,.88); display: flex; align-items: center; justify-content: center; }
.montage .mt-cut { position: absolute; width: 640px; transform: rotate(var(--tilt)) scale(1); animation: mt-in .22s steps(3); box-shadow: 0 16px 50px rgba(0,0,0,.7); }
.montage .mt-cut.mt-old { transform: rotate(var(--tilt)) scale(.86) translateY(-14px); filter: brightness(.55); }
.montage.mt-out { animation: mt-out .4s steps(4) forwards; }
@keyframes mt-in { 0% { transform: rotate(var(--tilt)) scale(1.25); opacity: 0; } 100% { transform: rotate(var(--tilt)) scale(1); opacity: 1; } }
@keyframes mt-out { to { opacity: 0; } }

/* ---------- 엔딩 크레딧 ---------- */
.credits { position: absolute; inset: 0; z-index: 60; background: #05060b; overflow: hidden; cursor: pointer; }
.cr-roll { position: absolute; left: 0; right: 0; top: 100%; text-align: center; color: var(--txt); animation: roll 34s linear forwards; }
.cr-roll h2 { font-size: 44px; margin: 0 0 10px; }
.cr-roll h3 { font-size: 20px; color: var(--sub); margin: 60px 0 14px; letter-spacing: .3em; }
.cr-roll p { font-size: 24px; margin: 8px 0; }
.cr-roll .cr-end { color: var(--accent); font-size: 26px; }
.cr-roll .cr-last { margin-top: 120px; font-size: 30px; }
@keyframes roll { to { transform: translateY(calc(-100% - 760px)); } }

/* ---------- 갤러리 / 저장 슬롯 ---------- */
#modal.gallery .md-box, #modal.slots .md-box { background: #12142a; color: var(--txt); border: 1px solid var(--line); }
.gal-tabs { display: flex; gap: 8px; margin: 10px 0 14px; }
.gal-tabs button, .gal-list button, .slot { background: var(--btn); color: var(--txt); border: 2px solid var(--btn-edge); border-radius: 4px; padding: 8px 16px; font-size: 18px; cursor: pointer; }
.gal-tabs button.on, .gal-list button.on { background: var(--accent); color: #111; }
.gal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gal-cg { aspect-ratio: 3 / 2; background: #222 center / cover; border: 2px solid var(--btn-edge); cursor: zoom-in; }
.gal-cg.locked, .gal-list .locked { display: flex; align-items: center; justify-content: center; color: #556; font-size: 26px; cursor: default; }
.gal-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gal-list .locked { font-size: 18px; padding: 8px 16px; border: 2px dashed #333; border-radius: 4px; justify-content: flex-start; }
.gal-cuts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.gal-cuts .cutv-img { object-fit: cover; }
.slot-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 16px; }
.slot { display: flex; align-items: center; gap: 16px; text-align: left; font-size: 20px; padding: 14px 18px; }
.slot .sl-n { font-size: 26px; color: var(--accent); width: 30px; }
.slot .sl-empty { color: #667; }
.slot small { margin-left: auto; color: var(--sub); }

/* 대사 몸짓 */
.char.re-hop { animation: re-hop .32s steps(4); }
.char.re-tilt { animation: re-tilt .45s steps(5); }
@keyframes re-hop { 40% { translate: 0 -14px; } }
@keyframes re-tilt { 50% { rotate: -2deg; translate: -4px 0; } }

/* 타이틀에서 여는 창(불러오기·갤러리)이 타이틀 위로 */
#modal.gallery, #modal.slots { z-index: 95; }
.montage .mt-cut .cutv-body { aspect-ratio: 3 / 2; flex: none; }
.montage .mt-cut .cutv-img { object-fit: cover; }
.montage .cutv-zoom { display: none; }
.ex-btn { padding: 9px 16px; font-size: 19px; }
.ex-list { max-height: 590px; }

/* 조사: 구역 이동 · 살펴보기/잔상 읽기 · 집중력 */
.ex-head { display: flex; align-items: center; gap: 14px; }
.ex-focus { margin-left: auto; font-size: 14px; color: var(--sub); display: inline-flex; align-items: center; gap: 3px; }
.ex-focus i { display: inline-block; width: 10px; height: 14px; border: 1px solid var(--accent); }
.ex-focus i.on { background: var(--accent); }
.ex-areas { display: flex; gap: 6px; margin-top: 8px; }
.ex-areas button { flex: 1; padding: 6px 8px; font-size: 16px; background: rgba(14,16,30,.8); color: var(--sub); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.ex-areas button.on { color: #111; background: var(--accent); border-color: var(--accent); }
.ex-row { display: flex; gap: 6px; }
.ex-row .ex-btn { flex: 1; }
.ex-btn.looked { box-shadow: inset 3px 0 0 var(--sub), 0 2px 0 var(--btn-edge); }
.ex-read { flex: none; width: 64px; font-size: 16px; cursor: pointer; background: #2a2440; color: #d9cff7; border: 2px solid var(--btn-edge); border-radius: 4px; }
.ex-read:hover:not(:disabled) { background: #3a3060; }
.ex-read:disabled { cursor: default; opacity: .55; }
.ex-row.read .ex-read { background: var(--accent); color: #111; opacity: 1; }
.ex-row.empty .ex-btn { opacity: .5; }
.ex-row.haunt .ex-btn { animation: haunt 2.4s steps(4) infinite; }
.ex-row.haunt .ex-btn::after { content: ' …누군가 있다'; color: #8a7fb8; font-size: 16px; }

/* 아이에게 컷을 보여 줄 때: 다그치는 반박이 아니라 조용히 */
#banner.gentle { background: radial-gradient(ellipse at center, rgba(40,36,70,.92), rgba(10,10,20,.85)); }
#banner.gentle .bn-main { font-size: 64px; color: #f3eefc; text-shadow: 0 0 18px rgba(190,170,255,.6); }

/* 컷 묶음: 가로 스크롤 없이 세로로만 */
.pz-tray { overflow-x: hidden; overflow-y: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pz-tray .cutv { min-width: 0; }
.montage .mt-cut { height: auto !important; }
.montage .mt-cut .cutv-cap { display: none; }

/* 수첩 「사건」 · 지난 이야기 */
.case-box { color: var(--txt, #eee); }
.case-ch { color: var(--accent); font-size: 15px; }
.case-box h3 { margin: 4px 0 8px; font-size: 24px; }
.case-sum { font-size: 18px; line-height: 1.6; color: var(--sub, #bbc); margin: 0 0 10px; }
.case-h { margin: 14px 0 6px; font-size: 15px; color: var(--sub, #aab); letter-spacing: .1em; }
.case-fact { font-size: 18px; line-height: 1.5; padding: 4px 0; }
.case-fact.unk { color: #889; }
.case-fact.next { color: var(--accent); }
#modal.case .md-box { background: #12142a; color: var(--txt); }
#modal.note .case-box { color: inherit; }
#modal.note .case-sum, #modal.note .case-h { color: #666; }

/* 만화 페이지 컷신 */
.manga { position: absolute; inset: 0; z-index: 46; background: rgba(6,7,12,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
.mg-page { width: 980px; height: 600px; background: #f4f1ea; padding: 14px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.7); transform: rotate(-.6deg); }
.mg-page.mg-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1.2fr; }
.mg-page.mg-3 .mg-last { grid-column: 1 / -1; }
.mg-page.mg-4 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1.3fr; }
.mg-page.mg-4 .mg-last { grid-column: 1 / -1; }
.mg-page.mg-2 { grid-template-columns: 1fr 1.3fr; }
.mg-cell { aspect-ratio: auto !important; width: auto !important; height: auto !important; min-height: 0; min-width: 0; overflow: hidden; animation: mg-in .3s steps(3); }
.mg-cell .cutv-body { min-height: 0; }
.mg-cell .cutv-img { object-fit: cover; }
.mg-cell .cutv-zoom { display: none; }
.mg-last { box-shadow: 0 0 0 4px #111; }
.mg-cap { margin-top: 18px; font-size: 26px; color: #f4f1ea; letter-spacing: .08em; }
@keyframes mg-in { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }
.manga.mt-out { animation: mt-out .4s steps(4) forwards; }

/* 증언 붕괴 변형 */
.fx-break-melt { animation: fx-melt 1s steps(10) both; }
@keyframes fx-melt { 0% { filter: none; transform: none; } 40% { filter: blur(2px) saturate(1.6) hue-rotate(20deg); } 100% { filter: blur(6px) saturate(2) hue-rotate(60deg); transform: translateY(60px) scaleY(1.25); opacity: 0; } }
.fx-break-split { animation: fx-split .9s steps(6) both; }
@keyframes fx-split { 0% { transform: none; } 30% { transform: translateX(-14px); filter: drop-shadow(10px 0 0 #e0405a) drop-shadow(-10px 0 0 #3b8fd0); clip-path: inset(0 0 52% 0); } 60% { transform: translateX(18px); clip-path: inset(38% 0 0 0); } 100% { transform: translateX(-30px); opacity: 0; clip-path: inset(48% 0 46% 0); } }
.fx-break-fade { animation: fx-fade 1s steps(8) both; }
@keyframes fx-fade { 0% { filter: none; } 50% { filter: brightness(1.8) contrast(.5); } 100% { filter: brightness(3) contrast(.2); opacity: 0; clip-path: inset(0 0 0 100%); } }

/* 다음 장 예고 */
.manga.preview { gap: 14px; }
.pv-head { font-size: 22px; letter-spacing: .2em; color: #b9b3a6; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pv-head b { font-size: 34px; letter-spacing: .06em; color: #fff; }
.pv-cut { width: 540px !important; height: auto !important; aspect-ratio: 3 / 2; transform: rotate(-1deg); box-shadow: 0 0 0 6px #f4f1ea, 0 12px 40px rgba(0,0,0,.6); }

/* 흔들림 끄기 */
.no-shake #stage.quake > *, .no-shake #stage.quake-big > *, .no-shake .char.shake, .no-shake #textbox.jolt { animation: none !important; }
/* 첫 로딩 */
#loading { position: fixed; inset: 0; z-index: 999; background: #0b0c12; color: #cfc8b8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; font-size: 20px; letter-spacing: .15em; transition: opacity .4s; }
#loading i { width: 220px; height: 6px; background: #2a2c38; position: relative; overflow: hidden; }
#loading i::after { content: ''; position: absolute; inset: 0; width: 40%; background: #c9961a; animation: ld 1s steps(8) infinite; }
@keyframes ld { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
#loading.out { opacity: 0; pointer-events: none; }
/* 손가락으로 누르기: 작은 버튼을 키운다 */
@media (pointer: coarse) {
  .hud-btn.small { padding: 14px 16px; font-size: 20px; }
  .act-btn.small { padding: 16px 22px; font-size: 22px; }
  .md-cancel, .set-seg button, .ex-row button { min-height: 56px; }
  .set-grid input[type=range] { height: 40px; }
}

/* 기록 */
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-row { color: var(--ink); display: grid; grid-template-columns: 1fr 56px 170px 110px 110px; align-items: center; gap: 10px; font-size: 22px; padding: 10px 14px; background: #fff; border: 3px solid var(--ink); }
.rec-row.locked { opacity: .45; }
.rec-rank { font-size: 32px; text-align: center; color: #c9961a; }
.rec-row i { font-style: normal; font-size: 17px; text-align: center; padding: 4px; border: 2px dashed #aaa; color: #999; }
.rec-row i.on { border: 2px solid var(--ink); background: #f2c14e; color: var(--ink); }
.rec-foot { display: flex; justify-content: space-between; font-size: 20px; margin-top: 12px; }

/* =====================================================================
   원고 테마 (마지막에 둬서 위의 반투명·둥근 스타일을 덮는다)
   규칙: 둥근 모서리·반투명·흐린 그림자 없음. 각진 테두리, 흐림 없는 오프셋 그림자,
   종이(원고지)와 먹(검은 칸) 두 가지 면, 바탕 무늬는 스크린톤 점. 강조색은 시점 색 하나.
   ===================================================================== */
:root {
  --ink: #141418; --paper: #efeadf; --paper-2: #e2dccd;
  --tone: radial-gradient(rgba(20,20,24,.22) 1.1px, transparent 1.4px) 0 0 / 6px 6px;
  --tone-w: radial-gradient(rgba(239,234,223,.16) 1.1px, transparent 1.4px) 0 0 / 6px 6px;
  --hard: 5px 5px 0 #000;
  --line: #efeadf; --txt: #efeadf; --sub: #b6b1a4; --glass: #141418; --glass-2: #26262c;
  --btn: #141418; --btn-hi: #26262c; --btn-edge: #000;
}
#stage *, #stage *::before, #stage *::after { border-radius: 0 !important; letter-spacing: 0 !important; }
.spot-mark { border-radius: 50% !important; }

/* 대사창: 검은 칸 + 흰 테두리 (만화 해설 칸) */
#textbox { background: var(--ink); border: 3px solid var(--paper); box-shadow: var(--hard); color: var(--txt); }
#textbox.narr { background: var(--ink) var(--tone-w); border-color: var(--sub); }
#tb-name { background: var(--paper) !important; color: var(--ink); border: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  box-shadow: inset 0 -5px 0 var(--name-accent, var(--accent)), 3px 3px 0 #000; padding: 2px 14px 6px; }
#tb-next { color: var(--paper); }
#textbox.has-face #tb-face { border: 3px solid var(--paper); box-shadow: 3px 3px 0 #000; }

/* 버튼: 종이 칸. 누를 곳은 눌렀을 때 그림자만큼 내려앉는다(계단식, 부드러운 전환 없음) */
.ch-btn, .act-btn, .md-ok, .md-cancel, .hud-btn, .ex-btn, .gal-tabs button, .gal-list button, .slot, .name-pop button, .ex-areas button, .ex-read, .set-seg button {
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 #000; transition: none;
}
.ch-btn:hover, .act-btn:hover:not(:disabled), .md-ok:hover, .md-cancel:hover, .hud-btn:hover, .ex-btn:hover, .gal-tabs button:hover, .gal-list button:hover, .slot:hover, .name-pop button:hover, .ex-areas button:hover, .ex-read:hover, .set-seg button:hover {
  background: var(--ink); color: var(--paper); border-color: var(--ink); transform: none; box-shadow: 4px 4px 0 var(--accent);
}
.ch-btn:active, .act-btn:active, .md-ok:active, .md-cancel:active, .hud-btn:active, .ex-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.ch-btn { background: var(--paper) var(--tone); }
.ch-btn:hover { transform: none; }
.act-btn.objection { background: var(--red); color: #fff; border-color: #000; }
.act-btn.objection:hover { background: #fff; color: var(--red); box-shadow: 4px 4px 0 var(--red); }
.act-btn.press { background: var(--ink); color: var(--paper); border-color: var(--paper); }
.act-btn.koharu { background: #f2a14a; color: var(--ink); }
.act-btn:disabled { opacity: .45; box-shadow: none; }
.hud-btn, .hud-btn.small { padding: 5px 12px; font-size: 15px; box-shadow: 3px 3px 0 #000; background: var(--paper); }
.hud-btn.on, .set-seg button.on, .gal-tabs button.on, .gal-list button.on { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--accent); }
.ex-btn.seen { opacity: 1; color: #77736a; background: var(--paper-2); }
.ex-areas button { box-shadow: 2px 2px 0 #000; }

/* 목표·알림: 만화 해설 칸 */
#goal { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-left-width: 10px; border-left-color: var(--accent); box-shadow: 4px 4px 0 #000; }
#toast { background: var(--ink); color: var(--paper); border: 3px solid var(--paper); box-shadow: var(--hard); }

/* 창(모달): 원고지 한 장 */
.md-box { background: var(--paper); border: 4px solid var(--ink); box-shadow: 8px 8px 0 #000; }
.md-title { border-bottom: 3px solid var(--ink); padding-bottom: 8px; background: none; }
#modal.gallery .md-box, #modal.slots .md-box, #modal.rank .md-box, #modal.case .md-box { background: var(--ink) var(--tone-w); color: var(--paper); border: 4px solid var(--paper); box-shadow: 8px 8px 0 #000; }
#modal.gallery .md-title, #modal.slots .md-title, #modal.case .md-title { border-bottom-color: var(--paper); }
.zoom-box { box-shadow: 8px 8px 0 #000; }

/* 심문·네임·조사 패널: 검은 칸 */
.tr-gauge, .tr-panel .tr-label, .tr-mind { background: var(--ink); color: var(--paper); border: 2px solid var(--paper); }
.tr-panel .cutv { box-shadow: 6px 6px 0 #000; }
.ink-b { border-radius: 0 !important; }
.name-box { background: var(--ink) var(--tone-w); border: 3px solid var(--paper); box-shadow: 8px 8px 0 #000; }
.cutv { box-shadow: none; }
.md-grid .cutv.pickable:hover { outline: 4px solid var(--accent); outline-offset: 2px; }
#loading i, #loading i::after { border-radius: 0; }

/* 타이틀: 원고 두 칸에 나눠 쓴 제목, 4칸 만화 같은 메뉴 */
.title-screen .ts-shade { background: none; }
.title-screen .ts-shade::before { content: ''; position: absolute; inset: 0;
  background: repeating-conic-gradient(#07070a 0 25%, transparent 0 50%) 0 0 / 4px 4px;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 22%, transparent 46%); mask-image: linear-gradient(90deg, #000 0%, #000 22%, transparent 46%); }
.title-screen .ts-shade::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 24%; background: rgba(7,7,10,.55); }
.ts-chapter, .ts-tag { display: none; }
.ts-logo { left: 56px; top: 40px; }
.ts-logo h1 { margin: 0; text-shadow: none; font-size: 70px; line-height: 1; gap: 14px; }
.ts-logo h1 span { display: block; width: max-content; padding: 14px 22px 16px; color: var(--ink); background: var(--paper);
  border: 5px solid var(--ink); box-shadow: 7px 7px 0 #000; }
.ts-logo h1 span:first-child { transform: rotate(-2deg); }
.ts-logo .ts-l2 { margin-left: 150px; color: var(--paper); background: var(--ink) var(--tone-w); border-color: var(--paper); transform: rotate(1.5deg); }
.ts-menu { left: 56px; bottom: 56px; display: grid; grid-template-columns: 250px 250px; gap: 12px; padding: 12px; background: var(--paper); border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 #000; transform: rotate(-.6deg); align-items: stretch; }
.ts-btn, .ts-btn.primary, .ts-btn.small { min-width: 0; padding: 26px 16px 14px; font-size: 22px; color: var(--ink); background: #fff var(--tone);
  border: 3px solid var(--ink); box-shadow: none; text-align: left; counter-increment: koma; transition: none; }
.ts-menu { counter-reset: koma; }
.ts-btn::before { content: counter(koma); opacity: 1; left: -3px; top: -3px; transform: none; font-size: 15px; color: var(--paper); background: var(--ink); padding: 1px 7px; transition: none; }
.ts-btn.primary { background: #fff; border-width: 4px; }
.ts-btn small { color: #555; font-size: 14px; }
.ts-btn:hover, .ts-btn:focus-visible, .ts-btn.primary:hover { transform: none; background: var(--ink); color: var(--paper); }
.ts-btn:hover small, .ts-btn:focus-visible small { color: var(--sub); }
.ts-btn:hover::before, .ts-btn:focus-visible::before { background: var(--accent); color: var(--ink); }
.ts-btn#t-cont { grid-column: 1 / -1; }
.ts-scenes { background: var(--ink); border: 4px solid var(--paper); box-shadow: 8px 8px 0 #000; }
.ts-hint { left: auto; right: 24px; bottom: 16px; text-shadow: none; color: #b6b1a4; background: var(--ink); padding: 2px 8px; }
#hud .hud-btn { color: var(--ink); background: var(--paper); }
#hud .hud-btn:hover, #hud .hud-btn.on, #hud #btn-note { color: var(--paper); background: var(--ink); border-color: var(--paper); }
#goal { right: 420px; }
.ex-head { background: var(--ink); color: var(--paper); border: 3px solid var(--paper); border-left: 10px solid var(--accent); box-shadow: 4px 4px 0 #000; }
.ex-areas button { background: var(--ink); color: var(--sub); border: 2px solid var(--paper); }
.ex-areas button.on { background: var(--paper); color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--accent); }
.ex-group { color: var(--paper); background: var(--ink); display: inline-block; padding: 1px 8px; }
.ex-read { background: var(--ink); color: var(--paper); border: 3px solid var(--paper); }
.ex-row.read .ex-read { background: var(--accent); color: var(--ink); border-color: var(--ink); }
.ex-focus i { border: 2px solid var(--accent); }
#puzzle { background: #1b1b20 var(--tone-w); }
.pz-paper, .tl-paper { box-shadow: 8px 8px 0 #000; }
.pz-tray { background: var(--ink); border: 3px solid var(--paper); box-shadow: 6px 6px 0 #000; color: var(--paper); }
.pz-tray h3 { color: var(--paper); background: none; }
.pz-tray .cutv:hover { box-shadow: 0 0 0 4px var(--accent); }
.pz-say { background: var(--ink); color: var(--paper); border: 3px solid var(--paper); border-left: 10px solid var(--accent); box-shadow: 4px 4px 0 #000; }

/* 긴 창(갤러리·저장·수첩)은 안쪽이 스크롤돼도 [닫기]가 늘 보이게 */
#modal.gallery .md-cancel, #modal.slots .md-cancel, #modal.note .md-cancel { position: sticky; bottom: 0; z-index: 2; }
.montage .mt-cut { aspect-ratio: auto; } /* 카드 아래 흰 띠 없이 그림 높이만큼 */

/* 기록 탭: 플레이 시간 / 목표 시간 (원고 테마: 종이 위 먹 막대, 둥근 모서리·흐림 없음) */
.rec-time { position: relative; font-size: 17px; text-align: center; padding: 4px 4px 9px; border: 2px solid var(--ink); background: #efeadf; }
.rec-time b { font-size: 19px; }
.rec-time em { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--ink); }
.rec-time.empty { border-style: dashed; border-color: #aaa; color: #999; }
.rec-export { font: inherit; font-size: 18px; padding: 6px 14px; background: var(--paper, #efeadf); color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 #000; cursor: pointer; }
.set-log button { white-space: nowrap; }
/* 갤러리: 탭 내용만 스크롤하고 [닫기]는 그 아래 제자리에 (내용을 가리지 않게) */
#modal.gallery .md-box { display: flex; flex-direction: column; overflow: hidden; }
#modal.gallery .gal-body { flex: 1; min-height: 0; overflow-y: auto; padding-right: 6px; }
#modal.gallery .md-cancel { position: static; flex: none; align-self: flex-start; }
/* 다음 장 예고: 그림 없는 컷의 설명 글은 단서를 미리 흘리므로 감춘다 */
.preview .pv-cut .cutv-desc, .preview .pv-cut .cutv-sfx, .preview .pv-cut .cutv-dist { visibility: hidden; }
.ts-menu > .ts-btn:last-child:nth-child(odd) { grid-column: span 2; } /* 메뉴 칸이 홀수면 마지막 칸을 넓혀 빈칸을 없앤다 */

/* ---------- 전수 점검(10/27) 수정 ---------- */
/* 대사창: 높이를 고정하지 않고 최소 높이만. 세 줄 넘는 대사는 위로 늘어난다(바닥 기준) */
#textbox { height: auto; min-height: 112px; }
#stage.in-trial #textbox { height: auto; min-height: 132px; }
/* 설정의 글자 크기가 모든 대사창 규칙에 적용되게 */
#tb-text { font-size: calc(24px * var(--tb-scale, 1)); }
#textbox.tip #tb-text { font-size: calc(21px * var(--tb-scale, 1)); }
/* 수첩 컷 탭: [닫기]가 두 번째 줄 컷을 덮지 않게 목록 높이를 줄인다 */
#modal.note .md-grid { max-height: 400px; }
#modal.note .md-cancel { position: static; }
/* 칸이 많은 시각표(종장 16칸): 묶음을 한 줄로 좁혀 칸을 넓힌다 */
#puzzle.tl-wide .pz-tray { width: 230px; grid-template-columns: minmax(0, 1fr); }
#puzzle.tl-wide .tl-paper { padding: 12px; gap: 6px; }
#puzzle.tl-wide .tl-time { font-size: 17px; letter-spacing: 0; }
/* 갤러리: 탭 내용이 길면(기록 6장, 음악) 안쪽만 스크롤해서 「엔딩」 줄·[닫기]와 겹치지 않게 */
#modal.gallery .gal-body { max-height: 430px; overflow-y: auto; padding-right: 4px; }

/* 누르고 끌어도 글자가 파랗게 선택되거나 그림이 끌려 나오지 않게 (입력칸은 예외) */
#stage, #stage * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#stage img { -webkit-user-drag: none; user-drag: none; }
#stage input, #stage textarea { -webkit-user-select: text; user-select: text; }

/* ---------- 화면 점검(10/28): 원고 테마에서 빠진 곳 메우기 ---------- */
/* 선택지 질문: 떠 있는 흰 글씨(흐린 그림자) 대신 먹 칸 */
.ch-prompt { color: var(--paper); background: var(--ink); border: 3px solid var(--paper); box-shadow: 4px 4px 0 #000; text-shadow: none; padding: 6px 18px; font-size: 22px; margin-bottom: 4px; }
#choices { background: rgba(0,0,0,.35); }

/* 목표가 두 줄이 돼도 조사 목록·퍼즐 원고가 그 밑으로 */
#explore { top: max(90px, calc(var(--goal-h, 44px) + 34px)); }
#puzzle { padding-top: max(90px, calc(var(--goal-h, 44px) + 34px)); }
.ex-list { max-height: calc(720px - max(90px, calc(var(--goal-h, 44px) + 34px)) - 110px); }

/* 조사 목록: 소제목은 글자 길이만큼, 빈 물건·못 읽는 칸은 반투명 대신 바랜 종이 */
.ex-group { align-self: flex-start; margin-top: 8px; }
.ex-row.empty .ex-btn { opacity: 1; background: var(--paper-2); color: #8d887c; }
.ex-read:disabled { opacity: 1; background: var(--paper-2); color: #8d887c; border-color: var(--ink); box-shadow: none; }
@keyframes haunt { 0%, 100% { box-shadow: 4px 4px 0 #000; } 50% { box-shadow: 4px 4px 0 #000, 0 0 0 4px #8a7fb8; } }

/* 컷 머리띠: 시점 이름·제목이 두 줄로 꺾이지 않게. 긴 제목은 말줄임 */
.cutv { min-width: 0; } /* 머리띠 글자가 길어도 격자 칸을 밀어내지 않게 */
.cutv-head { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; min-width: 0; }
.cutv-head > span { flex: 0 3 auto; min-width: 2.5em; overflow: hidden; text-overflow: ellipsis; }
.cutv-head > span + span { flex: 0 1 auto; } /* 좁으면 시점 이름부터 줄이고 제목은 남긴다 */
/* 「크게」 글자 단추 */
.cutv-head .cutv-zoom { flex: none; font-size: 12px; line-height: 1.2; padding: 1px 5px; background: var(--paper); border: 2px solid var(--ink); color: var(--ink); cursor: zoom-in; }
.cutv-head .cutv-zoom:hover { background: var(--ink); color: var(--paper); border-color: var(--paper); }
/* 컷 고르기(칸 많을 때): 임시 컷 글을 조금 작게 */
.md-grid.many .cutv-desc { font-size: 15px; }

/* 크게 보기: 닫기 단추를 다른 단추와 같은 모양으로, 그림과 띄워서 */
.zoom-box { padding: 16px 18px 18px; }
.zoom-box button { margin-top: 14px; font-size: 20px; padding: 8px 30px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 #000; }
.zoom-box button:hover { background: var(--ink); color: var(--paper); box-shadow: 4px 4px 0 var(--accent); }

/* 짚기·원본 복원: 그림이 창보다 커서 [취소]가 화면 밖으로 밀리던 것 */
#modal.spot .md-box { display: flex; flex-direction: column; }
.spot-wrap { flex: none; align-self: center; max-width: 100%; line-height: 0; border: 3px solid var(--ink); }
.spot-wrap:empty { display: none; }
.spot-wrap img { width: auto; max-width: 100%; max-height: 400px; margin: 0 auto; }
#modal.spot .md-cancel { align-self: flex-start; }

/* 대사 조각 고르기: 다섯 줄이 [취소]까지 한 화면에 */
#modal .md-lines .line-btn { padding: 8px 14px; font-size: 20px; gap: 2px; }
#modal .md-lines .line-btn small { font-size: 15px; }

/* 수첩: 탭을 바꿔도 창 높이가 그대로(탭이 위아래로 뛰지 않게) */
#modal.note .md-box { height: 620px; display: flex; flex-direction: column; }
#modal.note .nb-page { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }
#modal.note .md-grid { max-height: none; }
#modal.note .md-cancel { flex: none; align-self: flex-start; }
.case-ch { color: var(--ink); background: var(--accent); display: inline-block; padding: 0 8px; }
#modal.note .case-fact.unk { color: #77736a; }
#modal.note .case-fact.next { color: var(--ink); border-left: 6px solid var(--accent); padding-left: 8px; }
.nb-person img { image-rendering: pixelated; }

/* 어두운 창(갤러리·저장·평가·사건): 흐린 회색 글씨를 읽히게, 고른 탭은 눌린 칸 */
#modal.gallery .md-sub, #modal.slots .md-sub, #modal.case .md-sub, #modal.rank .md-sub { color: var(--sub); }
.gal-tabs button.on { background: var(--paper); color: var(--ink); border-color: var(--ink); transform: translate(3px, 3px); box-shadow: 0 0 0 3px var(--accent); }
.slot .sl-n { color: var(--ink); }
.rec-row.locked { opacity: 1; background: var(--paper-2); color: #8d887c; }
.rec-row.locked .rec-rank { color: #b6b1a4; }
.gal-cg.locked { background: #1d1d22 var(--tone-w); border: 2px dashed #3a3a40; color: #6a6a72; }
.gal-list .locked { border-color: #3a3a40; color: #6a6a72; }

/* 대사 기록: 해설 줄의 가짜 기울임 대신 회색 */
.log-row.narr span { font-style: normal; color: #6b675e; }

/* 설정: 한 화면에 다 들어오게 줄이고, 둥근 기본 슬라이더 대신 각진 눈금 */
#modal.settings .md-box { padding: 20px 30px 22px; }
.set-grid { gap: 12px 20px; margin: 12px 0; font-size: 20px; }
.set-seg button { padding: 7px 8px; font-size: 18px; }
.set-help { font-size: 15px; line-height: 1.5; }
.set-grid input[type=range] { -webkit-appearance: none; appearance: none; height: 24px; background: transparent; cursor: pointer; }
.set-grid input[type=range]::-webkit-slider-runnable-track { height: 8px; background: var(--paper-2); border: 2px solid var(--ink); }
.set-grid input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 24px; margin-top: -10px; background: var(--ink); border: 2px solid var(--paper); box-shadow: 2px 2px 0 #000; }
.set-grid input[type=range]::-moz-range-track { height: 8px; background: var(--paper-2); border: 2px solid var(--ink); }
.set-grid input[type=range]::-moz-range-thumb { width: 14px; height: 22px; background: var(--ink); border: 2px solid var(--paper); border-radius: 0; box-shadow: 2px 2px 0 #000; }

/* 컷 획득: 보라색 제목·위아래 검은 띠 없이 */
.md-title.gain { color: var(--ink); }
#modal.gain .md-one .cutv { aspect-ratio: auto; }
#modal.gain .md-one .cutv-body { aspect-ratio: 3 / 2; flex: none; }
#modal.gain .md-one .cutv-img { object-fit: cover; }
#modal.gain .md-sub { margin: 14px 0 0; }

/* 심문: 증언 진행 칸·증인의 마음을 반투명 막대 대신 먹 띠 하나로 */
.tr-dots { gap: 6px; background: var(--ink); border: 2px solid var(--paper); box-shadow: 4px 4px 0 #000; padding: 6px 8px; margin-top: 10px; }
.tr-dot { flex: 1; width: auto; max-width: 56px; height: 8px; background: #3a3a40; }
.tr-dot.on { background: var(--paper); }
.tr-dot.broken { background: #77736a; }
.tr-dot.hint { background: #3a3a40; outline: 2px solid var(--accent); }
.tr-mind { flex: none; white-space: nowrap; border: none; padding: 0 0 0 10px; border-left: 2px solid #3a3a40; margin-left: auto; }
.tr-mind small { display: inline; margin-left: 4px; }
.ink-b { border-color: var(--paper); }
/* 교차 심문: 두 번째 증인(오른쪽)이 증언 패널 뒤에 숨지 않게 왼쪽 반으로 당긴다 */
#stage.in-trial .char[data-pos="left"] { left: 22%; }
#stage.in-trial .char[data-pos="right"] { left: 48%; }

/* 네임: 단어 고르는 창도 먹 칸(남색·흐린 그림자 없이), 빈칸은 반투명 대신 짙은 칸 */
.name-pop { background: var(--ink); border: 3px solid var(--paper); box-shadow: 6px 6px 0 #000; }
.name-pop-head { color: var(--sub); }
.name-blank { background: #26262c; }
.name-blank.set { background: #34343c; }
.name-box { background-image: var(--tone-w); }

/* 몽타주·만화 페이지·예고: 흐린 그림자 대신 오프셋 그림자 */
.montage .mt-cut { box-shadow: 10px 10px 0 #000; }
.mg-page { box-shadow: 12px 12px 0 #000; }
.pv-cut { box-shadow: 0 0 0 6px #f4f1ea, 10px 10px 0 6px #000; }
.preview .cutv-zoom { display: none; }
.pz-ghost { box-shadow: 6px 6px 0 #000; }
#banner.gentle .bn-main { text-shadow: 4px 4px 0 #000; }

/* 퍼즐·시각표 */
.tl-who { border-left-color: var(--ink); }
/* 퍼즐 위의 도움말 대사창은 아래 단추 줄([확정] 등)을 가리지 않게 그 위로 */
#puzzle:not(.hidden) ~ #textbox { bottom: 150px; }
.pz-paper { outline-color: #b6c4d6; }

/* 세로 화면 안내: 원고 테마 */
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { background: var(--ink) var(--tone-w); color: var(--paper); }
  #rotate::before { color: var(--paper); background: var(--ink); border: 3px solid var(--paper); box-shadow: 4px 4px 0 #000; padding: 4px 16px 10px; }
}

/* 크게 보기: 그림을 상자에 contain으로 넣으면 양옆 검은 띠까지 그림으로 쳐서 짚은 곳 좌표가 어긋난다.
   그림 크기만큼만 상자를 잡아 클릭 좌표·표시 동그라미가 그림과 맞게 한다 */
.zoom-img { width: fit-content; max-width: 100%; margin: 0 auto; line-height: 0; border: 3px solid var(--ink); }
.zoom-box img { width: auto; max-width: 100%; max-height: 540px; object-fit: fill; }
.zoom-head, .zoom-cap { line-height: normal; }
.pv-cut .cutv-img { object-fit: cover; }

/* 심문 단추 줄이 대사창 안에 있을 때: 두 줄 대사가 단추 밑으로 들어가지 않게 아래를 비워 둔다 */
#textbox:has(> #actions:not(.hidden)) { padding-bottom: 58px; }

/* 손가락 화면: 위의 원고 테마 규칙(15px 작은 단추)이 예전 손가락용 크기를 덮어써서 다시 키운다.
   폰 가로 화면에서 무대가 0.5배쯤으로 줄어드니 무대 기준 50px 이상은 돼야 누르기 쉽다 */
@media (pointer: coarse) {
  #hud .hud-btn, #hud .hud-btn.small, #hud #btn-note { padding: 12px 16px; font-size: 20px; }
  #goal { right: 560px; }
  #textbox #actions .act-btn, #textbox #actions .act-btn.small { font-size: 21px; padding: 12px 18px; }
  #textbox #actions .act-btn.objection { font-size: 22px; }
  #textbox:has(> #actions:not(.hidden)) { padding-bottom: 76px; }
  .cutv-head .cutv-zoom { padding: 4px 8px; }
  .cutv-head .cutv-zoom { font-size: 15px; }
  .pz-tray .cutv-head .cutv-zoom { padding: 1px 5px; }
  .pz-tray .cutv-head .cutv-zoom::before { font-size: 12px; }
  .ex-areas button { min-height: 52px; font-size: 19px; }
  .nb-tabs button, .gal-tabs button { min-height: 52px; }
  .name-blank { min-height: 48px; }
  .name-pop button { padding: 10px 14px; font-size: 20px; }
}
/* 설정 창도 타이틀(z 90) 위에 뜨게 (지금은 타이틀에서 여는 단추가 없지만, 생기면 바로 보이도록) */
#modal.settings { z-index: 95; }

/* 닫기·확인 단추는 늘 창 오른쪽 아래 (왼쪽 구석에 붙어 있던 것 정리) */
#modal .md-cancel, #modal .md-ok { display: block; margin: 14px 0 0 auto; }
#modal.gain .md-ok { margin: 14px auto 0; }
#modal.gallery .md-cancel, #modal.spot .md-cancel { align-self: flex-end; }
/* 창이 무대(1280×720)를 넘지 않게: 넘치면 안쪽만 스크롤하고 닫기는 늘 보이게 */
#modal .md-box { max-height: 690px; overflow-y: auto; }
#modal .md-cancel, #modal .md-ok { position: sticky; bottom: 0; z-index: 3; }
#modal.gallery .md-cancel, #modal.note .md-cancel { position: static; }

/* =====================================================================
   모바일 점검(10/29)
   폰 가로 화면(높이 360~430px)에선 무대(1280×720)가 0.5~0.57배로 줄어든다.
   실제 화면에서 글자 11px·단추 32px 이상이 되려면 무대 기준 글자 22px·단추 64px 정도가 필요하다.
   ===================================================================== */

/* 심문 단추 줄이 대사를 덮던 것: UI 스킨(대사창 테두리 그림)이 아래 여백을 0으로 덮어써서
   단추가 대사 첫 줄 위에 얹혔다. 스킨이 있어도 단추 줄만큼 아래를 비운다 */
#stage.skin-textbox #textbox:not(.narr):has(> #actions:not(.hidden)),
#stage.skin-textbox_dark #textbox.narr:has(> #actions:not(.hidden)) { padding-bottom: 62px; }
@media (pointer: coarse) {
  #stage.skin-textbox #textbox:not(.narr):has(> #actions:not(.hidden)),
  #stage.skin-textbox_dark #textbox.narr:has(> #actions:not(.hidden)) { padding-bottom: 86px; }
  /* 손가락 화면의 심문: 대사창이 단추 줄만큼 높아지므로 증언 패널(오른쪽) 밑으로 들어가지 않게 왼쪽에만 둔다 */
  #stage.in-trial #textbox { left: 24px; right: 556px; width: auto; transform: none; }
  #stage.in-trial #textbox #actions { left: 12px; right: 12px; justify-content: flex-end; }
  /* 설정 창의 키보드 안내는 손가락 화면에선 필요 없고 [닫기]와 겹쳤다 */
  #modal.settings .set-help { display: none; }
  /* 슬라이더: 손가락으로 잡을 높이 */
  .set-grid input[type=range] { height: 44px; }
  /* 설정: 손가락용으로 커진 단추 때문에 창이 넘쳐 [닫기]가 단추 위에 떠 있었다. [닫기]를 제목 줄 오른쪽으로 */
  #modal.settings .md-box { position: relative; padding: 14px 30px 16px; }
  #modal.settings .md-cancel { position: absolute; top: 8px; right: 30px; bottom: auto; margin: 0; }
  #modal.settings .md-title { padding-right: 160px; }
  #modal.settings .set-grid { gap: 8px 20px; margin: 8px 0 0; }
}

@media (pointer: coarse) and (max-height: 540px) {
  /* ---------- 위 단추·목표 ---------- */
  #stage.skin-icons #hud .hud-btn, #hud .hud-btn, #hud .hud-btn.small, #hud #btn-note { width: 72px; height: 72px; }
  #hud { gap: 10px; }
  #goal { right: 520px; font-size: 23px; padding: 10px 16px; }
  #goal b { margin-right: 8px; }
  #stage.in-trial #goal { right: 400px; }

  /* ---------- 대사창 ---------- */
  #tb-text { font-size: calc(27px * var(--tb-scale, 1)); }
  #textbox.tip #tb-text { font-size: calc(24px * var(--tb-scale, 1)); }
  #tb-name, #stage.skin-name #tb-name { font-size: 24px; }
  #tb-next { font-size: 24px; }
  #textbox #actions .act-btn, #textbox #actions .act-btn.small { font-size: 23px; padding: 12px 16px; }
  #textbox #actions .act-btn.objection { font-size: 24px; }
  #textbox #actions { gap: 10px; }
  #toast { font-size: 24px; }
  .ch-prompt { font-size: 26px; }
  .ch-btn { font-size: 27px; padding: 20px 26px; }

  /* ---------- 컷 머리띠·[크게] ---------- */
  .cutv-head { font-size: 22px; padding: 4px 8px; }
  .cutv-head .cutv-zoom { font-size: 22px; padding: 6px 12px; min-height: 64px; min-width: 76px; }
  .dist-tag { font-size: 22px; top: 50px; }
  .cutv-cap { font-size: 22px; }
  .cutv-desc { font-size: 22px; }

  /* ---------- 심문 패널 ---------- */
  .tr-panel .tr-label { font-size: 22px; }
    .tr-mind { font-size: 22px; }
  .tr-mind small { font-size: 22px; }
  .tr-mind .ink-b { width: 18px; height: 26px; }

  /* ---------- 현장 조사 ---------- */
  #explore { width: 520px; right: 24px; }
  .ex-head { font-size: 24px; }
  .ex-focus { font-size: 22px; }
  .ex-focus i { width: 14px; height: 20px; }
  .ex-areas button { font-size: 23px; min-height: 64px; }
  .ex-group { font-size: 22px; }
  .ex-btn { font-size: 24px; padding: 12px 18px; min-height: 66px; }
  .ex-read { width: 88px; font-size: 22px; }
  .ex-row button { min-height: 66px; }
  .ex-face { width: 48px; height: 48px; }
  .ex-btn.haunt::after, .ex-row.haunt .ex-btn::after { font-size: 20px; }

  /* ---------- 창(모달) 공통 ---------- */
  .md-title { font-size: 34px; }
  .md-sub { font-size: 23px; }
  .md-empty { font-size: 23px; }
  .md-ok, .md-cancel, #modal .md-ok, #modal .md-cancel { font-size: 24px; min-height: 66px; min-width: 132px; padding: 10px 28px; }
  #modal .md-box { max-width: calc(100% - 40px); }
  #modal.settings .md-box, #modal.slots .md-box, #modal.gallery .md-box, #modal.note .md-box, #modal.log .md-box { width: 1240px; }

  /* 수첩 */
  .nb-tabs button { font-size: 23px; min-height: 64px; padding: 8px 18px; }
  .case-ch { font-size: 22px; }
  .case-box h3 { font-size: 28px; }
  .case-sum, .case-fact { font-size: 23px; }
  .case-h { font-size: 22px; }
  .nb-person b { font-size: 25px; }
  .nb-person p { font-size: 22px; }
  .nb-words .word-chip { font-size: 22px; }
  /* 대사 기록 */
  .log-row { font-size: 23px; grid-template-columns: 130px 1fr; }
  .log-list { max-height: 520px; }
  /* 저장·불러오기·장 선택 */
  .slot { font-size: 24px; min-height: 72px; }
  .slot small { font-size: 22px; }
  /* 설정 */
  .set-grid { font-size: 23px; grid-template-columns: 230px 1fr; gap: 14px 20px; }
  .set-seg button { font-size: 22px; min-height: 64px; }
  .set-grid input[type=range] { height: 64px; }
  #modal.settings .set-seg button { min-height: 60px; }
  #modal.settings .set-grid input[type=range] { height: 52px; }
  #modal.settings .set-grid { gap: 6px 20px; }
  #modal.settings .md-cancel { top: 6px; min-height: 58px; }
  .set-grid input[type=range]::-webkit-slider-thumb { width: 30px; height: 44px; margin-top: -20px; }
  /* 갤러리 */
  .gal-tabs button { font-size: 23px; min-height: 64px; padding: 8px 22px; }
  .gal-list button, .gal-list .locked { font-size: 22px; min-height: 64px; }
  .gal-grid { grid-template-columns: repeat(3, 1fr); }
  .gal-cuts { grid-template-columns: repeat(4, 1fr); }
  #modal.gallery .gal-body { max-height: 440px; }
  .rec-row { font-size: 23px; grid-template-columns: 1fr 56px 200px 130px 130px; }
  .rec-row i { font-size: 22px; }
  .rec-time { font-size: 22px; }
  .rec-foot { font-size: 23px; align-items: center; }
  .rec-export { font-size: 22px; min-height: 64px; padding: 6px 16px; }
  /* 원고 평가 */
  .rank-head { font-size: 24px; }
  .rank-rows { font-size: 23px; width: 380px; }
  /* 대사 조각·짚기 */
  #modal .md-lines .line-btn { font-size: 24px; min-height: 72px; }
  #modal .md-lines .line-btn small { font-size: 22px; }
  .spot-chips button { font-size: 22px; padding: 10px 14px; min-height: 56px; }
  /* 크게 보기 */
  .zoom-head { font-size: 26px; }
  .zoom-head small { font-size: 22px; }
  .zoom-cap { font-size: 23px; }
  .zoom-box button { font-size: 24px; min-height: 66px; min-width: 140px; }

  /* ---------- 컷 배열·시각표 ---------- */
  .pz-num { font-size: 22px; }
  .pz-slot, .pz-half, .pz-pagebreak, .tl-empty { font-size: 22px; }
  .pz-pagebreak { height: 30px; }
  .pz-say { font-size: 23px; }
  .pz-bar .act-btn, .pz-bar .act-btn.small { font-size: 24px; min-height: 72px; }
  .pz-tray h3 { font-size: 23px; }
  .tl-corner, .tl-time, #puzzle.tl-wide .tl-time { font-size: 22px; }
  .tl-who { font-size: 24px; }
  /* 묶음 컷: 머리띠 글자는 제목만(머리띠 색이 시점), [크게]는 그림 귀퉁이의 큰 칸 */
  .pz-tray .cutv-head { font-size: 22px; position: static; }
  .pz-tray .cutv-head > span:first-child { display: none; }
  .pz-tray .cutv-head .cutv-zoom, .tl-cell .cutv-head .cutv-zoom, .pz-slot .cutv-head .cutv-zoom, .md-grid .cutv-head .cutv-zoom {
    position: absolute; right: 0; bottom: 0; z-index: 3; min-height: 0; min-width: 0; width: 72px; height: 64px; padding: 0;
    font-size: 22px; display: flex; align-items: center; justify-content: center; border: 3px solid var(--ink); box-shadow: none; }
  .pz-tray .cutv-head .cutv-zoom::before { font-size: 20px; }
  .pz-slot .cutv-head .cutv-zoom, .tl-cell .cutv-head .cutv-zoom { width: 64px; height: 60px; font-size: 22px; }
  .pz-slot .cutv-head > span:first-child, .tl-cell .cutv-head > span:first-child { display: none; }
  /* 컷 고르기·수첩: [크게]는 그림 귀퉁이로, 컷이 많으면 머리띠엔 제목만 */
  .md-grid .cutv-head { font-size: 22px; }
  .md-grid.many .cutv-head { font-size: 20px; }
  .md-grid.many .cutv-head > span:first-child { display: none; }
  .md-grid.many .cutv-cap, .md-grid.many .cutv-desc { font-size: 20px; }
  .cutv-whisper { font-size: 22px; }
  .ch-btn { width: 920px; }
  .pz-slot .cutv-head, .tl-cell .cutv-head { font-size: 22px; }

  /* ---------- 네임 ---------- */
  .name-head { font-size: 27px; }
  .name-head small { font-size: 22px; }
  .name-text { font-size: 28px; }
  .name-blank { font-size: 25px; min-height: 66px; min-width: 120px; }
  .name-say { font-size: 22px; }
  .name-bar .act-btn { font-size: 24px; min-height: 68px; }
  .name-pop { max-width: 760px; }
  .name-pop-head { font-size: 22px; }
  .name-pop button { font-size: 23px; min-height: 66px; min-width: 70px; padding: 8px 14px; }

  /* ---------- 몽타주·만화·예고·엔딩 ---------- */
  .mg-cap { font-size: 28px; }
  .pv-head { font-size: 24px; }
  .cr-roll h3 { font-size: 24px; }
  .cr-roll p { font-size: 27px; }

  /* ---------- 타이틀 ---------- */
  .ts-btn small { font-size: 20px; }
}

/* 태블릿(손가락, 높이 541px 이상): 무대가 0.8배쯤이라 대부분 충분하고, 작은 [크게]·묶음 머리띠만 키운다 */
@media (pointer: coarse) and (min-height: 541px) {
  .cutv-head .cutv-zoom { min-height: 42px; min-width: 56px; font-size: 16px; }
  .pz-tray .cutv-head { font-size: 15px; position: static; }
  .pz-tray .cutv-head > span:first-child { display: none; }
  .pz-tray .cutv-head .cutv-zoom, .tl-cell .cutv-head .cutv-zoom, .pz-slot .cutv-head .cutv-zoom {
    position: absolute; right: 0; bottom: 0; z-index: 3; min-width: 0; min-height: 0; width: 56px; height: 44px; padding: 0;
    font-size: 16px; display: flex; align-items: center; justify-content: center; border: 3px solid var(--ink); box-shadow: none; }
  .tr-mind small { font-size: 14px; }
}

/* 심문 단추 줄이 있을 때: 대사창이 위로 늘어나 글과 단추가 겹치지 않게 (고정 높이라 두 줄이면 단추에 깔렸다) */
#textbox:has(> #actions:not(.hidden)) { height: auto; min-height: 170px; }
#textbox:has(> #actions:not(.hidden)) #tb-text { min-height: 2.6em; }
/* 이름표가 첫 줄 글자를 가리지 않게 */
#textbox:not(:has(#tb-name:empty)) { padding-top: 38px; }
