/* 무결 — 로비에서 이어지는 아이보리 종이와 올리브색 수사 노트.
   768px 이상은 기록과 회의를 나란히, 미만은 하단 탭으로 전환한다. */

:root {
  --bg: #f7f4ed;
  --panel: #fffdf7;
  --panel-2: #f0f1e7;
  --line: #dedfd1;
  --text: #363b32;
  --muted: #737866;
  --accent: #586c4d;

  --yes: #4d6a43;
  --no: #a15045;
  --irrelevant: #6e7266;
  --invalid: #89661f;
  --ghost: #78628e;

  --radius: 16px;
  --discuss-w: 30%;
  --serif: "Gowun Batang", "AppleMyungjo", "Batang", serif;
  --header-inset: 16px;
  --header-icon-size: 44px;
  --header-height: calc(var(--header-icon-size) + var(--header-inset) + var(--header-inset) + env(safe-area-inset-top));
}

* { box-sizing: border-box; }

/* HTML 의 hidden 속성은 CSS 의 display 선언에 진다. .ask 처럼 display 를 준
   요소는 hidden 을 걸어도 그대로 보이고, 접근성 트리에도 남는다. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
        "Malgun Gothic", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; color: inherit; }

/* 키보드 사용자를 위해 초점을 확실히 보이게 한다 */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 0 0 10px 10px;
  background: var(--accent);
  color: #fffdf7;
  font-weight: 700;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: 0; }

.app { display: flex; flex-direction: column; height: 100dvh; }

/* ---------- 상단 바 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--header-height);
  margin: 0;
  padding: calc(var(--header-inset) + env(safe-area-inset-top)) max(var(--header-inset), env(safe-area-inset-right)) var(--header-inset) max(var(--header-inset), env(safe-area-inset-left));
  background: var(--bg);
  flex: 0 0 auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.room { display: flex; align-items: center; gap: 10px; margin: 0; color: #45522f; }
.room-label { font: 700 25px/1.2 var(--serif); letter-spacing: -.6px; }
.room-code { font-size: 12px; letter-spacing: 1px; font-weight: 600; color: var(--muted); }

/* 사람이 늘어도 상단바 폭이 변하지 않는다. */
.players-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  min-height: 36px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
}
.players-btn:hover { border-color: var(--accent); }
.crown-badge { font-size: 11px; }

.avatar {
  display: grid;
  place-items: center;
  width: 27px; height: 27px;
  margin-left: -7px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #0e1014;
}
.avatar.ghost { box-shadow: 0 0 0 2px var(--ghost); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.dev-btn {
  height: 26px;
  padding: 0 9px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.tickets {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tickets.low { border-color: var(--invalid); color: var(--invalid); }
.ticket-icon { font-size: 12px; }

.badge {
  position: absolute;
  top: 0; right: 0;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fffdf7;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* ---------- 레이아웃 ---------- */

.panes { display: flex; flex: 1 1 auto; min-height: 0; width: min(calc(100% - 64px), 1100px); gap: 20px; margin: 0 auto; padding-bottom: 24px; }
.pane { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); overflow: hidden; }
.pane-questions { flex: 1 1 auto; min-width: 0; }
.pane-discuss {
  flex: 0 0 var(--discuss-w);
  min-width: 260px;
  background: var(--panel);
}

.section-head {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--accent);
}

/* ---------- 1. 문제 ---------- */

.scenario {
  display: flex;
  flex-direction: column;
  /* 줄어들기는 하되 형제들보다 천천히 줄어든다. 축소를 1 로 두면 카드의
     내용이 길다는 이유만으로(축소량은 basis 에 비례한다) 기록 빈 자리보다
     더 많이 빼앗겨서, 정작 사진과 사건 글이 먼저 사라졌다. 0 으로 잠그면
     반대로 가로 모드에서 입력창이 화면 밖으로 밀린다 — 그건 이미 한 번
     밟은 함정이다. 그래서 잠그지 않고 순서만 뒤로 미룬다. */
  flex: 0 .25 auto;
  min-height: 0;
  /* 아주 긴 상황 글이 들어와도 기록 자리가 0이 되지 않게 하는 보호선.
     보통은 걸리지 않는다 — 모바일에서 카드는 어차피 곧 접힌다. */
  max-height: 45dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* 안쪽 가로 스크롤 요소가 카드를 밀어내지 못하게 잠근다.
     이게 없으면 컷 스트립의 내용 폭이 그대로 밀고 나가 상황 글이 잘린다. */
  min-width: 0;
  position: relative;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #f4f3e9;
  /* 세로 스크롤은 유지하고, 컷 스트립만 카드 너비를 밀지 못하게 한다. */
  overflow-x: hidden;
}
/* 그림에 자리를 내주고 줄어드는 쪽. 넘치는 글은 카드 안에서 스크롤된다. */
.scenario-inner { min-width: 0; flex: 1 1 auto; min-height: 0; padding: 24px; }
.scenario-name { margin: 8px 0 14px; color: #30372d; font: 700 28px/1.4 var(--serif); letter-spacing: -.8px; overflow-wrap: anywhere; }
.scenario-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* ---------- 2. 힌트 (질문 기록 위 고정) ---------- */

.hintbar {
  flex: 0 1 auto;
  min-height: 0;
  /* 힌트에 이미지가 붙으면 이 칸이 커져 질문 기록을 눌러버린다.
     좁은 화면에서는 탭 하나를 통째로 쓰므로 아래에서 이 제한을 푼다. */
  max-height: 24dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 10px 14px 0;
  padding: 10px 13px 12px;
  border: 1px solid rgba(252, 211, 77, .3);
  border-radius: var(--radius);
  background: rgba(252, 211, 77, .06);
}
.hintbar .section-head { color: var(--invalid); }

.hint-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 7px; }

.hint-open {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.hint-open:hover { border-color: var(--invalid); }
.hint-tier {
  flex: 0 0 auto;
  min-width: 24px;
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}
/* 상으로 갈수록 결정적이라 색도 세진다. */
.hint-tier.t-하 { color: var(--irrelevant); }
.hint-tier.t-중 { color: var(--invalid); }
.hint-tier.t-상 { color: var(--no); }
.hint-src { margin-left: auto; font-size: 11px; color: var(--muted); }
.hint-cta { font-size: 12px; color: var(--muted); }

.hint-shown {
  padding: 10px 12px;
  border: 1px solid rgba(252, 211, 77, .35);
  border-radius: 9px;
  background: var(--panel-2);
}
.hint-shown .hint-head { display: flex; gap: 9px; margin-bottom: 5px; }
.hint-text { color: var(--text); word-break: keep-all; }

.hint-img {
  display: block;
  width: 100%;
  margin-top: 9px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #000;
  cursor: zoom-in;
}
.hint-img img { display: block; width: 100%; max-height: 260px; object-fit: contain; }

/* ---------- 접힌 문제 띠 ---------- */

/* 카드를 접고 나면 이것만 남는다. 눌러서 시트로 다시 본다. */
.peek {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  width: calc(100% - 28px);
  margin: 10px 14px 0;
  padding: 7px 12px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.peek:hover { border-color: var(--accent); }
.peek[hidden] { display: none; }
.peek-thumb {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #000;
}
.peek-thumb[hidden] { display: none; }
.peek-text { min-width: 0; flex: 1; display: flex; gap: 7px; align-items: baseline; }
.peek-text b { flex: 0 0 auto; font-size: 13px; }
.peek-text span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}
.peek-more { flex: 0 0 auto; font-size: 11.5px; color: var(--accent); }

/* ---------- 상황 컷 (전체 폭 히어로) ---------- */

/* 가로로 넘기며 본다. 컷이 없는 문제는 목록이 통째로 사라진다. */
/* 카드가 좁아지면 줄어드는 쪽은 글이다.
   예전에는 반대였다 — flex 축소를 그림에만 허용했더니 형제들이 자리를 다
   가져가서, 434×789 에서 그림 칸이 17px 로 눌렸다. 158px 짜리 사진의 윗줄
   한 겹만 띠처럼 남아 무슨 장면인지 알 수가 없었다. 글은 넘치면 카드 안에서
   스크롤되지만 그림은 넘치면 그냥 잘린다. 그래서 그림에 자리를 먼저 주고,
   모자라는 것은 글이 감당한다. */
.hero { position: relative; min-width: 0; flex: 0 0 auto; min-height: 0; overflow: hidden; }
.hero[hidden] { display: none; }

.hero-track {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.hero-track::-webkit-scrollbar { display: none; }

.hero-frame { position: relative; min-width: 0; }
.hero-slide { flex: 0 0 100%; scroll-snap-align: center; min-width: 0; }
.hero-view {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #000;
  cursor: zoom-in;
}
.hero-view img {
  display: block;
  width: 100%;
  /* 문제 그림은 전부 1600×1195, 즉 4:3 이다. 16/9 로 두면 cover 가 위아래를
     4분의 1씩 잘라내서, 어떤 사진을 넣든 한 번도 온전히 보인 적이 없었다.
     칸 높이를 원본 비율에 맞추면 잘라낼 것이 없어진다. 비율을 고정해 두는
     것은 컷을 넘길 때 트랙 높이가 튀지 않게 하려는 것이다. */
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* 캡션을 사진 위에 얹지 않는다. 어떤 사진이 올지 몰라 대비를 보장할 수 없다. */
.hero-caption[hidden] { display: none; }
.hero-caption {
  margin: 0;
  padding: 7px 15px 3px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  word-break: keep-all;
}

.hero-dots {
  position: absolute;
  left: 0; right: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}
.hero-dots li {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .6);
  transition: background .2s;
}
.hero-dots li.on { background: #fff; }

/* ---------- 클리어 컷 ---------- */

.clear-cuts { display: grid; gap: 10px; margin-top: 10px; }
.clear-cuts:empty { display: none; }
.clear-cut { margin: 0; }
.clear-view {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  cursor: zoom-in;
}
.clear-view img { display: block; width: 100%; max-height: 300px; object-fit: cover; }
.clear-cut figcaption {
  margin: 6px 2px 0;
  font-size: 11.5px;
  color: var(--muted);
  word-break: keep-all;
}

/* ---------- 컷 크게 보기 ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  padding: max(18px, env(safe-area-inset-top)) 0 calc(18px + env(safe-area-inset-bottom));
  /* 반투명이 아니라 꽉 찬 검정이다. 뒤에 비치는 화면이 사진의 배경색과
     섞여 장면을 읽기 어렵게 만든다 — 크게 보려고 연 창이니 사진 말고는
     아무것도 남기지 않는다. */
  background: #0b0b0a;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }

.lightbox-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-height: 0;
}
.lightbox-card:focus { outline: none; }

/* 몇 장 중 몇 장인지. 사진 위가 아니라 위쪽 한가운데에 알약으로 둔다 —
   어떤 사진이 올지 몰라 사진 위에 얹으면 대비를 보장할 수 없다. */
.lightbox-count {
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
  padding: 6px 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .6px;
}
.lightbox-count b { font-size: 17px; font-weight: 700; }

.lightbox-track {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.lightbox-track::-webkit-scrollbar { display: none; }

.lightbox-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0 14px;
}
.lightbox-slide img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* 넘기는 버튼. 손가락으로는 밀면 되지만 마우스와 키보드에는 잡을 것이 있어야 한다.
   바탕을 흰 반투명으로 두었더니 밝은 장면 위에서 통째로 사라졌다 — 사진이
   어떤 색일지 모르므로 어두운 알약에 흰 테를 둘러 양쪽 다 버티게 한다. */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  cursor: pointer;
}
.lightbox-nav.prev { left: 10px; }
.lightbox-nav.next { right: 10px; }
.lightbox-nav:hover:not(:disabled) { background: rgba(0, 0, 0, .78); border-color: #fff; }
.lightbox-nav:disabled { opacity: .3; cursor: default; }
.lightbox-nav svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lightbox-caption {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 24px;
  color: rgba(255, 255, 255, .8);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  word-break: keep-all;
}

/* ---------- 3. 질문 기록 ---------- */

.log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.turn { display: block; }

/* 줄 전체가 누를 수 있는 것이 된다. 버튼 기본 모양은 걷어낸다. */
.row-main {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
button.row-main { cursor: pointer; }
button.row-main:hover .turn-q,
button.row-main:hover .msg-body { background: #e9ecdf; }
.row-more {
  flex: 0 0 auto;
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  transition: transform .15s;
}
button.row-main[aria-expanded="true"] .row-more { transform: rotate(180deg); }

/* 펼쳤을 때만 나오는 조작. 평소에는 기록에 아무 버튼도 없다. */
.acts {
  display: flex;
  gap: 7px;
  margin: 7px 0 0 34px;
  flex-wrap: wrap;
}
.act {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}
.act:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.act:disabled { opacity: .5; cursor: default; }

.turn .avatar { margin: 2px 0 0; width: 25px; height: 25px; border: 0; }
.turn-body { min-width: 0; flex: 1; }
.turn-who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.turn-row { position: relative; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.turn-q {
  padding: 7px 12px;
  border-radius: 0 10px 10px 10px;
  background: var(--panel-2);
  word-break: keep-all;
}
.turn.mine .turn-q { background: #eef1e5; }

.verdict {
  flex: 0 0 auto;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid currentColor;
}
.verdict.yes { color: var(--yes); }
.verdict.no { color: var(--no); }
.verdict.irrelevant { color: var(--irrelevant); }
.verdict.invalid { color: var(--invalid); }

.turn-pending .turn-q { opacity: .6; }
.dots { display: inline-flex; gap: 3px; padding: 0 4px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

.notice {
  align-self: center;
  max-width: 90%;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.notice.graduate { color: var(--yes); }
.notice.hint { color: var(--invalid); }

/* ---------- 입력 ---------- */

.composer {
  flex: 0 0 auto;
  padding: 16px 22px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.composer-warn {
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(252, 211, 77, .12);
  border: 1px solid rgba(252, 211, 77, .35);
  color: var(--invalid);
  font-size: 12.5px;
}

.ask, .say { display: flex; gap: 8px; align-items: center; }
.field { position: relative; flex: 1 1 auto; min-width: 0; }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 54px 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  outline: none;
}
.field input::placeholder, .say input::placeholder { color: var(--muted); }
.counter {
  position: absolute;
  right: 15px; top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.counter.max { color: var(--invalid); }

.say input {
  flex: 1;
  height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  outline: none;
}
.say input:disabled { opacity: .5; }

.btn-answer {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.btn-answer[aria-pressed="true"] {
  border-color: var(--yes);
  color: var(--yes);
  background: rgba(74, 222, 128, .12);
}

.btn-send {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fffdf7;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.btn-send:disabled { background: var(--line); color: var(--muted); cursor: default; }

/* ---------- 4. 토론 — 하나의 흐름 ---------- */

.discuss-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 6px 11px 14px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.discuss-head .icon-btn { margin-left: auto; }

.ghost-tag {
  margin: 0;
  padding: 2px 9px;
  border: 1px solid var(--ghost);
  border-radius: 999px;
  color: var(--ghost);
  font-size: 11.5px;
}

.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.msg .row-main { flex-direction: column; align-items: stretch; gap: 0; position: relative; }
.msg .row-more { position: absolute; right: 0; top: 0; }
.msg .acts { margin-left: 0; }
.msg-who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg-row { position: relative; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.msg-body { color: var(--text); word-break: keep-all; overflow-wrap: anywhere; }
.msg.mine .msg-body { color: var(--accent); }

/* 유령의 글. 유령에게만 내려간다. */
.msg.ghost .msg-who, .msg.ghost .msg-body { color: var(--ghost); }
.msg.ghost .msg-body { font-style: italic; }
.ghost-mark { margin-left: 4px; }

.ghost-note {
  margin: 0;
  padding: 0 14px 10px;
  color: var(--ghost);
  font-size: 11.5px;
  line-height: 1.5;
}

.say {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.app.is-ghost .say input { border-color: rgba(196, 181, 253, .4); }

/* ---------- 주목 (유령이 뿌리는 파티클) ---------- */

.hl-count {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(196, 181, 253, .14);
  color: var(--ghost);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.particles {
  position: absolute;
  left: 50%; top: 50%;
  width: 0; height: 0;
  pointer-events: none;
}
.particles i {
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ghost);
  box-shadow: 0 0 7px var(--ghost);
  animation: sparkle 850ms ease-out var(--delay, 0ms) forwards;
}
@keyframes sparkle {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); }
}

/* ---------- 힌트 덱 (유령 전용) ---------- */

.hint-deck {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.hint-deck summary { cursor: pointer; list-style: none; }
.hint-deck summary::-webkit-details-marker { display: none; }
.hint-deck summary .section-head { color: var(--invalid); }
.hint-deck-note { margin: 6px 0 8px; font-size: 11.5px; color: var(--muted); }
.deck-next { display: grid; gap: 6px; }
.deck-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.deck-btn:hover:not(:disabled) { border-color: var(--invalid); }
.deck-btn:disabled { opacity: .45; cursor: default; }
.deck-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-cta { flex: 0 0 auto; font-size: 11.5px; font-weight: 700; color: var(--invalid); }
.deck-wait { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------- 넓은 화면: 한 칸에 쌓이므로 위쪽을 묶는다 ---------- */

/* 좁은 화면은 문제를 접고 힌트를 탭으로 빼서 기록이 화면을 차지한다.
   넓은 화면은 셋이 한 칸에 세로로 쌓이므로 위 둘을 묶어야 기록이 남는다. */
@media (min-width: 768px) {
  .scenario { max-height: 42dvh; }
}

/* ---------- 낮은 화면: 그림보다 글 ---------- */

/* 세로가 짧으면 34dvh 가 그림 하나로 다 찬다. 실제로 1024×640 에서 상황 글이
   45px, 가로로 눕힌 폰(812×375)에서는 77px 잘려 아예 안 보였다.
   높이 기준으로 한 번 더 조여 글이 들어갈 자리를 남긴다. */
@media (max-height: 700px) {
  .scenario { max-height: 52dvh; }
}

/* 눕힌 화면에서만 축소 순서를 되돌린다 — 그림이 먼저 줄어든다.
   카드를 천천히 줄게 둔 채로 두었더니 812×375 에서 카드가 143px 을 그대로
   쥐고 있어 입력창이 화면 밖(406px)으로 밀렸다. 여기서는 "질문을 못 쓰는
   것이 그림이 잘리는 것보다 나쁘다"가 이긴다.
   폭 기준을 같이 두는 이유: 375×667 같은 세운 폰도 높이만 보면 여기 걸리는데,
   거기서는 아직 그림을 살릴 여유가 있다. 세운 폰은 600px 보다 좁다.
   560px 아래는 폭과 무관하게 되돌린다 — 그 높이의 세운 화면은 없다. */
@media (max-height: 700px) and (min-width: 600px), (max-height: 560px) {
  .scenario { flex-shrink: 1; }
  .hero { flex-shrink: 1; }
}

/* 가로로 눕힌 폰. 그림은 띠처럼 얇아지지만 글은 다 보인다.
   상한을 넉넉히 주면 이번엔 입력창이 화면 밖으로 밀린다 — 실제로 62dvh 로
   뒀다가 812×375 에서 질문을 못 쓰게 만들었다. 계산은 이렇다.
     헤더 64 + 문제 + 기록(최소 60) + 입력창 63 ≤ 화면 높이
   375 기준으로 문제는 188px 아래여야 하고, 40dvh 가 150px 다.
   넘치는 글은 이제 카드 안에서 스크롤되므로 잘리지 않는다. */
@media (max-height: 480px) {
  /* min-height 가 필요하다. 카드에 flex 축소를 허용해두었더니 형제들이
     자리를 가져가 812×375 에서 61px 까지 눌렸다 — 내용은 236px 인데 한 번에
     한 줄 반만 보이는 꼴이라, 잘리지 않는다뿐이지 읽을 수가 없었다.
     상한과 하한을 같이 줘서 "이만큼은 확보하고, 넘치면 안에서 스크롤"로 만든다. */
  .scenario { max-height: 34dvh; min-height: 22dvh; }
  /* 여기 있던 `.hero-view img { max-height: 19dvh }` 는 지웠다. 특이도가
     `.scenario .hero-view img` 에 밀려 한 번도 걸린 적이 없는 줄이었다.
     이 높이에서 그림을 누르는 것은 위의 flex-shrink 복원이다. */
  .hero-caption { padding-top: 4px; padding-bottom: 2px; }

  /* 375px 높이에서는 세로 예산이 정말 빠듯하다. 실측하면 이렇다.
       패널 275 = 문제 + 기록 머리말 52 + 기록 + 입력창 108
     입력창과 머리말의 여백만으로 90px 을 쓰고 있어서, 문제 카드를 조금만
     키워도 입력창이 화면 밖으로 밀린다. 질문을 못 쓰는 것이 글이 잘리는
     것보다 나쁘므로 여기서는 여백을 깎아 입력창 자리를 먼저 확보한다. */
  .composer { padding: 9px 16px calc(9px + env(safe-area-inset-bottom)); }
  .notebook-head { padding: 8px 16px 6px; }
  .log { min-height: 0; padding-bottom: 8px; }
}

/* ---------- 좁은 화면: 하단 탭으로 전환 ---------- */

/* 드로어를 걷어냈다. 숨겨진 패널이라 존재를 모르고 지나치는 게 문제였다.
   768px 이상은 지금처럼 2단으로 나란히 두고, 미만은 탭으로 한 번에 하나씩 본다. */

.mobile-tabs { display: none; }

.app.discuss-closed .pane-discuss { display: none; }

@media (max-width: 767px) {
  /* 탭이 고르는 pane 하나만 보인다 */
  .app:not([data-mtab="discuss"]) .pane-discuss { display: none; }
  .app[data-mtab="discuss"] .pane-questions { display: none; }
  .app[data-mtab="discuss"] .pane-discuss { display: flex; border-left: 0; }

  /* 힌트는 DOM 을 옮기지 않고 탭 하나를 통째로 차지한다.
     질문 화면의 나머지 형제를 감추면 끝이라 코드가 갈라지지 않는다. */
  .app:not([data-mtab="hints"]) .hintbar { display: none; }
  .app[data-mtab="hints"] .pane-questions > *:not(.hintbar) { display: none; }
  .app[data-mtab="hints"] .hintbar {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 14px;
  }

  .mobile-tabs {
    display: flex;
    flex: 0 0 auto;
    border-top: 1px solid var(--line);
    background: var(--panel);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mtab {
    flex: 1;
    min-height: 50px;
    border: 0;
    border-top: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
  }
  .mtab[aria-selected="true"] {
    color: var(--text);
    border-top-color: var(--accent);
    font-weight: 700;
  }
  .mtab-badge {
    display: inline-block;
    min-width: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #fffdf7;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
  }

  /* 상단 말풍선은 데스크톱 접기 전용이라 여기선 필요 없다 */
  .discuss-toggle, .discuss-head .icon-btn { display: none; }

  .scenario-text { font-size: 16px; }
  .discuss-head { padding: 11px 14px; }
}

/* ---------- 정답 순간 ---------- */

.result {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(41, 47, 35, .4);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}
.result[hidden] { display: none; }

.result-card {
  width: min(100%, 400px);
  padding: 30px 26px 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 26px 70px rgba(54, 59, 50, .18);
  position: relative;
}
.result-card:focus-visible { outline: 3px solid var(--accent); }

.result-crown { font-size: 46px; line-height: 1; margin-bottom: 10px; }
.result.miss .result-crown { filter: grayscale(1); opacity: .5; }

.result-title { margin: 0 0 6px; font-size: 23px; letter-spacing: -.4px; }
.result.win .result-title { color: var(--yes); }
.result.miss .result-title { color: var(--invalid); }

.result-rank { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }

.result-answer {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  text-align: left;
}
.result-label {
  display: block;
  margin-bottom: 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--accent);
}
.result-answer p { margin: 0; word-break: keep-all; line-height: 1.6; }

/* 몇 칸을 채웠는지만 보여준다. 어느 요소가 빠졌는지 알려주면 정답을 흘리는 셈이다. */
.result-points {
  display: flex;
  gap: 7px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.result-points li {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--line);
}
.result-points li.on { background: var(--yes); }

.result-note {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
  word-break: keep-all;
}

.result-close {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fffdf7;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* 컨페티는 카드 위에서 흩어진다 */
.confetti { position: absolute; left: 50%; top: 30%; width: 0; height: 0; pointer-events: none; }
.confetti i {
  position: absolute;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: fall 1500ms ease-out var(--delay, 0ms) forwards;
}
@keyframes fall {
  from { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); }
}

/* ---------- 왕관 · 유령이 된 뒤 ---------- */

.avatar-wrap { position: relative; display: inline-block; line-height: 0; }
.crown {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
}
.turn .crown { font-size: 11px; top: -7px; }

/* 유령이 되면 화면 전체의 온도가 바뀐다 */
.app.is-ghost .investigation-status { color: var(--ghost); background: #eee8f2; }
.app.is-ghost .say input { border-color: rgba(196, 181, 253, .4); }

/* 유령은 질문할 수 없다. 서버가 403 을 주므로 화면에서 먼저 막는다. */
.ghost-lock {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid rgba(196, 181, 253, .3);
  border-radius: 12px;
  background: rgba(196, 181, 253, .08);
  color: var(--ghost);
  font-size: 12.5px;
  line-height: 1.55;
  word-break: keep-all;
}
.ghost-lock .crown-inline { flex: 0 0 auto; font-size: 17px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- 로비 ---------- */

.lobby {
  --lobby-header-height: var(--header-height);
  --lobby-quote-height: 24px;
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: #f7f4ed;
  color: #363b32;
  overflow-y: auto;
}
.lobby[hidden] { display: none; }

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  width: 100%;
  height: var(--lobby-header-height);
  margin: 0;
  padding: calc(var(--header-inset) + env(safe-area-inset-top)) max(var(--header-inset), env(safe-area-inset-right)) var(--header-inset) max(var(--header-inset), env(safe-area-inset-left));
}

.lobby-brand,
.stage-header-nav {
  display: inline-grid;
  grid-template-columns: var(--header-icon-size) max-content;
  align-items: center;
  column-gap: 11px;
  color: #45522f;
}
.lobby-brand {
  text-decoration: none;
}
.lobby-brand-mark,
.lobby-header-back {
  display: grid;
  place-items: center;
  width: var(--header-icon-size);
  height: var(--header-icon-size);
  border: 1.5px solid #6e795e;
  border-radius: 50%;
  color: #586c4d;
}
.lobby-brand-mark svg,
.lobby-header-back svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lobby-brand strong,
.stage-header-nav strong {
  font-family: "Gowun Batang", "AppleMyungjo", "Batang", serif;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.6px;
}
.lobby-header-back {
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}
.lobby-header-back:hover {
  background: #586c4d;
  color: #fffdf8;
}

.lobby-main {
  width: min(calc(100% - 64px), 1100px);
  margin: 0 auto;
  flex: 1 0 auto;
}

/* 입구 영상은 별도 헤더 바로 아래에서 좌우 여백 없이 이어진다. */
.lobby-main:has(> .lobby-entrance:not([hidden])) {
  width: 100%;
  max-width: none;
  padding: 0;
}

.lobby-visual {
  width: 100%;
  overflow: hidden;
  background: #dacbb7;
}
.lobby-visual video {
  display: block;
  width: 100%;
  aspect-ratio: 864 / 496;
  /* 넓고 낮은 화면에서도 아래 입력 폼까지 한 화면에 들어오게 한다. */
  max-height: max(160px, calc(100svh - var(--lobby-header-height) - 196px - (var(--header-inset) * 4) - var(--lobby-quote-height) - env(safe-area-inset-bottom)));
  object-fit: cover;
}

.lobby-card {
  display: flex;
  flex-direction: column;
  gap: var(--header-inset);
  width: 100%;
  margin: 0;
  padding: var(--header-inset) max(var(--header-inset), env(safe-area-inset-right)) calc(var(--header-inset) + env(safe-area-inset-bottom)) max(var(--header-inset), env(safe-area-inset-left));
}

.lobby-profile-fields { display: grid; gap: var(--header-inset); }
.lobby-profile-field { min-width: 0; }
.lobby-field-label {
  display: block;
  margin: 0 0 7px;
  color: #666a5c;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -.1px;
}
.lobby-card .lobby-error { margin: 0; }

.profile-photo {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 7px 13px 7px 9px;
  border: 1px solid #d2d6c6;
  border-radius: 10px;
  background: #fffdf8;
  color: #718064;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(93, 96, 56, .02);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.profile-photo:hover {
  border-color: #9baa89;
  box-shadow: 0 5px 12px rgba(81, 91, 51, .09);
  transform: translateY(-1px);
}
.profile-photo:disabled { cursor: wait; opacity: .58; transform: none; }
.profile-photo:focus-visible {
  border-color: #93a47e;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(145, 161, 123, .12);
}
.profile-preview {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 var(--header-icon-size);
  width: var(--header-icon-size);
  height: var(--header-icon-size);
  border-radius: 50%;
  background: #eef1e5;
}
.profile-preview > img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  image-rendering: auto;
}
.profile-default {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}
.profile-default svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
}
.profile-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid #f7f4ed;
  border-radius: 50%;
  background: #657455;
  color: #fffdf7;
}
.profile-edit svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.profile-photo-copy {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
}
.profile-photo-copy strong { color: #535947; font-size: 14px; font-weight: 600; }
.profile-photo-copy span { color: #8b8d80; font-size: 11px; line-height: 1.35; }
.profile-photo-arrow { flex: 0 0 auto; color: #8f9783; font-size: 25px; font-weight: 300; line-height: 1; }

.lobby-input {
  display: block;
  width: 100%;
  height: var(--header-icon-size);
  margin: 0;
  padding: 0 14px;
  border: 1px solid #dad9cb;
  border-radius: 9px;
  background: #fffdf8;
  color: #535947;
  font-size: 16px;
  outline: none;
  box-shadow: 0 2px 5px rgba(93, 96, 56, .02);
}
.lobby-input:focus {
  border-color: #93a47e;
  box-shadow: 0 0 0 3px rgba(145, 161, 123, .12);
}
.lobby-input::placeholder { color: #7d806e; font-size: 14px; }

.lobby-btn {
  width: 100%;
  min-height: 50px;
  border: 1px solid #d7d9c9;
  border-radius: 9px;
  background: #eef1e5;
  color: #4e5c42;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s, background .2s, border-color .2s, box-shadow .2s;
}
.lobby-btn:hover {
  border-color: #aab998;
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(74, 87, 48, .08);
}
.lobby-btn.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 112px;
  flex: 0 0 112px;
  padding: 0 16px;
  border: 0;
  background: #657455;
  color: #fffdf2;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .3px;
}
.lobby-btn.primary:hover { background: #536545; }
.lobby-btn.lobby-browse {
  width: 100%;
  flex: none;
  min-height: 56px;
  margin: 0;
}
.lobby-btn:disabled { opacity: .5; cursor: default; }

.lobby-error {
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px solid rgba(163, 85, 68, .32);
  border-radius: 9px;
  background: rgba(163, 85, 68, .07);
  color: #a35544;
  font-size: 12.5px;
}

/* ---------- 사건파일 목록 ---------- */

.stage-view {
  display: flex;
  flex-direction: column;
  gap: var(--header-inset);
  width: min(100%, 840px);
  margin: 0 auto;
  padding: var(--header-inset) 0 70px;
}
.stage-view[hidden], .lobby-entrance[hidden] { display: none; }

.stage-heading { margin: 0 0 0 74px; }
.stage-heading p, .lobby-quote {
  margin: 0;
  min-height: 1.6em;
  color: #848675;
  font-size: 15px;
  transition: opacity .5s ease, filter .5s ease;
}
.stage-heading p.is-typing, .lobby-quote.is-typing {
  opacity: 1;
  filter: none;
  transition: none;
}
.stage-heading p.is-typing::after, .lobby-quote.is-typing::after {
  content: '';
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -.12em;
  background: currentColor;
  animation: stage-caret .72s steps(1) infinite;
}
.stage-heading p.is-leaving, .lobby-quote.is-leaving { opacity: 0; filter: blur(3px); }
.lobby-quote {
  /* 실제 줄 수만큼만 차지해야 위아래 16px 간격이 같아진다. */
  min-height: 24px;
  flex: 0 0 auto;
  line-height: 24px;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
@keyframes stage-caret { 50% { opacity: 0; } }

.stage-list {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stage-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 18px;
  position: relative;
}
.stage-item + .stage-item { margin-top: var(--header-inset); }
.stage-rail {
  display: flex;
  justify-content: center;
  position: relative;
}
.stage-rail::after {
  content: '';
  position: absolute;
  top: 56px;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: #d8dbcb;
}
.stage-rail i {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 47px;
  height: 47px;
  border: 1px solid #c9d1bc;
  border-radius: 50%;
  background: #eef1e5;
  color: #657853;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 1px;
}

.stage-card {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  align-items: stretch;
  width: 100%;
  min-height: 220px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #dedfd1;
  border-radius: 16px;
  background: #fffdf7;
  color: #3e4437;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(81, 91, 51, .06);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.stage-card:hover {
  border-color: #a7b498;
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(85, 90, 53, .12);
}
.stage-card:focus-visible { outline-color: #72865f; }
.stage-card:active { transform: scale(.992); }
.stage-card:disabled { opacity: .62; transform: none; cursor: wait; }

.stage-thumb { position: relative; overflow: hidden; background: #ddd4c7; }
.stage-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  transition: transform .45s ease;
}
.stage-card:hover .stage-thumb img { transform: scale(1.025); }
.stage-thumb-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(24, 27, 20, .04), transparent 55%, rgba(24, 27, 20, .2));
  pointer-events: none;
}
.stage-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 28px 25px;
}
.stage-number {
  color: #7e886a;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2px;
}
.stage-copy strong {
  margin: 9px 0 25px;
  color: #30372d;
  font-family: "Gowun Batang", "AppleMyungjo", "Batang", serif;
  font-size: 27px;
  line-height: 1.4;
  letter-spacing: -.8px;
}
.stage-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.stage-activity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #7b846f;
  font-size: 14px;
}
.stage-activity i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b9f6c;
  box-shadow: 0 0 0 4px rgba(139, 159, 108, .1);
}
.stage-cta {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #657957;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.stage-cta b { font-size: 18px; font-weight: 500; transition: transform .2s ease; }
.stage-card:hover .stage-cta b { transform: translateX(3px); }
.stage-continuation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 21px;
  width: 56px;
  min-height: 150px;
  padding-top: 30px;
  background: linear-gradient(#d8dbcb 0 68%, transparent 100%) center top / 1px 100% no-repeat;
}
.stage-continuation span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #aeb8a0;
}
.stage-continuation span:nth-child(2) { opacity: .62; }
.stage-continuation span:nth-child(3) { opacity: .28; }
.stage-error { margin-left: 74px; }

@media (min-width: 900px) and (max-height: 900px) {
  .lobby-main { max-width: 920px; }
}

@media (max-width: 900px) {
  .lobby-main { width: calc(100% - 48px); }
}

@media (max-width: 620px) {
  .lobby { --lobby-quote-height: 48px; }
  .lobby-quote { font-size: 14px; }
  .lobby-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(247, 244, 237, .92);
    box-shadow: inset 0 -1px rgba(216, 219, 203, .72);
    backdrop-filter: blur(14px);
  }
  .lobby-brand,
  .stage-header-nav { column-gap: 8px; }
  .lobby-brand strong, .stage-header-nav strong { font-size: 20px; }
  .lobby-main { width: calc(100% - 32px); padding: 0 0 calc(30px + env(safe-area-inset-bottom)); }
  .lobby-btn { min-height: 52px; }
  .lobby-btn.lobby-browse { width: 100%; }
  .stage-view { padding-bottom: 36px; }
  .stage-heading { margin-left: 54px; }
  .stage-heading p { min-height: 1.55em; font-size: 14px; line-height: 1.55; }
  .stage-item { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; }
  .stage-rail { display: flex; }
  .stage-rail i { width: 42px; height: 42px; font-size: 11px; }
  .stage-rail::after { top: 50px; }
  .stage-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(81, 91, 51, .09);
  }
  .stage-thumb { aspect-ratio: 16 / 10; }
  .stage-thumb img { object-position: center 40%; }
  .stage-copy { padding: 20px 18px 18px; }
  .stage-number { font-size: 12px; }
  .stage-copy strong { margin: 5px 0 20px; font-size: 23px; }
  .stage-card-footer { padding-top: 15px; border-top: 1px solid #e8e8dd; }
  .stage-activity { font-size: 13px; }
  .stage-cta { gap: 7px; font-size: 13px; }
  .stage-continuation { width: 42px; min-height: 132px; padding-top: 26px; }
  .stage-error { margin-left: 54px; }
}

@media (max-width: 370px) {
  .lobby-main { width: calc(100% - 24px); }
  .stage-heading { margin-left: 48px; }
  .stage-item { grid-template-columns: 38px minmax(0, 1fr); gap: 10px; }
  .stage-rail i { width: 38px; height: 38px; }
  .stage-rail::after { top: 46px; }
  .stage-copy { padding-inline: 15px; }
  .stage-copy strong { font-size: 21px; }
  .stage-card-footer { gap: 10px; }
  .stage-activity, .stage-cta { font-size: 12px; }
  .stage-continuation { width: 38px; }
  .stage-error { margin-left: 48px; }
}

@media (hover: none) {
  .stage-card:hover { border-color: #dedfd1; transform: none; box-shadow: 0 8px 24px rgba(81, 91, 51, .09); }
  .stage-card:hover .stage-thumb img,
  .stage-card:hover .stage-cta b { transform: none; }
  .stage-card:not(:disabled):active { transform: scale(.985); }
}

/* 해설 — 방이 끝나면 문제 카드 아래에 붙는다 */
.reveal {
  flex: 0 0 auto;
  margin: 10px 14px 0;
  padding: 13px 15px;
  border: 1px solid var(--yes);
  border-radius: var(--radius);
  background: rgba(74, 222, 128, .08);
}
.reveal .section-head { color: var(--yes); }
.reveal p { margin: 7px 0 0; color: #f2f4f8; word-break: keep-all; }

/* ---------- 질문 필터 ---------- */

.log-filter {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  margin: 10px 14px 0;
}
.chip {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { color: var(--panel); font-weight: 700; background: var(--accent); border-color: transparent; }
.chip.yes[aria-pressed="true"] { background: var(--yes); }
.chip.no[aria-pressed="true"] { background: var(--no); }
.chip-n { font-variant-numeric: tabular-nums; opacity: .75; }

.log-empty {
  align-self: center;
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 입력 중 ---------- */

.typing {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 6px 14px 8px;
  list-style: none;
  min-height: 34px;
}
.typing li { display: flex; align-items: center; gap: 6px; }
.typing .avatar { width: 21px; height: 21px; border: 0; font-size: 10px; }
.typing-name { font-size: 11.5px; color: var(--muted); }

.typing-dots { display: inline-flex; gap: 3px; padding: 0 2px; }
.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.1s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- 참가자 시트 ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(41, 47, 35, .36);
  backdrop-filter: blur(4px);
}
.sheet[hidden] { display: none; }

.sheet-card {
  width: min(100%, 520px);
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  padding: 8px 0 max(14px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: var(--panel);
  animation: sheet-up .18s ease-out;
}
.sheet-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@keyframes sheet-up { from { transform: translateY(12px); opacity: .6 } to { transform: none; opacity: 1 } }

.sheet-grip {
  width: 38px;
  height: 4px;
  margin: 2px auto 10px;
  border-radius: 999px;
  background: var(--line);
}
.sheet-title { margin: 0 16px 10px; font-size: 15px; }
.sheet-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.sheet-close {
  flex: 0 0 auto;
  margin: 14px 16px 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14.5px;
  cursor: pointer;
}
.sheet-close:hover { border-color: var(--accent); }

.player-list { margin: 0; padding: 0 16px; list-style: none; display: grid; gap: 10px; }
.player-row { display: flex; align-items: center; gap: 10px; }
.player-row .avatar { width: 30px; height: 30px; border: 0; }
.player-name { font-size: 14px; }
.player-tag { margin-left: auto; font-size: 11.5px; color: var(--ghost); }

.hint-lead {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  word-break: keep-all;
}

/* ---------- 수사 노트 ---------- */

.app svg, .investigation-empty svg, .discussion-empty svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.game-back { width: var(--header-icon-size); height: var(--header-icon-size); flex: 0 0 auto; border: 1.5px solid #6e795e; border-radius: 50%; color: var(--accent); }
.game-back svg { width: 25px; height: 25px; }
.game-back:hover { background: var(--accent); color: var(--panel); }
.investigation-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 5px; background: #edf0e4; color: var(--accent); font-size: 11px; white-space: nowrap; }
.investigation-status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.topbar .players-btn svg, .tickets svg { width: 16px; height: 16px; }
.tickets { cursor: pointer; gap: 7px; }
.tickets:hover { border-color: var(--accent); }
#ticketCount { font-weight: 700; }
.ticket-label { font-size: 11px; }
.case-eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .4px; }
.case-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.case-fold { display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 3px; border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.case-fold:hover { color: var(--accent); }
.case-instruction { margin: 18px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; word-break: keep-all; }
.case-cover { display: block; width: 100%; height: 100%; min-height: 0; object-fit: cover; object-position: center 42%; }
.scenario:has(.case-cover:not([hidden])) { display: grid; grid-template-columns: 27% minmax(0, 1fr); }
.scenario:focus { outline: none; }
.scenario:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.notebook-head { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 12px; }
.notebook-head .section-head { display: flex; align-items: center; gap: 8px; color: var(--text); }
#logCount { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 50%; background: var(--panel-2); color: var(--accent); font-size: 11px; font-variant-numeric: tabular-nums; }
.notebook-note { color: var(--muted); font-size: 11px; }
.log { min-height: min(112px, 16dvh); padding: 8px 22px 20px; gap: 0; }
.turn { padding: 13px 0; border-bottom: 1px solid #edede3; }
.turn:last-child { border-bottom: 0; }
.turn .avatar { width: 28px; height: 28px; margin-top: 3px; filter: saturate(.35); }
.turn-who { display: block; margin: 0 0 5px; }
.turn-q { padding: 7px 11px; font-size: 14px; overflow-wrap: anywhere; }
.verdict { padding: 2px 9px; border: 0; font-size: 11px; }
.verdict.yes { background: #e8efdf; }
.verdict.no { background: #f6e8e2; }
.verdict.irrelevant { background: #efeee7; }
.verdict.invalid { background: #f5edda; }
.notice { margin: 9px 0; }
.peek { margin: 16px 20px 0; padding: 10px 12px; border-radius: 12px; background: #f4f3e9; }
.peek-thumb { width: 40px; height: 44px; object-fit: cover; border-radius: 6px; }
.peek-text { flex-direction: column; align-items: flex-start; gap: 1px; }
.peek-text b { font-family: var(--serif); font-size: 15px; }
.peek-text span { max-width: 100%; }
.log-filter { margin: 0 22px 8px; }
.chip { padding: 5px 12px; font-size: 11px; }
.investigation-empty, .discussion-empty { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; align-items: center; justify-content: center; padding: 20px; color: var(--muted); text-align: center; overflow-y: auto; }
.investigation-empty svg, .discussion-empty svg { width: 40px; height: 40px; margin-bottom: 16px; color: #939e7f; stroke-width: 1.2; }
.investigation-empty strong, .discussion-empty strong { color: #606b52; font: 500 17px/1.6 var(--serif); }
.investigation-empty p, .discussion-empty p { margin: 8px 0 0; font-size: 12px; line-height: 1.8; word-break: keep-all; }
.pane-questions:has(.investigation-empty:not([hidden])) .log,
.pane-discuss:has(.discussion-empty:not([hidden])) .chat { flex: 0 0 0; min-height: 0; padding: 0; }
.composer-caption { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-size: 10px; color: var(--muted); }
#composerMode { color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }
.field input { height: 46px; border-radius: 10px; background: #faf9f2; padding-left: 13px; font-size: 13px; }
.field:has(.counter[hidden]) input { padding-right: 12px; }
.field input:focus, .say input:focus { border-color: #8c9b76; box-shadow: 0 0 0 3px rgba(113, 134, 87, .1); }
.btn-answer { height: 46px; border-radius: 10px; padding: 0 13px; color: var(--accent); font-size: 12px; }
.btn-answer:hover { background: var(--panel-2); }
.btn-answer[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.btn-send { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; }
.btn-send:not(:disabled):hover { background: #455b39; }
.discuss-head { padding: 23px 18px 18px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.discuss-title .section-head { margin-top: 7px; font: 700 21px/1.4 var(--serif); color: var(--text); }
.discuss-head .icon-btn { width: 28px; height: 28px; }
.discussion-empty { padding: 24px 16px; }
.discussion-empty strong { font-size: 16px; }
.chat { min-height: 0; padding: 18px; gap: 18px; }
.msg-who { margin-bottom: 5px; }
.msg-body { padding: 8px 11px; border-radius: 0 10px 10px 10px; background: #f1f0e8; font-size: 13px; }
.msg.mine .msg-body { background: #edf0e3; color: var(--accent); }
.say { padding: 14px; gap: 7px; }
.say input { min-width: 0; border-radius: 10px; background: #faf9f2; height: 42px; padding: 0 11px; font-size: 12px; }
.say .btn-send { width: 38px; height: 40px; border-radius: 10px; }
.sheet-title { margin: 8px 24px 16px; font: 700 23px/1.4 var(--serif); }
.sheet-close { margin: 16px 24px 0; }
.result-title { font-family: var(--serif); }
.reveal { flex-shrink: 1; min-height: 0; max-height: 38dvh; overflow-y: auto; }

/* ---------- 판정을 못 받은 질문 ---------- */

/* 줄을 지우지 않고 남기므로, 남았다는 것과 아직 답이 아니라는 것이
   한눈에 보여야 한다. 판정 칩과 같은 자리에 다른 색으로 앉힌다. */
.verdict.failed { background: #f3e6e3; color: var(--no); }
.turn-broken .turn-q { opacity: .75; }
.turn-failed {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 7px 0 0 34px;
}
.turn-failed-why { color: var(--no); font-size: 11.5px; }
.turn-retry {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.turn-retry:hover { border-color: var(--accent); }

/* ---------- 친구 초대 ---------- */

.invite-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.invite-btn:hover { border-color: var(--accent); }
.invite-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* 초대 버튼이 오른쪽을 차지하므로 닫기는 그 옆에 붙는다. */
.discuss-head .icon-btn { margin-left: 0; }

.invite-box { padding: 0 16px; }
.invite-lead { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.8; word-break: keep-all; }
.invite-code {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.invite-code b { color: var(--text); font-size: 20px; letter-spacing: 3px; font-variant-numeric: tabular-nums; }
.invite-url {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf9f2;
  color: var(--muted);
  font-size: 12.5px;
}
.invite-actions { display: flex; gap: 8px; margin-top: 10px; }
.invite-note { margin: 10px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.7; }

.sheet-action {
  flex: 1 1 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.sheet-action:hover { border-color: var(--accent); }
.sheet-action.primary { border-color: var(--accent); background: var(--accent); color: #fffdf7; }
.sheet-action.primary:hover { background: #455b39; }
/* 참가자 시트의 초대 버튼은 목록 아래 한 줄을 통째로 쓴다. */
#playersInvite { display: block; width: calc(100% - 32px); margin: 14px 16px 0; }
.player-room { margin: 14px 16px 0; color: var(--muted); font-size: 12px; }
.player-room b { color: var(--text); letter-spacing: 2px; }

/* ---------- 로비 초대장 ---------- */

.lobby-invite {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #cfd8c2;
  border-radius: 10px;
  background: #eef2e6;
  color: #4e5c42;
  font-size: 12.5px;
  line-height: 1.6;
  word-break: keep-all;
}
.lobby-invite-tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #657455;
  color: #fffdf2;
  font-size: 11px;
  font-weight: 700;
}

@media (min-width: 768px) {
  .scenario:has(.hero:not([hidden])) { display: grid; grid-template-columns: 34% minmax(0, 1fr); }
  /* 260px 고정이면 칸 너비에 따라 4:3 이 어긋나 다시 잘린다. 비율에 맡긴다. */
  .scenario .hero-view img { height: auto; max-height: none; }
}

@media (min-width: 768px) and (max-width: 1000px) {
  .panes { width: calc(100% - 40px); gap: 14px; }
  .scenario:has(.case-cover:not([hidden])) { grid-template-columns: 1fr; }
  .scenario .case-cover { display: none; }
  .scenario-inner { padding: 20px; }
  .scenario-name { font-size: 25px; }
  .notebook-note, #composerHelp { display: none; }
}

@media (max-width: 767px) {
  .topbar { gap: 10px; }
  .room { gap: 7px; }
  .room-label { font-size: 23px; }
  .investigation-status { display: none; }
  .topbar-actions { gap: 0; }
  .players-btn { padding: 5px 9px; }
  .tickets { padding: 0 10px; }
  .panes { width: 100%; padding: 0; gap: 0; }
  .pane { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
  .pane-discuss { flex: 1 1 auto; min-width: 0; }
  /* 사진 한 장이 4:3 으로 다 들어가고 제목까지 보이는 높이. 남는 자리가
     없으면 카드가 알아서 줄어들고(flex: 0 1 auto), 그때 줄어드는 것은
     그림이 아니라 글이다. */
  .scenario { max-height: 64dvh; }
  .scenario:has(.case-cover:not([hidden])) { display: block; }
  .scenario-inner { padding: 18px 20px 20px; }
  .scenario-name { font-size: 25px; margin: 6px 0 16px; }
  .scenario-text { font-size: 14px; line-height: 1.85; }
  .scenario .case-cover { position: absolute; top: 20px; left: 20px; width: 68px; height: 78px; border-radius: 8px; }
  .scenario:has(.case-cover:not([hidden])) .case-heading-row { padding-left: 84px; }
  .scenario:has(.case-cover:not([hidden])) .scenario-name { padding-left: 84px; min-height: 43px; margin-bottom: 20px; }
  /* 폰 폭에서는 4:3 이 그대로 들어간다(375px 폭이면 281px). 상한은 세로가
     아주 넓거나 태블릿 폭일 때만 걸린다 — 767px 폭이면 원본 비율 한 장이
     575px 라 화면을 통째로 먹는다. */
  .scenario .hero-view img { max-height: 44dvh; }
  .case-instruction { margin-top: 12px; }
  .case-fold { min-height: 30px; }
  .notebook-head { padding: 16px 20px 10px; }
  .notebook-note { font-size: 10px; }
  .log { padding: 2px 20px 12px; }
  .turn { padding: 12px 0; }
  .turn-q { font-size: 13px; }
  .investigation-empty { padding: 16px 20px; }
  .investigation-empty svg { width: 32px; height: 32px; margin-bottom: 10px; }
  .investigation-empty strong { font-size: 16px; }
  .investigation-empty p { font-size: 11px; }
  .composer { padding: 12px 16px; }
  .composer-caption { margin-bottom: 8px; }
  #composerHelp { font-size: 9px; }
  .ask { gap: 6px; }
  .field input { height: 44px; padding-right: 47px; font-size: 12px; }
  .btn-answer { height: 44px; padding: 0 10px; font-size: 11px; }
  .btn-send { width: 42px; height: 42px; }
  .mobile-tabs { padding-right: 12px; padding-left: 12px; background: var(--bg); }
  .mtab { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 56px; border-top-width: 2px; font-size: 12px; }
  .mtab[aria-selected="true"] { color: var(--accent); }
  .mtab svg { width: 18px; height: 18px; }
  .discuss-head { padding: 22px 20px 18px; }
  .discussion-empty svg { width: 44px; height: 44px; }
  .chat { padding: 20px; }
  .say { padding: 14px 16px; }
}

@media (max-width: 380px) {
  .topbar { gap: 8px; }
  .room-label { font-size: 21px; }
  .ticket-label { display: none; }
  #composerHelp, .notebook-note { display: none; }
  .scenario-name { font-size: 22px; }
  .investigation-empty p { max-width: 240px; }
}

/* 세로에 여유가 있는 좁은 화면에서는 그림 한 장이 온전히 들어갈 높이를
   카드에 보장한다. max-height 만으로는 부족하다 — 카드가 flex 로 줄어들 수
   있어서, 상한을 64dvh 로 올려도 형제들이 자리를 가져가면 292px 까지 눌리고
   354px 짜리 그림이 다시 아래부터 잘렸다.
   기준을 dvh 가 아니라 화면 너비로 잡는 이유는 그림 높이가 곧 가로의 3/4
   이기 때문이다. 52px 은 그 위 "사건 개요 · 접기" 줄 몫이다.
   세로가 짧은 화면(700px 이하)은 이 규칙을 타지 않는다. 거기서는 그림보다
   입력창 자리가 먼저다 — 위의 max-height 블록들이 계속 그림을 누른다. */
@media (max-width: 767px) and (min-height: 701px) {
  .scenario { min-height: min(56dvh, calc(75vw + 74px)); }
}

/* 사건 카드가 펼쳐져 있는 동안 기록의 빈 자리는 한 줄로 줄인다.
   사진과 빈 자리 삽화가 같은 화면에서 자리를 다투면 둘 다 잘린 채로
   보인다. 글로 채운 자리부터 내주는 것이 이 화면의 순서다.
   카드를 접으면(질문을 치기 시작하면) 삽화는 그대로 돌아온다. */
@media (max-width: 767px) {
  .pane-questions:has(.scenario:not([hidden])) .investigation-empty svg,
  .pane-questions:has(.scenario:not([hidden])) .investigation-empty p { display: none; }
}

@media (max-height: 650px) {
  .scenario { max-height: 38dvh; }
  .case-instruction { display: none; }
  .investigation-empty svg { display: none; }
  .investigation-empty { justify-content: flex-start; }
}
