/* ═══════════════════════════════════════════════════════════════
   Easy Quiz – Premium Design System
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ─── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Light palette */
  --bg:           hsl(220 20% 96%);
  --bg-2:         hsl(220 18% 92%);
  --surface:      hsl(0 0% 100%);
  --surface-soft: hsl(220 22% 97%);
  --surface-2:    hsl(220 20% 94%);
  --text:         hsl(222 47% 11%);
  --text-2:       hsl(222 20% 35%);
  --muted:        hsl(220 14% 55%);
  --border:       hsl(220 16% 88%);
  --border-2:     hsl(220 14% 80%);

  /* Brand */
  --primary:      hsl(230 75% 56%);
  --primary-dark: hsl(230 75% 44%);
  --primary-lite: hsl(230 80% 95%);
  --primary-glow: hsl(230 75% 56% / 22%);

  /* Semantic */
  --success:      hsl(158 64% 34%);
  --success-bg:   hsl(158 64% 95%);
  --success-ring: hsl(158 64% 34% / 14%);
  --danger:       hsl(4 74% 41%);
  --danger-bg:    hsl(4 74% 97%);
  --danger-ring:  hsl(4 74% 41% / 12%);
  --warning:      hsl(38 92% 40%);
  --warning-bg:   hsl(38 92% 96%);

  /* Surfaces */
  --shadow-sm:  0 1px 3px hsl(222 47% 11% / 6%), 0 1px 2px hsl(222 47% 11% / 4%);
  --shadow:     0 4px 16px hsl(222 47% 11% / 8%), 0 1px 4px hsl(222 47% 11% / 4%);
  --shadow-lg:  0 10px 40px hsl(222 47% 11% / 10%), 0 2px 8px hsl(222 47% 11% / 5%);
  --shadow-xl:  0 20px 60px hsl(222 47% 11% / 14%);
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --gradient-1: hsl(230 75% 56% / 9%);
  --gradient-2: hsl(158 64% 34% / 6%);
  --body-bg-linear: linear-gradient(145deg, hsl(230 40% 97%) 0%, var(--bg) 50%, hsl(200 30% 96%) 100%);
  --dot-color:  hsl(230 75% 56% / 18%);

  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --bg:           hsl(222 47% 7%);
  --bg-2:         hsl(222 40% 10%);
  --surface:      hsl(224 40% 12%);
  --surface-soft: hsl(224 36% 15%);
  --surface-2:    hsl(224 32% 18%);
  --text:         hsl(220 20% 94%);
  --text-2:       hsl(220 14% 72%);
  --muted:        hsl(220 14% 52%);
  --border:       hsl(222 28% 20%);
  --border-2:     hsl(222 22% 26%);

  --primary:      hsl(230 80% 68%);
  --primary-dark: hsl(230 80% 58%);
  --primary-lite: hsl(230 60% 16%);
  --primary-glow: hsl(230 80% 68% / 25%);

  --success:      hsl(158 60% 48%);
  --success-bg:   hsl(158 60% 10%);
  --success-ring: hsl(158 60% 48% / 18%);
  --danger:       hsl(4 80% 58%);
  --danger-bg:    hsl(4 70% 10%);
  --danger-ring:  hsl(4 80% 58% / 16%);
  --warning:      hsl(38 92% 54%);
  --warning-bg:   hsl(38 80% 10%);

  --shadow-sm:  0 1px 3px hsl(0 0% 0% / 22%);
  --shadow:     0 4px 20px hsl(0 0% 0% / 28%);
  --shadow-lg:  0 10px 40px hsl(0 0% 0% / 36%);
  --shadow-xl:  0 20px 60px hsl(0 0% 0% / 44%);

  --gradient-1: hsl(230 80% 68% / 14%);
  --gradient-2: hsl(158 60% 48% / 9%);
  --body-bg-linear: linear-gradient(145deg, hsl(222 50% 8%) 0%, var(--bg) 50%, hsl(230 40% 8%) 100%);
  --dot-color:  hsl(230 80% 68% / 10%);
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--bg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  isolation: isolate;
  -webkit-font-smoothing: antialiased;
}

/* Animated background blobs */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 15% 10%, var(--gradient-1), transparent),
    radial-gradient(ellipse 50% 35% at 85% 80%, var(--gradient-2), transparent),
    var(--body-bg-linear);
}

/* Subtle dot grid */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: radial-gradient(var(--dot-color) 0.6px, transparent 0.6px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 65%);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

/* ─── Typography ────────────────────────────────────────────── */
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.25; }

/* ─── Layout ────────────────────────────────────────────────── */
.container {
  width: min(100% - 32px, 940px);
  margin-inline: auto;
}

/* ─── Site Header ───────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: hsl(0 0% 100% / 75%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

[data-theme="dark"] .site-header {
  background: hsl(224 40% 12% / 80%);
}

.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 900;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), hsl(260 70% 58%));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex-shrink: 0;
}

.muted { color: var(--muted); }

/* ─── Theme Toggle ──────────────────────────────────────────── */
.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.theme-toggle-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
  transform: scale(1.06);
}

.theme-toggle-btn:active { transform: scale(0.94); }

.theme-icon { display: flex; align-items: center; }
.theme-icon .sun-icon  { display: none; }
.theme-icon .moon-icon { display: block; }
[data-theme="dark"] .theme-icon .sun-icon  { display: block; }
[data-theme="dark"] .theme-icon .moon-icon { display: none; }

/* ─── Main ──────────────────────────────────────────────────── */
main.container {
  flex: 1;
  padding-block: 36px 56px;
  outline: none;
}

main > section,
main > .donate-box {
  animation: view-enter 0.44s cubic-bezier(0.22, 1, 0.36, 1) both;
}
main > section:nth-child(2) { animation-delay: 50ms; }
main > section:nth-child(3),
main > .donate-box { animation-delay: 100ms; }

/* ─── Page Heading ──────────────────────────────────────────── */
.page-heading { margin-bottom: 28px; }

.page-heading h1 {
  margin: 0 0 8px;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .page-heading h1 {
  background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 580px;
}

/* ─── Home Tools (Search) ───────────────────────────────────── */
.home-tools {
  margin-bottom: 20px;
  padding: 20px;
  background: hsl(0 0% 100% / 80%);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

[data-theme="dark"] .home-tools {
  background: hsl(224 40% 12% / 80%);
}

.home-tools label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-field { position: relative; }

.search-field span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-52%);
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  pointer-events: none;
}

.search-field input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px 12px 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.search-field input::placeholder { color: var(--muted); opacity: 0.7; }

.search-summary {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

/* ─── Category Tabs ─────────────────────────────────────────── */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.category-tab {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.84rem;
  padding: 7px 18px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}

.category-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-lite);
}

.category-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
  transform: translateY(-1px);
}

/* ─── Quiz Grid ─────────────────────────────────────────────── */
.quiz-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 680px) {
  .quiz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .quiz-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ─── Quiz Card ─────────────────────────────────────────────── */
.quiz-card {
  position: relative;
  padding: 22px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
  animation: card-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Accent bar top */
.quiz-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), hsl(260 70% 60%));
  opacity: 0;
  transition: opacity var(--transition);
}

.quiz-card:hover {
  transform: translateY(-5px);
  border-color: hsl(230 60% 80%);
  box-shadow: var(--shadow-lg), 0 0 0 1px hsl(230 60% 80% / 30%);
}

[data-theme="dark"] .quiz-card:hover {
  border-color: hsl(230 60% 35%);
  box-shadow: var(--shadow-lg), 0 0 0 1px hsl(230 80% 68% / 20%);
}

.quiz-card:hover::before { opacity: 1; }

.quiz-card:nth-child(2) { animation-delay: 60ms; }
.quiz-card:nth-child(3) { animation-delay: 120ms; }
.quiz-card:nth-child(4) { animation-delay: 180ms; }
.quiz-card:nth-child(5) { animation-delay: 240ms; }
.quiz-card:nth-child(n+6) { animation-delay: 300ms; }

.quiz-card h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--text);
}

.quiz-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.quiz-meta,
.history-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.quiz-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-weight: 600;
}

.history-row {
  width: 100%;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--surface-soft), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.history-row strong { color: var(--primary); }

.quiz-card .button { margin-top: auto; }

/* ─── Panels (Quiz Start / Result) ─────────────────────────── */
.panel,
.question-card,
.result-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 38px);
}

.start-details {
  margin: 20px 0;
  padding: 14px 18px;
  background: var(--primary-lite);
  border: 1.5px solid hsl(230 70% 85%);
  border-radius: var(--radius);
  color: var(--primary-dark);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="dark"] .start-details {
  border-color: hsl(230 50% 28%);
  color: var(--primary);
}

.quiz-settings {
  display: grid;
  gap: 14px;
  margin: 22px 0;
  padding: 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.check-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid transparent;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.check-row:hover { 
  border-color: var(--border-2);
  box-shadow: var(--shadow-sm);
}

.setting-text { font-size: 0.95rem; font-weight: 600; color: var(--text); }

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-2);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .slider { background-color: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ─── Buttons ───────────────────────────────────────────────── */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.button {
  min-height: 46px;
  padding: 10px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px var(--primary-glow), 0 1px 3px rgba(0,0,0,0.1);
  transition:
    background var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

/* Shimmer effect on hover */
.button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.button:hover::after { transform: translateX(100%); }

.button:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px var(--primary-glow), 0 2px 6px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.button:active { transform: translateY(0); box-shadow: 0 2px 8px var(--primary-glow); }

.button.secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.button.secondary:hover {
  background: var(--surface-soft);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.button.danger {
  background: var(--danger);
  box-shadow: 0 4px 14px var(--danger-ring);
}
.button.danger:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px var(--danger-ring);
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.button:disabled::after { display: none; }

/* ─── Quiz Layout (2-column) ────────────────────────────────── */
.quiz-layout {
  width: min(1200px, calc(100vw - 32px));
  margin-left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: start;
  gap: 24px;
}

/* ─── Question Card ─────────────────────────────────────────── */
.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.quiz-topbar strong {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz-topbar .muted {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 3px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 99px;
}

/* ─── Progress Bar ──────────────────────────────────────────── */
.progress {
  height: 6px;
  width: 100%;
  background: var(--surface-2);
  border-radius: 99px;
  margin-bottom: 26px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), hsl(260 70% 62%));
  background-size: 200% 100%;
  animation: progress-glow 2.5s ease-in-out infinite;
  transition: width 0.25s ease;
}

/* ─── Question Text ─────────────────────────────────────────── */
.question-text {
  margin: 0 0 22px;
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  font-weight: 700;
  line-height: 1.55;
  color: var(--text);
  animation: question-copy-enter 0.4s 40ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Answer Options ────────────────────────────────────────── */
.answers {
  display: grid;
  gap: 10px;
  border: 0;
  padding: 0;
  margin: 0;
}

.answer-option {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  animation: answer-enter 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition:
    border-color var(--transition),
    background var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.answer-option:nth-child(1) { animation-delay: 70ms; }
.answer-option:nth-child(2) { animation-delay: 120ms; }
.answer-option:nth-child(3) { animation-delay: 170ms; }
.answer-option:nth-child(4) { animation-delay: 220ms; }

.answer-option:hover {
  border-color: var(--primary);
  background: var(--primary-lite);
  transform: translateX(4px);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.answer-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-lite);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 4px 16px var(--primary-glow);
}

.answer-option:has(input:disabled) { cursor: default; }
.answer-option:has(input:disabled):hover { transform: none; }

.answer-option.correct-answer,
.answer-option.correct-answer:has(input:checked) {
  border-color: var(--success);
  background: var(--success-bg);
  box-shadow: 0 0 0 3px var(--success-ring), 0 4px 16px var(--success-ring);
}

.answer-option.wrong-answer,
.answer-option.wrong-answer:has(input:checked) {
  border-color: var(--danger);
  background: var(--danger-bg);
  box-shadow: 0 0 0 3px var(--danger-ring);
}

.answer-option input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.answer-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 900;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.answer-option:has(input:checked) .answer-letter {
  background: var(--primary);
  color: #fff;
}

.answer-option.correct-answer .answer-letter {
  background: var(--success);
  color: #fff;
}

.answer-option.wrong-answer .answer-letter {
  background: var(--danger);
  color: #fff;
}

/* ─── Instant Feedback ──────────────────────────────────────── */
.instant-feedback {
  margin-top: 16px;
  padding: 16px 20px;
  border: 1.5px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  animation: feedback-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  font-size: 0.92rem;
}

.instant-feedback p { margin: 8px 0 0; line-height: 1.6; }

.instant-feedback.feedback-correct {
  border-left-color: var(--success);
  background: var(--success-bg);
  color: hsl(158 64% 22%);
}

[data-theme="dark"] .instant-feedback.feedback-correct { color: hsl(158 60% 68%); }

.instant-feedback.feedback-incorrect {
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: hsl(4 74% 30%);
}

[data-theme="dark"] .instant-feedback.feedback-incorrect { color: hsl(4 80% 68%); }

/* ─── Question Nav ──────────────────────────────────────────── */
.question-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  animation: nav-enter 0.4s 210ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.question-nav .right-actions { display: flex; gap: 10px; }

/* Question slide animations */
.question-card.is-next     { animation: question-next     0.42s cubic-bezier(0.22,1,0.36,1) both; }
.question-card.is-previous { animation: question-previous 0.42s cubic-bezier(0.22,1,0.36,1) both; }
.question-card.is-stay     { animation: feedback-view-enter 0.25s ease-out both; }

/* ─── Question Picker (Sidebar) ─────────────────────────────── */
.question-picker {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
  padding: 18px;
  overflow-y: auto;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.question-picker-heading {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.question-picker-heading h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.question-picker-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

.question-picker-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-dot.answered  { background: var(--success); }
.legend-dot.unanswered { background: var(--danger); }

.question-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 36px);
  justify-content: space-between;
  gap: 8px 4px;
}

.question-picker-item {
  width: 36px;
  height: 36px;
  min-width: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid;
  border-radius: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform var(--transition-bounce), box-shadow var(--transition), filter var(--transition);
}

.question-picker-item.is-answered {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.question-picker-item.is-unanswered {
  border-color: var(--border-2);
  background: var(--surface-soft);
  color: var(--muted);
}

.question-picker-item:hover {
  transform: translateY(-2px) scale(1.08);
  filter: brightness(1.06);
}

.question-picker-item.is-current {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4.5px var(--primary);
}

.question-picker-item:focus-visible {
  outline: 3px solid var(--primary-glow);
  outline-offset: 2px;
}

/* ─── Score / Result ────────────────────────────────────────── */
.score-block {
  margin: 20px 0 28px;
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary-lite), var(--surface-soft));
  border: 1.5px solid hsl(230 60% 85%);
  text-align: center;
}

[data-theme="dark"] .score-block {
  background: linear-gradient(135deg, var(--primary-lite), var(--surface-2));
  border-color: hsl(230 50% 28%);
}

.score-number {
  display: block;
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text);
  animation: score-pop 0.5s 0.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.score-percent {
  display: block;
  margin-top: 4px;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
}

.score-block > p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ─── Result List ───────────────────────────────────────────── */
.result-list {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.result-item {
  padding: 18px 20px;
  border: 1.5px solid var(--border);
  border-left-width: 5px;
  border-radius: var(--radius);
  animation: result-enter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform var(--transition), box-shadow var(--transition);
}

.result-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.result-item:nth-child(2)  { animation-delay: 50ms; }
.result-item:nth-child(3)  { animation-delay: 100ms; }
.result-item:nth-child(4)  { animation-delay: 150ms; }
.result-item:nth-child(5)  { animation-delay: 200ms; }
.result-item:nth-child(n+6){ animation-delay: 250ms; }

.result-item.correct  { border-left-color: var(--success); background: var(--success-bg); }
.result-item.incorrect{ border-left-color: var(--danger);  background: var(--danger-bg);  }

.result-item h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.result-item p { margin: 5px 0; font-size: 0.88rem; line-height: 1.6; }

.result-status { font-weight: 800; font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
.correct  .result-status { color: var(--success); }
.incorrect .result-status { color: var(--danger); }

.explanation {
  margin-top: 12px !important;
  padding-top: 12px;
  border-top: 1px solid hsl(220 14% 55% / 20%);
  color: var(--text-2);
  font-size: 0.86rem !important;
}

/* ─── Status Card (Loading / Error / Empty) ─────────────────── */
.status-card,
.donate-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.status-card {
  padding: 48px 32px;
  text-align: center;
}

.status-card.error {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.status-card p { margin: 8px 0; color: var(--muted); }
.status-card.error p { color: var(--danger); opacity: 0.8; }

.empty-state {
  grid-column: 1 / -1;
  border-style: dashed;
  box-shadow: none;
  background: transparent;
}

/* ─── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ─── Donate Box ────────────────────────────────────────────── */
.donate-box {
  margin-top: 28px;
  padding: 22px 24px;
  background: linear-gradient(135deg, var(--warning-bg), var(--surface));
  border-color: hsl(38 80% 80%);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .donate-box {
  border-color: hsl(38 60% 25%);
  background: linear-gradient(135deg, var(--warning-bg), var(--surface));
}

.donate-box::after {
  content: "☕";
  position: absolute;
  right: -8px;
  bottom: -14px;
  font-size: 5rem;
  opacity: 0.06;
  pointer-events: none;
}

.donate-box p { margin: 0 0 14px; font-size: 0.9rem; color: var(--text-2); }

.support-links {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.support-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.support-links a:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* ─── Pagination ────────────────────────────────────────────── */
.pagination {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 24px;
}

.pagination[hidden] { display: none; }

.pagination span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ─── Footer ────────────────────────────────────────────────── */
.site-footer {
  padding: 20px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ─── Back to Top ───────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--primary-glow);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all var(--transition);
  font-size: 1.1rem;
  font-weight: 700;
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px var(--primary-glow);
}

/* ─── Keyframes ─────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes view-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes result-enter {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes score-pop {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes progress-glow {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

@keyframes question-next {
  from { opacity: 0; transform: translateX(22px) scale(0.99); }
  to   { opacity: 1; transform: translateX(0)   scale(1);    }
}

@keyframes question-previous {
  from { opacity: 0; transform: translateX(-22px) scale(0.99); }
  to   { opacity: 1; transform: translateX(0)     scale(1);    }
}

@keyframes question-copy-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

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

@keyframes nav-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

@keyframes feedback-enter {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes feedback-view-enter {
  from { opacity: 0.7; }
  to   { opacity: 1;   }
}

/* ─── Custom Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .quiz-layout {
    width: 100%;
    margin-left: 0;
    transform: none;
    grid-template-columns: minmax(0, 1fr);
  }

  .question-picker {
    position: static;
    max-height: none;
  }

  .question-picker-grid {
    grid-template-columns: repeat(auto-fill, 36px);
    justify-content: start;
    gap: 8px;
  }
}

@media (max-width: 560px) {
  .container { width: min(100% - 24px, 940px); }

  main.container { padding-top: 24px; }

  .page-heading h1 { -webkit-text-fill-color: var(--text); color: var(--text); }

  .question-nav,
  .question-nav .right-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .question-nav { grid-template-columns: 1fr; }
  .question-nav .button, .button-row .button { flex: 1 1 100%; }

  .quiz-card:hover   { transform: none; }
  .answer-option:hover { transform: none; }
  .question-picker-item:hover { transform: none; }
  .result-item:hover { transform: none; }

  .home-tools { padding: 16px; }

  .pagination {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .pagination span { grid-column: 1 / -1; grid-row: 1; text-align: center; }

  @media (min-width: 680px) {
    .quiz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
}

/* ─── Reduced Motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ─── QUIZ TIMER ────────────────────────────────────────────────────────────── */
.quiz-timer {
  position: fixed;
  top: 80px;
  right: 20px;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  transition: all 0.3s ease;
  animation: slideInDown 0.4s ease-out;
}

.quiz-timer.danger {
  color: var(--danger);
  animation: pulseDanger 1s infinite;
}

@keyframes slideInDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pulseDanger {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@media (max-width: 600px) {
  .quiz-timer {
    top: 70px;
    right: 10px;
    font-size: 1.1rem;
    padding: 8px 16px;
  }
}
