:root {
  --ink: #17333a;
  --muted: #5f7780;
  --primary: #0891b2;
  --secondary: #14b8a6;
  --accent: #f59e0b;
  --soft: #ecfeff;
  --line: #7dd3fc;
  --correct: #15803d;
  --wrong: #dc2626;
  --shadow: 0 18px 46px rgba(8, 145, 178, .16);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 12% 14%, rgba(245, 158, 11, .18), transparent 26%),
    radial-gradient(circle at 88% 10%, rgba(20, 184, 166, .18), transparent 24%),
    linear-gradient(90deg, rgba(8, 145, 178, .07) 1px, transparent 1px),
    linear-gradient(rgba(245, 158, 11, .08) 1px, transparent 1px),
    linear-gradient(135deg, #ecfeff 0%, #fff7ed 48%, #f0fdfa 100%);
  background-size: auto, auto, 30px 30px, 30px 30px, auto;
}

button,
a,
input { font: inherit; }

.quiz-page {
  width: min(1060px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.back-link {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  margin-bottom: 14px;
  padding: 14px 18px;
  border: 2px solid rgba(8, 145, 178, .2);
  border-radius: 10px;
  color: #0e7490;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 18px rgba(8, 145, 178, .08);
  font-weight: 950;
  text-align: center;
  text-decoration: none;
}

.quiz-shell {
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.quiz-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 30px;
  color: #fff;
  background: linear-gradient(135deg, #ea580c 0%, #2563eb 100%);
  border-bottom: 8px solid #eab308;
}

.quiz-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.9rem, 4.5vw, 3.35rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.quiz-hero p {
  max-width: 66ch;
  margin: 0;
  color: rgba(255, 255, 255, .94);
  font-weight: 800;
  line-height: 1.6;
}

.hero-badge {
  display: grid;
  place-items: center;
  width: 132px;
  aspect-ratio: 1;
  border: 4px solid rgba(255, 255, 255, .55);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(250, 245, 255, .9));
  color: #0e7490;
  font-size: 3rem;
  font-weight: 950;
  box-shadow: inset 0 -10px 0 rgba(245, 158, 11, .22);
}

.chapter-select,
.quiz-content {
  padding: 26px 30px 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(236, 254, 255, .9)),
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(8, 145, 178, .06) 30px 31px);
}

.chapter-select h2 {
  margin: 0 0 18px;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

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

.chapter-btn {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 18px;
  border: 2px solid rgba(255, 255, 255, .86);
  border-radius: 10px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(8, 145, 178, .1);
  transition: transform .15s ease, box-shadow .15s ease;
}

.chapter-btn.has-unit-image::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.chapter-btn.has-unit-image::after {
  background: linear-gradient(90deg, rgba(255, 255, 255, .84), rgba(255, 255, 255, .58) 58%, rgba(255, 255, 255, .2));
  z-index: 1;
}

.unit-card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-repeat: no-repeat;
  background-position: right 8px bottom 6px;
  background-size: min(48%, 154px) auto;
  opacity: .74;
  pointer-events: none;
}

.chapter-btn > * {
  position: relative;
  z-index: 2;
}

.chapter-btn:hover,
.chapter-btn:focus-visible {
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(8, 145, 178, .17);
}

.chapter-btn strong,
.chapter-btn span,
.chapter-btn em { display: block; }

.chapter-btn em {
  width: fit-content;
  margin-bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: rgba(14, 116, 144, .86);
  font-size: .78rem;
  font-style: normal;
  font-weight: 900;
}

.chapter-btn strong {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.chapter-btn span {
  color: #4c3f64;
  line-height: 1.45;
  font-weight: 800;
}

.chapter-btn:nth-child(1) { background: linear-gradient(135deg, #f4edff, #c4b5fd); }
.chapter-btn:nth-child(2) { background: linear-gradient(135deg, #fff1f7, #f9a8d4); }
.chapter-btn:nth-child(3) { background: linear-gradient(135deg, #eaf6ff, #93c5fd); }
.chapter-btn:nth-child(4) { background: linear-gradient(135deg, #ecfdf5, #86efac); }
.chapter-btn:nth-child(5) { background: linear-gradient(135deg, #fff8d7, #fde047); }
.chapter-btn:nth-child(6) { background: linear-gradient(135deg, #e5fffb, #5eead4); }
.chapter-btn:nth-child(7) { background: linear-gradient(135deg, #fff3e6, #fdba74); }
.chapter-btn:nth-child(8) { background: linear-gradient(135deg, #eef2ff, #c7d2fe); }
.chapter-btn:nth-child(9) { background: linear-gradient(135deg, #fbecff, #e9d5ff); }
.chapter-btn:nth-child(10) { background: linear-gradient(135deg, #f4ffd9, #d9f99d); }
.chapter-btn:nth-child(11) { background: linear-gradient(135deg, #fff1f2, #fda4af); }
.chapter-btn:nth-child(12) { background: linear-gradient(135deg, #ecfeff, #a5f3fc); }

.is-hidden { display: none; }

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

.progress-label {
  min-width: 120px;
  color: var(--muted);
  font-weight: 800;
  font-size: .95rem;
}

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

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f59e0b, #7c3aed, #a855f7);
  transition: width .24s ease;
}

.score-pill {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #0e7490;
  background: #fffbeb;
  text-align: center;
  font-weight: 900;
  white-space: nowrap;
}

.question-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, #fbf8ff);
}

.topic {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  color: #0e7490;
  background: #a5f3fc;
  font-size: .85rem;
  font-weight: 900;
}

.question {
  margin: 0 0 18px;
  font-size: clamp(1.22rem, 2.6vw, 1.72rem);
  line-height: 1.36;
}

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

.answer-btn {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  text-align: left;
  cursor: pointer;
  transition: transform .13s ease, border-color .13s ease, background .13s ease;
}

.answer-btn:hover:not(:disabled),
.answer-btn:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: var(--primary);
  background: #faf5ff;
}

.answer-btn:disabled { cursor: default; }
.answer-btn.is-correct { border-color: var(--correct); background: #bbf7d0; color: #064e3b; }
.answer-btn.is-wrong { border-color: var(--wrong); background: #fb7185; color: #7f1d1d; }

.text-answer {
  display: grid;
  gap: 10px;
}

.text-answer input {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.feedback {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 800;
}

.feedback.correct { background: #bbf7d0; color: #064e3b; }
.feedback.wrong { background: #fff7ed; color: #7c2d12; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.main-btn,
.ghost-btn {
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.main-btn {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 20px rgba(8, 145, 178, .16);
}

.main-btn:disabled {
  opacity: .45;
  cursor: default;
  box-shadow: none;
}

.ghost-btn {
  border: 2px solid rgba(8, 145, 178, .16);
  color: #0e7490;
  background: #fff;
}

.result-panel {
  display: none;
  padding: 26px;
  border-radius: 10px;
  background: #faf5ff;
  text-align: center;
}

.result-panel.is-visible { display: block; }

.big-score {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 950;
}

.result-panel p {
  color: var(--muted);
  line-height: 1.6;
  font-weight: 800;
}

@media (max-width: 720px) {
  .quiz-page { width: min(100% - 18px, 1060px); padding: 16px 0; }
  .quiz-hero { grid-template-columns: 1fr; padding: 22px; }
  .hero-badge { width: 96px; font-size: 2.25rem; }
  .chapter-select,
  .quiz-content { padding: 18px; }
  .chapter-grid { grid-template-columns: 1fr; }
  .progress-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .progress-label,
  .score-pill { min-width: 0; }
  .question-card { padding: 18px; }
  .actions { display: grid; grid-template-columns: 1fr; }
}
