:root {
  --bg: #0c1118;
  --bg2: #141c26;
  --panel: rgba(18, 26, 36, 0.92);
  --line: rgba(212, 175, 95, 0.18);
  --gold: #d4af5f;
  --gold2: #a8842c;
  --paper: #e8dcc8;
  --ink: #1a1f28;
  --muted: #8b97a8;
  --fog: #9bb0bc;
  --crimson: #a33b45;
  --sage: #5e9d78;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  --display: "STKaiti", "KaiTi", "Songti SC", serif;
  --nav: 64px;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 500px at 50% -8%, rgba(212, 175, 95, 0.1), transparent 55%),
    radial-gradient(700px 400px at 100% 100%, rgba(120, 30, 40, 0.16), transparent 50%),
    var(--bg);
  color: var(--paper);
  min-height: 100dvh;
}
button, input, textarea, select { font-family: inherit; color: inherit; }
button {
  cursor: pointer; border: none; background: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

#app { min-height: 100dvh; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; padding: 12px 18px;
  border-radius: 12px; letter-spacing: 0.12em; font-size: 15px;
}
.btn-primary { background: linear-gradient(180deg, #c9a44a, #8e6b22); color: #1a1408; font-weight: 600; }
.btn-ghost { border: 1px solid var(--line); color: var(--paper); }
.btn-danger { background: #6e2430; color: #f3d6d8; }
.btn-row { display: grid; gap: 10px; margin-top: 14px; }
.btn:disabled { opacity: 0.45; }

/* Title */
.title-view {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: #0c1118 center/cover no-repeat;
  position: relative;
}
.title-view::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(12,17,24,0.15) 20%, rgba(12,17,24,0.92) 78%);
}
.title-inner {
  position: relative; z-index: 1;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto; width: 100%;
}
.title-inner h1 {
  font-family: var(--display); font-size: clamp(32px, 8vw, 44px);
  font-weight: 400; letter-spacing: 0.22em; margin-bottom: 8px;
}
.title-inner .sub { color: var(--gold); letter-spacing: 0.18em; font-size: 13px; margin-bottom: 10px; }
.title-inner p { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 22px; }

.progress-rail {
  height: 6px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; margin: 10px 0 18px;
}
.progress-rail i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8e6b22, #e6c56a); }

/* Story */
.story-view { min-height: 100dvh; display: flex; flex-direction: column; }
.story-hero {
  height: 38vh; min-height: 200px; background: #111 center/cover no-repeat; position: relative;
}
.story-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, var(--bg) 100%);
}
.story-body { flex: 1; padding: 8px 20px 24px; max-width: 720px; margin: 0 auto; width: 100%; }
.kicker { color: var(--gold); letter-spacing: 0.22em; font-size: 12px; margin-bottom: 10px; }
.story-body p { white-space: pre-wrap; line-height: 2; font-size: 17px; color: #efe6d4; }
.fake-block { margin-bottom: 14px; line-height: 1.85; color: #ddd4c2; white-space: pre-wrap; }
.fake-block b { color: var(--gold); }
.mobile-nav.four { grid-template-columns: repeat(4, 1fr); }
.pager { color: var(--muted); font-size: 12px; margin: 16px 0 8px; letter-spacing: 0.12em; }

/* Hub */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(12,17,24,0.92); z-index: 5; backdrop-filter: blur(10px);
}
.topbar .logo { font-family: var(--display); letter-spacing: 0.16em; font-size: 16px; }
.case-tag { color: var(--gold); font-size: 12px; letter-spacing: 0.14em; }

.scene-banner {
  height: 64px; background: #111; position: relative;
  display: flex; align-items: flex-end;
}
.scene-banner .cap {
  padding: 12px 16px;
  font-family: var(--display); letter-spacing: 0.16em; font-size: 22px;
}
.map-banner { border-bottom: 1px solid var(--line); }
.map-card { padding: 12px 10px 14px; }
.map-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.floorplan {
  width: 100%; min-width: 640px; height: auto; display: block;
  border-radius: 10px; border: 1px solid var(--line);
}
.hotspot { cursor: pointer; }
.hotspot .spot-fill { transition: fill .15s; }
.hotspot:hover .spot-fill { fill: rgba(212, 175, 95, 0.28); }
.hotspot.done .spot-fill { fill: rgba(94, 157, 120, 0.32); stroke: #5e9d78; stroke-dasharray: none; }
.hotspot.lock { opacity: 0.38; pointer-events: none; cursor: default; }

.layout { max-width: 980px; margin: 0 auto; padding: 14px 14px calc(var(--nav) + var(--safe) + 16px); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card h3 { font-size: 13px; letter-spacing: 0.18em; color: var(--gold); margin-bottom: 10px; font-weight: 500; }
.public li { list-style: none; font-size: 14px; line-height: 1.7; color: #ddd4c2; padding-left: 12px; position: relative; margin-bottom: 4px; }
.public li::before { content: "·"; position: absolute; left: 0; color: var(--gold); }

.spot-grid, .char-grid, .clue-grid { display: grid; gap: 10px; }
.spot-grid { grid-template-columns: 1fr 1fr; }
.spot {
  text-align: left; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.03); min-height: 72px;
}
.spot b { display: block; margin-bottom: 4px; }
.spot span { color: var(--muted); font-size: 12px; }
.spot.done { opacity: 0.55; }
.spot.lock { opacity: 0.4; }

.char-grid { grid-template-columns: repeat(3, 1fr); }
.person { text-align: center; }
.person img, .portrait {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: #1a222c;
}
.person .nm { margin-top: 6px; font-size: 13px; }
.person .tt { color: var(--muted); font-size: 11px; }
.person.dead img { filter: grayscale(1) brightness(0.55); }

.clue-grid { grid-template-columns: 1fr 1fr; }
.clue-card {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #161e28; text-align: left;
}
.clue-card img { width: 100%; height: 110px; object-fit: cover; background: #222; }
.clue-card .meta { padding: 8px 10px 12px; }
.clue-card b { font-size: 13px; display: block; margin-bottom: 4px; }
.clue-card p { color: var(--muted); font-size: 12px; line-height: 1.5; }

.talk-box {
  margin-top: 10px; padding: 12px; border-left: 3px solid var(--gold);
  background: rgba(212,175,95,0.06); line-height: 1.8; font-size: 14px; white-space: pre-wrap;
}

.mobile-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav) + var(--safe)); padding-bottom: var(--safe);
  background: #101722; border-top: 1px solid var(--line);
}
.mobile-nav button { color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.mobile-nav button.on { color: var(--gold); }
.mobile-nav .ico { font-size: 16px; }

/* Accuse */
.field { display: block; margin-bottom: 12px; color: var(--muted); font-size: 12px; letter-spacing: 0.12em; }
.field select, .notes {
  width: 100%; margin-top: 6px; padding: 12px; border-radius: 10px;
  background: #0f1620; border: 1px solid var(--line); color: var(--paper); font-size: 16px;
}
.notes { min-height: 90px; resize: vertical; letter-spacing: 0; }
.opt-list { display: grid; gap: 8px; margin: 8px 0 14px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  padding: 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; color: var(--paper);
}
.opt.on { border-color: var(--gold); background: rgba(212,175,95,0.1); }
.killer-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 16px; }
.killer-pick button { border: 2px solid transparent; border-radius: 12px; overflow: hidden; padding: 0; background: #161e28; }
.killer-pick button.on { border-color: var(--gold); }
.killer-pick img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.killer-pick span { display: block; padding: 6px 4px 8px; font-size: 12px; }

.verdict { text-align: center; padding: 28px 18px; }
.verdict h2 { font-family: var(--display); letter-spacing: 0.18em; font-size: 28px; margin: 10px 0; }
.ok { color: var(--gold); }
.bad { color: #e07a7a; }
.score-line { color: var(--muted); margin: 8px 0 18px; }

.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 82vh; overflow: auto;
  background: #151c28; border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + var(--safe));
}
.sheet h3 { font-family: var(--display); letter-spacing: 0.14em; margin-bottom: 8px; }
.sheet .sub { color: var(--muted); font-size: 13px; line-height: 1.7; white-space: pre-wrap; }

.toast-layer { position: fixed; left: 0; right: 0; top: 18%; z-index: 30; display: flex; justify-content: center; pointer-events: none; }
.toast {
  background: rgba(20, 26, 36, 0.95); border: 1px solid var(--line);
  color: var(--paper); padding: 10px 16px; border-radius: 99px; font-size: 13px;
}

.empty { color: var(--muted); font-size: 13px; line-height: 1.6; }

.work-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: 4px; background: rgba(255,255,255,0.06);
}
.work-bar i { height: 100%; background: var(--gold); display: block; }

@media (min-width: 880px) {
  .spot-grid, .clue-grid { grid-template-columns: repeat(3, 1fr); }
  .char-grid, .killer-pick { grid-template-columns: repeat(6, 1fr); }
  .scene-banner { height: 72px; }
  .mobile-nav { display: none; }
  .layout { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; padding-bottom: 40px; }
  .layout.single { grid-template-columns: 1fr; max-width: 720px; }
  .desk-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
  .desk-tabs button { border: 1px solid var(--line); padding: 8px 14px; border-radius: 99px; color: var(--muted); }
  .desk-tabs button.on { color: var(--gold); border-color: var(--gold); }
}
@media (max-width: 879px) {
  .desk-tabs { display: none; }
  .story-hero { height: 22vh; min-height: 140px; max-height: 200px; }
  .story-body { padding: 8px 18px calc(28px + var(--safe)); }
  .story-body p { font-size: 16px; line-height: 1.85; }
  .killer-pick { grid-template-columns: repeat(3, 1fr); }
  .opt { min-height: 48px; padding: 12px; }
  .spot, .person { min-height: 48px; }
  .mobile-nav button { min-height: 48px; }
}

.dm-wrap { padding-top: 48px; max-width: 560px; }
.dm-h { font-family: var(--display); letter-spacing: 0.16em; font-size: 28px; margin: 8px 0 12px; }
.dm-page { max-width: 720px; }
.dm-nav {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 12px;
  position: sticky; top: 48px; z-index: 4;
  padding: 8px 0 10px; background: rgba(12,17,24,0.94);
}
.dm-tab {
  min-height: 44px; padding: 8px 12px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.dm-tab.on { color: var(--gold); border-color: var(--gold); }
.dm-sec h3 { margin-bottom: 12px; }
.dm-sec .fake-block { font-size: 15px; line-height: 1.85; }
