:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-soft: #555;
  --muted: #8a8a8a;
  --border: #ececec;
  --primary: #2563eb;
  --primary-soft: #eff5ff;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --error: #ef4444;
  --error-soft: #fef2f2;
  --warning: #f59e0b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.brand-name { font-weight: 500; font-size: 15px; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs span { margin: 0 6px; opacity: 0.5; }

/* Hero */
.hero {
  padding: 56px 0 24px;
  text-align: left;
}
.hero h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.4px;
}
.hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 16px;
  max-width: 560px;
}

/* Topic grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 24px 0 64px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.card:hover {
  border-color: #d6d6d6;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.card-title {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
}
.card-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}
.card-meta .go {
  font-weight: 500;
  color: var(--primary);
}

/* Quiz */
.quiz {
  padding: 32px 0 64px;
}
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.quiz-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.2px;
}
.quiz-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.progress {
  height: 4px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 32px;
}
.progress-bar {
  height: 100%;
  background: var(--text);
  transition: width 0.3s ease;
}

.question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.q-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
}
.q-text {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  margin: 0 0 18px;
  color: var(--text);
}
.q-text b { font-weight: 500; }

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  text-align: left;
  width: 100%;
}
.option:hover:not(.disabled) {
  border-color: #c8c8c8;
  background: #fafafa;
}
.option .letter {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
}
.option.correct {
  border-color: var(--success);
  background: var(--success-soft);
}
.option.correct .letter {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.option.wrong {
  border-color: var(--error);
  background: var(--error-soft);
}
.option.wrong .letter {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}
.option.disabled {
  cursor: default;
}
.option.dim {
  opacity: 0.55;
}

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  line-height: 1.6;
  display: none;
}
.feedback.show { display: block; }
.feedback.correct {
  background: var(--success-soft);
  border-left: 3px solid var(--success);
  color: #065f46;
}
.feedback.wrong {
  background: var(--error-soft);
  border-left: 3px solid var(--error);
  color: #991b1b;
}
.feedback strong { font-weight: 700; }
.feedback .label {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.score {
  font-size: 15px;
  color: var(--text-soft);
}
.score b { color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.85; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost:hover { background: #f3f3f3; opacity: 1; }

/* Result */
.result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
  margin: 32px 0 64px;
}
.result h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}
.result-score {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -1.5px;
  margin: 20px 0 6px;
  color: var(--primary);
}
.result-detail { color: var(--muted); margin: 0 0 28px; font-size: 15px; }
.result-actions { display: flex; gap: 12px; justify-content: center; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0;
  margin-top: 48px;
}
.footer p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 600px) {
  .hero { padding: 32px 0 16px; }
  .hero h1 { font-size: 26px; }
  .quiz-title { font-size: 19px; }
  .question { padding: 18px; }
  .result { padding: 28px 20px; }
  .result-score { font-size: 44px; }
}
