:root {
  color-scheme: light;
  --bg: #eef2f7;
  --ink: #18202a;
  --muted: #667085;
  --panel: #ffffff;
  --line: #d8dee8;
  --accent: #0d766e;
  --accent-dark: #095f59;
  --bad: #b42318;
  --good: #087443;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
}

.shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.back {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
}

.topbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.panel {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.hidden {
  display: none !important;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.level,
.primary,
.secondary {
  min-height: 46px;
  border-radius: 8px;
  cursor: pointer;
}

.level {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  font-weight: 700;
}

.level.selected {
  border-color: var(--accent);
  background: #dff7f2;
  color: var(--accent-dark);
}

.primary {
  border: 0;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  border: 1px solid var(--line);
  padding: 0 16px;
  background: #fff;
  color: var(--ink);
}

.small {
  min-height: 34px;
  padding: 0 12px;
}

.quiz-head,
.history-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meter {
  height: 10px;
  margin: 14px 0 20px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width .2s ease;
}

#question {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.45;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.option:hover {
  border-color: var(--accent);
}

.option.correct {
  border-color: var(--good);
  background: #e7f8ef;
}

.option.incorrect {
  border-color: var(--bad);
  background: #ffebe8;
}

.source,
.history,
.wrong-item {
  color: var(--muted);
}

.source {
  margin: 14px 0 0;
  font-size: .95rem;
}

.history,
.saved-wrongs {
  display: grid;
  gap: 10px;
}

.saved-wrongs {
  margin-bottom: 16px;
}

.saved-wrongs h3 {
  margin: 0;
  font-size: 1rem;
}

.history-row,
.wrong-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.wrong-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.wrong-item strong {
  color: var(--ink);
}

@media (max-width: 700px) {
  .shell {
    width: min(100% - 20px, 1100px);
    padding-top: 16px;
  }

  .topbar,
  .quiz-head,
  .history-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .level-grid {
    grid-template-columns: 1fr;
  }
}
