:root {
  --ink: #253752;
  --muted: #6d7b91;
  --paper: #ffffff;
  --page: #eef3fa;
  --purple: #7559d9;
  --purple-light: #eeeaff;
  --orange: #f49a4b;
  --orange-light: #fff2df;
  --teal: #39afab;
  --teal-light: #e1f6f4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: Nunito, Arial, sans-serif;
}

.worksheet {
  width: min(210mm, calc(100% - 32px));
  min-height: 297mm;
  margin: 24px auto 18px;
  padding: 14mm 15mm 12mm;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: 0 10px 36px rgb(38 57 82 / 12%);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  border-bottom: 2px solid #e8edf5;
  padding-bottom: 6mm;
}

.eyebrow { margin: 0 0 3px; color: var(--purple); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: 29px; line-height: 1.05; }

.student-fields { display: flex; gap: 14px; padding-top: 4px; color: var(--muted); font-size: 13px; font-weight: 700; }
.student-fields label { display: flex; gap: 6px; align-items: end; white-space: nowrap; }
.student-fields span { display: inline-block; width: 90px; height: 18px; border-bottom: 1.5px solid #aeb9c9; }

.intro { margin: 6mm 0 6mm; padding: 9px 12px; background: #f7f5ff; border-radius: 9px; color: #58449e; font-size: 14px; font-weight: 700; }
.sparkle { margin-right: 6px; color: var(--purple); font-size: 18px; }

.task-section { margin-top: 5mm; }
.section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 3.5mm; }
.number { display: grid; place-items: center; width: 25px; height: 25px; color: white; border-radius: 50%; font-size: 14px; font-weight: 800; }
h2 { margin: 0; font-size: 20px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 600; }
.multiplication-section .number { background: var(--purple); }
.addition-section .number { background: var(--orange); }
.subtraction-section .number { background: var(--teal); }

.tasks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px 14px; }
.task {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
  padding: 7px 5px 7px 9px;
  border-radius: 7px;
  font-size: 17px;
  font-weight: 800;
}
.multiplication-section .task { background: var(--purple-light); }
.addition-section .task { background: var(--orange-light); }
.subtraction-section .task { background: var(--teal-light); }
.task input {
  width: 42px;
  min-width: 42px;
  height: 27px;
  padding: 1px 4px;
  border: 1.5px solid #a9b4c3;
  border-radius: 4px;
  background: white;
  color: var(--ink);
  font: inherit;
  text-align: center;
}
.task input:focus { outline: 2px solid #9c8be7; border-color: #9c8be7; }
.task input.incorrect { border-color: #df4c58; background: #fff0f1; color: #b72e3a; }

.actions { display: flex; justify-content: center; gap: 10px; margin: 0 auto 28px; }
.button { border: 0; border-radius: 8px; padding: 11px 18px; cursor: pointer; font: 800 15px Nunito, Arial, sans-serif; transition: transform .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); box-shadow: 0 5px 13px rgb(46 62 89 / 17%); }
.button-primary { background: var(--purple); color: white; }
.button-secondary { background: white; color: var(--purple); box-shadow: inset 0 0 0 1.5px #c7bdf2; }
.button-check { background: var(--teal); color: white; }
.button-check:disabled { cursor: not-allowed; background: #b5c2ca; color: #f8fafb; }
.button-check:disabled:hover { transform: none; box-shadow: none; }

@media (max-width: 630px) {
  .worksheet { width: calc(100% - 20px); margin-top: 10px; padding: 24px 18px; }
  .page-header { flex-direction: column; }
  .student-fields { width: 100%; justify-content: space-between; }
  .student-fields span { width: 72px; }
  .tasks { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .hint { display: none; }
}

@page { size: A4 portrait; margin: 0; }
@media print {
  body { background: white; }
  .worksheet { width: 210mm; min-height: 297mm; margin: 0; padding: 14mm 15mm 12mm; border-radius: 0; box-shadow: none; }
  .actions { display: none; }
  .task input { appearance: none; }
}
