:root {
  --ink: #f6efe2;
  --muted: #c8baa0;
  --quiet: rgba(246, 239, 226, 0.72);
  --panel: rgba(18, 21, 23, 0.82);
  --panel-strong: rgba(12, 14, 16, 0.92);
  --line: rgba(246, 239, 226, 0.15);
  --gold: #d4a84e;
  --amber: #f0c56a;
  --moss: #7aa36a;
  --teal: #5da8a2;
  --red: #c95c50;
  --violet: #8d79c7;
  --paper: #f7e8c7;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #0f1112;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(6, 7, 8, 0.84), rgba(6, 7, 8, 0.44) 48%, rgba(6, 7, 8, 0.88)),
    linear-gradient(180deg, rgba(6, 7, 8, 0.18), rgba(6, 7, 8, 0.9)),
    url("./assets/council-night.png") center / cover no-repeat;
}

.backdrop::after {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 34px 34px;
  mix-blend-mode: soft-light;
}

.app {
  width: min(1800px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 4px 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 4px;
  font-size: 17px;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.top-actions,
.mini-actions,
.control-strip,
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.icon-btn,
.tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.primary-btn,
.ghost-btn {
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  border-color: rgba(240, 197, 106, 0.52);
  color: #251910;
  background: linear-gradient(180deg, #f4d285, #c89436);
}

.ghost-btn {
  color: var(--ink);
  background: rgba(10, 11, 12, 0.56);
}

.icon-btn,
.tab {
  min-width: 48px;
  padding: 0 10px;
  color: var(--quiet);
}

.tab.active {
  color: #251910;
  background: var(--amber);
}

.primary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover,
.tab:hover {
  transform: translateY(-1px);
  border-color: rgba(240, 197, 106, 0.5);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(420px, 1fr) minmax(280px, 350px);
  gap: 16px;
  align-items: start;
}

.panel,
.scene-card,
.speech-panel,
.log-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head p {
  margin-bottom: 0;
  font-size: 12px;
}

.panel-head.compact {
  margin-top: 16px;
}

.roster-panel,
.info-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.roster-editor {
  display: grid;
  gap: 10px;
}

.editor-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(246, 239, 226, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
}

.seat-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #111;
  font-weight: 900;
  background: var(--paper);
}

.editor-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

label {
  color: var(--quiet);
  font-size: 12px;
  line-height: 34px;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(246, 239, 226, 0.13);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.24);
  outline: none;
}

input {
  height: 34px;
  padding: 0 9px;
}

textarea {
  min-height: 62px;
  resize: vertical;
  padding: 8px 9px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: rgba(240, 197, 106, 0.72);
}

.game-surface {
  display: grid;
  gap: 16px;
}

.scene-card {
  position: relative;
  min-height: 430px;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(16, 18, 18, 0.62), rgba(16, 18, 18, 0.92)),
    url("./assets/council-night.png") center / cover no-repeat;
}

.scene-card::before {
  position: absolute;
  inset: 0;
  content: "";
  border: 1px solid rgba(240, 197, 106, 0.08);
  pointer-events: none;
}

.scene-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  z-index: 1;
}

.scene-head h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.win-badge {
  align-self: flex-start;
  max-width: 260px;
  padding: 9px 11px;
  border: 1px solid rgba(240, 197, 106, 0.4);
  border-radius: var(--radius);
  color: #20160d;
  font-weight: 900;
  line-height: 1.35;
  background: var(--amber);
}

.hidden {
  display: none !important;
}

.seat-board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.seat-card {
  min-height: 106px;
  padding: 10px;
  border: 1px solid rgba(246, 239, 226, 0.15);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.34);
}

.seat-card.dead {
  opacity: 0.58;
  filter: grayscale(0.45);
}

.seat-card.sheriff-seat {
  border-color: rgba(240, 197, 106, 0.72);
  box-shadow: inset 0 0 0 1px rgba(240, 197, 106, 0.2);
}

.seat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.seat-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.role-wolf {
  color: #fff1ed;
  background: rgba(201, 92, 80, 0.78);
}

.role-god {
  color: #20160d;
  background: rgba(240, 197, 106, 0.9);
}

.role-villager {
  color: #061514;
  background: rgba(93, 168, 162, 0.9);
}

.status-pill {
  color: var(--quiet);
  background: rgba(255, 255, 255, 0.08);
}

.seat-note {
  display: -webkit-box;
  min-height: 34px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.control-strip {
  position: relative;
  z-index: 1;
}

.log-panel {
  padding: 14px;
}

.speech-panel {
  padding: 14px;
}

.speech-empty {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 96px;
}

.timer-face {
  display: grid;
  place-items: center;
  min-width: 86px;
  height: 54px;
  border: 1px solid rgba(240, 197, 106, 0.45);
  border-radius: var(--radius);
  color: #21170d;
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(180deg, #f5d487, #c8953c);
}

.speaker-now {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.speaker-now h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.speech-text {
  padding: 12px;
  border: 1px solid rgba(246, 239, 226, 0.14);
  border-radius: var(--radius);
  color: var(--ink);
  line-height: 1.65;
  background: rgba(255, 255, 255, 0.06);
}

.speech-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.speech-chip {
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(246, 239, 226, 0.12);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.22);
}

.speech-chip span,
.speech-chip em {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speech-chip strong {
  display: block;
  overflow: hidden;
  margin: 3px 0;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-log {
  display: grid;
  gap: 9px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.log-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-left: 3px solid rgba(246, 239, 226, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
}

.log-item.night {
  border-left-color: var(--violet);
}

.log-item.public {
  border-left-color: var(--teal);
}

.log-item.system {
  border-left-color: var(--amber);
}

.log-item.death {
  border-left-color: var(--red);
}

.log-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.log-body {
  min-width: 0;
  line-height: 1.55;
}

.log-body strong {
  color: var(--paper);
}

.role-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric {
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(246, 239, 226, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
}

.metric.wide {
  grid-column: 1 / -1;
}

.metric-value {
  font-size: 22px;
  font-weight: 900;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.identity-list {
  display: grid;
  gap: 8px;
}

.identity-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 7px;
  border: 1px solid rgba(246, 239, 226, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
}

.identity-row.dead {
  opacity: 0.55;
}

.identity-main {
  min-width: 0;
}

.identity-name {
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-box textarea {
  min-height: 132px;
  margin-top: 4px;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
}

.source-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.source-note h2 {
  font-size: 15px;
}

.source-note p {
  margin-bottom: 0;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: minmax(300px, 370px) minmax(420px, 1fr);
  }

  .info-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }

  .identity-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .topbar,
  .layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .roster-panel {
    position: static;
    max-height: none;
  }

  .seat-board,
  .identity-list,
  .speech-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-card {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  .top-actions,
  .control-strip,
  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .primary-btn,
  .ghost-btn,
  .icon-btn,
  .tab {
    width: 100%;
  }

  .seat-board,
  .identity-list,
  .speech-list,
  .role-summary {
    grid-template-columns: 1fr;
  }

  .speaker-now,
  .speech-empty {
    grid-template-columns: 1fr;
  }

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

  .field-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  label {
    line-height: 1.2;
  }
}
