:root {
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-glow: rgba(249, 115, 22, 0.25);
  --success: #22c55e;
  --error: #ef4444;
  --info: #3b82f6;
  --transition-theme: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

html {
  transition: var(--transition-theme);
}

html.dark body {
  background: radial-gradient(ellipse at 50% 0%, #111827 0%, #0a0f1a 70%);
  color: #f1f5f9;
}

html:not(.dark) body {
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 40%);
  color: #0f172a;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
}

.screen-enter {
  animation: screenEnter 0.4s ease forwards;
}

@keyframes screenEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.question-card {
  animation: screenEnter 0.4s ease backwards;
}

.question-card:nth-child(1) { animation-delay: 0ms; }
.question-card:nth-child(2) { animation-delay: 50ms; }
.question-card:nth-child(3) { animation-delay: 100ms; }
.question-card:nth-child(4) { animation-delay: 150ms; }
.question-card:nth-child(5) { animation-delay: 200ms; }
.question-card:nth-child(n+6) { animation-delay: 250ms; }

.glass-card {
  transition: var(--transition-theme);
}

html.dark .glass-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

html:not(.dark) .glass-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 40px -12px rgba(148, 163, 184, 0.35);
}

.option-card {
  min-height: 44px;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}

html.dark .option-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

html:not(.dark) .option-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.option-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.option-card.selected {
  border-color: var(--accent) !important;
  background: rgba(249, 115, 22, 0.1) !important;
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.option-letter {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

html.dark .option-letter {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

html:not(.dark) .option-letter {
  background: #e2e8f0;
  color: #475569;
}

.option-card.selected .option-letter {
  background: var(--accent);
  color: #fff;
}

.option-check {
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.option-card.selected .option-check {
  opacity: 1;
  transform: scale(1);
}

.btn-primary {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 8px 24px -4px rgba(249, 115, 22, 0.45);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -4px rgba(249, 115, 22, 0.55);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary.ready-pulse:not(:disabled) {
  animation: readyPulse 2s ease-in-out infinite;
}

@keyframes readyPulse {
  0%, 100% { box-shadow: 0 8px 24px -4px rgba(249, 115, 22, 0.45); }
  50% { box-shadow: 0 8px 32px 0 rgba(249, 115, 22, 0.65); }
}

.btn-outline {
  transition: var(--transition-theme);
}

html.dark .btn-outline {
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

html.dark .btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
}

html:not(.dark) .btn-outline {
  border: 1px solid #cbd5e1;
  color: #334155;
}

html:not(.dark) .btn-outline:hover {
  background: #f1f5f9;
}

.theme-toggle {
  width: 3.5rem;
  height: 2rem;
  border-radius: 9999px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

html.dark .theme-toggle {
  background: rgba(255, 255, 255, 0.12);
}

html:not(.dark) .theme-toggle {
  background: #e2e8f0;
}

.theme-toggle-knob {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

html.dark .theme-toggle-knob {
  transform: translateX(1.5rem);
  background: #1e293b;
  color: #fbbf24;
}

html:not(.dark) .theme-toggle-knob {
  background: #fff;
  color: #f59e0b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.4s ease;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.stat-pill {
  transition: var(--transition-theme);
}

html.dark .stat-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

html:not(.dark) .stat-pill {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.score-ring-circle {
  transition: stroke-dashoffset 1s ease-out;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.result-item.correct {
  border-left: 3px solid var(--success);
}

.result-item.incorrect {
  border-left: 3px solid var(--error);
}

html.dark .result-item.correct {
  background: rgba(34, 197, 94, 0.08);
}

html.dark .result-item.incorrect {
  background: rgba(239, 68, 68, 0.08);
}

html:not(.dark) .result-item.correct {
  background: rgba(34, 197, 94, 0.06);
}

html:not(.dark) .result-item.incorrect {
  background: rgba(239, 68, 68, 0.06);
}

.badge-pass {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-fail {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

html:not(.dark) .badge-pass {
  color: #15803d;
  background: rgba(34, 197, 94, 0.12);
}

html:not(.dark) .badge-fail {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.1);
}

.question-text {
  font-family: "Source Serif 4", Georgia, serif;
}

.sign-image-wrap {
  transition: var(--transition-theme);
}

html.dark .sign-image-wrap {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

html:not(.dark) .sign-image-wrap {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.progress-bar-fill {
  transition: width 0.4s ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 640px) {
  .progress-ring-desktop {
    display: none;
  }
  .progress-bar-mobile {
    display: block;
  }
}

@media (min-width: 641px) {
  .progress-ring-desktop {
    display: flex;
  }
  .progress-bar-mobile {
    display: none;
  }
}
