:root {
  --ink: #101010;
  --paper: #fffdf4;
  --white: #ffffff;
  --yellow: #ffd84d;
  --pink: #ff6b9d;
  --cyan: #65dfff;
  --mint: #7ee8b7;
  --red: #ff7070;
  --purple: #b69cff;
  --blue: #7ab8ff;
  --orange: #ffad66;
  --muted: #f1efdf;
  --shadow: 7px 7px 0 var(--ink);
  --shadow-small: 4px 4px 0 var(--ink);
  --radius: 12px;
  --max: 1180px;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Arial Black", "Segoe UI Black", Impact, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  line-height: 1.55;
  overflow-x: hidden;
}
button, select, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 1000;
  background: var(--yellow);
  border: 3px solid var(--ink);
  padding: 10px 14px;
  font-weight: 900;
}
.skip-link:focus { top: 12px; }

.bg-shape {
  position: fixed;
  z-index: -1;
  border: 4px solid var(--ink);
  opacity: .7;
  transform: rotate(8deg);
}
.bg-shape--one {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: var(--cyan);
  right: -90px;
  top: 90px;
}
.bg-shape--two {
  width: 170px;
  height: 170px;
  background: var(--pink);
  left: -70px;
  bottom: 30px;
  transform: rotate(-16deg);
}

.app-shell {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.nb-card {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.nb-card--soft { background: var(--muted); }

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 5vw, 54px);
  background: var(--yellow);
  margin-bottom: 34px;
}
.hero::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -55px;
  bottom: -80px;
  background: var(--pink);
  border: 4px solid var(--ink);
  border-radius: 50%;
}
.hero__eyebrow,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  padding: 6px 12px;
  font-size: .82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.hero h1 {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: clamp(2.4rem, 8vw, 6rem);
  line-height: .94;
  letter-spacing: -.045em;
  margin: 18px 0 12px;
  max-width: 800px;
}
.hero p {
  position: relative;
  z-index: 1;
  max-width: 760px;
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 700;
  margin: 0;
}
.hero__stats {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}
.stat-pill {
  background: var(--white);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-small);
  padding: 10px 14px;
  font-weight: 900;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 30px 0 16px;
}
.section-title h2 {
  font-family: var(--font-display);
  text-transform: uppercase;
  line-height: 1;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  margin: 0;
}
.section-title p { margin: 0; max-width: 540px; font-weight: 650; }

.home-actions {
  display: grid;
  grid-template-columns: 1.45fr .55fr;
  gap: 20px;
  margin-bottom: 28px;
}
.action-card { padding: 24px; }
.action-card--general { background: var(--cyan); }
.action-card--continue { background: var(--mint); }
.action-card h2,
.action-card h3 { margin: 0 0 8px; font-family: var(--font-display); text-transform: uppercase; }
.action-card p { margin: 0 0 20px; font-weight: 650; }
.action-card__meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.theme-card {
  min-height: 235px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  transition: transform .16s ease, box-shadow .16s ease;
}
.theme-card:hover { transform: translate(-3px, -3px); box-shadow: 10px 10px 0 var(--ink); }
.theme-card__icon { font-size: 2.3rem; }
.theme-card h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  line-height: 1.05;
  margin: 12px 0 8px;
}
.theme-card p { margin: 0 0 18px; font-weight: 650; }
.theme-card .btn { margin-top: auto; }
.accent-cyan { background: var(--cyan); }
.accent-pink { background: var(--pink); }
.accent-yellow { background: var(--yellow); }
.accent-mint { background: var(--mint); }
.accent-red { background: var(--red); }
.accent-purple { background: var(--purple); }
.accent-blue { background: var(--blue); }
.accent-orange { background: var(--orange); }

.btn {
  appearance: none;
  border: 3px solid var(--ink);
  border-radius: 9px;
  background: var(--white);
  box-shadow: var(--shadow-small);
  padding: 12px 17px;
  font-weight: 950;
  cursor: pointer;
  text-align: center;
  transition: transform .08s ease, box-shadow .08s ease, opacity .2s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid var(--purple); outline-offset: 3px; }
.btn[disabled] { cursor: not-allowed; opacity: .45; transform: none; box-shadow: var(--shadow-small); }
.btn--dark { background: var(--ink); color: var(--white); }
.btn--yellow { background: var(--yellow); }
.btn--pink { background: var(--pink); }
.btn--red { background: var(--red); }
.btn--ghost { background: transparent; box-shadow: none; }
.btn--small { padding: 8px 12px; font-size: .88rem; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar__title {
  min-width: 0;
  text-align: center;
}
.topbar__title strong {
  display: block;
  font-family: var(--font-display);
  text-transform: uppercase;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.topbar__title span { font-weight: 700; font-size: .9rem; }
.streak {
  min-width: 96px;
  text-align: center;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 950;
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.quiz-main { min-width: 0; }
.quiz-sidebar { position: sticky; top: 16px; }

.progress-card { padding: 16px; margin-bottom: 18px; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; font-weight: 900; margin-bottom: 9px; }
.progress-track {
  height: 18px;
  border: 3px solid var(--ink);
  background: var(--white);
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--mint); width: 0; transition: width .3s ease; }

.question-card { padding: clamp(18px, 4vw, 34px); animation: pop-in .25s ease; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.question-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 3px solid var(--ink);
}
.question-card__meta { display: flex; gap: 8px; flex-wrap: wrap; }
.question-number { font-family: var(--font-display); text-transform: uppercase; }
.question-card h2 {
  font-size: clamp(1.25rem, 3vw, 1.85rem);
  line-height: 1.25;
  margin: 0 0 22px;
}
.question-visual {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  font-size: 2.7rem;
  border: 3px solid var(--ink);
  background: var(--yellow);
  box-shadow: var(--shadow-small);
  transform: rotate(3deg);
}
.cert-badge { background: var(--pink); }
.type-badge { background: var(--cyan); }

.options { display: grid; gap: 12px; }
.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  padding: 15px;
  border: 3px solid var(--ink);
  border-radius: 9px;
  background: var(--white);
  font-weight: 750;
  cursor: pointer;
  text-align: left;
  transition: transform .1s ease, background .1s ease;
}
.option:hover:not(.is-locked) { transform: translateX(3px); background: #fff9c7; }
.option input { margin-top: 4px; width: 19px; height: 19px; accent-color: var(--ink); }
.option.is-selected { background: var(--yellow); }
.option.is-correct { background: var(--mint); }
.option.is-wrong { background: var(--red); }
.option.is-locked { cursor: default; }
.option__mark { margin-left: auto; font-size: 1.2rem; font-weight: 950; }

.question-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 3px dashed var(--ink);
}
.question-actions__main { display: flex; gap: 12px; flex-wrap: wrap; }

.feedback {
  margin-top: 24px;
  padding: 18px;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-small);
  animation: feedback-in .25s ease;
}
@keyframes feedback-in { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.feedback--correct { background: var(--mint); }
.feedback--wrong { background: #ffd0d0; }
.feedback--skipped { background: var(--yellow); }
.feedback h3 { margin: 0 0 8px; font-family: var(--font-display); text-transform: uppercase; }
.feedback p { margin: 0; font-weight: 650; }
.feedback-detail { margin-top: 14px; display: grid; gap: 8px; }
.feedback-row {
  background: rgba(255,255,255,.72);
  border: 2px solid var(--ink);
  padding: 10px 12px;
  font-weight: 650;
}

.nav-card { padding: 17px; }
.nav-card h3 { margin: 0 0 8px; font-family: var(--font-display); text-transform: uppercase; }
.nav-card p { margin: 0 0 14px; font-size: .9rem; font-weight: 650; }
.question-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  padding: 3px 6px 8px 3px;
}
.q-nav {
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  background: var(--white);
  font-weight: 950;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.q-nav:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.q-nav.is-current { outline: 4px solid var(--purple); outline-offset: 1px; }
.q-nav.is-correct { background: var(--mint); }
.q-nav.is-wrong { background: var(--red); }
.q-nav.is-skipped { background: var(--yellow); }
.nav-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; font-size: .78rem; font-weight: 850; }
.legend-item { display: flex; gap: 7px; align-items: center; }
.legend-dot { width: 15px; height: 15px; border: 2px solid var(--ink); background: var(--white); }
.legend-dot.correct { background: var(--mint); }
.legend-dot.wrong { background: var(--red); }
.legend-dot.skipped { background: var(--yellow); }
.legend-dot.current { outline: 3px solid var(--purple); }
.sidebar-actions { display: grid; gap: 10px; margin-top: 16px; }

.tf-table { width: 100%; border-collapse: collapse; border: 3px solid var(--ink); }
.tf-table th, .tf-table td { border: 2px solid var(--ink); padding: 12px; vertical-align: middle; }
.tf-table th { background: var(--orange); font-family: var(--font-display); text-transform: uppercase; }
.tf-table th:not(:first-child), .tf-table td:not(:first-child) { text-align: center; width: 95px; }
.tf-table tr.is-correct { background: #d9ffe9; }
.tf-table tr.is-wrong { background: #ffd5d5; }
.tf-table input { width: 19px; height: 19px; accent-color: var(--ink); }

.fill-text {
  border: 3px solid var(--ink);
  background: var(--muted);
  padding: 20px;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 2.25;
}
.fill-select {
  border: 2px solid var(--ink);
  background: var(--white);
  padding: 7px 30px 7px 9px;
  font-weight: 800;
  max-width: 100%;
}
.fill-select.is-correct { background: var(--mint); }
.fill-select.is-wrong { background: var(--red); }

.match-board { position: relative; display: grid; grid-template-columns: minmax(150px, .7fr) minmax(250px, 1.3fr); gap: 90px; padding: 10px; }
.match-column { display: grid; gap: 15px; align-content: start; }
.match-item {
  position: relative;
  z-index: 2;
  min-height: 70px;
  display: flex;
  align-items: center;
  border: 3px solid var(--ink);
  background: var(--white);
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-small);
}
.match-item[data-side="left"]::after,
.match-item[data-side="right"]::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  top: 50%;
  transform: translateY(-50%);
}
.match-item[data-side="left"]::after { right: -12px; }
.match-item[data-side="right"]::before { left: -12px; }
.match-item.is-active { background: var(--yellow); transform: translate(-2px,-2px); }
.match-item.is-linked { background: var(--cyan); }
.match-item.is-correct { background: var(--mint); }
.match-item.is-wrong { background: var(--red); }
.match-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.match-lines line { stroke: var(--ink); stroke-width: 4; }

.order-list { display: grid; gap: 12px; }
.order-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  border: 3px solid var(--ink);
  background: var(--white);
  padding: 12px;
  box-shadow: var(--shadow-small);
  font-weight: 800;
}
.order-item.is-dragging { opacity: .5; }
.order-handle { font-size: 1.4rem; cursor: grab; }
.order-controls { display: flex; gap: 6px; }
.order-controls button { border: 2px solid var(--ink); background: var(--yellow); cursor: pointer; font-weight: 950; }
.order-item.is-correct { background: var(--mint); }
.order-item.is-wrong { background: var(--red); }

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal { width: min(520px, 100%); padding: 24px; background: var(--white); }
.modal h2 { font-family: var(--font-display); text-transform: uppercase; margin: 0 0 10px; }
.modal p { font-weight: 650; }

.results-hero { padding: 30px; background: var(--yellow); margin-bottom: 24px; }
.results-hero h1 { font-family: var(--font-display); text-transform: uppercase; font-size: clamp(2rem, 6vw, 4.5rem); line-height: .95; margin: 10px 0; }
.results-score { font-family: var(--font-display); font-size: clamp(3rem, 9vw, 7rem); line-height: 1; }
.results-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 22px 0; }
.result-stat { padding: 18px; text-align: center; }
.result-stat strong { display: block; font-family: var(--font-display); font-size: 2rem; }
.theme-results { display: grid; gap: 12px; }
.theme-result { padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.theme-result__bar { grid-column: 1 / -1; height: 13px; border: 2px solid var(--ink); background: var(--white); }
.theme-result__fill { height: 100%; background: var(--mint); }
.review-list { display: grid; gap: 14px; }
.review-item { padding: 18px; }
.review-item summary { cursor: pointer; font-weight: 950; }
.review-item.is-wrong { background: #ffd7d7; }
.review-item.is-skipped { background: #fff1a8; }
.review-item.is-correct { background: #dcffeb; }
.review-body { margin-top: 12px; font-weight: 650; }
.review-answer { border: 2px solid var(--ink); padding: 10px; background: rgba(255,255,255,.7); margin-top: 10px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.filter-row .btn.is-active { background: var(--purple); }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 10px; }
.toast {
  max-width: 340px;
  background: var(--white);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-small);
  padding: 12px 15px;
  font-weight: 850;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 300; }
.confetti {
  position: absolute;
  width: 12px;
  height: 18px;
  border: 2px solid var(--ink);
  animation: confetti-fall 1.8s ease-out forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(-30px) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(740deg); opacity: 0; }
}

.footer-note { margin-top: 34px; text-align: center; font-size: .9rem; font-weight: 650; }
.empty-state { padding: 28px; text-align: center; }
.empty-state h2 { font-family: var(--font-display); text-transform: uppercase; }

@media (max-width: 980px) {
  .theme-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .quiz-layout { grid-template-columns: 1fr; }
  .quiz-sidebar { position: static; }
  .question-grid { grid-template-columns: repeat(10, 1fr); max-height: none; }
  .results-grid { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 20px, var(--max)); padding-top: 12px; }
  .home-actions { grid-template-columns: 1fr; }
  .theme-grid { grid-template-columns: 1fr; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .topbar { grid-template-columns: auto 1fr; }
  .streak { grid-column: 1 / -1; justify-self: center; }
  .question-card__header { flex-direction: column-reverse; }
  .question-visual { width: 60px; height: 60px; font-size: 2rem; }
  .question-grid { grid-template-columns: repeat(7, 1fr); }
  .match-board { grid-template-columns: minmax(105px,.8fr) minmax(150px,1.2fr); gap: 38px; padding: 0; }
  .match-item { padding: 9px; min-height: 74px; font-size: .84rem; box-shadow: 2px 2px 0 var(--ink); }
  .tf-table { font-size: .86rem; }
  .tf-table th, .tf-table td { padding: 8px 5px; }
  .tf-table th:not(:first-child), .tf-table td:not(:first-child) { width: 58px; }
  .results-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .hero { padding: 22px; }
  .hero h1 { font-size: 2.65rem; }
  .question-grid { grid-template-columns: repeat(6, 1fr); }
  .results-grid { grid-template-columns: 1fr; }
  .question-actions, .question-actions__main { display: grid; width: 100%; }
  .question-actions .btn { width: 100%; }
  .fill-text { line-height: 2.7; font-size: .95rem; padding: 14px; }
  .fill-select { max-width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.table-scroll { overflow-x: auto; padding-bottom: 4px; }
