/* Show of Hands: shared styles for the audience page, the control room and the screen.
   The look follows amirmousavi.com: zinc neutrals, a teal accent, the system sans stack, and
   content on a white column over a zinc-50 page (zinc-900 over black in dark). */

/* ---------- tokens ---------- */

:root {
  --bg: #fafafa; /* zinc-50: the page either side of the column */
  --page: #ffffff; /* the column itself */
  --surface: #ffffff;
  --surface-2: #f4f4f5; /* zinc-100 */
  --hover: #fafafa; /* zinc-50 */
  --ink: #27272a; /* zinc-800 */
  --muted: #52525b; /* zinc-600 */
  --faint: #71717a; /* zinc-500 */
  --line: #f4f4f5; /* zinc-100: panels and dividers */
  --field: #e4e4e7; /* zinc-200: things you tap or type in */
  --field-hover: #d4d4d8; /* zinc-300 */
  --frame-ring: #f4f4f5; /* zinc-100 */
  --track: #f4f4f5;
  --accent: #0d9488; /* teal-600: bars, borders, focus */
  --accent-bright: #14b8a6; /* teal-500: the site's link and eyebrow teal */
  --accent-ink: #0f766e; /* teal-700: teal text at small sizes */
  --accent-fill: #0f766e; /* teal-700: under white text */
  --on-accent: #ffffff;
  --accent-soft: #f0fdfa; /* teal-50 */
  --accent-line: rgb(20 184 166 / 0.35);
  --focus-ring: rgb(20 184 166 / 0.1);
  --primary: #27272a; /* zinc-800, the site's primary button */
  --primary-hover: #3f3f46; /* zinc-700 */
  --on-primary: #f4f4f5; /* zinc-100 */
  --good: #15803d; /* green-700 */
  --good-soft: #f0fdf4; /* green-50 */
  --on-good: #ffffff;
  --danger: #dc2626; /* red-600 */
  --danger-soft: #fef2f2; /* red-50 */
  --danger-fill: #dc2626;
  --warn-soft: #fffbeb; /* amber-50 */
  --warn-ink: #92400e; /* amber-800 */
  --input-bg: #ffffff;
  --placeholder: #a1a1aa; /* zinc-400 */
  --float: rgb(255 255 255 / 0.9);
  --float-ring: rgb(24 24 27 / 0.05);
  --scrim: rgb(39 39 42 / 0.4);
  --shadow: 0 10px 15px -3px rgb(39 39 42 / 0.05), 0 4px 6px -4px rgb(39 39 42 / 0.05);
  --shadow-field: 0 4px 6px -1px rgb(39 39 42 / 0.05), 0 2px 4px -2px rgb(39 39 42 / 0.05);
  --radius: 16px;
  --radius-sm: 6px;
  --font: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  --frame: 100%;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000;
    --page: #18181b; /* zinc-900 */
    --surface: #18181b;
    --surface-2: #27272a; /* zinc-800 */
    --hover: rgb(39 39 42 / 0.5);
    --ink: #f4f4f5; /* zinc-100 */
    --muted: #a1a1aa; /* zinc-400 */
    --faint: #8a8a93; /* between zinc-400 and zinc-500, keeps 4.5:1 on zinc-900 */
    --line: rgb(63 63 70 / 0.4); /* zinc-700/40 */
    --field: #3f3f46; /* zinc-700 */
    --field-hover: #52525b; /* zinc-600 */
    --frame-ring: rgb(212 212 216 / 0.2); /* zinc-300/20 */
    --track: #27272a;
    --accent: #2dd4bf; /* teal-400 */
    --accent-bright: #2dd4bf;
    --accent-ink: #2dd4bf;
    --accent-fill: #2dd4bf;
    --on-accent: #18181b;
    --accent-soft: rgb(45 212 191 / 0.1);
    --accent-line: rgb(45 212 191 / 0.3);
    --focus-ring: rgb(45 212 191 / 0.1);
    --primary: #3f3f46; /* zinc-700 */
    --primary-hover: #52525b; /* zinc-600 */
    --on-primary: #f4f4f5;
    --good: #4ade80; /* green-400 */
    --good-soft: rgb(74 222 128 / 0.1);
    --on-good: #18181b;
    --danger: #f87171; /* red-400 */
    --danger-soft: rgb(248 113 113 / 0.1);
    --warn-soft: rgb(251 191 36 / 0.1);
    --warn-ink: #fcd34d; /* amber-300 */
    --input-bg: rgb(63 63 70 / 0.15);
    --placeholder: #71717a;
    --float: rgb(39 39 42 / 0.9); /* zinc-800/90 */
    --float-ring: rgb(255 255 255 / 0.1);
    --scrim: rgb(0 0 0 / 0.8);
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --shadow-field: none;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #000000;
  --page: #18181b; /* zinc-900 */
  --surface: #18181b;
  --surface-2: #27272a; /* zinc-800 */
  --hover: rgb(39 39 42 / 0.5);
  --ink: #f4f4f5; /* zinc-100 */
  --muted: #a1a1aa; /* zinc-400 */
  --faint: #8a8a93; /* between zinc-400 and zinc-500, keeps 4.5:1 on zinc-900 */
  --line: rgb(63 63 70 / 0.4); /* zinc-700/40 */
  --field: #3f3f46; /* zinc-700 */
  --field-hover: #52525b; /* zinc-600 */
  --frame-ring: rgb(212 212 216 / 0.2); /* zinc-300/20 */
  --track: #27272a;
  --accent: #2dd4bf; /* teal-400 */
  --accent-bright: #2dd4bf;
  --accent-ink: #2dd4bf;
  --accent-fill: #2dd4bf;
  --on-accent: #18181b;
  --accent-soft: rgb(45 212 191 / 0.1);
  --accent-line: rgb(45 212 191 / 0.3);
  --focus-ring: rgb(45 212 191 / 0.1);
  --primary: #3f3f46; /* zinc-700 */
  --primary-hover: #52525b; /* zinc-600 */
  --on-primary: #f4f4f5;
  --good: #4ade80; /* green-400 */
  --good-soft: rgb(74 222 128 / 0.1);
  --on-good: #18181b;
  --danger: #f87171; /* red-400 */
  --danger-soft: rgb(248 113 113 / 0.1);
  --warn-soft: rgb(251 191 36 / 0.1);
  --warn-ink: #fcd34d; /* amber-300 */
  --input-bg: rgb(63 63 70 / 0.15);
  --placeholder: #71717a;
  --float: rgb(39 39 42 / 0.9); /* zinc-800/90 */
  --float-ring: rgb(255 255 255 / 0.1);
  --scrim: rgb(0 0 0 / 0.8);
  --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --shadow-field: none;
  color-scheme: dark;
}

/* The column from amirmousavi.com: full width on phones, then a sheet inset 32 px from the
   window with a hairline edge, capped at 1280 px less its own 32 px padding. */
@media (min-width: 640px) {
  :root {
    --frame: calc(100% - 64px);
  }
}

@media (min-width: 1024px) {
  :root {
    --frame: calc(min(100% - 64px, 1280px) - 64px);
  }
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  width: var(--frame);
  margin-inline: auto;
  background: var(--page);
  box-shadow: 0 0 0 1px var(--frame-ring);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: var(--accent-ink);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

/* The site's eyebrow: small caps text led by a short teal rule. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.9em;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.eyebrow::before {
  content: '';
  flex: none;
  width: 2.15em;
  height: max(2px, 0.15em);
  border-radius: 999px;
  background: var(--accent-bright);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap, 16px);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--gap, 8px);
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

/* ---------- buttons and fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--field);
  border-radius: var(--radius-sm);
  background: var(--hover);
  color: var(--ink);
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms, border-color 150ms, color 150ms;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active:not(:disabled) {
  transition: none;
  color: color-mix(in srgb, var(--ink) 60%, transparent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  color: color-mix(in srgb, var(--on-primary) 70%, transparent);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
}

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

.btn-danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 56px;
  font-size: 1.06rem;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.875rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span,
.label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--field);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  box-shadow: var(--shadow-field);
  font-size: 1rem;
}

.input::placeholder {
  color: var(--placeholder);
}

.input:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

textarea.input {
  resize: vertical;
  line-height: 1.4;
}

.hint {
  font-size: 0.88rem;
  color: var(--faint);
}

.error-text {
  color: var(--danger);
  font-size: 0.95rem;
  font-weight: 500;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

/* The site's quiet topic pill; the live variant is its selected teal chip. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--field);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.pill-live {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.pill-live::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.banner {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  background: var(--warn-soft);
  color: var(--warn-ink);
}

/* ---------- letter badges ---------- */

.badge {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- results (shared renderer) ---------- */

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.92rem;
  color: var(--muted);
}

.results-meta strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: center;
}

.bar-row .badge {
  grid-row: span 2;
  align-self: start;
}

.bar-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.bar-label {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.bar-value {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.92rem;
}

.bar-value b {
  color: var(--ink);
  font-weight: 700;
  margin-right: 6px;
}

.bar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 2;
}

.bar-tags:empty {
  display: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 1px 8px;
  border-radius: 999px;
}

.tag-yours {
  color: var(--accent);
  background: var(--accent-soft);
}

.tag-correct {
  color: var(--good);
  background: var(--good-soft);
}

.bar-track {
  grid-column: 2;
  height: 12px;
  background: var(--track);
  border-radius: 0 4px 4px 0;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  transition: width 400ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.bar-row.is-yours .badge {
  box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--accent);
}

.bar-row.is-correct .badge {
  background: var(--good);
  color: var(--on-good);
}

.results-empty {
  padding: 16px;
  border: 1px dashed var(--field);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

/* text answers: grouped chips sized by count */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  max-width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.chip small {
  font-size: 0.75em;
  font-weight: 700;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.chip.is-yours {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* XL variant for the projector: sized in em so it scales with the container. Rows are
   single-line (badge | label | bar | value) so ten options still fit on a 16:9 screen. */
.results--xl {
  gap: 1.2em;
}

.results--xl .bar-list {
  gap: 0.75em;
}

.results--xl .bar-row {
  grid-template-columns: auto minmax(0, 34%) minmax(0, 1fr) auto;
  column-gap: 1em;
  row-gap: 0.2em;
}

.results--xl .badge {
  grid-row: 1 / span 2;
  align-self: center;
  width: 2em;
  height: 2em;
  border-radius: 999px;
  font-size: 1.5em;
}

.results--xl .bar-head {
  display: contents;
}

.results--xl .bar-label {
  grid-column: 2;
  grid-row: 1;
  font-size: 1.75em;
  font-weight: 600;
  line-height: 1.15;
}

.results--xl .bar-tags {
  grid-column: 2;
  grid-row: 2;
}

.results--xl .bar-track {
  grid-column: 3;
  grid-row: 1 / span 2;
  height: 1.6em;
  border-radius: 0 0.3em 0.3em 0;
}

.results--xl .bar-fill {
  border-radius: 0 0.3em 0.3em 0;
}

.results--xl .bar-value {
  grid-column: 4;
  grid-row: 1 / span 2;
  min-width: 5.2em;
  text-align: right;
  font-size: 1.45em;
}

.results--xl .tag {
  font-size: 1em;
  padding: 0.1em 0.6em;
}

.results--xl .results-meta {
  font-size: 1.3em;
}

.results--xl .chip {
  padding: 0.35em 0.75em;
  border-radius: 0.5em;
}

.results--xl .chips {
  gap: 0.6em;
  justify-content: center;
}

/* ---------- audience page ---------- */

.audience {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.015em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
}

.topbar .code-tag {
  margin-left: auto;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 0.9rem;
}

.screen-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 8px;
}

[tabindex='-1']:focus {
  outline: none;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 48px;
}

.hero h1 {
  font-size: clamp(1.9rem, 8vw, 2.5rem);
  font-weight: 700;
}

.hero p {
  font-size: 1.08rem;
  color: var(--muted);
}

.prompt {
  font-size: clamp(1.45rem, 6vw, 1.9rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--field);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-field);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms, box-shadow 150ms;
}

.choice:hover {
  border-color: var(--field-hover);
}

/* The extra 1 px ring makes the selected edge 2 px without shifting the layout. */
.choice[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.choice[aria-checked='true'] .badge {
  background: var(--accent-fill);
  color: var(--on-accent);
}

.choice-label {
  flex: 1;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.choice-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--field-hover);
  border-radius: var(--radius-sm);
  flex: none;
  display: grid;
  place-items: center;
}

.choice[aria-checked='true'] .choice-check {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
}

.choice[aria-checked='true'] .choice-check::after {
  content: '';
  width: 10px;
  height: 6px;
  border: solid var(--on-accent);
  border-width: 0 0 2.5px 2.5px;
  transform: translateY(-1px) rotate(-45deg);
}

.scale {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 8px;
}

.scale .choice {
  justify-content: center;
  min-height: 60px;
  padding: 0;
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.scale-ends {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.scale-ends span:last-child {
  text-align: right;
}

.counter {
  font-size: 0.85rem;
  color: var(--faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0 calc(8px + env(safe-area-inset-bottom));
  margin-top: auto;
  background: linear-gradient(to bottom, transparent, var(--page) 24px);
}

.sent {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.sent-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.sent-title {
  font-weight: 700;
}

.sent-answer {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.count-line {
  font-size: 0.95rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.join-code-input {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  min-height: 72px;
  padding-left: 0.25em;
}

.join-code-input::placeholder {
  color: var(--field-hover);
  letter-spacing: 0.25em;
}

.foot-link {
  text-align: center;
  font-size: 0.92rem;
  color: var(--faint);
  padding-top: 12px;
}

.foot-link a {
  color: var(--ink);
  font-weight: 500;
  text-decoration-color: var(--field-hover);
  text-underline-offset: 3px;
  transition: color 150ms;
}

.foot-link a:hover {
  color: var(--accent);
}

.wave {
  font-size: 2.6rem;
  line-height: 1;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Floating controls borrow the site's header pills: translucent, blurred, hairline ring. */
.conn {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 50;
  padding: 6px 14px;
  border: 0;
  background: var(--float);
  color: var(--ink);
  box-shadow: var(--shadow), 0 0 0 1px var(--float-ring);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ---------- control room ---------- */

.center {
  align-items: center;
  min-height: 60vh;
}

.page-host {
  font-size: 16px;
}

.host-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  width: var(--frame);
  min-height: 60px;
  margin-inline: auto;
  padding: 8px 20px;
  background: color-mix(in srgb, var(--page) 80%, transparent);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}

.host-page {
  width: 100%;
  max-width: min(980px, var(--frame));
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.page-head h1 {
  font-size: 2rem;
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 16px;
}

.section-head h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.btn-icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
}

.btn-danger-solid {
  background: var(--danger-fill);
  border-color: var(--danger-fill);
  color: #fff;
}

.btn-danger-solid:hover {
  background: color-mix(in srgb, var(--danger-fill) 88%, #000);
}

.code-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}

.pill-accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  margin-right: 3px;
  border: 1px solid var(--field);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

/* login */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
}

/* sessions list */

.session-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.session-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-title {
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: color 150ms;
}

.session-title:hover {
  color: var(--accent-ink);
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.empty {
  align-items: flex-start;
  padding: 28px;
}

/* dialogs */

/* Dialogs take the site's mobile menu panel: rounded-3xl, hairline ring, blurred scrim. */
.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border: 0;
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--float-ring), 0 20px 60px rgb(0 0 0 / 0.15);
}

/* Older engines don't pass custom properties to ::backdrop, hence the fallback. */
.dialog::backdrop {
  background: var(--scrim, rgb(39 39 42 / 0.4));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dialog h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.dialog-qr {
  width: min(440px, calc(100vw - 32px));
}

.qr-big {
  width: 100%;
  max-width: 320px;
  height: auto;
  margin: 0 auto;
  display: block;
  border-radius: 12px;
  background: #fff;
}

.qr-code-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.qr-url-row {
  flex-wrap: nowrap;
}

.qr-url {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.banner-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* editor */

.editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-sm {
  min-height: 40px;
  padding: 6px 10px;
  font-size: 0.95rem;
}

select.input {
  width: auto;
  padding-right: 32px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.input-code {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  max-width: 280px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
}

.check strong {
  color: var(--ink);
}

.check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--accent);
}

.q-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.q-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.q-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.q-num {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  margin-right: 4px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  font-weight: 600;
  font-size: 0.9rem;
}

.opt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opt-row .input {
  flex: 1;
  min-width: 0;
}

.opt-correct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.opt-correct input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--good);
}

.add-opt {
  align-self: flex-start;
}

.scale-grid {
  display: grid;
  grid-template-columns: 100px 100px 1fr 1fr;
  gap: 10px;
}

.scale-grid select.input {
  width: 100%;
}

.add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border: 1px dashed var(--field);
  border-radius: var(--radius);
}

.add-row .label {
  margin-right: 4px;
}

.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  margin-top: 8px;
  background: linear-gradient(to bottom, transparent, var(--page) 18px);
}

/* room */

.room-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.room-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.room-title {
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.conn-dot.is-live {
  background: var(--good);
}

.conn-dot.is-reconnecting {
  background: var(--danger);
  animation: pulse 1s ease-in-out infinite;
}

.room {
  flex: 1;
  width: var(--frame);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 60px;
  align-self: start;
  max-height: calc(100dvh - 60px - 57px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
}

.rail.is-dim {
  opacity: 0.55;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.rail-item:hover {
  background: var(--surface-2);
}

.rail-item.is-current {
  background: var(--accent-soft);
}

.rail-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rail-item.is-done .rail-num {
  background: var(--good-soft);
  color: var(--good);
}

.rail-item.is-current .rail-num {
  background: var(--accent-fill);
  color: var(--on-accent);
}

.rail-text {
  flex: 1;
  min-width: 0;
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-item.is-current .rail-text {
  font-weight: 600;
}

.rail-count {
  font-size: 0.78rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.stage {
  min-width: 0;
  padding: 28px 36px 40px;
}

.stage-inner {
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stage-lobby,
.stage-question {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stage-title {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.stage-sub {
  font-size: 1.1rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stage-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.stage-traits {
  margin-top: -8px;
  font-size: 0.92rem;
}

.stage-results {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.join-panel {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-self: flex-start;
  max-width: 100%;
}

.qr-img {
  flex: none;
  border-radius: 10px;
  background: #fff;
}

.join-url {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.join-code {
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: 0.14em;
  line-height: 1.1;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.controls-sticky {
  position: sticky;
  bottom: 57px;
  z-index: 5;
  padding: 12px 0;
  background: linear-gradient(to bottom, transparent, var(--page) 14px);
}

.secondary-controls {
  gap: 4px;
  margin-top: -8px;
}

.shortcut-hint {
  font-size: 0.82rem;
  color: var(--faint);
}

.responses {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.responses summary {
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.responses table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.responses th,
.responses td {
  padding: 8px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.responses th {
  position: sticky;
  top: 0;
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

.host-footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  width: var(--frame);
  min-height: 57px;
  margin-inline: auto;
  padding: 8px 20px calc(8px + env(safe-area-inset-bottom));
  background: var(--page);
  border-top: 1px solid var(--line);
}

.footer-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The site's navigation pill: the current tab turns teal over a fading hairline. */
.tabs {
  display: inline-flex;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--float);
  box-shadow: var(--shadow), 0 0 0 1px var(--float-ring);
}

.tab {
  position: relative;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms;
}

.tab:hover,
.tab[aria-selected='true'] {
  color: var(--accent-ink);
}

.tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(to right, transparent, color-mix(in srgb, var(--accent-bright) 40%, transparent), transparent);
}

.all-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.all-prompt {
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

@media (hover: none) {
  .hide-touch {
    display: none;
  }
}

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

  .rail {
    position: sticky;
    top: 60px;
    z-index: 10;
    max-height: none;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--page);
    scrollbar-width: none;
  }

  .rail-item {
    width: auto;
    flex: none;
    padding: 6px 8px;
  }

  .rail-text,
  .rail-count {
    display: none;
  }

  .stage {
    padding: 20px 16px 24px;
  }

  .controls-sticky .spacer {
    display: none;
  }

  .controls-sticky .btn {
    flex: 1 1 40%;
    padding: 0 12px;
  }
}

@media (max-width: 640px) {
  .hide-sm {
    display: none;
  }

  .host-header,
  .host-footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .host-page {
    padding: 16px 16px 48px;
  }

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

  .session-actions .btn-sm {
    flex: 1;
  }

  .session-actions .btn-icon {
    flex: none;
  }

  .scale-grid {
    grid-template-columns: 1fr 1fr;
  }

  .opt-correct span {
    display: none;
  }

  .join-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .secondary-controls .shortcut-hint {
    display: none;
  }
}

/* ---------- projector screen ---------- */

/* The screen is the site's dark column edge to edge. :root raises this above the dark
   theme's own :root[data-theme] block. */
:root.screen-html {
  --bg: #18181b;
  --line: rgb(63 63 70 / 0.7);
}

.page-screen {
  overflow: hidden;
  background: var(--bg);
}

.page-screen::before {
  display: none;
}

.screen {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 3vh;
  padding: 3.5vh 4.5vw;
  font-size: clamp(14px, 1.15vw, 30px);
}

.screen.is-idle {
  cursor: none;
}

.screen-top {
  display: flex;
  align-items: center;
  gap: 1em;
  color: var(--muted);
  font-size: 1.2em;
  min-height: 2em;
}

.screen-top .brand {
  color: var(--ink);
  font-size: 1em;
}

.screen-top .brand-mark {
  width: 1.4em;
  height: 1.4em;
}

.screen-title {
  margin-left: auto;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.screen-hint {
  font-size: 0.8em;
  color: var(--faint);
  transition: opacity 600ms;
}

.screen-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4vh;
}

.screen-stage {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 3.5vh;
}

.screen-lobby {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5vw;
}

.qr-tile {
  width: min(56vh, 38vw);
  aspect-ratio: 1;
  padding: 2.2vh;
  border-radius: 2.4vh;
  background: #fff;
  box-shadow: 0 2vh 6vh rgb(0 0 0 / 0.35);
}

.qr-tile img {
  display: block;
  width: 100%;
  height: 100%;
}

.screen-join {
  display: flex;
  flex-direction: column;
  gap: 1.5vh;
  min-width: 0;
}

.screen-label {
  font-size: 1.6em;
  color: var(--muted);
}

.screen-url {
  font-size: 3em;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.screen-code {
  font-size: min(10em, 22vh);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: var(--ink);
}

.screen-joined {
  font-size: 1.8em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.screen-joined strong {
  color: var(--ink);
}

.screen-q-meta {
  display: flex;
  align-items: center;
  gap: 0.8em;
  font-size: 1.35em;
}

.screen-q-meta .eyebrow {
  font-size: 0.85em;
}

.screen-q-meta .pill {
  font-size: 0.8em;
  padding: 0.25em 0.8em;
}

.screen-prompt {
  font-size: 3.6em;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.screen-counter {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
}

.screen-counter b {
  font-size: 9em;
  font-weight: 800;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.screen-counter span {
  font-size: 2.2em;
  color: var(--muted);
}

.screen-main {
  overflow: hidden;
}

.screen-end h1 {
  font-size: min(8em, 20vh);
  font-weight: 700;
  line-height: 1;
}

.screen-end p {
  font-size: 2em;
  color: var(--muted);
}

.screen-foot {
  display: flex;
  align-items: center;
  gap: 1.2em;
  padding-top: 2vh;
  border-top: 1px solid var(--line);
  font-size: 1.35em;
  color: var(--muted);
}

.screen-foot img {
  width: 4.2em;
  height: 4.2em;
  padding: 0.25em;
  border-radius: 0.4em;
  background: #fff;
}

.screen-foot strong {
  color: var(--ink);
  letter-spacing: 0.06em;
}

.screen-foot .spacer + span {
  font-variant-numeric: tabular-nums;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--float);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.875rem;
  box-shadow: var(--shadow), 0 0 0 1px var(--float-ring);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
