:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --correct: #16a34a;
  --correct-bg: #dcfce7;
  --wrong: #dc2626;
  --wrong-bg: #fee2e2;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 3rem;
}

.site-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 1.5rem 1rem 1.25rem;
  text-align: center;
}

.site-header h1 {
  margin: 0.25rem 0;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0.25rem 0 0;
  opacity: 0.9;
  font-size: 0.95rem;
}

.back-link {
  display: inline-block;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.back-link:hover { text-decoration: underline; }

.progress-bar {
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  height: 8px;
  max-width: 480px;
  margin: 0.75rem auto 0;
  overflow: hidden;
}

.progress-fill {
  background: #fff;
  height: 100%;
  width: 0%;
  transition: width 0.25s ease;
}

.progress-text {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

main {
  max-width: 640px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.loading { text-align: center; color: var(--muted); }

/* Chapter list */
.chapter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.chapter-card .chapter-info h2 {
  margin: 0 0 0.2rem;
  font-size: 1.1rem;
}

.chapter-card .chapter-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.secondary:hover { background: #eef2ff; }

/* Question card */
.question-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.question-number {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.question-text {
  font-size: 1.08rem;
  line-height: 1.45;
  margin: 0.4rem 0 1rem;
}

.question-image {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  margin: 0 auto 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.extra-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.extra-images figure {
  margin: 0;
  text-align: center;
}

.extra-images img {
  width: 100px;
  height: 70px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.extra-images figcaption {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.options {
  display: grid;
  gap: 0.6rem;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  font-size: 0.98rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #eef2ff;
}

.option-btn .option-letter {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}

.option-btn img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  flex: 0 0 auto;
}

.option-btn .option-label {
  flex: 1 1 auto;
}

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

.option-btn.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}
.option-btn.correct .option-letter { background: var(--correct); color: #fff; }

.option-btn.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}
.option-btn.wrong .option-letter { background: var(--wrong); color: #fff; }

.feedback {
  margin-top: 0.9rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
}
.feedback.correct { background: var(--correct-bg); color: var(--correct); }
.feedback.wrong { background: var(--wrong-bg); color: var(--wrong); }

.actions {
  margin-top: 1.1rem;
  text-align: right;
}

/* Review / results */
.score-banner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.score-banner .score-big {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary);
}

.review-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}

.review-item .review-q {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.review-line { font-size: 0.92rem; margin: 0.2rem 0; }
.review-line.your-correct { color: var(--correct); }
.review-line.your-wrong { color: var(--wrong); }
.review-line.correct-answer { color: var(--muted); }

.review-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2rem;
}

/* Character rewards */
.characters-link {
  margin-top: 0.75rem;
}

.character-popup {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  transform: translateY(0);
  background: #ffffff;
  border-bottom: 4px solid var(--primary);
  border-radius: 0 0 20px 20px;
  padding: 1.4rem 1.5rem 1.6rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  z-index: 1000;
  animation: character-pop-in 0.35s ease;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.character-popup.character-popup-hide {
  opacity: 0;
  transform: translateY(-20px);
}

.character-popup-emoji {
  font-size: 4.5rem;
  line-height: 1;
}

.character-popup-text {
  margin-top: 0.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 1.3rem;
}

@media (min-width: 720px) {
  .character-popup {
    top: 1.5rem;
    right: 1.5rem;
    left: auto;
    max-width: 320px;
    border-radius: 20px;
    border: 3px solid var(--primary);
    border-bottom: 3px solid var(--primary);
  }
}

@keyframes character-pop-in {
  0% { transform: translateY(-40px); opacity: 0; }
  60% { transform: translateY(6px); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

.finish-character {
  margin: 1rem 0;
  padding: 0.9rem;
  background: var(--bg);
  border-radius: 12px;
}

.finish-character-emoji {
  font-size: 2.6rem;
}

.finish-character p {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.album-count {
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.8rem;
}

.character-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.5rem;
  text-align: center;
}

.character-tile-emoji {
  font-size: 2.2rem;
}

.character-tile-reason {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--muted);
}
