:root {
  --bg: #0b0b12;
  --panel: #16161f;
  --panel-2: #1e1e2a;
  --line: #2a2a38;
  --text: #f6f6f8;
  --muted: #8d8d9e;
  --red: #ff2d4b;
  --red-dark: #4a1420;
  --green: #16d47b;
  --amber: #ffb020;
  --blue: #4d8dff;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  touch-action: manipulation;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

input,
textarea {
  font: inherit;
  color: inherit;
  color-scheme: dark;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------------ player */

.player-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.link-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.link-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.link-status[data-state='online']::before {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.link-status[data-state='offline']::before {
  background: var(--amber);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    opacity: 0.2;
  }
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding-bottom: 24px;
}

.panel h1 {
  font-size: clamp(28px, 9vw, 40px);
}

.panel p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.field {
  display: block;
  width: 100%;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  caret-color: var(--amber);
  font-size: 20px;
  outline: none;
  transition: border-color 0.15s;
}

.field::placeholder {
  color: var(--muted);
  opacity: 1;
}

.field:focus {
  border-color: var(--blue);
}

.field.code {
  font-size: clamp(34px, 13vw, 52px);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 60px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--blue);
  font-size: 18px;
  font-weight: 700;
  transition: transform 0.08s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.985);
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn.ghost {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.error {
  min-height: 20px;
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
}

/* buzzer */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
}

.stage-head {
  text-align: center;
}

.stage-head .who {
  font-size: 22px;
  font-weight: 700;
}

.stage-head .status {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.buzzer {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 45vh;
  border-radius: 28px;
  font-size: clamp(30px, 11vw, 54px);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: background 0.12s, transform 0.08s, box-shadow 0.2s;
}

.buzzer #buzzer-label {
  font-weight: 900;
  line-height: 1;
}

.buzzer .sub {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  opacity: 0.75;
}

.buzzer[data-state='idle'] {
  background: var(--panel-2);
  border: 2px solid var(--line);
  color: var(--muted);
}

.buzzer[data-state='armed'] {
  background: linear-gradient(180deg, #ff3b57, #d80f2c);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 45, 75, 0.18), 0 18px 50px -18px rgba(255, 45, 75, 0.8);
  animation: ready 1.4s ease-in-out infinite;
  font-size: clamp(52px, 18vw, 92px);
  gap: 12px;
}

.buzzer[data-state='armed'] .sub {
  font-size: clamp(18px, 5.5vw, 32px);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 1;
}

.buzzer[data-state='armed']:active {
  transform: scale(0.97);
  animation: none;
}

@keyframes ready {
  50% {
    box-shadow: 0 0 0 12px rgba(255, 45, 75, 0.1), 0 18px 50px -18px rgba(255, 45, 75, 0.9);
  }
}

.buzzer[data-state='won'] {
  background: linear-gradient(180deg, #1ce88a, #0fa860);
  color: #04231a;
  box-shadow: 0 0 0 4px rgba(22, 212, 123, 0.2), 0 18px 50px -18px rgba(22, 212, 123, 0.9);
  animation: pop 0.4s ease-out;
}

@keyframes pop {
  0% {
    transform: scale(0.9);
  }
  60% {
    transform: scale(1.03);
  }
}

.buzzer[data-state='locked'] {
  background: var(--red-dark);
  color: #ff9aa9;
  border: 2px solid #6b1c2b;
}

.buzzer[data-state='missed'] {
  background: var(--panel-2);
  border: 2px solid var(--line);
  color: var(--muted);
}

.buzzer[data-state='tap'] {
  background: linear-gradient(180deg, #ffb020, #e88900);
  color: #1a1200;
  box-shadow: 0 0 0 4px rgba(255, 176, 32, 0.2), 0 18px 50px -18px rgba(255, 176, 32, 0.85);
  user-select: none;
}

.buzzer[data-state='tap']:active,
.buzzer.tap-pulse {
  transform: scale(0.96);
}

.buzzer[data-state='roulette-spin'] {
  color: #fff;
  border: 2px solid transparent;
  /* One colour change per second (~0.5 full cycles/sec) — under the 3/sec limit */
  animation: roulette-rg-pulse 2s ease-in-out infinite;
}

.buzzer[data-state='roulette-out'] {
  background: linear-gradient(180deg, #6b1c2b, #4a1420);
  border: 2px solid #6b1c2b;
  color: #ff9aa9;
}

@keyframes roulette-rg-pulse {
  0%,
  40% {
    background: linear-gradient(180deg, #ff3b57, #d80f2c);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(255, 45, 75, 0.2);
  }
  50%,
  90% {
    background: linear-gradient(180deg, #1ce88a, #0fa860);
    color: #04231a;
    box-shadow: 0 0 0 4px rgba(22, 212, 123, 0.2);
  }
  100% {
    background: linear-gradient(180deg, #ff3b57, #d80f2c);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(255, 45, 75, 0.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .buzzer[data-state='roulette-spin'] {
    animation: none;
    background: linear-gradient(180deg, #3a3348, #241f30);
    color: #f2e9ff;
    border-color: rgba(255, 176, 32, 0.45);
    box-shadow: 0 0 0 4px rgba(255, 176, 32, 0.2);
  }

  .host-main[data-state='roulette'] .host-state,
  .host-main[data-state='roulette'] .host-winner {
    animation: none;
  }
}

.tap-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tap-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  text-align: center;
}

.tap-stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.tap-stat-value {
  font-size: 28px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.shake {
  animation: shake 0.3s;
}

@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* --------------------------------------------------------------- big screen */

.host {
  display: grid;
  grid-template-rows: auto 1fr;
  /* minmax(0, 1fr) rather than the default auto: a long winner name has a huge
     max-content width and would otherwise stretch the page past the viewport,
     shoving the join code off the right-hand edge of the projector. */
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  min-height: 100dvh;
  padding: 32px 40px 40px;
  overflow: hidden;
  position: relative;
  background: radial-gradient(120% 90% at 50% 0%, #1b1b2c 0%, var(--bg) 60%);
}

/* Standby: free the full stage for a huge QR; float the join code over it. */
.host:has(.host-main[data-state='idle']) {
  grid-template-rows: 1fr;
  gap: 0;
  padding: 12px;
}

.host:has(.host-main[data-state='idle']) .host-top {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
}

.host:has(.host-main[data-state='idle']) .host-main {
  grid-row: 1;
}

.host-top {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 32px;
  min-width: 0;
}

.host-headline {
  min-width: 0;
}

.host-title {
  font-size: clamp(24px, 2.4vw, 40px);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.host-title span {
  color: var(--red);
}

.host-count {
  margin-top: 6px;
  font-size: clamp(14px, 1.2vw, 20px);
  font-weight: 700;
  color: var(--muted);
}

.host-join {
  flex: none;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(22, 22, 31, 0.8);
}

.host-join .label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.host-join .code {
  margin-top: 4px;
  font-size: clamp(46px, 5.4vw, 92px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.1em;
  /* Balance the trailing letter-space so the digits stay optically centred. */
  text-indent: 0.1em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.host-main,
.host-tap,
.host-vote {
  grid-row: 2;
}

.host-main {
  display: grid;
  place-items: center;
  text-align: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(22, 22, 31, 0.55);
  padding: 40px;
}

.host-main[data-state='idle'] {
  place-items: center;
  align-content: center;
  padding: 8px 12px;
  border: none;
  background: transparent;
}

.host-main[data-state='idle'] .host-winner {
  font-size: clamp(22px, 3.2vw, 48px);
  margin-top: 4px;
}

.host-main[data-state='idle'] .host-state {
  font-size: clamp(22px, 3.2vw, 48px);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--text);
}

.host-main > div {
  width: 100%;
  min-width: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.host-state {
  font-size: clamp(18px, 2vw, 30px);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* The size here is the ideal; host.js shrinks it to fit long names. */
.host-winner {
  margin-top: 10px;
  font-size: clamp(56px, 13vw, 220px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.host-main[data-state='armed'] .host-state {
  color: var(--red);
  animation: ready-text 1.2s ease-in-out infinite;
}

@keyframes ready-text {
  50% {
    opacity: 0.45;
  }
}

.host-main[data-state='won'] {
  border-color: rgba(22, 212, 123, 0.5);
  background: rgba(22, 212, 123, 0.08);
}

.host-main[data-state='won'] .host-state {
  color: var(--green);
}

.host-main[data-state='won'] .host-winner {
  animation: pop 0.45s ease-out;
}

.host-main[data-state='roulette'] {
  border-color: rgba(255, 176, 32, 0.45);
  background: rgba(255, 176, 32, 0.06);
}

.host-main[data-state='roulette'] .host-state {
  color: var(--amber);
  animation: ready-text 1.6s ease-in-out infinite;
}

.host-main[data-state='roulette'] .host-winner {
  color: var(--amber);
  animation: roulette-pulse 2s ease-in-out infinite alternate;
}

@keyframes roulette-pulse {
  from {
    opacity: 0.7;
    transform: scale(0.99);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.host-order {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  justify-content: center;
  font-size: clamp(13px, 1.1vw, 19px);
  color: var(--muted);
}

.host-order b {
  color: var(--text);
}

.host-join-cta {
  display: block;
  margin-top: 2px;
  font-size: clamp(16px, 2.2vw, 32px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
}

.host-join-cta b {
  display: inline-block;
  margin-top: 0.06em;
  font-size: 1em;
  font-weight: 900;
  color: var(--amber);
}

.host-join-standby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

.host-cta-qr {
  display: block;
  width: min(2560px, calc(100dvh - 110px), calc(100dvw - 24px));
  height: min(2560px, calc(100dvh - 110px), calc(100dvw - 24px));
  flex: 0 0 auto;
  padding: 28px;
  box-sizing: border-box;
  border-radius: 28px;
  background: #fff;
  object-fit: contain;
}

/* tap race leaderboard on the projector */

.host-tap {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(22, 22, 31, 0.55);
  padding: 28px 32px 24px;
}

.host-tap[data-state='live'] {
  border-color: rgba(255, 176, 32, 0.45);
}

.host-tap[data-state='finished'] {
  border-color: rgba(22, 212, 123, 0.5);
  background: rgba(22, 212, 123, 0.08);
}

.tap-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.tap-headline {
  margin-top: 4px;
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 900;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.tap-clock {
  flex: none;
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.host-tap[data-state='finished'] .tap-clock {
  color: var(--green);
}

.tap-board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 28px;
  overflow: hidden;
}

.tap-empty {
  grid-column: 1 / -1;
  padding: 40px 12px;
  text-align: center;
  color: var(--muted);
  font-size: clamp(16px, 1.6vw, 24px);
}

.tap-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(11, 11, 18, 0.55);
  font-size: clamp(15px, 1.4vw, 24px);
  transition: background 0.15s, transform 0.15s;
}

.tap-row.lead {
  background: rgba(255, 176, 32, 0.16);
  border: 1px solid rgba(255, 176, 32, 0.35);
}

.host-tap[data-state='finished'] .tap-row.lead {
  background: rgba(22, 212, 123, 0.16);
  border-color: rgba(22, 212, 123, 0.4);
}

.tap-place {
  font-weight: 900;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tap-row.lead .tap-place {
  color: var(--amber);
}

.host-tap[data-state='finished'] .tap-row.lead .tap-place {
  color: var(--green);
}

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

.tap-score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.host-tap[data-state='finished'] .tap-score {
  color: var(--text);
}

@media (max-width: 900px) {
  .tap-board {
    grid-template-columns: 1fr;
  }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 24px;
  background: rgba(11, 11, 18, 0.96);
  text-align: center;
}

.overlay .inner {
  display: grid;
  gap: 18px;
  max-width: 420px;
}

/* -------------------------------------------------------------------- admin */

.admin {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.admin-head h1 {
  font-size: 22px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 700;
}

.pill b {
  font-variant-numeric: tabular-nums;
}

.pill[data-state='armed'] {
  border-color: var(--red);
  color: var(--red);
}

.pill[data-state='won'] {
  border-color: var(--green);
  color: var(--green);
}

.card {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.card h2 {
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.controls .btn {
  min-height: 76px;
  flex-direction: column;
  gap: 4px;
}

.controls .btn small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}

.btn.arm {
  background: linear-gradient(180deg, #ff3b57, #d80f2c);
}

.btn.stop {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.btn.danger {
  background: transparent;
  border: 1px solid #6b1c2b;
  color: #ff9aa9;
}

.btn.small {
  min-height: 36px;
  width: auto;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.order-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.order-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 15px;
}

.order-row .place {
  font-weight: 900;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.order-row.first {
  background: rgba(22, 212, 123, 0.12);
  border: 1px solid rgba(22, 212, 123, 0.35);
}

.order-row.first .place {
  color: var(--green);
}

.order-row .gap {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.roster {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
}

.roster-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
}

.roster-row .name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.roster-row[data-connected='false'] .dot {
  background: var(--amber);
}

.roster-row[data-connected='false'] .name {
  color: var(--muted);
}

.roster-row[data-locked='true'] {
  border: 1px solid #6b1c2b;
}

.tag {
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 45, 75, 0.14);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ff9aa9;
}

.search {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  caret-color: var(--amber);
  font-size: 15px;
  outline: none;
}

.search::placeholder {
  color: var(--muted);
  opacity: 1;
}

.vote-textarea {
  resize: vertical;
  min-height: 96px;
  font-family: inherit;
  line-height: 1.4;
  color: var(--text);
  caret-color: var(--amber);
}

.gate {
  max-width: 380px;
  margin: 18vh auto;
  display: grid;
  gap: 14px;
  text-align: center;
}

/* --------------------------------------------------------------- voting */

.vote-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.vote-question {
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.vote-options {
  display: grid;
  gap: 10px;
}

.vote-option {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  text-align: left;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}

.vote-option:active:not(:disabled) {
  transform: scale(0.985);
}

.vote-option.selected {
  border-color: var(--blue);
  background: rgba(77, 141, 255, 0.14);
}

.vote-option:disabled {
  opacity: 0.7;
}

.vote-letter {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--panel-2);
  font-weight: 900;
  color: var(--amber);
}

.vote-option.selected .vote-letter {
  background: var(--blue);
  color: #fff;
}

.vote-label {
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.vote-hint {
  text-align: center;
  font-size: 13px;
  min-height: 18px;
}

.field-label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.vote-live-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.vote-live-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.host-vote {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(22, 22, 31, 0.55);
  padding: 28px 32px 28px;
}

.host-vote[data-state='open'] {
  border-color: rgba(77, 141, 255, 0.45);
}

.host-vote[data-state='revealed'] {
  border-color: rgba(22, 212, 123, 0.5);
  background: rgba(22, 212, 123, 0.06);
}

.vote-host-question {
  margin-top: 6px;
  font-size: clamp(28px, 4.2vw, 56px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.vote-host-meta {
  margin-top: 8px;
  font-size: clamp(14px, 1.3vw, 20px);
  font-weight: 700;
  color: var(--muted);
}

.vote-bars {
  display: grid;
  gap: 14px;
  min-height: 0;
}

.vote-bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 28%) 1fr auto;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.vote-bar-label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: clamp(16px, 1.6vw, 26px);
  font-weight: 700;
}

.vote-bar-label > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vote-bar-letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--panel-2);
  font-weight: 900;
  color: var(--amber);
}

.vote-bar-track {
  height: clamp(18px, 2.2vw, 28px);
  border-radius: 999px;
  background: rgba(11, 11, 18, 0.7);
  overflow: hidden;
}

.vote-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #4d8dff, #7aa7ff);
  transition: width 0.35s ease-out;
}

.vote-bar-row.lead .vote-bar-fill {
  background: linear-gradient(90deg, #16d47b, #5aefab);
}

.vote-bar-row.lead .vote-bar-letter {
  background: rgba(22, 212, 123, 0.2);
  color: var(--green);
}

.vote-bar-count {
  min-width: 7ch;
  text-align: right;
  font-size: clamp(14px, 1.4vw, 22px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.vote-bar-row.lead .vote-bar-count {
  color: var(--green);
}

@media (max-width: 800px) {
  .vote-bar-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .vote-bar-track {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------- 512×384 pixel */

/*
  Ultra-compact host layout for LED / pixel panels.
  Force with ?pixel on the host URL, or it auto-enables under 520×400.
*/
body.host-pixel {
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background: #000;
}

body.host-pixel .overlay .inner {
  max-width: 90vw;
  gap: 10px;
  padding: 8px;
}

body.host-pixel .overlay h1 {
  font-size: 22px;
}

body.host-pixel .overlay p {
  font-size: 11px;
  line-height: 1.3;
}

body.host-pixel .overlay .btn {
  min-height: 36px;
  font-size: 14px;
  padding: 8px;
}

body.host-pixel .host {
  gap: 4px;
  padding: 4px;
  min-height: 100vh;
  height: 100vh;
  background: #0b0b12;
}

body.host-pixel .host-top {
  gap: 6px;
  align-items: center;
}

body.host-pixel .host-title {
  font-size: 11px;
  letter-spacing: 0;
}

body.host-pixel .host-count {
  margin-top: 0;
  font-size: 9px;
}

/* Code is the only join affordance that fits — QR is useless at this size. */
body.host-pixel .host-join {
  gap: 0;
  padding: 2px 6px;
  border-radius: 6px;
}

body.host-pixel .host-join .label {
  display: none;
}

body.host-pixel .host-join .code {
  font-size: 28px;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
}

body.host-pixel .host-cta-qr {
  width: 220px;
  height: 220px;
  padding: 8px;
  border-radius: 8px;
}

body.host-pixel .host-main,
body.host-pixel .host-tap,
body.host-pixel .host-vote {
  border-radius: 8px;
  padding: 6px 8px;
  gap: 4px;
}

body.host-pixel .host-main {
  padding: 4px 6px;
}

body.host-pixel .host-state {
  font-size: 9px;
  letter-spacing: 0.12em;
}

body.host-pixel .host-main[data-state='idle'] .host-state {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--text);
}

body.host-pixel .host-main[data-state='idle'] .host-winner {
  font-size: 22px;
}

body.host-pixel .host-winner {
  margin-top: 2px;
  font-size: 42px;
  letter-spacing: -0.02em;
}

/* Armed: fill the pixel panel with huge Buzz / Buzzers are live */
body.host-pixel .host-main[data-state='armed'] {
  padding: 8px;
}

body.host-pixel .host-main[data-state='armed'] .host-state {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--red);
}

body.host-pixel .host-main[data-state='armed'] .host-winner {
  margin-top: 4px;
  font-size: 140px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.88;
}

body.host-pixel .host-main[data-state='armed'] .host-order,
body.host-pixel .host-main[data-state='armed'] .host-join-standby {
  display: none;
}

/* Won: readable “Buzzed in first” + large winner name */
body.host-pixel .host-main[data-state='won'] {
  padding: 8px;
}

body.host-pixel .host-main[data-state='won'] .host-state {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green);
}

body.host-pixel .host-main[data-state='won'] .host-winner {
  margin-top: 4px;
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

body.host-pixel .host-main[data-state='won'] .host-join-standby {
  display: none;
}

/* Roulette: Choosing… / ??? / Ready? readable on 512×384 */
body.host-pixel .host-main[data-state='roulette'] {
  padding: 8px;
}

body.host-pixel .host-main[data-state='roulette'] .host-state {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber);
}

body.host-pixel .host-main[data-state='roulette'] .host-winner {
  margin-top: 4px;
  font-size: 120px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

body.host-pixel .host-main[data-state='roulette'] .host-order {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

body.host-pixel .host-main[data-state='roulette'] .host-join-standby {
  display: none;
}

body.host-pixel .host-order {
  margin-top: 2px;
  gap: 4px 8px;
  font-size: 9px;
}

body.host-pixel .host-join-cta {
  margin-top: 2px;
  font-size: 42px;
  letter-spacing: -0.02em;
}

body.host-pixel .host-join-cta b {
  margin-top: 0.08em;
  font-size: 1em;
}

/* Tap race on the pixel panel: top 10, as large as 512×384 allows. */
body.host-pixel:has(.host-tap:not(.hidden)) .host-top {
  display: none;
}

body.host-pixel:has(.host-tap:not(.hidden)) .host {
  gap: 0;
  padding: 2px;
}

body.host-pixel .host-tap {
  gap: 4px;
  padding: 4px 6px;
}

body.host-pixel .tap-head {
  gap: 8px;
  align-items: center;
}

body.host-pixel .tap-head .host-state {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--text);
}

body.host-pixel .tap-headline {
  margin-top: 2px;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

body.host-pixel .tap-clock {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

body.host-pixel .tap-board {
  flex: 1;
  min-height: 0;
  gap: 3px;
  grid-template-columns: 1fr;
  align-content: stretch;
}

body.host-pixel .tap-empty {
  padding: 12px 6px;
  font-size: 18px;
  font-weight: 700;
}

body.host-pixel .tap-row {
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 26px;
  line-height: 1.05;
}

body.host-pixel .tap-place {
  font-size: 28px;
  font-weight: 900;
}

body.host-pixel .tap-name {
  font-size: 28px;
  font-weight: 900;
}

body.host-pixel .tap-score {
  font-size: 26px;
  font-weight: 900;
  min-width: 2.2ch;
  text-align: right;
}

/* Vote on the pixel panel: full stage, centred, large type for 512×384. */
body.host-pixel[data-host-mode='vote'] .host-top {
  display: none !important;
}

body.host-pixel[data-host-mode='vote'] .host {
  grid-template-rows: 1fr;
  gap: 0;
  padding: 2px;
  height: 100vh;
  min-height: 100vh;
}

body.host-pixel[data-host-mode='vote'] .host-vote {
  grid-row: 1;
  align-self: stretch;
  justify-self: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  text-align: center;
  box-sizing: border-box;
}

body.host-pixel .vote-host-head {
  width: 100%;
  text-align: center;
  flex: none;
}

body.host-pixel .vote-host-head .host-state {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--text);
}

body.host-pixel .vote-host-question {
  margin-top: 4px;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.host-pixel .vote-host-meta {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 800;
  color: var(--amber);
}

body.host-pixel .vote-bars {
  width: 100%;
  gap: 8px;
  flex: none;
  align-content: center;
}

body.host-pixel .vote-bar-row {
  grid-template-columns: minmax(110px, 38%) 1fr auto;
  gap: 8px;
}

body.host-pixel .vote-bar-label {
  gap: 6px;
  font-size: 20px;
  font-weight: 900;
  text-align: left;
}

body.host-pixel .vote-bar-letter {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 900;
}

body.host-pixel .vote-bar-track {
  height: 22px;
  border-radius: 8px;
}

body.host-pixel .vote-bar-count {
  min-width: 6ch;
  font-size: 18px;
  font-weight: 900;
  text-align: right;
}
