:root {
  --ink: #2b2430;
  --muted: #695d73;
  --cream: #fff8ea;
  --paper: rgba(255, 250, 240, 0.94);
  --paper-strong: rgba(255, 250, 240, 0.99);
  --paper-soft: rgba(255, 255, 255, 0.60);
  --moon: #f4dca8;
  --berry: #8d5fa3;
  --berry-dark: #5f3f7f;
  --teal: #6ebdb5;
  --teal-dark: #2f7d75;
  --warn: #b3506a;
  --warn-soft: rgba(179, 80, 106, 0.12);
  --shadow: rgba(38, 28, 49, 0.30);
  --line: rgba(95, 63, 127, 0.20);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 9%, rgba(244, 220, 168, 0.45), transparent 30%),
    linear-gradient(150deg, #2f263f, #5c4b73 50%, #a87990);
  overscroll-behavior: none;
}
body { min-height: 100dvh; }

button, select { font: inherit; }
button { border: 0; cursor: pointer; }

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.app-shell { min-height: 100dvh; width: min(1180px, 100%); margin: 0 auto; }

/* ---------- Shared paper surfaces ---------- */
.title-card, .top-hud, .scene-card, .drawer-card, .story-card, .speech-bubble, .question-tray {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow: 0 18px 50px var(--shadow);
  backdrop-filter: blur(12px);
}

/* ---------- Start screen ---------- */
.start-screen {
  min-height: 100dvh;
  display: none;
  place-items: center;
  padding: max(calc(18px + var(--safe-top)), 48px) 16px calc(20px + var(--safe-bottom));
  position: relative;
  overflow: hidden;
}
.start-screen.active { display: grid; }
.moon-glow {
  position: absolute; width: 440px; height: 440px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 242, 190, 0.75), rgba(255, 242, 190, 0.10) 58%, transparent 70%);
  top: -90px; right: -100px; filter: blur(2px);
}
.title-card {
  width: min(640px, 94vw); text-align: center; border-radius: 34px;
  padding: 26px 22px 24px; position: relative; z-index: 2;
}
.title-tofu {
  width: min(230px, 56vw); aspect-ratio: 1; object-fit: contain;
  margin: -8px auto 0; display: block;
  filter: drop-shadow(0 14px 16px rgba(55, 38, 72, 0.25));
}
.eyebrow {
  margin: 0 0 6px; color: var(--berry-dark); text-transform: uppercase;
  font-size: 0.72rem; letter-spacing: 0.12em; font-weight: 900;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.2rem, 8vw, 4.55rem); line-height: 0.95; margin-bottom: 14px; color: #3a294c; }
h2 { margin-bottom: 4px; }
h3 { margin-bottom: 10px; color: #3b2c4e; }
.case-line, .case-teaser, .intro-copy, .small-note { color: var(--muted); }
.intro-copy { line-height: 1.55; max-width: 54ch; margin-inline: auto; }
.small-note { font-size: 0.88rem; line-height: 1.42; }

/* ---------- Buttons ---------- */
.primary-btn, .ghost-btn, .dock-btn, .room-card-btn, .question-btn, .hotspot-btn {
  border-radius: 999px; font-weight: 900;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.primary-btn {
  color: #fffaf0; background: linear-gradient(135deg, var(--berry-dark), var(--berry));
  padding: 13px 18px; box-shadow: 0 12px 22px rgba(95, 63, 127, 0.30);
}
.primary-btn.disabled { background: rgba(105, 93, 115, 0.45); box-shadow: none; cursor: not-allowed; }
.ghost-btn { color: var(--berry-dark); background: rgba(255, 255, 255, 0.62); border: 1px solid var(--line); padding: 11px 15px; }
.small-btn { padding: 9px 13px; }
button:active { transform: translateY(1px) scale(0.99); }
button:focus-visible { outline: 3px solid rgba(110, 189, 181, 0.65); outline-offset: 3px; }

/* ---------- Game shell ---------- */
.game-screen {
  min-height: 100dvh;
  padding: max(calc(12px + var(--safe-top)), 58px) 10px calc(10px + var(--safe-bottom));
}
.stage-shell {
  min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 20px);
  display: grid; grid-template-rows: auto 1fr auto; gap: 8px;
  max-width: 560px; margin-inline: auto;
}
.top-hud { border-radius: 24px; padding: 12px 14px; display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.top-hud h2 { font-size: clamp(1.08rem, 4vw, 1.45rem); }
.case-teaser { margin: 0; font-size: 0.9rem; line-height: 1.28; }

.scene-card { border-radius: 28px; padding: 8px; align-self: stretch; display: grid; place-items: center; min-height: 0; }
.scene-frame {
  position: relative; overflow: hidden; border-radius: 22px; background: #463756;
  aspect-ratio: 1024 / 1820;
  height: min(100%, calc(100dvh - 188px - var(--safe-top) - var(--safe-bottom)));
  max-height: 880px; width: auto; max-width: 100%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.20), 0 16px 34px rgba(29, 20, 37, 0.28);
}
.room-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.sprite-layer, .hotspot-layer { position: absolute; inset: 0; }
.sprite-layer { pointer-events: none; }
.hotspot-layer { pointer-events: none; z-index: 8; }

/* ---------- Sprites (placement comes from inline roomStages) ---------- */
.tofu-sprite, .suspect-sprite, .victim-sprite {
  position: absolute; bottom: 1.5%; transform: translateX(-50%); height: auto;
  transition: left 180ms ease, bottom 180ms ease, width 180ms ease, transform 180ms ease, opacity 180ms ease;
  filter: drop-shadow(0 13px 10px rgba(33, 26, 40, 0.40));
}
.tofu-sprite { transform-origin: bottom center; }
.suspect-button {
  pointer-events: auto; background: transparent; padding: 0; color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.62); z-index: 7;
}
.suspect-button img { width: 100%; display: block; pointer-events: none; }
.suspect-button span {
  position: relative; display: table; margin: -4px auto 0; padding: 5px 11px; border-radius: 999px;
  background: rgba(64, 45, 82, 0.78); border: 1px solid rgba(255, 255, 255, 0.38);
  font-size: 0.76rem; font-weight: 900; white-space: nowrap;
}
.victim-sprite { pointer-events: none; }
#sceneFrame.interview-open .sprite-layer { z-index: 12; }
#sceneFrame.dialogue-open .tofu-sprite, #sceneFrame.dialogue-open .suspect-sprite {
  filter: drop-shadow(0 15px 12px rgba(33, 26, 40, 0.40));
}

/* ---------- Hotspots ---------- */
.hotspot-btn {
  pointer-events: auto; position: absolute; width: 46px; height: 46px; translate: -50% -50%;
  border: 2px solid rgba(255, 255, 255, 0.70);
  background: radial-gradient(circle, rgba(255, 245, 184, 0.95), rgba(244, 220, 168, 0.45) 48%, rgba(141, 95, 163, 0.22) 70%);
  box-shadow: 0 0 0 7px rgba(255, 242, 190, 0.16), 0 8px 20px rgba(48, 32, 62, 0.26);
  color: #473459; font-size: 1.25rem; z-index: 9; animation: pulseHotspot 1.9s ease-in-out infinite;
}
.hotspot-btn.found {
  animation: none; background: rgba(255, 250, 240, 0.70); color: var(--teal-dark);
  box-shadow: 0 0 0 5px rgba(110, 189, 181, 0.15);
}
@keyframes pulseHotspot { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
body.no-sparkles .hotspot-btn { animation: none; background: rgba(255, 250, 240, 0.42); box-shadow: 0 6px 14px rgba(48, 32, 62, 0.22); }

/* ---------- Speech bubble ---------- */
.speech-bubble {
  position: absolute; z-index: 14; top: 30%; max-width: 76%; padding: 12px 13px 13px;
  border-radius: 20px; line-height: 1.36; cursor: pointer; user-select: none;
}
.speech-bubble.left { left: 6%; }
.speech-bubble.right { right: 5%; top: 30%; }
.speech-bubble.thought { left: 9%; top: 14%; border-style: dashed; max-width: 78%; }
.speech-bubble p { margin: 3px 0 0; }
.speech-bubble strong { color: var(--berry-dark); }
.speech-bubble::after {
  content: ""; position: absolute; bottom: -10px; width: 18px; height: 18px;
  background: var(--paper-strong); transform: rotate(45deg);
  border-right: 1px solid rgba(255, 255, 255, 0.56); border-bottom: 1px solid rgba(255, 255, 255, 0.56);
}
.speech-bubble.left::after { left: 34px; }
.speech-bubble.right::after { right: 34px; }
.speech-bubble.thought::after { border-radius: 50%; width: 13px; height: 13px; transform: none; bottom: -15px; left: 48px; border: 1px solid rgba(255, 255, 255, 0.56); }
.bubble-hint {
  display: inline-block; margin-top: 8px; padding: 4px 9px; border-radius: 999px;
  background: rgba(95, 63, 127, 0.10); color: var(--berry-dark); font-size: 0.72rem; font-weight: 900;
}
#sceneFrame[data-room="parlor"] .speech-bubble.left { top: 20%; }

/* ---------- Question tray ---------- */
.question-tray {
  position: absolute; left: 5.5%; right: 5.5%; bottom: 2.5%; z-index: 30;
  border-radius: 20px; padding: 9px 11px; max-height: 30%; overflow: auto;
}
.question-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.question-title { margin: 0; color: var(--berry-dark); font-weight: 900; font-size: 0.9rem; }
.question-done {
  border-radius: 999px; padding: 7px 12px; color: var(--berry-dark);
  background: rgba(255, 255, 255, 0.72); border: 1px solid var(--line); font-weight: 900; font-size: 0.84rem;
}
.question-grid { display: grid; gap: 6px; }
.question-btn {
  text-align: left; padding: 9px 12px; color: var(--berry-dark);
  background: rgba(255, 255, 255, 0.72); border: 1px solid var(--line); line-height: 1.15; font-size: 0.9rem;
}
.question-btn.asked { background: rgba(232, 255, 249, 0.80); border-color: rgba(110, 189, 181, 0.42); }
.question-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Room plaque + dock ---------- */
.room-plaque {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 12;
  padding: 7px 12px; border-radius: 999px; color: #fffaf0; background: rgba(58, 41, 76, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.28); font-size: 0.8rem; font-weight: 900;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.30);
}
.bottom-dock {
  position: sticky; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 7px; padding: 7px; border-radius: 24px; background: rgba(48, 37, 63, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.22); box-shadow: 0 14px 34px rgba(28, 18, 39, 0.26); backdrop-filter: blur(12px);
}
.dock-btn { min-height: 46px; padding: 9px 7px; color: #fff8ea; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.20); }
.primary-dock { background: linear-gradient(135deg, var(--berry-dark), var(--berry)); }
#notesChip {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 3px;
  border-radius: 999px; color: var(--berry-dark); background: #fff8ea; font-size: 0.78rem;
}

/* ---------- Drawer + story overlay ---------- */
.drawer, .story-overlay {
  position: fixed; inset: 0; z-index: 50;
  padding: max(calc(14px + var(--safe-top)), 50px) 12px calc(14px + var(--safe-bottom));
  background: rgba(29, 20, 39, 0.52); display: grid; place-items: end center;
}
.drawer-card, .story-card {
  width: min(640px, 100%); max-height: min(86dvh, 820px); overflow: auto; border-radius: 28px;
  padding: 16px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.story-card { place-self: center; display: grid; gap: 10px; }
.drawer-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 12px; }
.drawer-body { display: grid; gap: 12px; }

/* ---------- Rooms grid ---------- */
.room-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.room-card-btn {
  padding: 12px; text-align: left; color: var(--berry-dark); background: var(--paper-soft);
  border: 1px solid var(--line); border-radius: 18px;
}
.room-card-btn.active { background: rgba(232, 255, 249, 0.78); outline: 2px solid rgba(110, 189, 181, 0.45); }
.room-card-btn strong { display: block; }
.room-card-btn small { display: block; color: var(--muted); margin-top: 3px; font-weight: 650; }

/* ============================================================
   CASEBOOK
   ============================================================ */
.cb-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px;
  background: rgba(95, 63, 127, 0.10); border-radius: 16px; margin-bottom: 4px; position: sticky; top: 0; z-index: 2;
}
.cb-tab {
  position: relative; padding: 9px 4px; border-radius: 12px; font-weight: 900; font-size: 0.86rem;
  color: var(--berry-dark); background: transparent;
}
.cb-tab.active { background: #fffaf0; box-shadow: 0 4px 12px rgba(55, 38, 72, 0.12); }
.cb-tab-flag {
  position: absolute; top: 2px; right: 6px; width: 16px; height: 16px; border-radius: 999px;
  background: var(--warn); color: #fff; font-size: 0.66rem; display: grid; place-items: center; line-height: 1;
}
.cb-panel { display: grid; gap: 10px; }
.cb-list { display: grid; gap: 8px; }
.cb-subhead {
  margin-top: 4px; color: var(--berry-dark); font-weight: 900; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.cb-hint-line { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.4; font-style: italic; }
.cb-empty { margin: 0; padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.48); border: 1px dashed var(--line); color: var(--muted); }

.cb-back {
  justify-self: start; padding: 8px 13px; border-radius: 999px; color: var(--berry-dark);
  background: var(--paper-soft); border: 1px solid var(--line); font-weight: 900; font-size: 0.86rem;
}

/* ---- Suspect rows ---- */
.cb-person {
  display: grid; grid-template-columns: 56px 1fr 18px; align-items: center; gap: 12px; padding: 9px 12px 9px 9px;
  border-radius: 18px; background: var(--paper-soft); border: 1px solid var(--line); text-align: left;
  box-shadow: 0 8px 18px rgba(55, 38, 72, 0.07);
}
.cb-person img { width: 56px; height: 66px; object-fit: contain; filter: drop-shadow(0 5px 5px rgba(55, 38, 72, 0.18)); }
.cb-person-meta strong { display: block; color: var(--berry-dark); font-size: 1.02rem; }
.cb-person-meta small { display: block; margin-top: 2px; color: var(--muted); font-weight: 700; line-height: 1.3; }
.cb-chevron { color: var(--berry); font-size: 1.3rem; font-weight: 900; }
.cb-warn { color: var(--warn); margin-left: 4px; }

/* ---- Dossier ---- */
.cb-dossier-head {
  display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 12px; padding: 10px;
  border-radius: 18px; background: rgba(255, 255, 255, 0.55); border: 1px solid var(--line);
}
.cb-dossier-head img { width: 78px; height: 90px; object-fit: contain; filter: drop-shadow(0 5px 5px rgba(55, 38, 72, 0.18)); }
.cb-dossier-head strong { display: block; color: var(--berry-dark); font-size: 1.12rem; }
.cb-dossier-head small { display: block; margin-top: 2px; color: var(--muted); font-weight: 700; }
.cb-field { padding: 11px 13px; border-radius: 16px; background: var(--paper-soft); border: 1px solid var(--line); }
.cb-field strong { color: var(--berry-dark); font-size: 0.92rem; }
.cb-field p { margin: 5px 0 0; color: var(--ink); line-height: 1.46; }
.cb-field.locked { background: rgba(255, 255, 255, 0.32); border-style: dashed; }
.cb-field.locked p { color: var(--muted); font-style: italic; }
.cb-flag-block { padding: 11px 13px; border-radius: 16px; background: var(--warn-soft); border: 1px solid rgba(179, 80, 106, 0.30); }
.cb-flag-block strong { color: var(--warn); }
.cb-flag-block.cleared { background: rgba(110, 189, 181, 0.12); border-color: rgba(47, 125, 103, 0.34); }
.cb-flag-block.cleared strong { color: var(--teal-dark); }
.cb-flag-block p { margin: 5px 0 0; color: var(--ink); line-height: 1.44; }
.cb-flag-block small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.4; }

/* ---- Hunch pins ---- */
.cb-pin-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-pin {
  padding: 7px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 800;
  color: var(--muted); background: rgba(255, 255, 255, 0.5); border: 1px solid var(--line);
}
.cb-pin.on { color: #fff; background: linear-gradient(135deg, var(--warn), #c76d83); border-color: transparent; box-shadow: 0 4px 10px rgba(179, 80, 106, 0.3); }

/* ---- Compare ---- */
.cb-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-filter-btn {
  flex: 1 1 auto; padding: 8px 10px; border-radius: 999px; font-weight: 850; font-size: 0.8rem;
  color: var(--berry-dark); background: var(--paper-soft); border: 1px solid var(--line); white-space: nowrap;
}
.cb-filter-btn.active { color: #fffaf0; background: linear-gradient(135deg, var(--berry-dark), var(--berry)); border-color: transparent; }
.cb-compare { display: grid; gap: 8px; }
.cb-compare-row {
  display: grid; grid-template-columns: 48px 1fr; align-items: start; gap: 11px; padding: 10px 12px;
  border-radius: 16px; background: var(--paper-soft); border: 1px solid var(--line);
}
.cb-compare-row img { width: 48px; height: 58px; object-fit: contain; filter: drop-shadow(0 4px 4px rgba(55, 38, 72, 0.18)); }
.cb-compare-name { color: var(--berry-dark); font-weight: 900; font-size: 0.92rem; }
.cb-compare-val { margin-top: 3px; color: var(--ink); line-height: 1.42; font-size: 0.92rem; }
.cb-compare-val i { color: var(--muted); }
.cb-con-stack { display: grid; gap: 8px; }

/* ---- Contradiction card ---- */
.cb-con { padding: 12px 14px; border-radius: 16px; background: var(--warn-soft); border: 1px solid rgba(179, 80, 106, 0.34); }
.cb-con-head { color: var(--warn); font-weight: 900; }
.cb-con p { margin: 6px 0 9px; color: var(--ink); line-height: 1.45; }
.cb-con-btn {
  padding: 9px 14px; border-radius: 999px; color: #fff; font-weight: 900; font-size: 0.86rem;
  background: linear-gradient(135deg, var(--warn), #c76d83); box-shadow: 0 6px 14px rgba(179, 80, 106, 0.28);
}
.cb-con.confirmed { background: rgba(110, 189, 181, 0.14); border-color: rgba(47, 125, 103, 0.36); }
.cb-con.confirmed .cb-con-head { color: var(--teal-dark); }

/* ---- Evidence ---- */
.cb-clue {
  display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 11px; padding: 11px 12px;
  border-radius: 16px; background: var(--paper-soft); border: 1px solid var(--line); text-align: left;
}
.cb-clue.pending { opacity: 0.78; }
.cb-clue-icon { font-size: 1.5rem; text-align: center; }
.cb-clue-meta strong { display: block; color: var(--berry-dark); font-size: 0.98rem; }
.cb-clue-meta small { display: block; margin-top: 2px; color: var(--muted); line-height: 1.32; font-weight: 650; }
.cb-badge {
  display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 900;
  font-style: normal; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); background: rgba(95, 63, 127, 0.10);
}
.cb-badge.earned { color: var(--teal-dark); background: rgba(110, 189, 181, 0.18); }
.cb-clue-detail { padding: 14px; border-radius: 18px; background: var(--paper-soft); border: 1px solid var(--line); }
.cb-clue-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cb-clue-detail-head span { font-size: 1.8rem; }
.cb-clue-detail-head strong { display: block; color: var(--berry-dark); font-size: 1.1rem; }
.cb-clue-detail p { color: var(--ink); line-height: 1.5; margin: 0; }
.cb-connects { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.cb-connects strong { color: var(--berry-dark); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.cb-connects p { margin: 5px 0 0; color: var(--muted); line-height: 1.46; }
.cb-linked-people { margin-top: 10px; color: var(--berry-dark); font-weight: 800; font-size: 0.86rem; }
.cb-doctor-btn { margin-top: 12px; }
.cb-doctor-note {
  margin-top: 10px; padding: 10px 12px; border-radius: 14px;
  background: rgba(110, 189, 181, 0.10); border: 1px solid rgba(47, 125, 117, 0.22);
  color: var(--teal-dark); font-size: 0.84rem; line-height: 1.42; font-weight: 700;
}

/* ---- Theory ---- */
.cb-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cb-stat { padding: 12px 8px; text-align: center; border-radius: 16px; background: var(--paper-soft); border: 1px solid var(--line); }
.cb-stat strong { display: block; color: var(--berry-dark); font-size: 1.4rem; }
.cb-stat small { display: block; margin-top: 2px; color: var(--muted); font-weight: 850; font-size: 0.74rem; }
.cb-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-pill { padding: 7px 11px; border-radius: 999px; font-size: 0.8rem; font-weight: 850; color: var(--muted); background: var(--paper-soft); border: 1px solid var(--line); }
.cb-pill.done { color: var(--teal-dark); background: rgba(232, 255, 249, 0.78); border-color: rgba(110, 189, 181, 0.42); }
.cb-accuse { width: 100%; margin-top: 4px; text-align: center; }

/* ---- Solve / accuse ---- */
.notebook-intro { margin: 0; line-height: 1.42; }
.accuse-form { display: grid; gap: 10px; }
.accuse-form label { display: grid; gap: 5px; font-weight: 900; color: var(--berry-dark); }
select { width: 100%; border-radius: 14px; border: 1px solid var(--line); background: #fffaf0; padding: 12px; color: var(--ink); }
.result-panel { margin-top: 10px; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--paper-soft); line-height: 1.5; }
.result-panel.win { border-color: rgba(47, 125, 103, 0.38); background: rgba(234, 255, 247, 0.80); }
.result-panel.miss { border-color: rgba(156, 77, 95, 0.32); background: rgba(255, 241, 245, 0.80); }
.reveal-dialogue p { margin-bottom: 10px; }
.locked-warning { border-radius: 18px; padding: 13px; background: rgba(255, 246, 219, 0.82); border: 1px solid rgba(141, 95, 163, 0.22); }
.locked-warning p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }

/* ---- Menu + Settings ---- */
.detail-card { padding: 13px; border-radius: 16px; background: var(--paper-soft); border: 1px solid var(--line); }
.detail-card strong { color: var(--berry-dark); }
.detail-card p { margin: 5px 0 6px; color: var(--ink); line-height: 1.45; }
.detail-card small { display: block; color: var(--muted); line-height: 1.4; }
.menu-grid { display: grid; gap: 10px; }
.danger-btn { background: rgba(255, 237, 237, 0.72) !important; border-color: rgba(169, 74, 74, 0.32) !important; }
.danger-btn strong { color: #8b3535; }
.setting-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 13px;
  border-radius: 16px; background: var(--paper-soft); border: 1px solid var(--line);
}
.setting-row strong { color: var(--berry-dark); }
.setting-row small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.38; font-weight: 650; }
.toggle { width: 52px; height: 30px; border-radius: 999px; background: rgba(95, 63, 127, 0.22); position: relative; transition: background 0.16s ease; flex: none; }
.toggle.on { background: linear-gradient(135deg, var(--teal-dark), var(--teal)); }
.toggle-knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 999px; background: #fffaf0; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25); transition: left 0.16s ease; }
.toggle.on .toggle-knob { left: 25px; }

/* ---------- Story overlay visual ---------- */
.story-text { line-height: 1.55; color: var(--muted); }
.story-text p { margin-bottom: 11px; }
.story-text strong { color: var(--berry-dark); }
.story-visual { width: 100%; }
.story-frame {
  position: relative; overflow: hidden; width: min(100%, 360px); margin-inline: auto;
  aspect-ratio: 1024 / 1360; border-radius: 22px; background: #463756; border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.20), 0 12px 26px rgba(38, 28, 49, 0.18);
}
.story-room { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; filter: saturate(1.02) brightness(0.96); }
.story-character { position: absolute; transform: translateX(-50%); filter: drop-shadow(0 12px 12px rgba(33, 26, 40, 0.34)); }
.story-victim { filter: drop-shadow(0 9px 8px rgba(33, 26, 40, 0.34)); }
.story-scene-label {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 20; padding: 6px 11px;
  border-radius: 999px; color: #fffaf0; background: rgba(58, 41, 76, 0.72); border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 0.72rem; font-weight: 900; white-space: nowrap;
}

/* ---------- Reduced motion ---------- */
body.no-motion *, body.no-motion *::before, body.no-motion *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important;
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .game-screen { padding-inline: 7px; }
  .top-hud { border-radius: 20px; padding: 10px 11px; }
  .top-hud .ghost-btn { padding: 9px 10px; font-size: 0.82rem; }
  .scene-card { border-radius: 22px; padding: 6px; }
  .scene-frame { border-radius: 18px; height: min(100%, calc(100dvh - 178px - var(--safe-top) - var(--safe-bottom))); }
  .speech-bubble { max-width: 82%; font-size: 0.9rem; }
  .dock-btn { font-size: 0.82rem; min-height: 44px; padding-inline: 4px; }
  .drawer-card, .story-card { border-radius: 24px; padding: 14px; }
  .room-grid { grid-template-columns: 1fr; }
  .cb-stats { grid-template-columns: 1fr 1fr 1fr; }
  .story-frame { width: min(100%, 330px); aspect-ratio: 1024 / 1280; }
}
@media (min-width: 900px) {
  .scene-frame { height: min(100%, calc(100dvh - 188px - var(--safe-top) - var(--safe-bottom))); }
}
