:root {
  --ink: #201b18;
  --paper: #f6efe3;
  --panel: #fffaf0;
  --line: #d6c8b5;
  --muted: #73675d;
  --wine: #7f2d3b;
  --green: #2f6d5b;
  --blue: #3f6385;
  --gold: #c9893a;
  --model-qwen: #2f6d5b;
  --model-llama: #3f6385;
  --model-gemma: #c9893a;
  --model-fixture: #7f2d3b;
  --model-other: #73675d;
  --shadow: rgba(45, 30, 18, .18);
  font-family: Inter, ui-sans-serif, system-ui, Segoe UI, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #211b17;
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

button,
select {
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

.viewer-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(47, 109, 91, .08), transparent 38%),
    var(--paper);
}

.show-header,
.phase-strip,
.scene-grid,
.playback-rail {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.show-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, .86);
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1.05;
}

h2 {
  color: var(--ink);
  font-size: 1rem;
}

.night-summary {
  margin-top: 5px;
  max-width: 620px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.35;
  font-weight: 720;
}

.transcript-source {
  margin-top: 7px;
  color: var(--green);
  font-size: .72rem;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.viewer-controls {
  display: flex;
  align-items: end;
  gap: 10px;
}

.viewer-controls button {
  min-width: 80px;
  height: 40px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fffaf0;
  font-weight: 900;
  cursor: pointer;
}

.viewer-controls button:hover,
.viewer-controls button:focus-visible {
  background: var(--wine);
  border-color: var(--wine);
  outline: none;
}

.viewer-controls button:disabled {
  border-color: var(--line);
  background: #d8cbb9;
  color: var(--muted);
  cursor: not-allowed;
}

.viewer-controls label {
  display: grid;
  gap: 5px;
}

.viewer-controls span {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.viewer-controls select {
  min-width: 92px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.model-swap-rail {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, .45fr) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.model-swap-summary,
.model-chip {
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, .82);
}

.model-swap-summary {
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px 12px;
}

.model-swap-summary b,
.model-swap-summary small {
  overflow-wrap: anywhere;
}

.model-swap-summary b {
  color: var(--ink);
  font-size: .95rem;
}

.model-swap-summary small {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.model-chip-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.model-chip {
  min-height: 58px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 8px;
  align-content: center;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.model-chip:hover,
.model-chip:focus-visible {
  outline: 2px solid rgba(32, 27, 24, .24);
  outline-offset: 2px;
  background: #fffdf7;
}

.model-chip.active {
  box-shadow: 0 0 0 2px rgba(32, 27, 24, .13);
  background: #fffdf7;
}

.model-dot {
  grid-row: 1 / span 2;
  width: 12px;
  height: 12px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--model-other);
}

.model-chip b,
.model-chip small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.model-chip b {
  font-size: .86rem;
}

.model-chip small {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-arc {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.game-node {
  min-height: 58px;
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  background: rgba(255, 250, 240, .78);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.game-gap {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 9px 10px;
  border: 1px dashed var(--line);
  background: rgba(255, 250, 240, .48);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.game-node.active {
  border-left-color: var(--wine);
  background: #fffdf7;
  box-shadow: 0 0 0 2px rgba(127, 45, 59, .12);
}

.game-node.complete {
  border-left-color: var(--green);
}

.game-node.model-qwen,
.model-chip.model-qwen {
  border-left-color: var(--model-qwen);
}

.game-node.model-llama,
.model-chip.model-llama {
  border-left-color: var(--model-llama);
}

.game-node.model-gemma,
.model-chip.model-gemma {
  border-left-color: var(--model-gemma);
}

.game-node.model-fixture,
.model-chip.model-fixture {
  border-left-color: var(--model-fixture);
}

.game-node.model-other,
.game-node.model-unknown,
.model-chip.model-other,
.model-chip.model-unknown {
  border-left-color: var(--model-other);
}

.model-chip.model-qwen .model-dot,
.game-model-badge.model-qwen,
.model-badge.model-qwen {
  background: var(--model-qwen);
}

.model-chip.model-llama .model-dot,
.game-model-badge.model-llama,
.model-badge.model-llama {
  background: var(--model-llama);
}

.model-chip.model-gemma .model-dot,
.game-model-badge.model-gemma,
.model-badge.model-gemma {
  background: var(--model-gemma);
}

.model-chip.model-fixture .model-dot,
.game-model-badge.model-fixture,
.model-badge.model-fixture {
  background: var(--model-fixture);
}

.model-chip.model-other .model-dot,
.model-chip.model-unknown .model-dot,
.game-model-badge.model-other,
.game-model-badge.model-unknown,
.model-badge.model-other,
.model-badge.model-unknown {
  background: var(--model-other);
}

.game-node b,
.game-node small {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.game-node small {
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.25;
  font-weight: 760;
}

.game-node .game-provenance {
  color: var(--muted);
  font-weight: 950;
  text-transform: uppercase;
}

.game-node .game-model-badge {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  color: #fffaf0;
  font-size: .66rem;
  line-height: 1.1;
  font-weight: 950;
  text-transform: uppercase;
}

.phase-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.phase-strip span {
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, .72);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.phase-strip span.active {
  border-color: var(--wine);
  background: var(--wine);
  color: #fffaf0;
}

.scene-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, .78fr) minmax(420px, 1.6fr) minmax(280px, .9fr);
  gap: 14px;
}

.cast-panel,
.table-stage,
.confessional,
.playback-rail {
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, .9);
  box-shadow: 0 18px 50px var(--shadow);
}

.cast-panel,
.confessional {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.section-head .eyebrow {
  margin-bottom: 2px;
}

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

.leaderboard-summary {
  min-height: 38px;
  display: grid;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--green);
  font-size: .84rem;
  font-weight: 900;
  line-height: 1.3;
}

.cast-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: #fffdf7;
}

.cast-card.active {
  border-left-color: var(--wine);
  box-shadow: 0 0 0 2px rgba(127, 45, 59, .14);
}

.cast-card.eliminated {
  opacity: .56;
}

.mini-portrait,
.portrait {
  display: grid;
  place-items: center;
  border: 2px solid rgba(32, 27, 24, .18);
  background: var(--avatar-color, var(--blue));
  color: #fffaf0;
  font-weight: 950;
}

.mini-portrait {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.cast-copy {
  min-width: 0;
}

.cast-copy b,
.cast-copy small {
  display: block;
  overflow-wrap: anywhere;
}

.cast-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.25;
}

.standing {
  color: var(--green);
  font-size: .82rem;
  font-weight: 950;
  white-space: nowrap;
}

.table-stage {
  display: grid;
  grid-template-rows: minmax(420px, 1fr) auto;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
}

.table-wrap {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 250, 240, .75), rgba(242, 226, 202, .8)),
    #efe0ca;
}

.table-surface {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(58%, 460px);
  aspect-ratio: 1.7;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 16px solid #6c4330;
  border-radius: 50%;
  background: #8d5b3f;
  box-shadow: inset 0 0 0 2px rgba(255, 250, 240, .18), 0 28px 58px rgba(70, 42, 22, .22);
}

.table-surface span {
  color: rgba(255, 250, 240, .78);
  font-size: 1rem;
  font-weight: 950;
  text-transform: uppercase;
}

.seat-map {
  position: absolute;
  inset: 0;
}

.seat {
  position: absolute;
  width: 118px;
  min-height: 118px;
  display: grid;
  justify-items: center;
  gap: 5px;
  transform: translate(-50%, -50%);
  text-align: center;
}

.seat .mini-portrait {
  width: 58px;
  height: 58px;
  font-size: 1rem;
}

.seat b {
  display: block;
  max-width: 118px;
  color: var(--ink);
  font-size: .86rem;
  overflow-wrap: anywhere;
}

.seat small {
  display: inline-flex;
  max-width: 118px;
  min-height: 24px;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: .67rem;
  font-weight: 900;
  text-transform: uppercase;
}

.seat.active .mini-portrait {
  border-color: var(--wine);
  box-shadow: 0 0 0 5px rgba(127, 45, 59, .18);
}

.seat.eliminated {
  opacity: .5;
}

.public-beat {
  min-height: 160px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fffdf7;
}

.beat-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.beat-meta span,
.role-chip {
  width: max-content;
  max-width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: #f2e7d7;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.model-badge {
  color: #fffaf0;
}

#speaker-name {
  font-size: 1.45rem;
}

#public-text {
  color: #2d2621;
  font-size: 1.18rem;
  line-height: 1.45;
  font-weight: 760;
}

.confessional {
  position: relative;
  border-color: #57313a;
  background: #241d1d;
  color: #fffaf0;
  overflow: hidden;
}

.confessional::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--wine), var(--gold), var(--green));
}

.confessional .section-head {
  border-color: rgba(255, 250, 240, .16);
}

.confessional .eyebrow,
.confessional h2,
.confessional p {
  color: #fffaf0;
}

.portrait {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  margin: 4px auto 2px;
  font-size: 2.25rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .26);
}

.confessional .role-chip {
  justify-self: center;
  border-color: rgba(255, 250, 240, .18);
  background: rgba(255, 250, 240, .08);
  color: #f6d78f;
}

#confessional-text {
  min-height: 130px;
  color: #f8ebd8;
  font-size: 1.06rem;
  line-height: 1.48;
  font-weight: 720;
}

.opponent-notes {
  display: grid;
  gap: 8px;
}

.note-row {
  display: grid;
  gap: 4px;
  padding: 9px;
  border-left: 3px solid var(--gold);
  background: rgba(255, 250, 240, .08);
}

.note-row b {
  color: #fffaf0;
  font-size: .84rem;
}

.note-signal {
  width: max-content;
  max-width: 100%;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid rgba(255, 250, 240, .16);
  background: rgba(255, 250, 240, .1);
  color: #f6d78f;
  font-size: .68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.note-row small {
  color: #d8c8b7;
  line-height: 1.35;
}

.evolution-panel {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.section-head.compact {
  padding-bottom: 7px;
}

.read-evolution {
  display: grid;
  gap: 8px;
}

.evolution-row {
  min-height: 62px;
  display: grid;
  gap: 5px;
  padding: 9px;
  border: 1px solid rgba(255, 250, 240, .12);
  border-left: 3px solid var(--green);
  background: rgba(255, 250, 240, .06);
}

.evolution-row b,
.evolution-row small {
  color: #fffaf0;
  overflow-wrap: anywhere;
}

.evolution-row small {
  color: #d8c8b7;
  line-height: 1.35;
}

.playback-rail {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(190px, auto) minmax(180px, 1fr) minmax(240px, .7fr);
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.playback-rail > div:first-child {
  display: grid;
  gap: 3px;
}

#beat-counter,
#game-label {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 900;
  text-transform: uppercase;
}

#game-outcome {
  color: var(--ink);
  overflow-wrap: anywhere;
}

#beat-scrubber {
  width: 100%;
  accent-color: var(--wine);
}

.vote-receipt {
  min-width: 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: anywhere;
}

@media (max-width: 1080px) {
  .scene-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-stage {
    grid-row: 1;
  }

  .cast-panel,
  .confessional {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  .viewer-shell {
    padding: 10px;
    gap: 10px;
  }

  .show-header,
  .viewer-controls,
  .playback-rail {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .viewer-controls {
    width: 100%;
  }

  .viewer-controls button,
  .viewer-controls label,
  .viewer-controls select {
    width: 100%;
  }

  .game-arc {
    grid-template-columns: 1fr;
  }

  .model-swap-rail {
    grid-template-columns: 1fr;
  }

  .phase-strip {
    grid-template-columns: 1fr;
  }

  .table-stage {
    grid-template-rows: minmax(360px, auto) auto;
  }

  .table-wrap {
    min-height: 360px;
  }

  .table-surface {
    width: 56%;
    border-width: 10px;
  }

  .seat {
    width: 96px;
    min-height: 100px;
  }

  .seat .mini-portrait {
    width: 48px;
    height: 48px;
  }

  #public-text,
  #confessional-text {
    font-size: 1rem;
  }

  .vote-receipt {
    text-align: left;
  }
}

/* Research findings panel ------------------------------------------------- */
.research-findings {
  margin: 0 0 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px var(--shadow);
}
.research-summary {
  cursor: pointer;
  list-style: none;
}
.research-summary::-webkit-details-marker { display: none; }
.research-summary h2 {
  margin: .15rem 0 .35rem;
  font-size: 1.4rem;
  color: var(--ink);
}
.research-verdict {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--green);
}
.research-body { margin-top: .9rem; }
.research-subtitle {
  margin: 0 0 .9rem;
  color: var(--muted);
  max-width: 64ch;
  line-height: 1.5;
}
.research-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1rem;
}
.research-metric {
  display: flex;
  flex-direction: column;
  padding: .55rem .8rem;
  background: rgba(47, 109, 91, .08);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 140px;
}
.research-metric-value { font-size: 1.3rem; color: var(--ink); }
.research-metric-label { font-size: .75rem; color: var(--muted); }
.research-chart-head { margin-bottom: .4rem; }
.research-chart { display: flex; flex-direction: column; gap: .4rem; }
.research-row {
  display: grid;
  grid-template-columns: 8rem 1fr 5rem;
  align-items: center;
  gap: .6rem;
}
.research-row-name { font-weight: 600; color: var(--ink); font-size: .9rem; }
.research-bars { display: flex; flex-direction: column; gap: .25rem; }
.research-bar-wrap { display: flex; align-items: center; gap: .5rem; }
.research-bar {
  height: 12px;
  border-radius: 6px;
  min-width: 2px;
}
.research-bar.is-qwen { background: var(--model-qwen); }
.research-bar.is-llama { background: var(--model-llama); }
.research-bar-tag { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.research-row-gap { font-size: .8rem; color: var(--muted); text-align: right; }
.research-caveats {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}
.research-caveats li { margin-bottom: .35rem; }
@media (max-width: 640px) {
  .research-row { grid-template-columns: 1fr; }
  .research-row-gap { text-align: left; }
}
