:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1f2937;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #2563eb;
  --blue-dark: #1e40af;
  --indigo: #4f46e5;
  --indigo-dark: #3730a3;
  --green: #20b86a;
  --green-dark: #149657;
  --teal: #0ea5a3;
  --teal-dark: #0f766e;
  --amber: #f59e0b;
  --amber-dark: #b45309;
  --amber-soft: #fff7ed;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background:
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 42%, #f8fafc 100%);
  color: var(--text);
}

a {
  color: inherit;
}

.quiz-wrapper {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto;
  background: var(--surface);
  padding: 34px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.quiz-wrapper h1,
.quiz-title {
  margin: 0 0 12px;
  text-align: center;
  font-size: clamp(2rem, 3vw, 3.1rem);
  line-height: 1.1;
  color: #172033;
}

.quiz-intro {
  max-width: 840px;
  margin: 0 auto 24px;
  text-align: center;
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--muted);
}

#progress-bar {
  width: 100%;
  height: 8px;
  margin: 24px 0 28px;
  overflow: hidden;
  background: #e8edf4;
  border-radius: 999px;
}

#progress {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--teal), var(--amber));
  transition: width 240ms ease;
}

.step-label {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
}

.quiz-question h2,
.results-intro h2,
.loading-state h2,
.error-state h2 {
  margin: 0;
  color: #172033;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.2;
}

.question-help,
.results-intro p,
.loading-state p,
.error-state p {
  max-width: 820px;
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.quiz-options {
  display: grid;
  gap: 12px;
}

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

.quiz-choice {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.quiz-choice strong {
  font-size: 1.05rem;
  line-height: 1.25;
}

.quiz-choice span {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.quiz-choice:hover,
.quiz-choice:focus {
  outline: none;
  border-color: #7dd3fc;
  box-shadow: 0 12px 28px rgba(14, 165, 163, 0.14);
  transform: translateY(-2px);
}

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

.quiz-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.quiz-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.quiz-nav,
.quiz-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.quiz-btn,
.quiz-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 20px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.quiz-btn:hover,
.quiz-link:hover {
  filter: brightness(0.96);
  box-shadow: 0 14px 28px rgba(79, 70, 229, 0.24);
  transform: translateY(-1px);
}

.quiz-btn-secondary {
  background: #e8edf4;
  color: #243041;
}

.quiz-btn-secondary:hover {
  background: #dbe3ee;
}

.restart-btn {
  min-width: 240px;
  background: linear-gradient(135deg, var(--green), var(--teal));
}

.restart-btn:hover {
  filter: brightness(0.96);
}

.results-intro {
  margin-bottom: 20px;
}

.answer-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
}

.answer-summary span {
  padding: 7px 11px;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  color: #075985;
  font-size: 0.9rem;
  font-weight: 650;
}

.quiz-products {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  align-items: stretch;
}

.quiz-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dde8f4;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.quiz-card.rank-1 {
  border-color: #f8cf7a;
  box-shadow: 0 16px 42px rgba(245, 158, 11, 0.15), 0 10px 26px rgba(32, 184, 106, 0.1);
}

.quiz-card.rank-1::before {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--amber), var(--green), var(--blue));
  content: "";
}

.top-ribbon {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #fed7aa;
  background: var(--amber-soft);
  color: var(--amber-dark);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: 0 8px 18px rgba(245, 158, 11, 0.16);
}

.quiz-card.rank-2 .top-ribbon {
  border-color: #99f6e4;
  background: #ecfeff;
  color: var(--teal-dark);
}

.quiz-card.rank-3 .top-ribbon {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--blue-dark);
}

.image-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1.32 / 1;
  padding: 18px;
  background: #fff;
  text-decoration: none;
}

.quiz-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px 18px 0;
}

.brand {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.quiz-card h3 {
  margin: 0 0 14px;
  color: #1f2937;
  font-size: 1.18rem;
  line-height: 1.28;
  text-align: center;
}

.match-bar {
  width: 100%;
  height: 9px;
  margin: 6px 0 12px;
  overflow: hidden;
  background: #e4ebf3;
  border-radius: 999px;
}

.match-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--green), var(--teal));
}

.match-text {
  width: fit-content;
  margin: 0 auto 14px;
  padding: 5px 11px;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ecfdf5, #ecfeff);
  color: var(--teal-dark);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.price {
  margin: 0;
  color: #1f2937;
  text-align: center;
  font-size: 1.08rem;
}

.price strong {
  color: #172033;
}

.price-label {
  margin-right: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  text-transform: lowercase;
}

.price-bgn {
  margin: 6px 0 16px;
  color: var(--muted);
  text-align: center;
}

.reason-block {
  margin: 2px 0 14px;
  padding-top: 14px;
  border-top: 1px solid #dbeafe;
}

.reason-block h4 {
  margin: 0 0 8px;
  color: #172033;
  font-size: 0.98rem;
}

.reason-block h4::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--amber);
  content: "";
  vertical-align: 0.08em;
}

.reason-block ul,
.benefit-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reason-block li,
.benefit-list li {
  position: relative;
  padding-left: 23px;
  color: #445166;
  font-size: 0.92rem;
  line-height: 1.45;
}

.reason-block li::before {
  position: absolute;
  left: 0;
  top: 0.2em;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #e0f2fe;
  color: var(--teal-dark);
  content: "i";
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}

.benefit-list {
  margin: 0 0 14px;
}

.benefit-list li::before {
  position: absolute;
  left: 0;
  top: 0.15em;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--green), var(--teal));
  color: #fff;
  content: "";
}

.benefit-list li::after {
  position: absolute;
  left: 4px;
  top: 0.2em;
  color: #fff;
  content: "✓";
  font-size: 0.78rem;
  font-weight: 800;
}

.desc {
  margin: auto 0 18px;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.55;
  text-align: center;
}

.quiz-card .quiz-link {
  width: calc(100% - 36px);
  margin: 0 18px 18px;
}

.quiz-email,
.quiz-trust,
.quiz-seo-text {
  margin-top: 34px;
}

.quiz-email {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.quiz-email[hidden] {
  display: none;
}

.quiz-email h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.quiz-email p {
  margin: 0 auto 16px;
  max-width: 680px;
  color: var(--muted);
  line-height: 1.55;
}

.quiz-email form {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.quiz-email input {
  width: min(340px, 100%);
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
}

.email-msg {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
}

.email-msg.success {
  color: var(--green-dark);
}

.email-msg.error {
  color: #dc2626;
}

.quiz-trust {
  padding: 18px;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #f0fbf5;
  color: #244635;
  line-height: 1.6;
}

.quiz-trust p {
  margin: 0;
}

.quiz-seo-text {
  color: #334155;
  line-height: 1.7;
}

.quiz-seo-text h2,
.quiz-seo-text h3 {
  color: #172033;
  line-height: 1.25;
}

.quiz-seo-text h2 {
  margin-top: 0;
  font-size: 1.55rem;
}

.quiz-seo-text h3 {
  margin: 24px 0 8px;
  font-size: 1.18rem;
}

.quiz-footer {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.loading-state,
.error-state {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.fade-in {
  animation: fadeIn 360ms ease both;
}

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

.quiz-choice[aria-pressed="true"] { border-color: #2563eb; background: #eff6ff; }
.quiz-choice:focus-visible, .quiz-btn:focus-visible, summary:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
#custom-budget { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 24px 0; }
#budget-value { padding: 12px; border: 1px solid #94a3b8; border-radius: 6px; max-width: 160px; font: inherit; }
.variant { color: #334155; }
.merchant-note { padding: 12px 16px; background: #fff7ed; border-left: 3px solid #d97706; color: #713f12; border-radius: 6px; }
.merchant-ribbon { font-size: .72rem; background: #fff7ed; color: #92400e; max-width: calc(100% - 28px); white-space: normal; }
.limitations { margin: 14px 0; padding: 12px; background: #fff7ed; color: #7c2d12; border-radius: 8px; font-size: .9rem; }
.limitations ul { padding-left: 18px; }
summary { cursor: pointer; padding: 18px 0; color: #1d4ed8; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } }

@media (max-width: 980px) {
  .quiz-wrapper {
    padding: 26px;
  }

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

@media (max-width: 720px) {
  .quiz-wrapper {
    width: min(100% - 20px, 680px);
    margin: 16px auto;
    padding: 20px;
  }

  .quiz-options-choice,
  .quiz-options-check,
  .quiz-products {
    grid-template-columns: 1fr;
  }

  .quiz-choice {
    min-height: auto;
  }

  .quiz-nav,
  .quiz-actions,
  .quiz-email form {
    flex-direction: column;
  }

  .quiz-btn,
  .quiz-link {
    width: 100%;
  }

  .quiz-card .quiz-link {
    width: calc(100% - 32px);
    margin: 0 16px 16px;
  }
}
