:root {
  color-scheme: dark;
  --bg: #050607;
  --panel: #101317;
  --panel-2: #171b20;
  --line: #272d35;
  --muted: #9ba6b2;
  --text: #f4f7fb;
  --accent: #24d18f;
  --accent-2: #57a6ff;
  --danger: #ff5d72;
  --warn: #ffd166;
  --ok-soft: rgba(36, 209, 143, .16);
  --bad-soft: rgba(255, 93, 114, .14);
  --shadow: 0 20px 80px rgba(0, 0, 0, .48);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(36, 209, 143, .12), transparent 26rem),
    radial-gradient(circle at 90% 10%, rgba(87, 166, 255, .12), transparent 22rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px 18px 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 26px;
}

.brand {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 7vw, 4.7rem);
  line-height: .94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 4vw, 2.35rem);
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.lead,
.muted {
  color: var(--muted);
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 1.03rem;
  line-height: 1.65;
}

.icon-btn,
.primary,
.secondary,
.ghost,
.danger {
  min-height: 44px;
  border-radius: 8px;
  color: var(--text);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.icon-btn {
  width: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.primary,
.secondary,
.ghost,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #02100b;
}

.secondary {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.danger {
  background: rgba(255, 93, 114, .12);
  border: 1px solid rgba(255, 93, 114, .35);
  color: #ffd7dd;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
}

.hero {
  min-height: calc(100vh - 96px);
  display: grid;
  align-content: center;
}

.mode-grid,
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.topic-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-card,
.topic-card,
.panel,
.quiz-card {
  border: 1px solid var(--line);
  background: rgba(16, 19, 23, .84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.mode-card,
.topic-card {
  position: relative;
  overflow: hidden;
  min-height: 208px;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.mode-card > *:not(.card-bg-icon) {
  position: relative;
  z-index: 1;
}

.card-bg-icon {
  position: absolute;
  right: -14px;
  top: 20px;
  width: 150px;
  height: 150px;
  color: var(--accent);
  opacity: .075;
  stroke: currentColor;
  stroke-width: 1.4;
  fill: none;
  pointer-events: none;
  transform: rotate(-8deg);
}

.mode-card:nth-child(2) .card-bg-icon {
  color: var(--accent-2);
  opacity: .07;
  right: -10px;
  top: 24px;
  transform: rotate(7deg);
}

.mode-card:nth-child(3) .card-bg-icon {
  color: var(--warn);
  opacity: .065;
  right: -18px;
  top: 22px;
  transform: rotate(-4deg);
}

.mode-card h3 {
  text-align: center;
  font-size: 1.28rem;
  line-height: 1.2;
}

.mode-card p,
.topic-card p {
  color: var(--muted);
  line-height: 1.5;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #0b0e11;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.quiz-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - 128px);
  align-content: center;
}

.quiz-homebar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.panel,
.quiz-card {
  border-radius: 8px;
  padding: 18px;
}

.quiz-card.result-pop-ok {
  animation: resultPopOk .52s ease;
}

.quiz-card.result-pop-bad {
  animation: resultPopBad .52s ease;
}

@keyframes resultPopOk {
  0% {
    transform: scale(1);
    box-shadow: var(--shadow);
  }
  35% {
    transform: scale(1.012);
    border-color: var(--accent);
    box-shadow: 0 0 0 8px rgba(36, 209, 143, .12), var(--shadow);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--shadow);
  }
}

@keyframes resultPopBad {
  0% {
    transform: scale(1);
    box-shadow: var(--shadow);
  }
  35% {
    transform: scale(1.012);
    border-color: var(--danger);
    box-shadow: 0 0 0 8px rgba(255, 93, 114, .13), var(--shadow);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--shadow);
  }
}

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

.stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.stat strong {
  color: var(--text);
}

.progress {
  height: 10px;
  margin: 16px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #090b0e;
  border: 1px solid var(--line);
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.question-type {
  color: var(--accent);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.question-title {
  margin: 8px 0 18px;
  font-size: clamp(1.25rem, 4vw, 2rem);
  line-height: 1.18;
}

.answers,
.match-grid,
.order-list {
  display: grid;
  gap: 10px;
}

.answer {
  min-height: 54px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 8px;
  text-align: left;
  background: #0c0f13;
  border: 1px solid var(--line);
  color: var(--text);
}

.answer.selected {
  border-color: var(--accent-2);
  background: rgba(87, 166, 255, .13);
}

.answer.correct {
  border-color: var(--accent);
  background: var(--ok-soft);
}

.answer.missed {
  border-color: var(--warn);
  background: rgba(255, 209, 102, .14);
}

.answer.wrong {
  border-color: var(--danger);
  background: var(--bad-soft);
}

.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, .95fr);
  gap: 10px;
  align-items: center;
}

.match-left {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #0c0f13;
  border: 1px solid var(--line);
}

select {
  min-height: 48px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0c0f13;
  color: var(--text);
  padding: 0 12px;
}

.order-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 10px;
  border-radius: 8px;
  background: #0c0f13;
  border: 1px solid var(--line);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, opacity .18s ease;
}

.order-item:hover {
  transform: translateY(-2px);
  border-color: rgba(87, 166, 255, .55);
}

.order-item.dragging {
  cursor: grabbing;
  opacity: .88;
  border-color: var(--accent);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .38);
  z-index: 5;
}

.order-item.drag-over {
  border-color: var(--accent-2);
  background: rgba(87, 166, 255, .14);
  transform: translateY(2px);
}

.order-rank {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 900;
}

.order-item.correct,
.match-row.correct select {
  border-color: var(--accent);
  background: var(--ok-soft);
}

.order-item.wrong,
.match-row.wrong select {
  border-color: var(--danger);
  background: var(--bad-soft);
}

.order-item.correct,
.order-item.wrong {
  cursor: default;
}

.mini-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.feedback {
  margin-top: 16px;
  padding: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #0b0d10;
  line-height: 1.5;
}

.feedback-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.feedback-list p {
  margin: 0;
}

.feedback-list .ok-line {
  color: #caffeb;
}

.feedback-list .bad-line {
  color: #ffd7dd;
}

.feedback.ok {
  border-color: rgba(36, 209, 143, .45);
  color: #caffeb;
}

.feedback.bad {
  border-color: rgba(255, 93, 114, .45);
  color: #ffd7dd;
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

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

.result-box {
  padding: 16px;
  border-radius: 8px;
  background: #0c0f13;
  border: 1px solid var(--line);
}

.result-box strong {
  display: block;
  font-size: 1.8rem;
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-item {
  padding: 13px;
  border-radius: 8px;
  background: #0c0f13;
  border: 1px solid var(--line);
}

@media (max-width: 860px) {
  .mode-grid,
  .topic-grid,
  .quiz-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    align-content: start;
    padding-top: 26px;
  }

  .quiz-layout .panel {
    order: 2;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 18px 12px 30px;
  }

  .topbar {
    align-items: flex-start;
  }

  .mode-card,
  .topic-card,
  .panel,
  .quiz-card {
    padding: 14px;
  }

  .match-row {
    grid-template-columns: 1fr;
  }

  .quiz-actions,
  .result-grid {
    grid-template-columns: 1fr;
    display: grid;
  }
}
