:root {
  --paper: #f8faf7;
  --ink: #1e2528;
  --muted: #627071;
  --line: #d7dfdc;
  --surface: #ffffff;
  --affirm: #0f766e;
  --affirm-soft: #dff3ef;
  --negative: #b4232c;
  --negative-soft: #f9e1e3;
  --neutral: #314b5f;
  --gold: #c57f10;
  --shadow: 0 18px 42px rgba(29, 40, 43, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(140deg, rgba(15, 118, 110, 0.09), transparent 34%),
    linear-gradient(28deg, rgba(180, 35, 44, 0.08), transparent 42%),
    var(--paper);
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #aab9b5;
}

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

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3rem, 3rem);
  line-height: 1.06;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

h3 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.match-badge {
  flex: 0 1 auto;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--neutral);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.68);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, 0.88fr);
  gap: 20px;
  align-items: start;
}

.timer-surface,
.timeline-surface,
.vote-surface {
  border: 1px solid rgba(215, 223, 220, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.timer-surface {
  position: sticky;
  top: 18px;
  overflow: hidden;
  min-height: 680px;
  padding: 26px;
}

.stage-visual {
  position: relative;
  height: 188px;
  margin: -26px -26px 24px;
  border-bottom: 1px solid var(--line);
  background: #263a45;
}

.stage-visual canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.current-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.team-pill,
.phase-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
}

.team-pill.affirm {
  color: #07534d;
  background: var(--affirm-soft);
}

.team-pill.negative {
  color: #842028;
  background: var(--negative-soft);
}

.team-pill.neutral {
  color: #213c50;
  background: #dfeaf0;
}

.phase-pill {
  color: var(--neutral);
  background: #edf1f2;
}

#currentTitle {
  margin-bottom: 10px;
  font-size: 2.15rem;
  line-height: 1.16;
}

.speaker-line {
  margin-bottom: 22px;
  color: var(--muted);
  font-weight: 700;
}

.timer-readout {
  width: 100%;
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: clamp(5.8rem, 8rem, 8rem);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff, #edf5f3);
}

.timer-readout.warning {
  color: var(--gold);
  background: linear-gradient(180deg, #ffffff, #fff7e9);
}

.timer-readout.done {
  color: var(--negative);
  background: linear-gradient(180deg, #ffffff, #fae8ea);
}

.progress-track {
  height: 14px;
  margin: 18px 0 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e8eeec;
}

.progress-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--affirm), #2d6f99, var(--negative));
  transition: width 0.2s ease;
}

.timer-controls {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.timer-controls button {
  padding: 0 8px;
  font-weight: 850;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

button.primary {
  border-color: #0e625c;
  color: #ffffff;
  background: var(--affirm);
}

.clash-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.clash-board[hidden] {
  display: none;
}

.clash-card {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.clash-card span {
  color: var(--muted);
  font-weight: 800;
}

.clash-card strong {
  font-size: 2.35rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.clash-card.active {
  border-color: var(--neutral);
  box-shadow: inset 0 0 0 2px rgba(49, 75, 95, 0.18);
}

.clash-card.affirm.active {
  background: var(--affirm-soft);
}

.clash-card.negative.active {
  background: var(--negative-soft);
}

.surprise-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.surprise-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 0 14px;
  font-weight: 900;
}

.surprise-button span {
  flex: 0 0 auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.surprise-button.affirm {
  border-color: rgba(15, 118, 110, 0.36);
  background: var(--affirm-soft);
}

.surprise-button.negative {
  border-color: rgba(180, 35, 44, 0.32);
  background: var(--negative-soft);
}

.side-rail {
  display: grid;
  gap: 20px;
}

.timeline-surface,
.vote-surface {
  padding: 18px;
}

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

.ghost {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.timeline {
  display: grid;
  gap: 8px;
  max-height: 430px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.timeline-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 60px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.timeline-item.active {
  border-color: #617f8f;
  box-shadow: inset 4px 0 0 var(--neutral);
}

.timeline-item.done {
  color: #637270;
  background: #f2f5f4;
}

.timeline-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 900;
  background: var(--neutral);
}

.timeline-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.timeline-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
}

.timeline-time {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--neutral);
  font-weight: 800;
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--affirm);
}

.live-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--neutral);
  font-size: 0.88rem;
  font-weight: 850;
  background: #f5f8f7;
}

.live-status.connected {
  border-color: rgba(15, 118, 110, 0.28);
  color: #07534d;
  background: var(--affirm-soft);
}

.live-status.error {
  border-color: rgba(180, 35, 44, 0.28);
  color: #842028;
  background: var(--negative-soft);
}

.vote-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.vote-match {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.vote-match.second {
  display: none;
}

.vote-match.second.enabled {
  display: block;
}

.vote-match label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.vote-match input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 800;
  background: #f9fbfa;
}

.margin-line,
.result-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.margin-line {
  min-height: 38px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.margin-line strong,
.result-box strong {
  font-variant-numeric: tabular-nums;
}

.result-box {
  min-height: 70px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #bfd0cb;
  border-radius: 8px;
  background: #edf6f3;
  font-weight: 900;
}

.result-box b {
  color: var(--affirm);
  font-size: 1.28rem;
}

.result-box.negative b {
  color: var(--negative);
}

.result-box.tie b {
  color: var(--neutral);
}

.vote-ledger {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.vote-ledger-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.vote-ledger-actions button,
.hidden-final-button {
  padding: 0 12px;
  font-weight: 900;
}

.vote-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.vote-stat-grid div {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.vote-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.vote-stat-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ledger-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ledger-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: #ffffff;
}

.ledger-table th,
.ledger-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.86rem;
  white-space: nowrap;
}

.ledger-table th {
  color: var(--neutral);
  font-weight: 900;
  background: #edf1f2;
}

.ledger-table td {
  color: var(--ink);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.ledger-table tr:last-child td {
  border-bottom: 0;
}

.hidden-final-button {
  border-color: rgba(197, 127, 16, 0.42);
  color: #6f4709;
  background: #fff4dc;
}

.final-result {
  padding: 14px;
  border: 1px solid #bfd0cb;
  border-radius: 8px;
  background: #edf6f3;
  font-weight: 850;
  line-height: 1.55;
}

.final-result.negative {
  border-color: rgba(180, 35, 44, 0.24);
  background: var(--negative-soft);
}

.final-result.tie {
  background: #edf1f2;
}

.live-vote-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.live-vote-box h3 {
  margin-bottom: 4px;
}

.live-vote-box p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.live-vote-box a {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--affirm);
  font-weight: 850;
}

.live-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.danger {
  color: var(--negative);
}

@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .timer-surface {
    position: static;
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 2rem;
  }

  #currentTitle {
    font-size: 1.55rem;
  }

  .timer-readout {
    min-height: 148px;
    font-size: 4.8rem;
  }

  .timer-controls,
  .surprise-row,
  .clash-board,
  .live-actions,
  .vote-ledger-actions,
  .vote-stat-grid,
  .vote-grid {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .timeline-time {
    grid-column: 2;
  }
}
