:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d8dee9;
  --text: #111827;
  --muted: #5b6472;
  --accent: #2563eb;
  --accent-soft: #e8f0ff;
  --good: #15803d;
  --good-soft: #e8f8ee;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 260px),
    var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

.app {
  width: min(1080px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.screen {
  display: none;
  min-height: calc(100dvh - 36px);
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.topbar,
.panel,
.question-card,
.controls,
.package-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  padding: 16px 0;
}

.package-card {
  display: grid;
  min-height: 158px;
  gap: 8px;
  align-content: start;
  padding: 18px;
  text-align: left;
}

.package-card strong {
  color: var(--text);
  font-size: 1.05rem;
}

.package-card span,
.package-card small {
  color: var(--muted);
}

.package-card b {
  align-self: end;
  color: var(--accent);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.topbar strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.2;
}

.topbar span {
  color: var(--muted);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats span {
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 8px 10px;
  text-align: center;
}

.stats b {
  color: var(--text);
}

.question-card {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  margin-top: 12px;
  overflow: hidden;
}

.question-head {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  padding: clamp(16px, 3vw, 28px);
}

.tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: var(--accent-soft);
  padding: 5px 10px;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 800;
}

h1 {
  margin: 12px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 3.2vw, 2.25rem);
  line-height: 1.16;
  letter-spacing: 0;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: clamp(14px, 2vw, 20px);
}

.option {
  display: flex;
  min-height: 76px;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 14px;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.option:hover,
.option:focus-visible {
  border-color: #93c5fd;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.option[disabled] {
  cursor: default;
  transform: none;
}

.option span {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--accent);
  font-weight: 900;
}

.option b {
  min-width: 0;
  padding-top: 4px;
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  font-weight: 650;
  line-height: 1.36;
  overflow-wrap: anywhere;
}

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

.option.correct span {
  border-color: var(--good);
  background: var(--good);
  color: white;
}

.option.wrong {
  border-color: #fca5a5;
  background: var(--bad-soft);
}

.option.wrong span {
  border-color: var(--bad);
  background: var(--bad);
  color: white;
}

.option.ghost {
  opacity: 0.58;
}

.feedback {
  min-height: 48px;
  margin: auto clamp(14px, 2vw, 20px) clamp(14px, 2vw, 20px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 12px 14px;
  color: var(--muted);
  line-height: 1.4;
}

.feedback.good {
  border-color: #bbf7d0;
  background: var(--good-soft);
  color: var(--good);
}

.feedback.bad {
  border-color: #fecaca;
  background: var(--bad-soft);
  color: var(--bad);
}

.controls {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
}

button {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 9px 14px;
  font-weight: 800;
}

button:hover,
button:focus-visible {
  border-color: #93c5fd;
  outline: none;
}

#nextBtn,
#summaryRestartBtn {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.center {
  display: grid;
  width: min(620px, 100%);
  margin: auto;
  place-items: center;
  padding: 36px;
  text-align: center;
}

.center p {
  color: var(--muted);
  line-height: 1.5;
}

.loader {
  width: 42px;
  height: 42px;
  border: 3px solid #dbeafe;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (max-width: 720px) {
  .app {
    padding: 0;
  }

  .screen {
    min-height: 100dvh;
  }

  .topbar,
  .question-card,
  .controls,
  .package-card {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats span {
    min-width: 0;
  }

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

  .controls {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.96);
  }
}
