:root {
  --bg-top: #fff7db;
  --bg-bottom: #e0f2fe;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --gold-500: #f59e0b;
  --gold-600: #d97706;
  --gold-100: #fef3c7;
  --blue-500: #0ea5e9;
  --blue-600: #0284c7;
  --blue-100: #e0f2fe;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-100: #dcfce7;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-100: #fee2e2;
  --border: #e2e8f0;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--bg-top) 0%, #fef9c3 40%, var(--bg-bottom) 100%);
  -webkit-font-smoothing: antialiased;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

.app-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  position: relative;
  z-index: 1;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.bell-badge {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fde047, #f59e0b);
  display: grid;
  place-items: center;
  font-size: 26px;
  box-shadow: 0 4px 0 #b45309;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: #b45309;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.icon-btn:hover {
  background: #f8fafc;
}

.icon-btn:active {
  transform: translateY(2px);
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeSlideUp 0.3s ease;
}

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

/* Cards */
.hero-card,
.question-card,
.result-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(245, 158, 11, 0.18);
}

.hero-card {
  text-align: center;
}

.hero-bell {
  font-size: 64px;
  display: inline-block;
  animation: swingBell 2.8s ease-in-out infinite;
  transform-origin: top center;
}

@keyframes swingBell {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(12deg); }
  30% { transform: rotate(-10deg); }
  45% { transform: rotate(6deg); }
  60% { transform: rotate(0deg); }
}

.hero-card h1 {
  margin: 8px 0 12px;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 900;
  line-height: 1.25;
}

.hero-card h1 span {
  color: var(--gold-600);
}

.hero-desc {
  max-width: 580px;
  margin: 0 auto 20px;
  color: var(--text-muted);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.55;
}

.stats-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gold-100);
  color: #92400e;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 800;
  margin-bottom: 22px;
}

.settings-grid {
  text-align: left;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
  background: #f8fafc;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.setting-group label {
  display: block;
  font-weight: 800;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.setting-group select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  align-items: flex-end;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  width: 100%;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-500);
}

/* Buttons */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  color: #fff;
  text-shadow: 0 1px 2px rgba(146, 64, 14, 0.35);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 #b45309;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

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

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #b45309;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 2px solid var(--blue-500);
  border-radius: 14px;
  background: var(--blue-100);
  color: var(--blue-600);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

.secondary-btn:hover {
  background: #bae6fd;
}

.ghost-btn {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.ghost-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

/* Quiz HUD */
.quiz-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.hud-pill {
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  border: 2px solid var(--border);
}

.score-pill {
  background: var(--gold-100);
  border-color: #fde68a;
  color: #92400e;
}

.streak-pill {
  background: #ffedd5;
  border-color: #fed7aa;
  color: #c2410c;
}

.timer-pill {
  margin-left: auto;
  background: var(--blue-100);
  border-color: #bae6fd;
  color: #0369a1;
}

.timer-pill.danger {
  background: var(--red-100);
  border-color: #fecaca;
  color: var(--red-600);
  animation: pulseFast 0.6s infinite alternate;
}

@keyframes pulseFast {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.progress-track {
  height: 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #fbbf24, #22c55e);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* Question Card */
.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.tag {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  background: var(--gold-100);
  color: #92400e;
}

.tag-type {
  background: var(--blue-100);
  color: #0369a1;
}

.speak-btn {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.speak-btn:hover {
  background: #e0f2fe;
}

.question-text {
  margin: 0 0 22px;
  font-size: clamp(1.25rem, 3.2vw, 1.65rem);
  font-weight: 900;
  line-height: 1.4;
  color: var(--text-main);
}

/* Multiple Choice Options */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  border: 2px solid var(--border);
  border-bottom-width: 5px;
  background: #fff;
  text-align: left;
  font-family: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--blue-500);
  background: #f0f9ff;
}

.option-btn:active:not(:disabled) {
  transform: translateY(2px);
}

.option-key {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--text-main);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.option-btn.correct {
  background: var(--green-100);
  border-color: var(--green-500);
  color: #14532d;
}

.option-btn.correct .option-key {
  background: var(--green-500);
  color: #fff;
}

.option-btn.wrong {
  background: var(--red-100);
  border-color: var(--red-500);
  color: #7f1d1d;
  animation: shake 0.32s ease;
}

.option-btn.wrong .option-key {
  background: var(--red-500);
  color: #fff;
}

.option-btn:disabled {
  cursor: default;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Fill in the blank */
.fill-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fill-input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fill-input {
  flex: 1 1 220px;
  padding: 14px 18px;
  border-radius: 16px;
  border: 2px solid var(--border);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.fill-input:focus {
  border-color: var(--blue-500);
}

.fill-input.correct {
  background: var(--green-100);
  border-color: var(--green-500);
}

.fill-input.wrong {
  background: var(--red-100);
  border-color: var(--red-500);
}

.fill-helpers {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.hint-text {
  background: #fef9c3;
  color: #854d0e;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Feedback */
.feedback-box {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 2px solid transparent;
  animation: fadeSlideUp 0.2s ease;
}

.feedback-box.correct {
  background: var(--green-100);
  border-color: #86efac;
  color: #14532d;
}

.feedback-box.wrong {
  background: var(--red-100);
  border-color: #fca5a5;
  color: #7f1d1d;
}

.feedback-header {
  font-size: 1.08rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.feedback-explain {
  margin: 0;
  font-weight: 700;
  line-height: 1.5;
}

.quiz-footer {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Results */
.result-card {
  text-align: center;
}

.trophy-icon {
  font-size: 68px;
  margin-bottom: 6px;
}

.result-card h2 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  font-weight: 900;
}

.result-subtitle {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 1.05rem;
}

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

.stat-box {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--gold-600);
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.result-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

/* Review List */
.review-section {
  text-align: left;
  border-top: 2px dashed var(--border);
  padding-top: 20px;
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.review-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 900;
}

.review-filters {
  display: flex;
  gap: 8px;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-chip.active {
  background: var(--gold-100);
  border-color: var(--gold-500);
  color: #92400e;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-item {
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #fff;
}

.review-item.is-correct {
  border-left: 6px solid var(--green-500);
}

.review-item.is-wrong {
  border-left: 6px solid var(--red-500);
  background: #fffafa;
}

.review-q {
  font-weight: 900;
  margin-bottom: 6px;
}

.review-answers {
  font-size: 0.94rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.review-explain {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

@media (max-width: 600px) {
  .hero-card,
  .question-card,
  .result-card {
    padding: 20px 16px;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }

  .btn-label {
    display: none;
  }
}
