:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-muted: #eef2ef;
  --text: #1a2b24;
  --muted: #5c6f66;
  --border: rgba(26, 43, 36, 0.1);
  --accent: #008c53;
  --accent-hover: #007347;
  --accent-soft: rgba(0, 140, 83, 0.12);
  --accent-text: #006b40;
  --correct: #008c53;
  --wrong: #c2410c;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(26, 43, 36, 0.08);
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 4px;
}

.topbar-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.topbar-tag {
  font-size: 13px;
  color: var(--muted);
}

.load-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  padding: 28px;
  margin-bottom: 16px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--accent-soft);
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.1;
  margin: 0 0 12px;
  font-weight: 700;
}

.lead {
  color: var(--muted);
  font-size: 16px;
  margin: 0;
  max-width: 62ch;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 22px;
}

.stat {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
}

.live {
  padding: 22px 24px;
  margin-bottom: 16px;
}

.live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.live-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.live-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.live-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 720px) {
  .live-grid {
    grid-template-columns: 1fr;
  }
}

.qr-wrap {
  text-align: center;
}

#qrCanvas {
  display: block;
  margin: 0 auto 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.qr-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
}

.live-bars {
  min-height: 80px;
}

.vote-bar-row {
  margin-bottom: 12px;
}

.vote-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
}

.vote-bar-track {
  height: 12px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.vote-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #00b368);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.quiz {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
}

.quiz-main {
  padding: 24px;
}

.quiz-side {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.badge {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.question-title {
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.2;
  margin: 0 0 8px;
}

.question-subtitle {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 15px;
}

.prompt-box,
.result-box,
.explanation-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface-muted);
  margin-bottom: 14px;
}

.prompt-label {
  color: var(--accent-text);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 8px;
}

.prompt-text {
  white-space: pre-line;
  line-height: 1.6;
  font-size: 15px;
}

.option-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.option-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font: inherit;
  text-align: left;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-letter {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  font-weight: 700;
  font-size: 14px;
}

.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-btn.correct {
  border-color: var(--correct);
  background: rgba(0, 140, 83, 0.12);
}

.option-btn.wrong {
  border-color: var(--wrong);
  background: rgba(194, 65, 12, 0.08);
}

.hidden {
  display: none !important;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 18px;
  min-width: 130px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

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

.btn-ghost {
  background: transparent;
}

.side-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.side-copy {
  color: var(--muted);
  font-size: 13px;
}

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

.progress-bar {
  height: 8px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #00b368);
  transition: width 0.22s ease;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.score-card {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 13px;
  color: var(--muted);
}

.score-card strong {
  font-size: 20px;
  display: block;
  margin-top: 4px;
  color: var(--text);
}

.footer-note {
  margin-top: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 920px) {
  .quiz {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: 1fr;
  }
}

/* Vote page */
.vote-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px;
}

.vote-card {
  width: 100%;
  max-width: 480px;
  padding: 24px;
}

.vote-page h1 {
  font-size: 20px;
  margin: 0 0 8px;
}

.vote-status {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
}

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

.vote-opt {
  padding: 18px 16px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.vote-opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.vote-opt:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vote-opt.done {
  border-color: var(--accent);
  background: var(--accent-soft);
}
