:root {
  --bg: #f7f7f8;
  --fg: #1a1a1a;
  --muted: #5a5a5a;
  --card: #ffffff;
  --border: #d9d9dc;
  --primary: #2563eb;
  --primary-fg: #ffffff;
  --danger: #dc2626;
  --correct: #16a34a;
  --wrong: #dc2626;
  --focus: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --fg: #f1f1f1;
    --muted: #a3a3a3;
    --card: #1d1d20;
    --border: #3a3a3e;
    --primary: #4d8dff;
    --primary-fg: #0a0a0a;
    --danger: #ef4444;
    --correct: #4ade80;
    --wrong: #f87171;
    --focus: #4d8dff;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.15rem;
  line-height: 1.5;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.screen[hidden] {
  display: none;
}

h1 { font-size: 1.8rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.5rem; margin: 0; }
h3 { font-size: 1.1rem; margin: 1rem 0 0.25rem; color: var(--muted); }

.btn {
  font-size: 1.1rem;
  padding: 0.9rem 1.2rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  min-height: 48px;
}

.btn:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
  font-weight: 600;
}

.btn-secondary { background: transparent; }

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toggle input, .field input[type="range"] { width: auto; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field select {
  font-size: 1rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
}

.note {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--muted);
}

.score {
  font-weight: 600;
  font-size: 1.1rem;
}

#question-text {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}

#options-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.btn-option {
  text-align: left;
}

.btn-option.correct {
  border-color: var(--correct);
  box-shadow: inset 0 0 0 2px var(--correct);
}

.btn-option.wrong {
  border-color: var(--wrong);
  box-shadow: inset 0 0 0 2px var(--wrong);
}

.status-line {
  min-height: 1.5em;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.controls .btn { flex: 1 1 auto; }

#missed-list {
  padding-left: 1.2rem;
}

#missed-list li { margin-bottom: 0.5rem; }

@media (max-width: 420px) {
  body { font-size: 1.05rem; }
  #question-text { font-size: 1.25rem; }
}
