:root {
  --wall: #10151a;
  --wall-deep: #080b0f;
  --panel: rgba(17, 23, 28, 0.84);
  --panel-strong: rgba(10, 14, 18, 0.9);
  --paper: #eadbb8;
  --paper-2: #f3e7c8;
  --paper-ink: #201914;
  --ink: #f3efe5;
  --muted: #aeb8b7;
  --line: rgba(239, 224, 188, 0.2);
  --thread: #b74242;
  --brass: #d9b66f;
  --blue: #8db8d7;
  --green: #7fbe8a;
  --red: #d76565;
  --violet: #a98ed6;
  --shadow: rgba(0, 0, 0, 0.5);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(7, 9, 11, 0.72), rgba(10, 12, 15, 0.88)),
    radial-gradient(circle at 18% 16%, rgba(183, 66, 66, 0.22), transparent 30%),
    radial-gradient(circle at 78% 10%, rgba(141, 184, 215, 0.16), transparent 28%),
    url("./assets/background.jpg") center / cover fixed,
    var(--wall);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.26;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(0deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 36px 36px;
  mix-blend-mode: screen;
}

button, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.55; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,0.07) 0, rgba(255,255,255,0.07) 1px, transparent 1px, transparent 7px);
  mix-blend-mode: overlay;
}

.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, transparent, rgba(183, 66, 66, 0.32), transparent);
  transform: translateY(-110%);
}
.scanline.active { animation: scan 1100ms ease-out; }

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 32px 16px;
}

.brand-block { min-width: 0; }

.eyebrow, .section-title, .case-meta, .status-pill {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  color: #fff7db;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(0,0,0,0.45), 0 0 24px rgba(217, 182, 111, 0.24);
}

.tagline {
  margin: 8px 0 0;
  color: #d6c8a7;
  font-size: 0.95rem;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 156px;
  padding: 8px 10px;
  border: 1px solid rgba(239, 224, 188, 0.22);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(9, 13, 17, 0.72);
  box-shadow: 0 10px 22px rgba(0,0,0,0.25);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(217, 182, 111, 0.7);
  border-radius: 50%;
  color: #19120d;
  background: radial-gradient(circle at 32% 24%, #fff5d4, #d9b66f 62%, #8c5b2c);
  font-weight: 900;
}

.player-chip strong,
.player-chip small { display: block; line-height: 1.1; }
.player-chip small { margin-top: 3px; color: var(--muted); font-size: 0.72rem; }

.status-pill {
  min-width: 96px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(14, 19, 23, 0.76);
  text-align: center;
}

.audio-toggle.active {
  color: #12110d;
  background: var(--brass);
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 250px minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  min-height: calc(100vh - 130px);
  padding: 0 32px 32px;
}

.case-list, .case-board, .deduction-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 26px 56px var(--shadow);
  backdrop-filter: blur(10px);
}

.case-list {
  position: relative;
  padding: 18px;
}

.case-list::after {
  content: "";
  position: absolute;
  top: 52px;
  bottom: 92px;
  left: 34px;
  width: 2px;
  background: linear-gradient(var(--thread), transparent);
  opacity: 0.45;
}

.case-board {
  position: relative;
  overflow: auto;
  padding: 22px;
}

.deduction-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.case-button {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: 12px;
  padding: 16px 13px 14px 18px;
  border: 1px solid rgba(77, 55, 34, 0.22);
  border-radius: 4px;
  color: #201914;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.32), transparent 42%),
    var(--paper);
  text-align: left;
  box-shadow: 0 12px 22px rgba(0,0,0,0.24);
  transform: rotate(-0.6deg);
  transition: transform 170ms ease, box-shadow 170ms ease, filter 170ms ease;
}

.case-button:nth-child(2n) { transform: rotate(0.8deg); }
.case-button:hover, .case-button.active {
  filter: brightness(1.06);
  transform: translateY(-3px) rotate(0deg);
  box-shadow: 0 18px 30px rgba(0,0,0,0.34), 0 0 0 2px rgba(217, 182, 111, 0.28);
}
.case-button .pin {
  position: absolute;
  top: -7px;
  left: 18px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd5d5, var(--thread));
  box-shadow: 0 3px 7px rgba(0,0,0,0.35);
}
.case-button strong { display: block; color: #6d2424; font-size: 0.75rem; letter-spacing: 0.05em; }
.case-button span:not(.pin) { display: block; margin-top: 4px; }
.case-button .small { color: #5f5b51; font-size: 0.78rem; }
.case-button.solved::after {
  content: "已解开";
  position: absolute;
  right: 12px;
  top: 12px;
  color: #1e6e3c;
  font-size: 0.76rem;
  font-weight: 900;
  transform: rotate(7deg);
}

.ghost-button {
  width: 100%;
  margin-top: 18px;
  padding: 11px;
  border: 1px dashed rgba(239, 224, 188, 0.28);
  border-radius: 6px;
  color: #e3d2a9;
  background: rgba(0,0,0,0.14);
  transition: background 160ms ease, color 160ms ease;
}
.ghost-button:hover { color: #fff7db; background: rgba(183, 66, 66, 0.14); }

.case-meta { display: flex; flex-wrap: wrap; gap: 10px; }
h2 { margin: 10px 0 16px; color: #fff7db; font-size: 1.65rem; letter-spacing: 0; }

.artifact {
  position: absolute;
  top: 22px;
  right: 20px;
  width: 126px;
  height: 84px;
  border: 6px solid #efe1bc;
  border-radius: 3px;
  opacity: 0.88;
  transform: rotate(2deg);
  background: #dfe6ee;
  box-shadow: 0 10px 22px rgba(0,0,0,0.3);
}
.artifact::before, .artifact::after { content: ""; position: absolute; }
.artifact::before { inset: 9px; border: 1px solid rgba(13, 16, 22, 0.22); }
.artifact::after { width: 48px; height: 10px; top: -14px; left: 34px; background: rgba(217, 182, 111, 0.86); transform: rotate(-4deg); }
.artifact.album { background: linear-gradient(135deg, #eef2f5 0 46%, #c8d2de 46% 54%, #eef2f5 54%); }
.artifact.bus { background: linear-gradient(90deg, #dfe6ee 0 33%, #9fb3c8 33% 45%, #dfe6ee 45%); }
.artifact.hidden { background: #111722; border-color: rgba(183, 66, 66, 0.72); }
.artifact.welcome { background: linear-gradient(135deg, #eadbb8, #9fb3c8); }

.soup-text, .truth-panel { white-space: pre-line; line-height: 1.76; }
.soup-text {
  position: relative;
  max-height: 286px;
  overflow: auto;
  margin-top: 12px;
  padding: 22px 156px 22px 22px;
  border: 1px solid rgba(75, 48, 29, 0.25);
  border-radius: 5px;
  color: var(--paper-ink);
  background:
    linear-gradient(90deg, rgba(122, 73, 41, 0.08) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper-2);
  box-shadow: inset 0 0 32px rgba(90, 45, 24, 0.12), 0 20px 34px rgba(0,0,0,0.28);
}
.soup-text::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #ffd4d4, var(--thread));
  box-shadow: 0 5px 10px rgba(0,0,0,0.28);
}
.lead-note { display: block; color: #6d2424; font-size: 1.08rem; font-weight: 900; }

mark {
  padding: 1px 4px;
  border-radius: 4px;
  color: #111;
  background: rgba(217, 182, 111, 0.72);
}

.clue-panel, .truth-panel {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}
.clue-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  min-height: 38px;
  margin-top: 10px;
}
.clue {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 9px 11px;
  border: 1px solid rgba(141, 184, 215, 0.32);
  border-radius: 4px;
  color: #f6f0df;
  background: rgba(141, 184, 215, 0.14);
  font-size: 0.9rem;
  box-shadow: 0 8px 16px rgba(0,0,0,0.18);
}
.clue:nth-child(2n) { border-color: rgba(183, 66, 66, 0.34); background: rgba(183, 66, 66, 0.13); }
.clue:nth-child(3n) { border-color: rgba(127, 190, 138, 0.34); background: rgba(127, 190, 138, 0.12); }
.clue b {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #19120d;
  background: var(--brass);
  font-size: 0.72rem;
}
.clue.empty { color: var(--muted); background: rgba(0,0,0,0.16); }

.truth-panel {
  padding: 15px;
  border: 1px solid rgba(217, 182, 111, 0.22);
  border-radius: 5px;
  color: #f5eddb;
  background: rgba(0,0,0,0.18);
}
.truth-panel.locked #truthText { color: var(--muted); }

.host-status {
  position: relative;
  min-height: 42px;
  margin-top: 12px;
  padding: 11px 13px 11px 35px;
  border: 1px solid rgba(217, 182, 111, 0.28);
  border-radius: 6px;
  color: #fff1c5;
  background: linear-gradient(90deg, rgba(183, 66, 66, 0.15), rgba(10, 14, 18, 0.55));
}
.host-status::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brass);
  transform: translateY(-50%);
}
.host-status.thinking::before { animation: pulse 780ms ease-in-out infinite; }

.timeline {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 360px;
  max-height: calc(100vh - 414px);
  overflow: auto;
  margin: 14px 0;
  padding: 5px 5px 5px 0;
}

.entry {
  position: relative;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(9, 13, 17, 0.72);
  box-shadow: 0 12px 20px rgba(0,0,0,0.2);
  animation: messageIn 220ms ease-out both;
}
.entry.player {
  margin-left: 36px;
  border-color: rgba(141, 184, 215, 0.36);
  background: rgba(34, 54, 70, 0.72);
}
.entry.character.host {
  margin-right: 28px;
  border-color: rgba(127, 190, 138, 0.38);
  background: rgba(18, 43, 28, 0.62);
}
.entry.character.narrator {
  margin-left: 18px;
  border-color: rgba(183, 66, 66, 0.38);
  background: rgba(54, 18, 22, 0.58);
}
.entry.character.helper {
  margin-right: 18px;
  border-color: rgba(217, 182, 111, 0.38);
  background: rgba(64, 50, 25, 0.56);
}
.entry.unknown {
  border-color: rgba(169, 142, 214, 0.46);
  background: rgba(71, 50, 102, 0.32);
}
.entry.final {
  border-color: rgba(217, 182, 111, 0.52);
  background: rgba(217, 182, 111, 0.12);
}
.entry.system {
  border-style: dashed;
  color: #ddd2bb;
}
.speaker {
  display: block;
  margin-bottom: 5px;
  color: var(--brass);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.entry.player .speaker { color: var(--blue); }
.entry.character.host .speaker { color: var(--green); }
.entry.character.narrator .speaker { color: #f07d7d; }
.entry.character.helper .speaker { color: #f1cf82; }
.entry p { margin: 0; line-height: 1.62; }

.input-row, .guess-box { display: grid; gap: 10px; }
.guess-box {
  flex: 0 0 auto;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.guess-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: #f8ebc4;
  font-weight: 900;
}
.guess-heading small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.solution-slots {
  display: grid;
  gap: 9px;
}
.solution-slot {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(239, 224, 188, 0.18);
  border-radius: 6px;
  background: rgba(0,0,0,0.16);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.solution-slot:hover { transform: translateY(-1px); border-color: rgba(217, 182, 111, 0.36); }
.solution-slot span {
  color: #ecdba9;
  font-size: 0.84rem;
  font-weight: 800;
}
.solution-slot.correct {
  border-color: rgba(127, 190, 138, 0.72);
  background: rgba(28, 82, 42, 0.25);
}
.solution-slot.wrong {
  border-color: rgba(215, 101, 101, 0.76);
  background: rgba(91, 24, 25, 0.25);
}
.solution-slot.correct::after,
.solution-slot.wrong::after {
  justify-self: end;
  margin-top: -4px;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}
.solution-slot.correct::after { content: "线索吻合"; color: var(--green); }
.solution-slot.wrong::after { content: "批注：再查"; color: var(--red); }
.empty-slots {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
}

label { color: var(--muted); font-size: 0.86rem; }
textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(239, 224, 188, 0.18);
  border-radius: 5px;
  padding: 11px;
  color: var(--ink);
  background: rgba(5, 8, 11, 0.82);
  transition: border-color 150ms ease, background 150ms ease;
}
textarea:hover { border-color: rgba(217, 182, 111, 0.34); }
textarea::placeholder { color: #75817c; }
.input-row button, .guess-box button {
  padding: 12px 14px;
  border-radius: 6px;
  color: #14100a;
  background: linear-gradient(180deg, #f4d889, var(--brass));
  font-weight: 900;
  transition: transform 160ms ease, filter 160ms ease;
}
.input-row button:hover, .guess-box button:hover { filter: brightness(1.07); transform: translateY(-1px); }
.guess-box button { background: linear-gradient(180deg, #e69a86, #c95d54); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 5;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(12, 16, 18, 0.96);
  box-shadow: 0 14px 32px var(--shadow);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.confetti i { position: absolute; top: -18px; width: 8px; height: 14px; background: var(--blue); animation: fall 1800ms ease-in forwards; }
.confetti i:nth-child(3n) { background: var(--red); }
.confetti i:nth-child(4n) { background: var(--brass); }

@keyframes scan {
  0% { opacity: 0; transform: translateY(-110%); }
  16% { opacity: 1; }
  100% { opacity: 0; transform: translateY(110%); }
}
@keyframes fall { to { transform: translateY(105vh) rotate(520deg); opacity: 0; } }
@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 182, 111, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(217, 182, 111, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; scroll-behavior: auto !important; transition-duration: 1ms !important; }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 230px minmax(0, 1fr);
  }
  .deduction-panel {
    grid-column: 1 / -1;
    min-height: 600px;
  }
  .timeline {
    max-height: 480px;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 16px 14px;
  }
  h1 { font-size: 1.7rem; }
  .top-actions { justify-content: flex-start; }
  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 0 16px 22px;
  }
  .case-list, .case-board, .deduction-panel { padding: 15px; }
  .artifact {
    position: relative;
    top: auto;
    right: auto;
    width: 116px;
    height: 76px;
    margin: 2px 0 14px;
  }
  .soup-text {
    max-height: 330px;
    padding: 18px;
    font-size: 0.95rem;
  }
  .timeline {
    max-height: none;
    min-height: 300px;
  }
  .entry.player,
  .entry.character.host,
  .entry.character.narrator,
  .entry.character.helper {
    margin-left: 0;
    margin-right: 0;
  }
}
