:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --panel: #ffffff;
  --bg: #f6f7fb;
  --brand: #2f6fed;
  --brand-dark: #174bb8;
  --green: #22a566;
  --green-soft: #e9f8ef;
  --red: #e5484d;
  --red-soft: #fff0f0;
  --yellow: #f5c542;
  --shadow: 0 18px 45px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(47, 111, 237, .16), transparent 24rem),
    radial-gradient(circle at 85% 0%, rgba(34, 165, 102, .14), transparent 20rem),
    var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

.is-hidden { display: none !important; }

.loading-screen,
.error-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 5px solid #dbeafe;
  border-top-color: var(--brand);
  border-radius: 999px;
  animation: spin .85s linear infinite;
}

.error-icon { font-size: 44px; }

.error-screen h1 {
  margin: 0;
  font-size: 24px;
}

.error-screen button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px 10px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(229, 231, 235, .84);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  font-size: 30px;
  line-height: 1;
}

.icon-btn:disabled { opacity: .35; }
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ecf3;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #8bd450);
  transition: width .42s cubic-bezier(.2, .8, .2, 1);
}

.progress-text {
  margin-top: 5px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.score-pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid #f0d777;
  border-radius: 999px;
  background: #fff8d9;
  color: #9a6b00;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.emoji {
  display: inline-grid;
  place-items: center;
  min-width: 1.45em;
  font-size: 1.45em;
  line-height: 1;
  transform: translateY(.04em);
}

.emoji.big {
  min-width: 1.7em;
  font-size: 1.7em;
}

.streak-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px 0;
}

.chip {
  border-color: #d9e2ef;
  background: #f8fafc;
  color: #344054;
}

.chip.hot {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.button-chip {
  cursor: pointer;
}

.lesson {
  flex: 1;
  padding: 16px 16px 112px;
}

.question-panel,
.helper-panel,
.feedback {
  border: 1px solid rgba(229, 231, 235, .92);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
}

.question-panel {
  padding: 18px;
  animation: enter .28s ease both;
}

.question-kicker {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.image-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
  line-height: 1.45;
}

.question-text {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.58;
}

.helper-panel {
  margin-top: 12px;
  padding: 14px;
  border-color: #bfdbfe;
  background: #eff6ff;
  animation: slideDown .22s ease both;
}

.helper-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #174bb8;
  font-weight: 900;
}

.helper-text,
.answer-explanation {
  white-space: pre-wrap;
  color: #344054;
  font-size: 14px;
  line-height: 1.55;
}

.action-line {
  display: flex;
  justify-content: flex-end;
  padding: 12px 0 8px;
}

.ghost-btn {
  border: 1px solid #d9e2ef;
  border-radius: 999px;
  padding: 9px 12px;
  background: #fff;
  color: #344054;
  font-size: 13px;
  font-weight: 850;
}

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

.alternative {
  width: 100%;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}

.alternative:hover { transform: translateY(-1px); }
.alternative:active { transform: scale(.985); }

.alternative .letter {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eef2f7;
  color: #344054;
  font-weight: 950;
}

.alternative .text {
  padding-top: 5px;
  font-size: 15px;
  line-height: 1.4;
}

.alternative.selected {
  border-color: var(--brand);
  background: #eef5ff;
  box-shadow: 0 8px 18px rgba(47, 111, 237, .14);
}

.alternative.selected .letter {
  background: var(--brand);
  color: #fff;
}

.alternative.correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.alternative.correct .letter {
  background: var(--green);
  color: #fff;
}

.alternative.wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.alternative.wrong .letter {
  background: var(--red);
  color: #fff;
}

.alternative.locked {
  pointer-events: none;
}

.feedback {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  margin-top: 14px;
  padding: 16px;
  animation: pop .28s ease both;
}

.feedback-badge {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: #eef2f7;
  font-size: 32px;
}

.feedback h2 {
  margin: 0 0 6px;
  font-size: 17px;
}

.feedback p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.feedback.correct {
  border-color: #bbf7d0;
  background: #fbfffd;
}

.feedback.wrong {
  border-color: #fecaca;
  background: #fffafa;
}

.bottom-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 6;
  width: min(100%, 520px);
  transform: translateX(-50%);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(229, 231, 235, .92);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(14px);
}

.primary-btn {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 950;
  box-shadow: 0 12px 18px rgba(47, 111, 237, .18);
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, opacity .14s ease;
}

.primary-btn:hover { background: var(--brand-dark); }
.primary-btn:active { transform: scale(.99); }
.primary-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
  box-shadow: none;
}

.primary-btn.success {
  background: var(--green);
  box-shadow: 0 12px 18px rgba(34, 165, 102, .18);
}

@media (min-width: 800px) {
  .app-shell {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    border-radius: 18px;
    overflow: clip;
  }

  .bottom-actions {
    bottom: 24px;
    border-radius: 0 0 18px 18px;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  0% { opacity: 0; transform: scale(.98); }
  100% { opacity: 1; transform: scale(1); }
}
