:root {
  --ink: #334155;
  --muted: #64748b;
  --night: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  /* Each accent carries a soft fill, a light line and a glow so a theme can
     recolor the app from :root alone. */
  --acid: #2563eb;
  --acid-soft: rgba(37, 99, 235, .08);
  --acid-border: #bfdbfe;
  --acid-glow: rgba(37, 99, 235, .55);
  --coral: #dc2626;
  --coral-soft: #fef2f2;
  --coral-border: #fecaca;
  font-family: "Open Sans", sans-serif;
  color: var(--ink);
  background: var(--night);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 85% 5%, var(--acid-soft), transparent 28rem),
    var(--night);
}

button, input { font: inherit; }
a { color: inherit; }

.eyebrow {
  color: var(--acid);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.home-shell {
  width: min(760px, calc(100% - 40px));
  margin: 18vh auto 0;
}

.home-shell h1 {
  margin: 0 0 12px;
  font-family: Poppins, sans-serif;
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1;
}

.lede { max-width: 620px; color: var(--muted); font-size: 1.2rem; line-height: 1.65; }

.join-card {
  max-width: 760px;
  margin-top: 48px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 10px 30px -18px rgba(15, 23, 42, .25);
}

.join-card label, .link-card label, .label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.join-row { display: flex; align-items: center; gap: 10px; }
.join-row span { color: var(--muted); }
.join-row input {
  min-width: 0;
  flex: 1;
  padding: 12px 4px;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
  background: transparent;
}

button {
  padding: 11px 16px;
  color: white;
  border: 1px solid var(--acid);
  border-radius: 10px;
  background: var(--acid);
  font-weight: 700;
  cursor: pointer;
}

button:hover { filter: brightness(1.06); transform: translateY(-1px); }
button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
button.secondary { color: var(--ink); border-color: var(--line); background: #f1f5f9; }
button.ghost { color: var(--muted); border-color: transparent; background: transparent; }
button.danger { border-color: var(--coral); background: var(--coral); }
button.danger-text { color: var(--coral); border-color: var(--coral-border); background: var(--coral-soft); }

/* Floats over the stage so showing it never shifts a projected slide. */
.connection-notice {
  position: fixed;
  bottom: 16px;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 8px 8px 8px 16px;
  transform: translateX(-50%);
  color: var(--ink);
  border: 1px solid var(--coral-border);
  border-radius: 12px;
  background: var(--coral-soft);
  box-shadow: 0 8px 24px -12px rgba(15, 23, 42, .35);
  font-size: .9rem;
  white-space: nowrap;
}
.connection-notice[hidden] { display: none; }
.connection-notice button { padding: 7px 12px; }

.poll-shell, .results-shell {
  width: min(980px, calc(100% - 40px));
  margin: 4vh auto 0;
}

.poll-page, .results-page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

/* The poll and results pages are projected on slides, so they fill the viewport. */
.poll-page .poll-shell, .results-page .results-shell {
  width: calc(100% - clamp(20px, 3vw, 56px) * 2);
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  margin-top: 0;
  padding: clamp(14px, 2.4vh, 28px) 0;
}

.poll-page .poll-shell > :last-child,
.results-page .results-shell > :last-child {
  min-height: 0;
}

.embedded .poll-shell, .embedded .results-shell { margin-top: 0; }

.poll-stage, .results-stage {
  --stage-qr: clamp(92px, 14vh, 160px);
  min-height: 70vh;
  display: grid;
  align-items: center;
  padding: 5vh 0;
}

/* The code sits beside the question so anyone watching can still join the poll. */
.stage-top { display: flex; align-items: start; justify-content: space-between; gap: clamp(16px, 3vw, 44px); }
.stage-qr { flex: none; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: white; text-align: center; }
.stage-qr img { display: block; width: var(--stage-qr); height: auto; margin: 0 auto; }
/* Wider than the code itself so most URLs stay on one line. */
.stage-qr figcaption { margin-top: 7px; max-width: 250px; overflow-wrap: anywhere; color: var(--muted); font-size: .74rem; }

.poll-page .poll-stage, .results-page .results-stage {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

/* The question block owns the whole stage: prompt on top, answers taking the rest. */
.poll-page .question-wrap, .results-page .results-wrap {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 2.6vh, 30px);
}

.poll-page .question-wrap h1, .results-page .results-wrap h1 {
  margin: 0;
  max-width: none;
  font-size: clamp(1.8rem, 7vh, 5.5rem);
}

.waiting { text-align: center; }
.waiting h1 { margin-bottom: 8px; font-family: Poppins, sans-serif; font-size: clamp(2.4rem, 7vw, 5rem); font-weight: 700; }
.waiting p { color: var(--muted); }
.waiting-orbit {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--acid);
  border-radius: 50%;
  animation: orbit 1.1s linear infinite;
}
@keyframes orbit { to { transform: rotate(360deg); } }

.question-wrap h1, .results-wrap h1 {
  max-width: 900px;
  margin: 0 0 38px;
  font-family: Poppins, sans-serif;
  font-size: clamp(2.5rem, 6vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1;
}

/* Answers stretch into whatever height the prompt leaves, so they read from the back of a room. */
.choices { display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr; gap: clamp(10px, 1.8vh, 20px); height: 100%; }
.choices form { display: flex; }
.choice {
  position: relative;
  min-height: 86px;
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(12px, 1.6vw, 26px);
  overflow: hidden;
  padding: clamp(12px, 2vh, 26px) clamp(16px, 1.8vw, 34px);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: clamp(14px, 1.4vw, 22px);
  background: var(--panel);
  box-shadow: 0 4px 14px -10px rgba(15, 23, 42, .3);
  /* Width guards the height-based size so answers still fit a narrow 4:3 slide. */
  font-size: clamp(1.15rem, min(6.5vh, 4.2vw), 4.5rem);
  line-height: 1.1;
  text-align: left;
  width: 100%;
}
.choice:hover { border-color: var(--acid); filter: none; }
.choice.is-selected { border-color: var(--acid); box-shadow: inset 0 0 0 1px var(--acid), 0 8px 22px -16px var(--acid-glow); }
.choice-index {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  color: var(--acid);
  border: 1px solid var(--acid-border);
  background: var(--acid-soft);
  border-radius: 9px;
  font-size: .78rem;
  font-weight: 700;
}
.choice .choice-index {
  width: clamp(34px, 6vh, 76px);
  height: clamp(34px, 6vh, 76px);
  border-radius: clamp(9px, 1vw, 16px);
  font-size: clamp(.78rem, 2.4vh, 1.6rem);
}
.choice-label { position: relative; z-index: 1; }
.response-meta { display: flex; justify-content: space-between; margin-top: 18px; color: var(--muted); font-size: .84rem; }
.poll-page .response-meta { margin-top: 0; font-size: clamp(.8rem, 1.8vh, 1.15rem); }

.result-rows { display: grid; gap: 24px; }
.results-page .result-rows { grid-auto-rows: 1fr; height: 100%; gap: clamp(10px, 2.5vh, 24px); }
.results-page .result-row { display: grid; align-content: center; font-size: clamp(1rem, 3.4vh, 2.2rem); }
.results-page .result-copy { grid-template-columns: auto 1fr auto; gap: clamp(10px, 1.4vw, 22px); margin-bottom: clamp(6px, 1.2vh, 16px); }
.results-page .result-copy .choice-index { width: clamp(34px, 5vh, 62px); height: clamp(34px, 5vh, 62px); border-radius: clamp(9px, .9vw, 14px); font-size: clamp(.75rem, 2vh, 1.3rem); }
.results-page .result-track { height: clamp(10px, 2.2vh, 26px); }
.results-page .response-total { margin-top: 0; font-size: clamp(.8rem, 1.8vh, 1.15rem); }
/* The highlight stays inside the row because the results stage clips overflow. */
.result-row { padding: 7px 9px; border: 2px solid transparent; border-radius: 14px; }
.result-row.is-winner { border-color: var(--acid-border); background: var(--acid-soft); }
.result-copy { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px; margin-bottom: 8px; }
.result-copy > span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.result-track { height: 13px; overflow: hidden; border-radius: 99px; background: var(--line); }
.result-track span { display: block; height: 100%; border-radius: inherit; background: var(--acid); transition: width .5s ease; }
.response-total { margin-top: 28px; color: var(--muted); text-align: right; }

.presenter-shell { width: min(1180px, calc(100% - 40px)); margin: 40px auto 80px; }
.presenter-topline { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.presenter-topline h1 { margin: 6px 0 0; font-family: Poppins, sans-serif; font-size: clamp(2.5rem, 5vw, 4.5rem); font-weight: 700; }
.quiet-link { color: var(--muted); font-size: .88rem; }
.shortcut-bar { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 24px; color: var(--muted); font-size: .78rem; }
.shortcut-bar span { display: inline-flex; align-items: center; gap: 5px; }
kbd { min-width: 24px; padding: 3px 6px; color: var(--ink); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--panel); font: 600 .72rem/1.2 "Open Sans", sans-serif; text-align: center; }
.control-card, .link-card, .empty-card { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.current-control { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin: 32px 0 44px; padding: 24px; }
.current-control h2 { margin: 4px 0 14px; font-size: 1.4rem; }
.control-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.status-pill { display: inline-block; margin: 0 5px 5px 0; padding: 5px 8px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; font-size: .75rem; }
.status-pill.is-open { color: var(--acid); border-color: var(--acid-border); }
.presenter-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 36px; }
.section-title { margin: 0 0 14px; font-size: .9rem; letter-spacing: .08em; text-transform: uppercase; }
.question-list { display: grid; gap: 8px; }
.question-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .8); }
.question-row.is-current { border-color: var(--acid); }
.question-number { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.question-copy { min-width: 0; display: grid; gap: 3px; }
.question-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.question-copy small { color: var(--muted); }
.link-card { display: grid; gap: 8px; padding: 20px; }
.qr-code { padding: 18px; border-radius: 12px; background: white; text-align: center; }
.qr-code svg { width: min(100%, 220px); height: auto; }
.link-card label:not(:first-child) { margin-top: 16px; }
.link-card a { overflow-wrap: anywhere; color: var(--acid); font-size: .86rem; }
.link-card code { overflow-x: auto; padding: 10px; color: #e2e8f0; border-radius: 8px; background: #1e293b; font-size: .72rem; white-space: nowrap; }
.empty-card { padding: 28px; color: var(--muted); }

@media (max-width: 760px) {
  .join-row { align-items: stretch; flex-direction: column; }
  .join-row span { font-size: .82rem; }
  .choices, .presenter-grid { grid-template-columns: 1fr; }
  .presenter-topline, .current-control { align-items: stretch; flex-direction: column; }
  .control-actions { justify-content: flex-start; }
  /* A phone is held close, so the slide-sized type comes back down. */
  .choice { min-height: 72px; font-size: 1.05rem; }
  .choice .choice-index { width: 34px; height: 34px; border-radius: 9px; font-size: .78rem; }
  .poll-page .question-wrap h1 { font-size: clamp(1.7rem, 4.4vh, 2.6rem); }
  .response-meta { gap: 16px; }
  .poll-page .poll-shell, .results-page .results-shell { padding: 18px 0; }
  .poll-stage, .results-stage { --stage-qr: 72px; }
  .stage-qr { padding: 7px; }
  .stage-qr figcaption { max-width: 86px; font-size: .58rem; }
}
