:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #61708c;
  --primary: #2f6fed;
  --primary-dark: #1d4fb3;
  --success: #1c9b5f;
  --danger: #d44848;
  --border: #d8e0ef;
  --shadow: 0 14px 32px rgba(34, 56, 96, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef3ff 0%, var(--bg) 100%);
  color: var(--text);
}
button {
  font: inherit;
}
.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 16px 14px 40px;
}
.hero, .panel, .result-card, .question-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero {
  padding: 22px 18px;
  margin-bottom: 16px;
}
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.1;
}
.hero-text, .section-title p, .result-note, #progress-label {
  color: var(--muted);
}
.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}
.panel {
  display: none;
  padding: 18px;
}
.panel.active {
  display: block;
}
.section-title h2, .quiz-head h2, .result-card h2 {
  margin: 0 0 8px;
}
.cards {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.quiz-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: #fbfcff;
}
.quiz-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}
.quiz-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
}
.card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.badge, .score-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.83rem;
  font-weight: 700;
  background: #eaf0ff;
  color: var(--primary-dark);
}
.topbar, .quiz-head, .actions-row, .result-actions {
  display: flex;
  gap: 12px;
}
.topbar, .quiz-head {
  justify-content: space-between;
  align-items: center;
}
.quiz-head {
  flex-direction: column;
  align-items: stretch;
  margin: 18px 0;
}
.progress-wrap { width: 100%; }
.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e8edf7;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #6fa0ff);
  transition: width 0.25s ease;
}
.question-card {
  padding: 18px;
}
.question-card h3 {
  margin-top: 0;
  line-height: 1.35;
}
.options-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.chronology-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.chronology-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.chronology-index {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #eaf0ff;
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.chronology-label {
  line-height: 1.35;
}
.chronology-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chronology-move {
  width: 42px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8faff;
  color: var(--text);
  cursor: pointer;
}
.chronology-move:disabled {
  opacity: 0.45;
  cursor: default;
}
.chronology-item.locked {
  background: #fbfcff;
}
.option-button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  background: #fff;
  color: var(--text);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.option-button strong {
  color: var(--primary-dark);
}
.option-button:hover, .option-button:focus-visible {
  border-color: var(--primary);
  outline: none;
}
.option-button:disabled {
  opacity: 1;
}
.option-button.correct {
  border-color: rgba(28, 155, 95, 0.55);
  background: rgba(28, 155, 95, 0.12);
}
.option-button.incorrect {
  border-color: rgba(212, 72, 72, 0.55);
  background: rgba(212, 72, 72, 0.12);
}
.feedback {
  margin-top: 16px;
  border-radius: 16px;
  padding: 14px;
  font-size: 0.95rem;
  line-height: 1.45;
}
.feedback.correct {
  background: rgba(28, 155, 95, 0.12);
  color: #125b39;
}
.feedback.incorrect {
  background: rgba(212, 72, 72, 0.12);
  color: #7b2525;
}
.hidden { display: none !important; }
.primary-button, .ghost-button {
  border-radius: 14px;
  padding: 12px 16px;
  border: none;
  cursor: pointer;
  min-height: 48px;
}
.primary-button {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(47, 111, 237, 0.22);
}
.primary-button:hover, .primary-button:focus-visible {
  background: var(--primary-dark);
  outline: none;
}
.ghost-button {
  background: #edf2fb;
  color: var(--text);
}
.actions-row { margin-top: 16px; justify-content: flex-end; }
.result-card {
  padding: 22px 18px;
  text-align: center;
}
.result-score {
  font-size: 2rem;
  font-weight: 800;
  margin: 10px 0;
}
.result-actions {
  margin-top: 18px;
  justify-content: center;
  flex-wrap: wrap;
}
@media (min-width: 640px) {
  .app-shell { padding: 24px 18px 48px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .quiz-head { flex-direction: row; align-items: center; }
  .progress-wrap { max-width: 300px; }
}
