:root {
  --bg-top: #1b1146;
  --bg-mid: #2b1e66;
  --bg-bottom: #4c2a85;
  --card: #ffffff;
  --ink: #1b1b2f;
  --muted: #5d6079;
  --line: #e4e6f2;
  --accent: #ffb703;
  --accent-dark: #e0a002;
  --accent-ink: #3a2a00;
  --good: #2a9d8f;
  --good-ink: #124c45;
  --bad: #e63946;
  --radius: 16px;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px 14px 96px;
  color: #f4f2ff;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%);
  background-attachment: fixed;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
}

.hero {
  text-align: center;
  margin: 8px 0 20px;
}

.title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 6px 0 0;
  color: #cfc7f5;
}

.card {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 16px;
  animation: rise 0.24s ease-out both;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.big-code {
  margin: 4px 0 14px;
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--ink);
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.field {
  margin-bottom: 14px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: #fbfbff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

select {
  max-width: 220px;
  min-height: 48px;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.code-input {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-align: center;
}

.count-input {
  width: 100%;
  max-width: 120px;
  min-height: 48px;
}

/* Sits under a form control rather than under a card, so it hugs the field. */
.field-hint {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.ideas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.ideas-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.idea-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4c2a85;
  background: #efeafc;
  border: 1px solid #c9c4e6;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  background: #e2d9f8;
  border-color: #a99fdc;
}

.link-button {
  /* Anchors are inline by default, so the height has to be requested explicitly. */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #3b3466;
  background: none;
  border: none;
  border-radius: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-button:hover {
  color: var(--bg-bottom);
}

/* For the link-buttons that sit on the page gradient instead of a white card. */
.link-button.on-dark {
  color: #cfc7f5;
}

.link-button.on-dark:hover {
  color: #ffffff;
}

.btn:focus-visible,
.link:focus-visible,
.chip:focus-visible,
.link-button:focus-visible,
.option:focus-visible,
.remove:focus-visible {
  outline: 3px solid #6d5bd0;
  outline-offset: 2px;
}

.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: #f0f1fa;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: #e6e8f5;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent-dark);
}

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.ghost {
  background: #ffffff;
  border: 1px solid #c9c4e6;
  color: #3b3466;
}

.btn.ghost:hover {
  background: #f3f1fd;
}

.btn:disabled,
.remove:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.option:disabled {
  cursor: not-allowed;
}

/* Keep the reveal colours saturated: those options are disabled but must stay readable. */
.option:disabled:not(.correct):not(.wrong):not(.chosen) {
  opacity: 0.72;
}

.btn:disabled {
  background: #e9eaf2;
  color: #7d8095;
  border-color: var(--line);
}

.btn.primary:disabled {
  background: #f3e6c4;
  color: #9a8a5e;
  border-color: #e6dcc0;
}

.link {
  display: inline-block;
  min-height: 48px;
  padding: 12px 10px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e7e1fb;
  background: none;
  border: none;
  border-radius: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link:hover {
  color: #ffffff;
}

.leave {
  margin: 4px 0 0;
  text-align: center;
}

.hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* The one thing to do next on every screen. */
.next-step {
  margin: 14px 0 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #3b3466;
  background: #efeafc;
  border-radius: 12px;
  overflow-wrap: anywhere;
}

/* Standalone in the lobby, where it sits between cards on the page gradient. */
section > .next-step {
  margin: 0 0 16px;
  color: var(--ink);
  animation: rise 0.24s ease-out both;
}

.join-heading {
  margin: 0 0 14px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
}

.join-code {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

#lobby-qr {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 12px;
  background: #ffffff;
  border-radius: 12px;
  image-rendering: pixelated;
}

.join-line {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.host-line {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.lobby-actions {
  justify-content: center;
}

.lobby-actions .btn {
  flex: 1 1 140px;
  width: auto;
}

.seat-panel {
  margin-top: 10px;
  text-align: left;
}

.seat-panel .btn {
  margin-top: 10px;
}

#btn-seat-question {
  margin: 4px 0 0;
}

.screen-block {
  margin-top: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #4c2a85;
  background: #efeafc;
  border-radius: 999px;
  white-space: nowrap;
}

.type-badge {
  color: var(--good-ink);
  background: #d9f2ee;
}

.kind-picker {
  position: relative;
  margin: 0 0 14px;
  padding: 0;
  /* Fieldsets default to min-inline-size: min-content, which overflows a phone. */
  min-width: 0;
  border: none;
}

.kind-picker legend {
  margin: 0 0 6px;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.kind-options {
  position: relative;
  display: flex;
  gap: 8px;
}

/* The radios carry the state and stay keyboard focusable; the labels render it,
   so the inputs must not inherit the shared text-input sizing above. */
.kind-options input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: none;
  opacity: 0;
}

.kind-options label {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.25;
  color: var(--ink);
  background: #f0f1fa;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.kind-options label:hover {
  background: #e6e8f5;
}

.kind-options input:checked + label {
  color: #ffffff;
  background: var(--bg-bottom);
  border-color: var(--bg-bottom);
  font-weight: 700;
}

.kind-options input:checked + label:hover {
  background: var(--bg-mid);
}

.kind-options input:focus-visible + label {
  outline: 3px solid #6d5bd0;
  outline-offset: 2px;
}

.player-list,
.fact-list,
.score-list,
.final-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-list li,
.score-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.player-list li:last-child,
.score-list li:last-child {
  border-bottom: none;
}

.name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.you {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.counter {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.fact-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.fact-list li:last-child {
  border-bottom: none;
}

.fact-body {
  flex: 1;
  min-width: 0;
}

.fact-text {
  display: block;
  overflow-wrap: anywhere;
}

.fact-body .badge {
  margin-top: 6px;
}

.remove {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  min-height: 48px;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--bad);
  background: #fdecee;
  border: 1px solid #f4c7cd;
  border-radius: 10px;
  cursor: pointer;
}

.remove:hover {
  background: #fbdfe2;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.bar {
  margin-top: 10px;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* The per-question countdown at the top of the question card. app.js re-bases it
   from each poll and ticks it in between, hence the linear width transition. */
.q-timer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--accent-dark);
}

.q-timer-text {
  min-width: 3.5ch;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.q-timer-track {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.q-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s linear;
}

.q-timer.urgent {
  color: var(--bad);
}

.q-timer.urgent .q-timer-fill {
  background: var(--bad);
}

.prompt {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 800;
}

.author-line {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.quote {
  margin: 0 0 16px;
  padding: 16px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  background: #f6f4ff;
  border-left: 4px solid #6d5bd0;
  border-radius: 12px;
  overflow-wrap: anywhere;
}

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

.option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 56px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  background: #fbfbff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.option:hover:not(:disabled) {
  background: #f1eeff;
  border-color: #6d5bd0;
}

.option-label {
  width: 100%;
  overflow-wrap: anywhere;
}

.option.chosen {
  background: #fdf3d8;
  border-color: var(--accent);
}

.option.correct {
  color: var(--good-ink);
  background: #d9f2ee;
  border-color: var(--good);
}

.option.wrong {
  color: #7d1f28;
  background: #fdecee;
  border-color: var(--bad);
}

.mark {
  font-weight: 800;
}

.option-picks {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.result {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 800;
}

.result.good {
  color: var(--good-ink);
}

.result.bad {
  color: #7d1f28;
}

.score-list .score,
.final-row .score {
  margin-left: auto;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Stands in for the players between the top rows and the viewer's own row. */
.ellipsis {
  justify-content: center;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.3em;
}

/* A player who left keeps their score on the board but must read as gone. */
.gone {
  opacity: 0.55;
}

.left-tag {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.final-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 12px;
  border-bottom: 1px solid var(--line);
}

.final-row.top {
  background: #fdf3d8;
  border-bottom-color: #f0e2bb;
}

.rank {
  width: 2rem;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

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

.actions .btn {
  flex: 1 1 200px;
  width: auto;
}

.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 10px 14px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  font-size: 0.9rem;
  color: #ffffff;
  background: rgba(20, 12, 48, 0.94);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  animation: toast-in 0.2s ease-out both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (min-width: 460px) {
  .options.four-up {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .btn:active {
    transform: none;
  }

  .q-timer-fill {
    transition: none;
  }
}
