
:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.18);
  --green: #22c55e;
  --yellow: #facc15;
  --red: #ef4444;
  --grey: #475569;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --radius: 20px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.24), transparent 26%),
    radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.14), transparent 22%),
    linear-gradient(135deg, #020617, #0f172a 40%, #111827);
  color: var(--text);
}
.screen { display: none; min-height: 100vh; padding: 24px; }
.screen.active { display: flex; }
.glass {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
#start-screen, #result-screen {
  align-items: center;
  justify-content: center;
}
.start-card, .result-card {
  width: min(1100px, 100%);
  padding: 30px;
  border-radius: 28px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: #dbeafe;
  background: rgba(37, 99, 235, 0.18);
  margin-bottom: 14px;
}
.subtitle { color: var(--muted); max-width: 760px; line-height: 1.6; }
.start-grid, .result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}
.info-card, .metric-card {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  border-radius: 22px;
  padding: 20px;
}
.info-card h3 { margin-top: 0; }
.info-card ul { margin: 12px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.9; }
.choice-group { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0 22px; }
.choice {
  position: relative;
  cursor: pointer;
}
.choice input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.choice span {
  display: inline-block;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
}
.choice input:checked + span {
  border-color: rgba(37,99,235,0.7);
  background: var(--primary-soft);
  color: #dbeafe;
}
.start-actions, .result-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  border: none;
  outline: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.95); color: white; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,0.08); }
.hidden { display: none !important; }

#exam-screen {
  gap: 20px;
  align-items: stretch;
}
.sidebar {
  width: 330px;
  min-width: 330px;
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}
.sidebar-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}
.small-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.set-label, .progress-label { font-weight: 700; margin-top: 6px; }
.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 18px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}
.dot.current { background: var(--primary); }
.dot.correct { background: var(--green); }
.dot.incorrect { background: var(--yellow); }
.dot.unattempted { background: var(--grey); }
.question-grid {
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding-right: 4px;
}
.question-chip {
  border: none;
  min-height: 42px;
  border-radius: 12px;
  font-weight: 700;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  transition: background 0.22s ease, color 0.22s ease, transform 0.16s ease;
}
.question-chip.current { background: var(--primary); color: white; }
.question-chip.correct { background: var(--green); color: #052e16; }
.question-chip.incorrect { background: var(--yellow); color: #422006; }
.question-chip.unattempted { background: var(--grey); color: white; }
.question-chip:hover { transform: none; }
.exam-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.topbar, .question-card, .bottom-nav {
  border-radius: 24px;
}
.topbar {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.title-wrap h2 { margin: 0; }
.chapter-text { margin: 8px 0 0; color: var(--muted); }
.timer-wrap {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.timer-card {
  min-width: 180px;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.timer-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.timer-value { font-size: 28px; font-weight: 800; margin-top: 8px; }
.question-card {
  padding: 26px;
  flex: 1;
}
.question-meta-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
}
.question-number-pill, .source-page-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 13px;
}
.feedback-box {
  margin-top: 16px;
  border-radius: 16px;
  padding: 14px 16px;
  font-weight: 600;
  line-height: 1.55;
}
.feedback-box.correct { background: rgba(34,197,94,0.18); color: #bbf7d0; border: 1px solid rgba(34,197,94,0.35); }
.feedback-box.incorrect { background: rgba(239,68,68,0.18); color: #fecaca; border: 1px solid rgba(239,68,68,0.35); }
.feedback-box.unattempted { background: rgba(71,85,105,0.24); color: #e2e8f0; border: 1px solid rgba(148,163,184,0.28); }
.question-text { margin-top: 22px; line-height: 1.65; font-size: 23px; }
.options-container {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}
.option-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.option-card:hover { transform: translateY(-1px); }
.option-card.selected {
  border-color: rgba(37,99,235,0.85);
  background: var(--primary-soft);
}
.option-card.locked { cursor: default; }
.option-card.correct-answer {
  border-color: rgba(34,197,94,0.65);
  background: rgba(34,197,94,0.16);
}
.option-card.wrong-answer {
  border-color: rgba(239,68,68,0.55);
  background: rgba(239,68,68,0.12);
}
.option-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.option-letter {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.option-text { flex: 1; line-height: 1.55; }
.bottom-nav {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.metric-card { display: flex; flex-direction: column; gap: 10px; }
.metric-card span { color: var(--muted); }
.metric-card strong { font-size: 30px; }
@media (max-width: 1100px) {
  #exam-screen { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; max-height: none; }
  .question-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .screen { padding: 14px; }
  .start-grid, .result-grid { grid-template-columns: 1fr; }
  .question-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .topbar { flex-direction: column; align-items: stretch; }
  .timer-wrap { justify-content: stretch; }
  .timer-card { width: 100%; }
  .question-text { font-size: 20px; }
  .bottom-nav { justify-content: center; }
  .bottom-nav .btn { flex: 1 1 100%; }
}
