:root {
  --bg: #050814;
  --bg-2: #09111f;
  --panel: #101827;
  --panel-2: #152032;
  --text: #f8fafc;
  --muted: #a8b3c7;
  --line: rgba(255, 255, 255, 0.12);
  --red: #b91c1c;
  --red-2: #ef4444;
  --gold: #e6c36a;
  --green: #22c55e;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(185, 28, 28, 0.16), transparent 34rem),
    radial-gradient(circle at top left, rgba(230, 195, 106, 0.12), transparent 24rem),
    var(--bg);
  color: var(--text);
}

button,
input,
a.button-link {
  font: inherit;
}

button,
a.button-link {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover,
a.button-link:hover {
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.primary {
  background: var(--red);
  border-color: rgba(255, 255, 255, 0.2);
}

.danger {
  color: #fecaca;
}

.subtle {
  background: transparent;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.topbar,
.screen-header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--gold);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 1.02;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 18px 48px var(--shadow);
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.button-row .button-link {
  grid-column: span 1;
}

.stat,
.screen-count {
  min-width: 160px;
  border-left: 3px solid var(--red-2);
  padding-left: 1rem;
  text-align: left;
}

.stat span,
.screen-count span {
  display: block;
  font-size: 3rem;
  line-height: 1;
  font-weight: 800;
}

.stat small,
.screen-count small,
.muted {
  color: var(--muted);
}

.status-line {
  color: var(--muted);
  min-height: 1.4rem;
}

.question-preview {
  font-size: 1.2rem;
  line-height: 1.45;
}

.answer-stats {
  display: grid;
  gap: 0.55rem;
}

.answer-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.answer-stat.correct {
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.14);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
  counter-reset: places;
}

.leaderboard li {
  counter-increment: places;
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.leaderboard li::before {
  content: counter(places);
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(185, 28, 28, 0.35);
  font-weight: 800;
}

.leaderboard .name {
  font-weight: 700;
}

.leaderboard .details {
  color: var(--muted);
  font-size: 0.9rem;
}

.leaderboard .score {
  color: var(--gold);
  font-weight: 800;
}

.screen-shell {
  width: min(1500px, calc(100% - 4rem));
  min-height: 100vh;
  margin: 0 auto;
  padding: 3rem 0;
  display: flex;
  flex-direction: column;
}

.join-block {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 3rem;
  align-items: center;
}

.join-block h2,
.screen-leaderboard h2,
.question-block h2 {
  font-size: clamp(2.4rem, 5vw, 6rem);
  line-height: 1.05;
}

.join-url {
  display: inline-block;
  margin-top: 1rem;
  color: var(--gold);
  font-size: clamp(1rem, 2vw, 1.65rem);
}

.qr {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 8px;
  padding: 0.75rem;
  justify-self: end;
}

.question-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  color: var(--gold);
  font-weight: 800;
  margin-bottom: 1rem;
}

.answered-pill,
.answered-line {
  color: var(--text);
  font-weight: 800;
}

.answered-pill {
  min-height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(230, 195, 106, 0.45);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  background: rgba(230, 195, 106, 0.1);
  font-size: clamp(1rem, 1.8vw, 1.55rem);
}

.answered-line {
  margin: 0 0 1rem;
}

.answered-pill.complete,
.answered-line.complete {
  color: #bbf7d0;
}

.answer-progress {
  width: 100%;
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  margin: -0.35rem 0 1.2rem;
}

.answer-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width 180ms ease;
}

.question-head.compact {
  margin-bottom: 0.6rem;
}

.timer {
  min-width: 4.5rem;
  min-height: 4.5rem;
  display: grid;
  place-items: center;
  border: 2px solid rgba(239, 68, 68, 0.72);
  border-radius: 50%;
  color: var(--text);
  font-size: 1.55rem;
}

.screen-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.screen-option,
.participant-option {
  min-height: 5rem;
  border: 1px solid var(--line);
  border-left: 5px solid var(--red);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.screen-option {
  font-size: clamp(1.4rem, 2.3vw, 2.5rem);
  font-weight: 750;
}

.screen-option.correct,
.participant-option.correct {
  border-left-color: var(--green);
  background: rgba(34, 197, 94, 0.16);
}

.screen-leaderboard {
  margin: auto 0;
}

.tie-note {
  margin: -0.35rem 0 1.25rem;
  font-size: clamp(1rem, 1.7vw, 1.5rem);
}

.leaderboard.large {
  gap: 0.8rem;
}

.leaderboard.large li {
  grid-template-columns: 4rem 1fr auto;
  font-size: clamp(1.3rem, 2vw, 2.2rem);
  padding: 1rem;
}

.participant-shell {
  width: min(620px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.25rem 0;
}

.participant-header {
  margin-bottom: 1rem;
}

.form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  resize: vertical;
  font: inherit;
  line-height: 1.45;
}

input:focus {
  outline: 2px solid rgba(239, 68, 68, 0.45);
  border-color: transparent;
}

textarea:focus {
  outline: 2px solid rgba(239, 68, 68, 0.45);
  border-color: transparent;
}

.error-text {
  color: #fecaca;
  min-height: 1.4rem;
}

.participant-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.participant-line span {
  font-weight: 800;
}

.participant-options {
  display: grid;
  gap: 0.75rem;
}

.participant-option {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  font-weight: 700;
}

.participant-option.selected {
  border-color: rgba(230, 195, 106, 0.75);
}

.questions-editor {
  display: grid;
  gap: 1rem;
}

.question-editor-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.045);
}

.question-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.question-editor-head h2 {
  margin: 0;
}

.options-editor {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.option-editor {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.04);
}

.option-editor.correct {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.12);
}

.correct-choice {
  display: flex;
  grid-template-columns: none;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--text);
  font-weight: 800;
}

.correct-choice input {
  width: auto;
  min-height: auto;
}

.question-save-note {
  margin-bottom: 0;
}

@media (max-width: 820px) {
  .topbar,
  .screen-header,
  .participant-line,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-grid,
  .join-block,
  .screen-options {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .screen-shell {
    width: min(100% - 1.5rem, 720px);
    padding: 1.25rem 0;
  }

  .qr {
    justify-self: start;
    max-width: 320px;
  }

  .leaderboard li,
  .leaderboard.large li {
    grid-template-columns: 2.7rem 1fr;
  }

  .leaderboard .score {
    grid-column: 2;
  }
}
