:root {
  --bg: #f5f3ff;
  --surface: #ffffff;
  --ink: #1a1033;
  --muted: #6b6283;
  --primary: #6d28d9;
  --primary-dark: #5b21b6;
  --accent: #f43f5e;
  --green: #059669;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(80, 40, 140, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 80px;
}

.site-header {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px 6px;
}

.brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--primary);
  text-decoration: none;
}

.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3 {
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 12px;
}

p {
  margin: 0 0 16px;
}

/* ---------- Hero / cards ---------- */
.hero {
  text-align: center;
  padding: 26px 4px 10px;
}

.hero h1 {
  font-size: clamp(34px, 9vw, 54px);
  font-weight: 900;
}

.hero .tagline {
  font-size: 19px;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 10px;
}

.hero .sub {
  color: var(--muted);
  font-size: 16px;
  max-width: 460px;
  margin: 0 auto 26px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}

.cta-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  padding: 14px 22px;
  border-radius: 999px;
  text-decoration: none;
  transition: transform 0.06s ease, filter 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 8px 22px rgba(109, 40, 217, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-accent {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  box-shadow: 0 8px 22px rgba(244, 63, 94, 0.32);
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 2px solid #dfd6f5;
}

.btn-block {
  width: auto;
  min-width: 240px;
}

/* mobile pills are full-width; on wider screens keep compact */
@media (min-width: 480px) {
  .cta-row {
    flex-direction: row;
    justify-content: center;
  }
  .btn {
    width: auto;
  }
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin: 16px 0 6px;
}

input[type="text"],
textarea,
select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 13px 14px;
  border: 2px solid #e4def5;
  border-radius: 12px;
  background: #fdfcff;
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

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

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Question editor ---------- */
.q-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.q-card .q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.q-card .q-num {
  font-weight: 800;
  color: var(--primary);
}

.q-remove {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

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

.option-row input[type="text"] {
  padding: 11px 12px;
}

.option-move {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
}

.correct-pick {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.correct-pick select {
  width: auto;
  padding: 8px 10px;
}

.icon-btn {
  background: #f0ebfb;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

/* ---------- Quiz (play) ---------- */
.intro-title {
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 900;
  margin-bottom: 6px;
}

.creator-byline {
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #e7dff7;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.quiz-q {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 18px;
}

.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  padding: 15px 18px;
  margin-bottom: 10px;
  border-radius: 14px;
  border: 2px solid #e4def5;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.1s ease, background 0.1s ease, transform 0.06s ease;
}

.quiz-option:active {
  transform: scale(0.99);
}

.quiz-option:hover {
  border-color: var(--primary);
}

/* ---------- Result ---------- */
.result-score {
  font-size: clamp(52px, 16vw, 84px);
  font-weight: 900;
  text-align: center;
  line-height: 1;
  margin: 6px 0 2px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-sub {
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 18px;
}

.result-msg {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 22px;
}

.result-emojis {
  text-align: center;
  font-size: 40px;
  margin-bottom: 10px;
}

/* ---------- Share ---------- */
.share-url {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f2edfc;
  border: 2px dashed var(--primary);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 14px 0;
}

.share-url code {
  flex: 1;
  word-break: break-all;
  font-size: 15px;
  color: var(--primary-dark);
}

/* ---------- Stats ---------- */
.stat-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.stat-box {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}

.stat-box .num {
  font-size: 30px;
  font-weight: 900;
  color: var(--primary);
}

.stat-box .lbl {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.attempt-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.attempt-table th,
.attempt-table td {
  text-align: left;
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 1px solid #f0ebfb;
}

.attempt-table th {
  background: #f7f4ff;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.attempt-table tr:last-child td {
  border-bottom: none;
}

.empty-note {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
}

/* ---------- Misc ---------- */
.error-box {
  background: #fef2f4;
  border: 1px solid #fbc7cf;
  color: #be123c;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 600;
}

.spinner {
  text-align: center;
  padding: 40px 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #252036;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden {
  display: none !important;
}

/* ---------- Try a Challenge ---------- */
.try-card {
  position: relative;
}

.try-badge {
  position: absolute;
  top: -10px;
  left: 18px;
  background: linear-gradient(135deg, var(--accent), #e11d48);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(244, 63, 94, 0.35);
}

.try-title {
  font-size: 20px;
  font-weight: 800;
  margin: 6px 0 18px;
}

/* ---------- Gallery / explore ---------- */
.gallery {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.g-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.g-body h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

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

.g-plays {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.play-btn {
  flex: 0 0 auto;
  padding: 11px 18px;
  font-size: 15px;
}

/* ---------- Result page ---------- */
.result-divider {
  height: 1px;
  background: #efe9fb;
  margin: 18px 0;
}

.result-prompt {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
}

.btn-half {
  min-width: 0;
  flex: 1;
}

@media (min-width: 480px) {
  .btn-half {
    flex: 0 1 220px;
  }
}
