@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@400;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-sans: "Space Grotesk", "Trebuchet MS", sans-serif;
  --bg: #f5efe6;
  --bg-2: #e6f4ee;
  --ink: #1d2b25;
  --ink-muted: #5e6c65;
  --card: #fffaf3;
  --accent: #f06a4f;
  --accent-2: #1b7b6a;
  --accent-3: #d5b16b;
  --shadow: 0 20px 40px rgba(23, 34, 30, 0.1);
  --border: rgba(29, 43, 37, 0.12);
}

body[data-theme="dark"] {
  --bg: #0d1413;
  --bg-2: #182421;
  --ink: #f3f6f2;
  --ink-muted: #b8c3bd;
  --card: #17201e;
  --accent: #f47a5c;
  --accent-2: #36bfa7;
  --accent-3: #d4b06b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --border: rgba(243, 246, 242, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--ink);
  background: linear-gradient(120deg, var(--bg), var(--bg-2) 55%, #f3e6cf);
  background-attachment: fixed;
}

body[data-theme="dark"] {
  background: linear-gradient(120deg, var(--bg), var(--bg-2) 55%, #0b1211);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.glow {
  position: absolute;
  width: 46vw;
  height: 46vw;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  mix-blend-mode: multiply;
}

.glow-1 {
  top: -10%;
  left: -15%;
  background: #ffd7b0;
}

.glow-2 {
  top: 10%;
  right: -10%;
  background: #b7e6d5;
}

.glow-3 {
  bottom: -25%;
  left: 30%;
  background: #f7aa97;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.5) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.4) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.25;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 32px;
  align-items: start;
}

.hero-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 4.2vw, 4rem);
  margin: 0.2rem 0 1rem;
  letter-spacing: 0.01em;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin: 0 0 0.3rem;
}

.lead {
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 44ch;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 24px 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-bottom: 18px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: rgba(29, 43, 37, 0.2);
  border-radius: 999px;
  transition: background 0.2s ease;
  border: 1px solid var(--border);
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 4px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background: rgba(27, 123, 106, 0.6);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: #fef3e6;
}

.name-field {
  margin-top: 16px;
  display: grid;
  gap: 8px;
  max-width: 320px;
}

.name-field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
}

.name-field input {
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.9);
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #f49b63);
  color: #fff;
  box-shadow: 0 15px 30px rgba(240, 106, 79, 0.35);
}

.btn.primary#next-question {
  background: linear-gradient(135deg, var(--accent-2), #55d3b5);
  box-shadow: 0 15px 30px rgba(27, 123, 106, 0.35);
}

.btn.primary:hover {
  transform: translateY(-2px);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--border);
  color: var(--ink);
}

.btn.ghost:disabled,
.btn.primary:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
}

.hud-value {
  font-size: 1.2rem;
  font-weight: 600;
}

.stats-card {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stats-card h2 {
  font-family: var(--font-display);
  margin-top: 0;
  margin-bottom: 10px;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.stat-block {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 4px;
}

.history h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
}

.history-list li {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(29, 43, 37, 0.06);
}

.quiz {
  margin-top: 48px;
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.subtle {
  color: var(--ink-muted);
  margin: 6px 0 0;
}

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  width: 180px;
  height: 10px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(120deg, var(--accent-2), #33b49a);
  transition: width 0.2s ease;
}

.progress-text {
  font-weight: 600;
}

.status {
  margin-top: 20px;
  color: var(--ink-muted);
}

.question-stage {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.question-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(27, 42, 35, 0.08);
  animation: rise 0.45s ease both;
  animation-delay: var(--delay, 0s);
}

.question-card.is-correct {
  border-color: rgba(27, 123, 106, 0.5);
}

.question-card.is-wrong {
  border-color: rgba(240, 106, 79, 0.5);
}

.question-card.is-unanswered {
  border-color: rgba(213, 177, 107, 0.6);
}

.question-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.question-label {
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.question-head h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
}

.feedback {
  min-height: 28px;
  font-weight: 600;
  color: var(--ink-muted);
}

.feedback.correct {
  color: var(--accent-2);
}

.feedback.wrong {
  color: var(--accent);
}

.feedback.done {
  color: var(--ink);
}

.options {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.option:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(29, 43, 37, 0.08);
}

.option.is-locked {
  cursor: default;
}

.option.is-locked:hover {
  transform: none;
  box-shadow: none;
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-ui {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(29, 43, 37, 0.35);
  display: inline-block;
  position: relative;
}

.option input:checked + .option-ui {
  border-color: var(--accent-2);
  background: radial-gradient(circle, var(--accent-2) 55%, transparent 60%);
  box-shadow: 0 0 0 4px rgba(27, 123, 106, 0.12);
}

.option-text {
  font-size: 0.98rem;
  line-height: 1.5;
}

.option.is-correct {
  border-color: rgba(27, 123, 106, 0.6);
  background: rgba(27, 123, 106, 0.08);
}

.option.is-wrong {
  border-color: rgba(240, 106, 79, 0.6);
  background: rgba(240, 106, 79, 0.08);
}

.footer {
  margin-top: 48px;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.question-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

body[data-theme="dark"] .grid-overlay {
  background-image: linear-gradient(
      rgba(0, 0, 0, 0.4) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(0, 0, 0, 0.35) 1px, transparent 1px);
}

body[data-theme="dark"] .stats-card,
body[data-theme="dark"] .question-card {
  background: rgba(23, 32, 30, 0.92);
}

body[data-theme="dark"] .hud {
  background: rgba(20, 28, 26, 0.85);
}

body[data-theme="dark"] .progress-bar {
  background: rgba(20, 28, 26, 0.85);
}

body[data-theme="dark"] .btn.ghost {
  background: rgba(15, 20, 19, 0.9);
}

body[data-theme="dark"] .option {
  background: rgba(15, 20, 19, 0.9);
}

body[data-theme="dark"] .option-ui {
  border-color: rgba(243, 246, 242, 0.4);
}

body[data-theme="dark"] .slider {
  background: rgba(243, 246, 242, 0.25);
}

body[data-theme="dark"] .btn.primary {
  background: linear-gradient(135deg, #2fb69d, #2a6e5f);
  box-shadow: 0 15px 30px rgba(47, 182, 157, 0.35);
}

body[data-theme="dark"] #next-question {
  background: linear-gradient(135deg, #f47a5c, #f0b069);
  box-shadow: 0 15px 30px rgba(244, 122, 92, 0.35);
}

body[data-theme="dark"] .question-label {
  background: #23332f;
  color: #f3f6f2;
}

body[data-theme="dark"] .history-list li {
  background: rgba(255, 255, 255, 0.08);
}

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

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

  .stats-card {
    order: -1;
  }

  .name-field {
    max-width: 100%;
  }

  .progress {
    width: 100%;
    justify-content: space-between;
  }

  .progress-bar {
    flex: 1;
  }
}

@media (max-width: 600px) {
  .question-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .question-nav .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
