:root {
  --bg: #1a1d25;
  --bg-soft: #242932;
  --panel: #2c323d;
  --panel-2: #343b48;
  --ink: #e9e6dc;
  --ink-dim: #a9a89d;
  --muted: #7d7c73;
  --accent: #d4a24a;
  --accent-2: #8fb5d4;
  --danger: #d4604a;
  --ok: #6ab04c;
  --line: #3b4250;
  --paper: #f2ead5;
  --paper-ink: #3a342a;
  --shadow: 0 8px 24px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
}
.case-title {
  flex: 1;
  font-size: 15px;
  color: var(--ink-dim);
  text-align: center;
}
.topbar-actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover:not(:disabled) { background: var(--panel-2); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1f0a;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #e0b35b; }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}
.btn-danger:hover:not(:disabled) { background: #e06e57; }

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

/* Map section */
.map-section {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 0;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.hint { color: var(--muted); font-size: 12px; }

.map {
  flex: 1;
  position: relative;
  margin: 12px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 30%, rgba(143,181,212,0.08), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(212,162,74,0.08), transparent 40%),
    linear-gradient(135deg, #2e3644 0%, #252b36 100%);
  border: 1px solid var(--line);
  overflow: hidden;
  min-height: 360px;
}
/* subtle grid */
.map::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.building {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 100px;
  padding: 8px 6px;
  background: rgba(40,46,57,0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  backdrop-filter: blur(4px);
}
.building:hover {
  border-color: var(--accent);
  transform: translate(-50%, -50%) scale(1.05);
  z-index: 5;
}
.building.victim { border-color: var(--danger); background: rgba(66,40,40,.92); }
.building.has-person { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(143,181,212,.15); }

.building-icon { font-size: 28px; line-height: 1; }
.building-name { font-size: 12px; margin-top: 4px; color: var(--ink); }
.building-pips {
  margin-top: 4px;
  font-size: 10px;
  color: var(--accent-2);
  min-height: 12px;
}

/* Time bar */
.timebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}
.timebar-label { font-size: 13px; color: var(--ink-dim); }
.time-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.time-btn {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
.time-btn.active {
  background: var(--accent);
  color: #2a1f0a;
  border-color: var(--accent);
  font-weight: 600;
}

/* Side panels */
.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel.grow { flex: 1; }
.panel-title {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
}
.panel-body {
  padding: 12px 14px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.55;
}
.panel-body.small { font-size: 13px; }
.muted { color: var(--muted); }

/* Suspects list */
.suspects-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.suspect-card {
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all .15s ease;
}
.suspect-card:hover { border-color: var(--accent); }
.suspect-card .sus-name { font-weight: 600; color: var(--ink); }
.suspect-card .sus-role { color: var(--ink-dim); font-size: 11px; margin-top: 2px; }

/* Notebook */
.notebook {
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box;
  color: var(--paper-ink);
  font-family: "Georgia", "Songti SC", serif;
  border-radius: 0 0 10px 10px;
}
.note-entry {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(58,52,42,.25);
}
.note-entry:last-child { border-bottom: none; }
.note-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(58,52,42,.12);
  color: var(--paper-ink);
  margin-right: 6px;
  font-family: -apple-system, "PingFang SC", sans-serif;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10,12,16,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.small-card { max-width: 440px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.modal-title { font-weight: 600; color: var(--accent); }
.modal-close {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--ink); }
.modal-sub {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.badge {
  padding: 2px 8px;
  background: var(--accent);
  color: #2a1f0a;
  border-radius: 10px;
  font-weight: 600;
  font-size: 11px;
}
.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
}

.subhead {
  font-size: 12px;
  color: var(--ink-dim);
  margin: 8px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* People / items list inside location modal */
.people-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

/* Person avatar card — face on top, name on bottom */
.person-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
  text-align: center;
}
.person-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
}
.person-card .p-face {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.35));
}
.person-card .p-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

/* Dialog avatar header */
.dlg-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.dlg-face {
  font-size: 60px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.4));
}
.dlg-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.item-row:hover { border-color: var(--accent); }
.item-row .i-name { font-weight: 600; }
.item-row .i-hint { font-size: 11px; color: var(--ink-dim); }

.empty-note {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* Dialog */
.dialog-body {
  padding: 10px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent-2);
  border-radius: 4px;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* Accuse */
.accuse-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.accuse-card {
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: all .15s ease;
}
.accuse-card:hover {
  border-color: var(--danger);
  background: rgba(212,96,74,.1);
}

/* Result */
.result-correct { color: var(--ok); }
.result-wrong { color: var(--danger); }
.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* Hint floating button */
.hint-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #2a1f0a;
  font-size: 26px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.45), 0 0 0 4px rgba(212,162,74,.15);
  z-index: 40;
  transition: transform .15s ease, box-shadow .15s ease;
}
.hint-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 22px rgba(0,0,0,.55), 0 0 0 6px rgba(212,162,74,.2);
}
.hint-fab:active { transform: scale(0.95); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: var(--panel-2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #4a5263; }

/* Responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { max-height: 40vh; }
}
