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

:root {
  --cream: #e2e2e2;
  --ink: #010000;
  --ink-muted: #6b6560;
  --ink-light: #a09990;
  --accent: #fa271b;
  --accent-bg: #ebebeb;
  --correct: #36c445;
  --correct-bg: #ebf5f0;
  --wrong: #fa271b;
  --wrong-bg: #faede9;
  --border: rgba(26, 23, 20, 0.12);

  --radius: 12px;
  --radius-lg: 20px;
}

html {
  font-size: 100%;
}

body {
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-size: 1.6rem;
  -webkit-font-smoothing: antialiased;
}

/* ── Background grid ──────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  z-index: 0;
}

/* ── Shell ────────────────────────────────────── */
.quiz-shell {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.screen {
  width: 70%;
  max-width: 50rem;
  animation: screenIn 0.35s ease both;
}

.hidden {
  display: none !important;
}

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

/* ── Start screen ─────────────────────────────── */
.start-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.start-image {
  width: 30rem;
  height: auto;
}

.start-badge {
  display: inline-block;

  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);

  border-radius: 999px;
  padding: 4px 14px;
  margin-bottom: 2rem;
}

.start-title {
  font-size: clamp(2.8rem, 8vw, 3rem);
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.start-title em {
  font-style: italic;
  color: var(--accent);
}

.start-sub {
  font-size: 13px;
  color: var(--ink-muted);
  letter-spacing: 0.03em;
  margin-bottom: 2.5rem;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--cream);

  font-size: 1.4rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  padding: 14px 32px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s;
}

.btn-start:hover {
  background: #3a3530;
}
.btn-start:active {
  transform: scale(0.97);
}

.start-description {
  display: block;
  margin: 0 auto;
  text-align: center;
  margin-top: 2rem;
  color: var(--ink);
  font-size: 1.3rem;
}

.start-link {
  color: var(--accent);
  text-decoration: underline;
  font-weight: bold;
}

/* ── Question screen ──────────────────────────── */
.q-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 2.5rem;
}

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

.q-progress-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.q-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.q-counter {
  font-size: 12px;
  /* color: var(--ink-light); */

  letter-spacing: 0.05em;
  white-space: nowrap;
}

.q-score-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--correct);
  background: var(--correct-bg);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.q-body {
  margin-bottom: 2rem;
  width: 100%;
}

.q-num {
  font-size: 5rem;
  /* color: var(--border); */
  color: #fff;
  line-height: 1;
  margin-bottom: 0.5rem;
  user-select: none;
}

.q-text {
  font-size: clamp(3vw, 1.7rem);
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink);
}

.q-text.fade-in {
  animation: fadeUp 0.3s ease both;
}

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

.q-image {
  width: 60%;
  height: auto;
  border-radius: var(--radius);
  object-fit: cover;
}

.q-question {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* ── Options ──────────────────────────────────── */
.options {
  width: 80%;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 auto;
}

.options li {
  animation: fadeUp 0.3s ease both;
}

.option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;

  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;

  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.12s;
}

.option-btn:hover:not(:disabled) {
  border-color: rgba(26, 23, 20, 0.3);
  transform: translateX(3px);
}

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

.opt-content img {
  width: 40%;
  height: auto;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
}

.opt-content {
  font-size: 1.2rem;
}

.opt-label {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--cream);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

/* Correct */
.option-btn.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}
.option-btn.correct .opt-label {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

/* Wrong */
.option-btn.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}
.option-btn.wrong .opt-label {
  background: var(--wrong);
  border-color: var(--wrong);
  color: #fff;
}

/* Reveal the right answer */
.option-btn.reveal-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}
.option-btn.reveal-correct .opt-label {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

/* ── Next button ──────────────────────────────── */
.btn-next {
  margin: 0 auto;
  margin-top: 1.25rem;
  display: block;
  width: 40%;
  background: var(--ink);
  color: var(--cream);

  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.12s;
  animation: fadeUp 0.25s ease both;
}

.btn-next:hover {
  background: #3a3530;
}
.btn-next:active {
  transform: scale(0.98);
}

/* ── Results screen ───────────────────────────── */
.results-inner {
  text-align: center;
  padding: 1rem 0;
}

.results-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-light);
  margin-bottom: 1rem;
}

.results-score {
  font-size: clamp(4rem, 16vw, 7rem);
  line-height: 1;
  color: var(--ink);
  margin-bottom: 1.5rem;
}

.score-denom {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  color: var(--ink-light);
  margin-left: 8px;
}

.results-msg {
  font-size: clamp(1.1rem, 3.5vw, 1.4rem);
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
  font-style: italic;
}

.results-image {
  width: 100%;
  max-width: 28rem;
  margin: 1.5rem auto;
  display: block;
  border-radius: var(--radius);
  object-fit: cover;
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--cream);
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  padding: 12px 28px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.12s;
}

.btn-download:hover {
  background: #3a3530;
}

.btn-download:active {
  transform: scale(0.97);
}

.btn-restart {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 28px;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.12s;
}

.btn-restart:hover {
  background: #fff;
  border-color: rgba(26, 23, 20, 0.3);
}
.btn-restart:active {
  transform: scale(0.97);
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 769px) {
  html {
    font-size: 50%;
  }

  .screen {
    margin-top: 5rem;
    width: 100%;
  }

  .start-header {
    margin-top: 1rem;
    flex-direction: column;
    gap: 2rem;
  }

  .start-image {
    width: 100%;
    max-width: 32rem;
  }

  .start-title,
  .start-badge {
    display: block;
    text-align: center;
  }

  .btn-start {
    display: block;
    margin: 0 auto;
    margin-top: 3rem;
  }

  .start-description {
    font-size: 2.2rem;
    width: 70%;
  }

  .quiz-shell {
    align-items: flex-start;
    padding-top: 3rem;
  }

  .q-body,
  .options,
  .btn-next {
    margin: 0 auto;
  }

  .options {
    margin-bottom: 2rem;
  }

  .q-num {
    font-size: 36px;
  }

  .q-question {
    flex-direction: column;
  }

  .q-image {
    margin-bottom: 1.25rem;
    width: 80%;
  }

  .opt-content {
    display: flex;
    align-items: center;
    gap: 1rem;
  }
}

/* Preview page styles */
.preview-page {
  min-height: 100vh;
  padding: 2rem 1rem;
  background: var(--cream);
}

.preview-page__inner {
  width: min(100%, 70rem);
  margin: 0 auto;
}

.preview-title {
  font-size: clamp(2.2rem, 4vw, 3rem);
  margin-bottom: 0.5rem;
  color: var(--ink);
}

.preview-summary {
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.toolbar label {
  font-size: 1rem;
  color: var(--ink);
}

.toolbar input {
  width: 6rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
}

.toolbar button {
  background: var(--ink);
  color: var(--cream);
  border: none;
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  transition: background 0.2s;
}

.toolbar button:hover {
  background: #3a3530;
}

.preview-list {
  display: grid;
  gap: 1.5rem;
}

.preview-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.05);
}

.preview-card.active {
  border-color: var(--accent);
  box-shadow: 0 16px 32px rgba(26, 23, 20, 0.08);
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.preview-meta span {
  font-weight: 700;
  color: var(--accent);
}

.preview-question {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  color: var(--ink);
}

.preview-image {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.preview-options {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.preview-option {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--accent-bg);
}

.preview-option-label {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  flex-shrink: 0;
}

.preview-option-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-option-text {
  margin: 0;
  color: var(--ink);
}

.preview-option-image {
  width: 100%;
  max-width: 24rem;
  border-radius: var(--radius);
  object-fit: cover;
}

.message {
  color: #d32f2f;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar input,
  .toolbar button {
    width: 100%;
  }
}
