:root {
  --bg: #141212;
  --panel: #211f1d;
  --panel-strong: #2b2925;
  --paper: #f3efe4;
  --paper-muted: #d8cfbd;
  --ink: #f7f1e5;
  --muted: #a8a09a;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --teal: #45c4b0;
  --wine: #8d2f47;
  --brass: #d0a84f;
  --danger: #ef6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(10, 10, 10, 0.96), rgba(15, 14, 13, 0.78) 42%, rgba(8, 10, 10, 0.94)),
    linear-gradient(180deg, rgba(12, 13, 13, 0.68), rgba(8, 8, 8, 0.96)),
    url("./assets/manor-cinematic-bg.png") center / cover fixed no-repeat,
    #101010;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 14px;
  align-items: center;
  max-width: 1480px;
  margin: 0 auto 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid rgba(208, 168, 79, 0.5);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(208, 168, 79, 0.95), rgba(69, 196, 176, 0.75)),
    #1b1a18;
  box-shadow: 0 12px 30px rgba(69, 196, 176, 0.14);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  line-height: 1.25;
}

.session-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.api-badge,
.phase-badge,
.score-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--paper);
  font-size: 0.86rem;
  font-weight: 750;
  white-space: nowrap;
}

.api-badge {
  color: var(--teal);
}

.score-badge {
  color: var(--brass);
}

.icon-button,
.send-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.icon-button.active {
  border-color: rgba(69, 196, 176, 0.75);
  background: rgba(69, 196, 176, 0.14);
  color: var(--teal);
}

.icon-button:hover,
.send-button:hover,
.secondary-button:hover,
.mode-button:hover {
  border-color: rgba(69, 196, 176, 0.5);
  background: rgba(69, 196, 176, 0.12);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(290px, 380px);
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto;
}

.scene-panel,
.dm-panel,
.evidence-panel {
  min-width: 0;
}

.scene-panel,
.evidence-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scene-visual,
.phase-card,
.task-section,
.role-section,
.search-section,
.evidence-section,
.vote-panel,
.deduction-panel,
.ending-panel,
.transcript-shell,
.message-composer,
.setup-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(33, 31, 29, 0.88);
  box-shadow: var(--shadow);
}

.scene-visual {
  position: relative;
  min-height: 280px;
  overflow: hidden;
}

.scene-visual::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, transparent 50%, rgba(10, 9, 8, 0.62)),
    radial-gradient(circle at 50% 45%, transparent 0 48%, rgba(0, 0, 0, 0.28) 100%);
  pointer-events: none;
}

.scene-visual img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
  object-position: 52% 52%;
}

.scene-live-tag {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(15, 14, 13, 0.72);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 750;
  backdrop-filter: blur(12px);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 14px var(--teal);
}

.phase-card,
.task-section,
.role-section,
.search-section,
.evidence-section,
.vote-panel,
.deduction-panel,
.ending-panel {
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.section-heading strong {
  color: var(--paper);
  font-size: 0.8rem;
  white-space: nowrap;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--brass));
  transition: width 250ms ease;
}

.phase-description {
  margin: 12px 0 0;
  color: var(--paper-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.task-section h3,
.ending-panel h3 {
  margin: 0 0 7px;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  line-height: 1.3;
}

.task-section p,
.ending-panel p {
  margin: 0;
  color: var(--paper-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.task-choice-list,
.ending-checks {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.task-choice-button,
.ending-check {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--paper-muted);
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.35;
}

.task-choice-button.selected,
.ending-check.passed {
  border-color: rgba(69, 196, 176, 0.62);
  background: rgba(69, 196, 176, 0.12);
  color: var(--ink);
}

.ending-check.failed {
  border-color: rgba(239, 107, 107, 0.45);
  background: rgba(239, 107, 107, 0.08);
}

.role-list,
.setup-roles {
  display: grid;
  gap: 10px;
}

.role-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: inherit;
  text-align: left;
}

.role-card.selected {
  border-color: rgba(69, 196, 176, 0.75);
  background: rgba(69, 196, 176, 0.12);
}

.role-card img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
}

.role-card h3,
.role-card p {
  margin: 0;
}

.role-card h3 {
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.role-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.dm-panel {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  gap: 14px;
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 16px;
  padding: 18px;
}

.setup-copy p:last-child {
  margin-bottom: 0;
  color: var(--paper-muted);
  line-height: 1.6;
}

.setup-roles {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  width: fit-content;
  align-self: end;
  border: 1px solid rgba(69, 196, 176, 0.65);
  background: linear-gradient(135deg, var(--teal), #79d3a8);
  color: #111;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.transcript-shell {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.transcript-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.transcript-toolbar > div:first-child {
  min-width: 0;
}

.transcript-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.transcript-actions .secondary-button {
  gap: 8px;
  white-space: nowrap;
}

.transcript-actions .secondary-button.active {
  border-color: rgba(69, 196, 176, 0.75);
  background: rgba(69, 196, 176, 0.14);
  color: var(--ink);
}

.transcript-actions span {
  color: var(--brass);
  font-size: 0.74rem;
}

.archive-panel {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  padding: 12px 14px;
}

.archive-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.archive-tool-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 800;
}

.archive-tool-button:hover {
  border-color: rgba(208, 168, 79, 0.58);
  background: rgba(208, 168, 79, 0.12);
}

.archive-tools span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.archive-list {
  display: grid;
  max-height: 230px;
  gap: 9px;
  overflow-y: auto;
  padding-right: 2px;
}

.archive-item,
.archive-empty {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.archive-item.active {
  border-color: rgba(69, 196, 176, 0.62);
  background: rgba(69, 196, 176, 0.1);
}

.archive-item strong,
.archive-empty strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--paper);
  font-size: 0.86rem;
}

.archive-item span,
.archive-empty span,
.archive-item time {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.archive-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.archive-action-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 800;
}

.archive-action-button:hover {
  border-color: rgba(69, 196, 176, 0.58);
  background: rgba(69, 196, 176, 0.12);
}

.archive-action-button.danger {
  color: #ffaaaa;
}

.archive-action-button.danger:hover {
  border-color: rgba(239, 107, 107, 0.58);
  background: rgba(239, 107, 107, 0.12);
}

.archive-empty {
  grid-template-columns: 1fr;
}

.transcript {
  display: flex;
  min-height: 320px;
  max-height: 58vh;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 14px;
  scroll-behavior: smooth;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  max-width: 84%;
}

.message.player {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr) 38px;
}

.message.private {
  max-width: 92%;
}

.message.system {
  align-self: center;
  grid-template-columns: minmax(0, 1fr);
  max-width: 96%;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--brass);
  font-size: 0.8rem;
  font-weight: 900;
}

.message.player .message-avatar {
  grid-column: 2;
  grid-row: 1;
  color: var(--teal);
}

.message-bubble {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.message.player .message-bubble {
  grid-column: 1;
  grid-row: 1;
  background: rgba(69, 196, 176, 0.12);
}

.message.private .message-bubble {
  border-color: rgba(208, 168, 79, 0.45);
  background: rgba(208, 168, 79, 0.12);
}

.message.system .message-bubble {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.035);
  color: var(--paper-muted);
  text-align: center;
}

.message-meta {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

.message-text {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-line;
  color: var(--paper);
  font-size: 0.92rem;
  line-height: 1.55;
}

.message-composer {
  padding: 12px;
}

.composer-modes,
.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-button,
.quick-prompts button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--paper-muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.mode-button.active {
  border-color: rgba(69, 196, 176, 0.75);
  background: rgba(69, 196, 176, 0.14);
  color: var(--ink);
}

.input-row {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr) 42px;
  gap: 8px;
  margin-top: 10px;
}

.npc-select,
.input-row input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.npc-select {
  padding: 0 10px;
}

.input-row input {
  padding: 0 12px;
}

.input-row input::placeholder {
  color: rgba(216, 207, 189, 0.55);
}

.quick-prompts {
  margin-top: 9px;
}

.quick-prompts button:hover {
  border-color: rgba(208, 168, 79, 0.55);
  color: var(--ink);
}

.location-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.location-button,
.vote-button {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  text-align: left;
}

.location-button strong,
.vote-button strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.location-button span,
.vote-button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.location-button.available:hover,
.vote-button:hover {
  border-color: rgba(69, 196, 176, 0.58);
  background: rgba(69, 196, 176, 0.12);
}

.location-button.visited {
  border-color: rgba(208, 168, 79, 0.32);
}

.clue-board {
  display: grid;
  gap: 9px;
  max-height: 56vh;
  overflow: auto;
  padding-right: 2px;
}

.clue-card {
  min-height: 86px;
  padding: 10px;
  border: 1px solid rgba(37, 29, 20, 0.16);
  border-radius: 8px;
  background: var(--paper);
  color: #2f2a24;
  text-align: left;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.clue-card.locked {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  box-shadow: none;
}

.clue-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.clue-card p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  line-height: 1.45;
}

.clue-card:not(.locked):hover {
  transform: translateY(-1px);
}

.vote-list {
  display: grid;
  gap: 9px;
}

.deduction-board {
  display: grid;
  gap: 10px;
}

.deduction-item {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.deduction-item label {
  color: var(--paper);
  font-size: 0.82rem;
  font-weight: 800;
}

.deduction-item select {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  padding: 0 10px;
}

.deduction-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

.vote-button.selected {
  border-color: rgba(239, 107, 107, 0.8);
  background: rgba(239, 107, 107, 0.12);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  }

  .evidence-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  }

  .vote-panel,
  .deduction-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .game-layout,
  .evidence-panel,
  .setup-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 10px;
  }

  .session-status {
    justify-content: flex-start;
  }

  .icon-button {
    position: absolute;
    top: 14px;
    right: 12px;
  }

  #voiceButton {
    right: 62px;
  }

  .setup-roles {
    grid-column: auto;
    grid-row: auto;
  }

  .primary-button {
    width: 100%;
  }

  .dm-panel {
    grid-template-rows: auto minmax(420px, auto) auto;
  }

  .message {
    max-width: 96%;
  }

  .transcript-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .transcript-actions {
    width: 100%;
    justify-content: stretch;
  }

  .transcript-actions .secondary-button {
    flex: 1 1 140px;
  }

  .archive-item {
    grid-template-columns: 1fr;
  }

  .archive-actions {
    justify-content: stretch;
  }

  .archive-action-button {
    flex: 1;
  }

  .input-row {
    grid-template-columns: 1fr 42px;
  }

  .npc-select {
    grid-column: 1 / -1;
  }

  .location-list {
    grid-template-columns: 1fr;
  }
}
