:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --ink: #201d1b;
  --muted: #6e6760;
  --line: #d9d0c3;
  --panel: #fffdfa;
  --accent: #1f6f78;
  --accent-dark: #124d54;
  --good: #237a45;
  --bad: #b43b35;
  --shadow: 0 18px 45px rgba(52, 43, 33, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.review-open {
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

.app {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.topbar {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 6vw, 58px);
  line-height: 1;
}

.controls,
.quiz,
.review-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input,
button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select,
input {
  padding: 0 12px;
}

.range-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

button {
  cursor: pointer;
  padding: 0 16px;
  font-weight: 800;
}

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

button.active,
#nextButton {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.quiz {
  padding: 20px;
}

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

.progress {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

.question-card {
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf7ef;
  text-align: center;
}

.review-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(32, 29, 27, 0.24);
}

.review-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
  border-radius: 0;
  transform: translateX(100%);
  transition: transform 180ms ease;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.review-panel.open {
  transform: translateX(0);
}

.review-header,
.review-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-header {
  margin-bottom: 18px;
}

.review-header h2 {
  font-size: 24px;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.review-progress {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

.review-question-card {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf7ef;
  text-align: center;
}

.question-label {
  color: var(--muted);
  font-weight: 800;
}

.question-text {
  margin-top: 12px;
  font-size: clamp(54px, 16vw, 118px);
  font-weight: 900;
  line-height: 1;
}

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

.choice {
  min-height: 64px;
  font-size: 20px;
}

.choice.correct {
  border-color: var(--good);
  background: #e9f6ee;
  color: var(--good);
}

.choice.wrong {
  border-color: var(--bad);
  background: #fff0ee;
  color: var(--bad);
}

.feedback {
  min-height: 28px;
  color: var(--muted);
  font-weight: 800;
}

.feedback.good {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.actions {
  margin-top: 14px;
  flex-wrap: wrap;
}

.review-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 18px -24px calc(-24px - env(safe-area-inset-bottom));
  padding: 12px 24px calc(18px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 24px rgba(52, 43, 33, 0.08);
}

.review-actions button {
  width: 100%;
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 960px);
    padding: 20px 0;
  }

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

  .range-controls {
    grid-template-columns: 1fr;
  }

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

  .review-panel {
    width: 100%;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .review-actions {
    margin: 16px -16px calc(-18px - env(safe-area-inset-bottom));
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .review-question-card {
    min-height: 170px;
  }

  .review-header h2 {
    font-size: 28px;
    line-height: 1.15;
  }
}
