:root {
  --bg: #0f1b2b;
  --card: #121f32;
  --accent: #2ed8a4;
  --accent-2: #ffb457;
  --text: #eaf1ff;
  --muted: #9ab0d0;
  --danger: #ff6b6b;
  --shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --transition: 180ms ease;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, rgba(46, 216, 164, 0.08), transparent 30%),
              radial-gradient(circle at 80% 10%, rgba(255, 180, 87, 0.1), transparent 32%),
              radial-gradient(circle at 10% 80%, rgba(255, 107, 107, 0.08), transparent 28%),
              var(--bg);
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: 'Syne', 'DM Sans', sans-serif;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.page {
  display: none;
  min-height: 100vh;
}

.page.active {
  display: grid;
  place-items: center;
  padding: 48px 20px;
}

/* ===== HOME PAGE ===== */
.home-content {
  position: relative;
  width: min(960px, 92vw);
  background: linear-gradient(135deg, rgba(18, 31, 50, 0.9), rgba(18, 31, 50, 0.75));
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 48px 48px 56px;
  overflow: hidden;
}

.home-bg .blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(48px);
  opacity: 0.7;
}

.home-bg .blob1 { width: 320px; height: 320px; background: #2ed8a4; top: -40px; left: -80px; }
.home-bg .blob2 { width: 260px; height: 260px; background: #ffb457; bottom: -60px; right: 40px; }
.home-bg .blob3 { width: 180px; height: 180px; background: #4da1ff; top: 10%; right: 38%; opacity: 0.45; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(46, 216, 164, 0.12);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.home-title {
  font-size: clamp(48px, 6vw, 72px);
  margin: 18px 0 12px;
  letter-spacing: -1px;
}

.home-title span {
  color: var(--accent-2);
}

.home-sub {
  max-width: 640px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.home-stats {
  display: flex;
  gap: 18px;
  margin: 28px 0 36px;
}

.stat {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.stat label {
  font-size: 14px;
  color: var(--muted);
}

.btn-primary,
.btn-secondary,
.btn-skip {
  border-radius: 12px;
  padding: 14px 22px;
  font-weight: 700;
  font-size: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #29c18f);
  color: #0b121f;
  box-shadow: 0 15px 30px rgba(46, 216, 164, 0.25);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(46, 216, 164, 0.35); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.16);
}

.btn-secondary:hover { border-color: rgba(255,255,255,0.32); transform: translateY(-1px); }

/* ===== QUESTION PAGE ===== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(900px, 94vw);
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.category-tag {
  background: rgba(46, 216, 164, 0.18);
  color: var(--accent);
  padding: 8px 12px;
  border-radius: 10px;
}

.timer-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 10px 14px;
}

.timer-ring {
  width: 56px;
  height: 56px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 0;
  transition: stroke 200ms linear;
}

#timer-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.progress-bar-wrap {
  width: min(900px, 94vw);
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  margin: 20px 0 14px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 220ms ease;
}

.question-card {
  width: min(900px, 94vw);
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 18px;
  padding: 26px 24px 22px;
  box-shadow: var(--shadow);
}

.question-text {
  font-size: 22px;
  margin-bottom: 18px;
  line-height: 1.5;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 600;
}

.option-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(46, 216, 164, 0.55);
}

.option-btn.correct {
  border-color: rgba(46, 216, 164, 0.8);
  background: rgba(46, 216, 164, 0.12);
  color: #d9fff2;
}

.option-btn.wrong {
  border-color: rgba(255, 107, 107, 0.8);
  background: rgba(255, 107, 107, 0.15);
}

.option-btn.disabled {
  opacity: 0.65;
  pointer-events: none;
}

.quiz-footer {
  width: min(900px, 94vw);
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-skip {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px dashed rgba(255,255,255,0.2);
}

.btn-skip:hover { color: var(--text); border-style: solid; }

.buddy-bar {
  width: min(900px, 94vw);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
}

.buddy-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(46, 216, 164, 0.18), rgba(255, 180, 87, 0.22));
  font-size: 22px;
}

.buddy-title {
  font-weight: 800;
  margin: 0 0 2px;
}

.buddy-line {
  margin: 0;
  color: var(--muted);
}

.footer-hint {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ===== RESULT PAGE ===== */
.result-content {
  position: relative;
  width: min(720px, 92vw);
  background: linear-gradient(145deg, rgba(18, 31, 50, 0.92), rgba(18, 31, 50, 0.82));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 24px;
  padding: 42px 36px 46px;
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: center;
}

.result-bg .blob {
  position: absolute;
  filter: blur(42px);
  opacity: 0.7;
}

.result-bg .blob1 { width: 240px; height: 240px; background: #2ed8a4; top: -60px; right: 12px; }
.result-bg .blob2 { width: 260px; height: 260px; background: #ffb457; bottom: -80px; left: -40px; opacity: 0.55; }

.result-emoji {
  font-size: 42px;
  margin-bottom: 8px;
}

.result-title {
  font-size: 32px;
  margin-bottom: 8px;
}

.result-sub {
  color: var(--muted);
  margin-bottom: 26px;
}

.score-circle {
  position: relative;
  width: 180px;
  margin: 0 auto 24px;
}

.score-circle svg {
  width: 100%;
  height: 100%;
}

.score-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 12;
}

.score-arc {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 500ms ease;
}

.score-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
}

.score-label small { color: var(--muted); font-size: 16px; margin-left: 6px; }

.result-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.breakdown-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.05);
}

.breakdown-item span {
  display: block;
  font-size: 26px;
  font-weight: 800;
}

.breakdown-item label {
  color: var(--muted);
}

.breakdown-item.correct { border-color: rgba(46, 216, 164, 0.6); }
.breakdown-item.wrong { border-color: rgba(255, 107, 107, 0.6); }
.breakdown-item.skipped { border-color: rgba(255, 180, 87, 0.65); }

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ===== REVIEW MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: grid;
  place-items: center;
  z-index: 30;
}

.modal-overlay.hidden { display: none; }

.modal {
  width: min(820px, 92vw);
  max-height: 80vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 18px 22px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}

.review-question {
  font-weight: 700;
  margin-bottom: 6px;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
}

.pill.correct { background: rgba(46, 216, 164, 0.16); color: var(--accent); }
.pill.wrong { background: rgba(255, 107, 107, 0.16); color: var(--danger); }
.pill.skipped { background: rgba(255, 180, 87, 0.16); color: var(--accent-2); }

.review-answers {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 720px) {
  .home-content { padding: 36px 24px 42px; }
  .quiz-header { flex-direction: column; align-items: flex-start; }
  .timer-wrap { align-self: flex-end; }
}
