:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --ink: #1c2130;
  --muted: #5c6478;
  --line: #e2e6ef;
  --brand: #ee1515;
  --brand-dark: #b80f0f;
  --accent: #2a75bb;
  --accent-dark: #1e5a91;
  --good: #2e9e4f;
  --good-bg: #e6f6ec;
  --bad: #d23b3b;
  --bad-bg: #fbe9e9;
  --shadow: 0 8px 30px rgba(20, 26, 48, 0.10);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151d;
    --card: #1b2030;
    --ink: #eef1f8;
    --muted: #9aa3ba;
    --line: #2b3244;
    --good-bg: #16301f;
    --bad-bg: #33191a;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(238, 21, 21, 0.10), transparent 60%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 18px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-title {
  margin: 8px 0 20px;
  text-align: center;
}

.app-logo {
  width: auto;
  height: auto;
  max-width: min(340px, 80%);
  max-height: 200px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(20, 26, 48, 0.18));
}

main { flex: 1; }

/* ---- cards / views ---- */
.view {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.hidden { display: none !important; }

.tagline, .loading {
  color: var(--muted);
  margin-top: 0;
}
.loading { text-align: center; padding: 30px 0; font-size: 1.1rem; }

/* ---- config ---- */
.field { margin-bottom: 22px; }
.field > label {
  display: block;
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.pill-group { display: flex; flex-wrap: wrap; gap: 10px; }
.pill {
  border: 2px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill:hover { border-color: var(--accent); }
.pill.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pill-custom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: text;
}
.pill-custom input {
  width: 48px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}
.pill-custom input::-webkit-outer-spin-button,
.pill-custom input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.92rem;
  user-select: none;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.check.on { border-color: var(--accent); background: rgba(42, 117, 187, 0.06); }

/* ---- buttons ---- */
.primary {
  display: inline-block;
  width: 100%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.primary:hover { background: var(--brand-dark); }
.primary:active { transform: translateY(1px); }
.primary.big { padding: 16px; font-size: 1.15rem; }

/* ---- question ---- */
.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.score-label { font-weight: 700; color: var(--ink); }
.progress-bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--brand));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.question-media {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.question-media img {
  width: 240px;
  max-width: 70%;
  height: 240px;
  object-fit: contain;
  transition: filter 0.6s ease, transform 0.6s ease;
}
/* Silhouette: pure black until revealed */
.question-media.silhouette img {
  filter: brightness(0);
}
.question-media.revealed img {
  filter: none;
  transform: scale(1.04);
}

.quote {
  margin: 0 0 18px;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  background: rgba(42, 117, 187, 0.08);
  border-radius: 8px;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
}
.quote::before { content: "“"; }
.quote::after { content: "”"; }

.prompt {
  font-size: 1.35rem;
  line-height: 1.35;
  margin: 0 0 20px;
  text-align: center;
}

.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  text-align: left;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option .option-note {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.option .marker {
  font-weight: 800;
  font-size: 1.2rem;
}
.option.correct {
  border-color: var(--good);
  background: var(--good-bg);
  color: var(--good);
}
.option.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
}

.feedback {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  text-align: center;
}
.feedback.right { background: var(--good-bg); color: var(--good); }
.feedback.wrong { background: var(--bad-bg); color: var(--bad); }

#next-btn { margin-top: 16px; }

/* ---- results ---- */
.results-title { text-align: center; margin-top: 0; }
.scorecard { text-align: center; margin-bottom: 24px; }
.score-ring {
  width: 150px;
  height: 150px;
  margin: 10px auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--good) var(--pct, 0%), var(--line) 0);
  position: relative;
}
.score-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  background: var(--card);
  border-radius: 50%;
}
.score-ring span {
  position: relative;
  font-size: 2rem;
  font-weight: 800;
}
.score-summary { font-size: 1.2rem; font-weight: 700; margin: 4px 0; }
.score-flavor { color: var(--muted); margin: 0; }

.review {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.review-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.92rem;
}
.review-item .icon { font-size: 1.1rem; line-height: 1.4; }
.review-item.right .icon { color: var(--good); }
.review-item.wrong .icon { color: var(--bad); }
.review-item .q { font-weight: 600; }
.review-item .a { color: var(--muted); margin-top: 2px; }
.review-item .a b { color: var(--good); font-weight: 700; }
.review-item .a .miss { color: var(--bad); font-weight: 700; }

.error { color: var(--bad); font-weight: 600; margin-top: 12px; text-align: center; }

.app-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.app-footer a { color: var(--accent); }

@media (max-width: 480px) {
  .view { padding: 18px; }
  .check-grid { grid-template-columns: 1fr; }
}
