:root {
  --purple-950: #321043;
  --purple-900: #48115f;
  --purple-800: #641b83;
  --purple-700: #782798;
  --purple-100: #f1e8f6;
  --purple-50: #faf6fc;
  --green-700: #347e18;
  --green-100: #eaf6e5;
  --blue-800: #173f75;
  --blue-100: #e9f4fd;
  --yellow-500: #f7b900;
  --yellow-100: #fff7d6;
  --red-100: #fff0f0;
  --ink: #26182d;
  --muted: #6e6473;
  --line: #e8deeb;
  --surface: #fff;
  --background: #f8f4fa;
  --shadow: 0 24px 70px rgba(67, 25, 82, 0.13);
  --font: "Tajawal", Tahoma, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(211, 239, 255, .85), transparent 24rem),
    radial-gradient(circle at 92% 90%, rgba(235, 214, 246, .85), transparent 25rem),
    var(--background);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--yellow-500); outline-offset: 3px; }
.skip-link {
  position: fixed; top: 12px; left: 50%; z-index: 100;
  padding: 9px 18px; color: #fff; background: var(--purple-900); border-radius: 999px;
  transform: translate(-50%, -160%); transition: transform .18s ease;
}
.skip-link:focus { transform: translate(-50%, 0); }
.assessment-header {
  display: flex; width: min(1120px, calc(100% - 40px)); height: 78px; margin: 0 auto;
  align-items: center; justify-content: space-between;
}
.assessment-brand { display: grid; width: 116px; height: 62px; overflow: hidden; place-items: center; }
.assessment-brand img { width: 120px; height: auto; margin-block: -29px; }
.exit-link { color: var(--muted); font-size: 15px; font-weight: 700; }
.exit-link:hover { color: var(--purple-800); }
.assessment-main { width: min(1060px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 64px; }
.screen { display: none; }
.screen.is-active { display: grid; animation: screen-in .3s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.intro-screen {
  min-height: calc(100vh - 150px); grid-template-columns: minmax(300px, .78fr) minmax(420px, 1.22fr);
  gap: clamp(34px, 7vw, 86px); align-items: center;
}
.intro-art { position: relative; display: grid; min-height: 590px; place-items: center; }
.intro-art::before {
  position: absolute; inset: 8% 4%; content: "";
  background: linear-gradient(145deg, #e9d7f2, #e7f5fd); border-radius: 46% 54% 48% 52% / 55% 43% 57% 45%;
  transform: rotate(-4deg);
}
.intro-mark {
  position: relative; display: grid; width: 245px; height: 300px; color: #fff;
  background: linear-gradient(155deg, var(--purple-700), var(--purple-950)); border: 9px solid rgba(255,255,255,.85);
  border-radius: 46% 54% 45% 55% / 43% 47% 53% 57%; box-shadow: var(--shadow); place-items: center;
  font-size: 150px; font-weight: 900; transform: rotate(5deg);
}
.math-chip {
  position: absolute; z-index: 2; padding: 8px 17px; direction: ltr; color: var(--purple-900);
  background: rgba(255,255,255,.94); border: 1px solid rgba(100,27,131,.13); border-radius: 999px;
  box-shadow: 0 10px 25px rgba(67,25,82,.11); font-size: 20px; font-weight: 900;
}
.chip-one { top: 15%; right: 2%; transform: rotate(7deg); }
.chip-two { bottom: 19%; left: 0; color: var(--green-700); transform: rotate(-8deg); }
.chip-three { top: 39%; left: -2%; color: var(--blue-800); transform: rotate(4deg); }
.eyebrow { display: inline-block; margin-bottom: 12px; color: var(--purple-700); font-size: 15px; font-weight: 900; }
.intro-copy h1, .complete-screen h1 { margin: 0 0 18px; font-size: clamp(38px, 5vw, 62px); line-height: 1.15; letter-spacing: -.025em; }
.intro-copy > p, .complete-screen > p { max-width: 660px; margin: 0 0 22px; color: var(--muted); font-size: 19px; }
.intro-points { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 28px; padding: 0; list-style: none; color: #514657; font-size: 14px; font-weight: 700; }
.intro-points li { display: flex; align-items: center; gap: 6px; }
.intro-points span { display: grid; width: 21px; height: 21px; color: var(--green-700); background: var(--green-100); border-radius: 50%; place-items: center; }
.student-form { padding: 25px; background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 14px 40px rgba(67,25,82,.08); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { margin-bottom: 15px; }
.field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 800; }
.field input, .field select {
  width: 100%; height: 52px; padding: 0 15px; color: var(--ink); background: #fff;
  border: 1px solid #d9cddd; border-radius: 13px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--purple-700); box-shadow: 0 0 0 4px rgba(120,39,152,.1); }
.privacy-note { margin: 10px 4px 0 !important; font-size: 12px !important; }
.assessment-consent { display: flex; align-items: flex-start; gap: 9px; margin: 2px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.assessment-consent input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--purple-700); }

.primary-button, .secondary-button, .unknown-button {
  display: inline-flex; min-height: 52px; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 25px; border-radius: 15px; font-weight: 800; cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.primary-button { color: #fff; background: linear-gradient(135deg, var(--purple-700), var(--purple-900)); border: 0; box-shadow: 0 12px 28px rgba(100,27,131,.24); }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 16px 30px rgba(100,27,131,.3); }
.student-form .primary-button { width: 100%; }
.secondary-button { color: var(--purple-800); background: #fff; border: 1px solid #d9cddd; }
.unknown-button { color: var(--muted); background: transparent; border: 0; font-size: 15px; }
.unknown-button.is-selected { color: var(--purple-800); background: var(--purple-100); }

.question-screen { max-width: 820px; min-height: calc(100vh - 160px); margin: 0 auto; align-content: start; }
.progress-shell { margin-bottom: 18px; }
.progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; font-size: 14px; font-weight: 800; }
.section-label { color: var(--muted); }
.progress-track { height: 11px; overflow: hidden; background: #e9e1ec; border-radius: 999px; }
.progress-fill { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--yellow-500), #ffcf3f); border-radius: inherit; transition: width .4s ease; }
.question-card {
  min-height: 500px; padding: clamp(25px, 5vw, 48px); background: rgba(255,255,255,.96);
  border: 1px solid var(--line); border-radius: 30px; box-shadow: var(--shadow);
}
.question-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.question-kind { padding: 6px 12px; color: var(--purple-700); background: var(--purple-100); border-radius: 999px; font-size: 13px; font-weight: 900; }
.sound-button { display: grid; width: 42px; height: 42px; color: var(--purple-700); background: #fff; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; place-items: center; }
.sound-button svg { width: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.question-card h1 { margin: 0 0 6px; font-size: clamp(27px, 4vw, 40px); line-height: 1.35; }
.question-help { min-height: 28px; margin: 0 0 20px; color: var(--muted); font-size: 15px; }
.question-visual { display: grid; min-height: 72px; margin: 12px 0 25px; place-items: center; }
.dots { display: flex; max-width: 460px; flex-wrap: wrap; gap: 13px; justify-content: center; direction: ltr; }
.dot { width: 34px; height: 34px; background: var(--purple-700); border: 5px solid #e9d9f0; border-radius: 50%; }
.dot:nth-child(3n+2) { background: var(--yellow-500); border-color: var(--yellow-100); }
.groups-visual { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; direction: ltr; }
.visual-group { display: flex; gap: 7px; padding: 14px; background: var(--purple-50); border: 2px dashed #cbaed7; border-radius: 18px; }
.visual-group .dot { width: 24px; height: 24px; border-width: 3px; }
.sequence { padding: 16px 26px; direction: ltr; color: var(--purple-900); background: var(--purple-50); border-radius: 18px; font-size: clamp(26px, 5vw, 38px); font-weight: 900; letter-spacing: .08em; }
.equation { direction: ltr; color: var(--purple-900); font-size: clamp(34px, 7vw, 58px); font-weight: 900; }
.answer-area { display: grid; gap: 12px; }
.number-answer, .text-answer {
  width: min(280px, 100%); height: 64px; margin: 0 auto; padding: 0 18px; color: var(--ink); background: #fff;
  border: 2px solid #d9cddd; border-radius: 17px; outline: 0; text-align: center; direction: ltr; font-size: 26px; font-weight: 800;
}
.text-answer { width: min(500px, 100%); height: 58px; font-size: 19px; }
.number-answer:focus, .text-answer:focus { border-color: var(--purple-700); box-shadow: 0 0 0 5px rgba(120,39,152,.1); }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice {
  display: flex; min-height: 66px; align-items: center; gap: 12px; padding: 14px 17px; text-align: right;
  color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 17px; cursor: pointer;
}
.choice:hover { border-color: #c9afd4; }
.choice.is-selected { background: var(--purple-50); border-color: var(--purple-700); box-shadow: 0 0 0 3px rgba(120,39,152,.08); }
.choice-marker { display: grid; width: 28px; height: 28px; flex: 0 0 auto; color: var(--muted); border: 2px solid #cfc1d4; border-radius: 50%; place-items: center; font-size: 13px; font-weight: 900; }
.choice.is-selected .choice-marker { color: #fff; background: var(--purple-700); border-color: var(--purple-700); }
.choice-math { direction: ltr; font-size: 23px; font-weight: 800; }
.multi-inputs { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; direction: ltr; }
.multi-inputs input { width: 82px; height: 58px; text-align: center; border: 2px solid #d9cddd; border-radius: 15px; outline: 0; font-size: 22px; font-weight: 800; }
.group-builder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; direction: ltr; }
.build-group { min-height: 155px; padding: 12px; background: var(--purple-50); border: 2px dashed #cbaed7; border-radius: 18px; text-align: center; }
.built-dots { display: flex; min-height: 76px; flex-wrap: wrap; align-content: center; justify-content: center; gap: 5px; }
.built-dots .dot { width: 20px; height: 20px; border-width: 2px; }
.group-controls { display: flex; justify-content: center; gap: 7px; }
.group-controls button { width: 34px; height: 34px; color: var(--purple-800); background: #fff; border: 1px solid #d9cddd; border-radius: 10px; cursor: pointer; font-weight: 900; }
.sub-prompt { margin: 7px 0 3px; color: var(--muted); font-size: 14px; font-weight: 700; }
.nudge { margin-top: 22px; padding: 12px 15px; color: var(--blue-800); background: var(--blue-100); border-radius: 13px; font-size: 14px; }
.question-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 18px; }
.question-actions .primary-button { justify-self: end; }
.question-actions .secondary-button { justify-self: start; }
.question-actions button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.save-status { margin: 10px 0 0; color: #8a7f8f; text-align: center; font-size: 12px; }

.complete-screen { max-width: 760px; min-height: calc(100vh - 150px); margin: 0 auto; text-align: center; align-content: center; justify-items: center; }
.celebration { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; color: var(--yellow-500); font-size: 30px; }
.celebration strong { display: grid; width: 94px; height: 94px; color: #fff; background: linear-gradient(145deg, var(--green-700), #62a944); border: 8px solid var(--green-100); border-radius: 50%; place-items: center; font-size: 48px; }
.student-summary { display: grid; width: 100%; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 24px 0 30px; text-align: right; }
.summary-card { padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 28px rgba(67,25,82,.07); }
.summary-card span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; font-weight: 700; }
.summary-card strong { color: var(--purple-900); font-size: 19px; }
.complete-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.report-generation-status { min-height: 24px; margin: -8px 0 15px; color: var(--muted); font-size: 14px; }
.generated-report-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 20px; }
.generated-report-actions[hidden] { display: none; }

@media (max-width: 800px) {
  .intro-screen { grid-template-columns: 1fr; }
  .intro-art { display: none; }
  .intro-copy { max-width: 620px; margin: 5vh auto 0; }
  .question-card { min-height: 470px; border-radius: 24px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .assessment-header, .assessment-main { width: min(100% - 24px, 1060px); }
  .assessment-header { height: 68px; }
  .assessment-main { padding-top: 14px; }
  .intro-copy h1, .complete-screen h1 { font-size: 37px; }
  .intro-copy > p { font-size: 17px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .student-form { padding: 19px; border-radius: 20px; }
  .progress-meta { align-items: flex-start; flex-direction: column; gap: 2px; }
  .question-card { min-height: 460px; padding: 22px 18px; }
  .question-card h1 { font-size: 27px; }
  .choices { grid-template-columns: 1fr; }
  .choice { min-height: 58px; }
  .group-builder { gap: 7px; }
  .build-group { min-height: 145px; padding: 8px 5px; }
  .question-actions { grid-template-columns: 1fr 1fr; }
  .question-actions .unknown-button { grid-column: 1 / -1; grid-row: 2; }
  .question-actions .primary-button, .question-actions .secondary-button { width: 100%; }
  .student-summary { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
