/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f5f3ee;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── SCREENS ── */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ── HOME ── */
#homeScreen {
  background: #0f1e35;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.home-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
  max-width: 800px;
  width: 100%;
}

.badge {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e8b84b;
  border: 1px solid rgba(200,146,42,0.4);
  padding: 0.3rem 0.9rem;
  border-radius: 2rem;
  display: inline-block;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  color: #f8f4ed;
  line-height: 1.1;
}

h1 .accent { color: #e8b84b; font-style: italic; }

.subtitle { color: rgba(248,244,237,0.55); font-size: 0.95rem; }

/* ── TOPIC GRID ── */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.5rem;
  width: 100%;
}

.topic-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(200,146,42,0.2);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: rgba(248,244,237,0.65);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
  position: relative;
}

.topic-pill:hover {
  background: rgba(200,146,42,0.12);
  border-color: #c8922a;
  color: #f8f4ed;
}

.topic-pill.selected {
  background: rgba(200,146,42,0.2);
  border-color: #e8b84b;
  color: #e8b84b;
}

.topic-pill .weak-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e24b4a;
}

/* ── BUTTONS ── */
.btn-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-primary {
  background: #c8922a;
  color: #0f1e35;
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-primary:hover { background: #e8b84b; }

.btn-ghost {
  background: transparent;
  color: #f8f4ed;
  border: 1px solid rgba(248,244,237,0.3);
  padding: 0.75rem 1.75rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-ghost:hover { border-color: #e8b84b; color: #e8b84b; }
.btn-ghost.dark { color: #0f1e35; border-color: #c5bfb5; }
.btn-ghost.dark:hover { border-color: #0f1e35; background: #f0ead8; }

.btn-sm {
  background: transparent;
  color: rgba(248,244,237,0.5);
  border: 1px solid rgba(248,244,237,0.2);
  padding: 0.4rem 1rem;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-sm:hover { color: #e8b84b; border-color: #e8b84b; }

/* ── STATS ── */
.stats-row {
  display: flex;
  gap: 2.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-num {
  font-size: 2rem;
  font-weight: 400;
  color: #e8b84b;
}

.stat-label {
  font-size: 0.68rem;
  color: rgba(248,244,237,0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.2rem;
}

.io-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ── QUIZ HEADER ── */
.quiz-header {
  background: #0f1e35;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.quiz-topic {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e8b84b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #c8922a;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.quiz-counter {
  font-size: 0.78rem;
  color: rgba(248,244,237,0.5);
  white-space: nowrap;
}

.btn-quit {
  background: none;
  border: 1px solid rgba(248,244,237,0.2);
  color: rgba(248,244,237,0.5);
  padding: 0.3rem 0.65rem;
  border-radius: 0.35rem;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-quit:hover { border-color: #e8b84b; color: #e8b84b; }

/* ── QUIZ BODY ── */
#quizScreen { background: #f5f3ee; }

.quiz-body {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-tag {
  display: inline-block;
  background: #1a2e4a;
  color: #e8b84b;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: 2rem;
}

.question-text {
  font-size: clamp(1.05rem, 2.5vw, 1.3rem);
  font-weight: 500;
  color: #0f1e35;
  line-height: 1.5;
}

/* ── OPTIONS ── */
.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-btn {
  background: white;
  border: 1.5px solid #e5e0d5;
  border-radius: 0.6rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  color: #1a1a2e;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  line-height: 1.5;
  transition: all 0.15s;
  width: 100%;
}

.option-btn:hover:not(:disabled) { border-color: #c8922a; background: #fffdf7; }
.option-btn:disabled { cursor: default; }

.option-btn.correct { border-color: #2d7a4f; background: #e8f5ee; color: #1a5c35; font-weight: 500; }
.option-btn.incorrect { border-color: #c0392b; background: #fdecea; color: #8b1a1a; }
.option-btn.reveal { border-color: #2d7a4f; background: #e8f5ee; color: #1a5c35; font-weight: 500; }

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  background: #f0ead8;
  font-size: 0.7rem;
  font-weight: 700;
  color: #888;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
}

.option-btn.correct .option-letter { background: #2d7a4f; color: white; }
.option-btn.incorrect .option-letter { background: #c0392b; color: white; }
.option-btn.reveal .option-letter { background: #2d7a4f; color: white; }

/* ── FEEDBACK ── */
.feedback-box {
  display: none;
  border-radius: 0.6rem;
  padding: 1rem 1.1rem;
  border-left: 4px solid;
  flex-direction: column;
  gap: 0.5rem;
}

.feedback-box.correct { background: #e8f5ee; border-color: #2d7a4f; }
.feedback-box.incorrect { background: #fdecea; border-color: #c0392b; }

.feedback-header {
  font-weight: 700;
  font-size: 0.85rem;
}

.feedback-box.correct .feedback-header { color: #1a5c35; }
.feedback-box.incorrect .feedback-header { color: #8b1a1a; }

.feedback-rationale {
  font-size: 0.87rem;
  color: #1a1a2e;
  line-height: 1.6;
}

.feedback-tip {
  font-size: 0.8rem;
  color: #7a5000;
  background: rgba(200,146,42,0.1);
  border-radius: 0.4rem;
  padding: 0.5rem 0.75rem;
  line-height: 1.5;
}

/* ── QUIZ NAV ── */
.quiz-nav { display: flex; justify-content: flex-end; margin-top: auto; padding-top: 0.5rem; }

.btn-next {
  display: none;
  background: #0f1e35;
  color: #f8f4ed;
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-next:hover { background: #1a2e4a; }

/* ── RESULTS ── */
#resultsScreen {
  background: #0f1e35;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1.5rem;
  overflow-y: auto;
}

.results-card {
  background: #f8f4ed;
  border-radius: 1rem;
  padding: 2rem;
  max-width: 660px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.results-title {
  font-size: 1.6rem;
  font-weight: 400;
  color: #0f1e35;
  text-align: center;
}

.results-sub {
  text-align: center;
  color: #6b7280;
  font-size: 0.85rem;
}

/* ── SCORE RING ── */
.score-ring-wrap { display: flex; justify-content: center; }

.score-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.score-ring::after {
  content: '';
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #f8f4ed;
  z-index: 1;
}

.score-inner {
  position: relative;
  z-index: 2;
  text-align: center;
}

.score-pct {
  font-size: 1.5rem;
  font-weight: 500;
  color: #0f1e35;
  line-height: 1;
}

.score-label {
  font-size: 0.65rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── BREAKDOWN ── */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.breakdown-item {
  background: white;
  border-radius: 0.6rem;
  padding: 0.75rem;
  text-align: center;
  border: 1px solid #e5e0d5;
}

.breakdown-num { font-size: 1.5rem; font-weight: 500; }
.breakdown-num.green { color: #2d7a4f; }
.breakdown-num.red { color: #c0392b; }
.breakdown-num.gold { color: #c8922a; }

.breakdown-label {
  font-size: 0.68rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}

/* ── WEAK TOPICS ── */
.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #999;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.weak-topic-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #fff5f5;
  border: 1px solid #fdd;
  border-radius: 0.4rem;
  margin-bottom: 0.4rem;
  font-size: 0.83rem;
}

.weak-count {
  font-size: 0.72rem;
  color: #c0392b;
  background: #fdecea;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-weight: 600;
}

/* ── MISSED QUESTIONS ── */
.missed-section { max-height: 340px; overflow-y: auto; }

.missed-item {
  background: white;
  border: 1px solid #e5e0d5;
  border-radius: 0.6rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.missed-q { font-size: 0.85rem; font-weight: 600; color: #0f1e35; line-height: 1.4; }
.missed-yours { font-size: 0.78rem; color: #c0392b; }
.missed-correct { font-size: 0.78rem; color: #2d7a4f; font-weight: 500; }
.missed-tip { font-size: 0.75rem; color: #7a5000; background: rgba(200,146,42,0.08); border-radius: 0.35rem; padding: 0.45rem 0.65rem; line-height: 1.5; }

/* ── RESULTS ACTIONS ── */
.results-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.results-actions .btn-primary { flex: 1; min-width: 130px; text-align: center; }
.results-actions .btn-ghost { flex: 1; min-width: 130px; text-align: center; }
