:root { --ink: #1f2a44; --soft: #5b6b88; --ice: #e8f3fb; --line: #9fb3c8; --accent: #2f7fb8; }
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", Tahoma, sans-serif; color: var(--ink); background: #f4f8fc; }
[dir="rtl"] body, body[dir="rtl"] { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", sans-serif; }
a { color: inherit; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: #fff; border-bottom: 1px solid #dbe6f0; }
.brand { font-weight: 700; text-decoration: none; color: #3b5b8a; }
.langs { display: flex; gap: 12px; font-size: 14px; }
.langs a[aria-current="true"] { font-weight: 700; text-decoration: underline; }
.intro { max-width: 1100px; margin: 24px auto 8px; padding: 0 16px; }
.intro h1 { margin: 0 0 6px; font-size: 30px; }
.intro p { margin: 0; color: var(--soft); }
.picker { max-width: 1100px; margin: 16px auto; padding: 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.picker a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 16px; background: #fff; border: 1px solid #d8e4ef; text-decoration: none; font-weight: 600; font-size: 14px; min-height: 56px; }
.picker a[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px #cfe5f5; }
.picker img { width: 34px; height: 34px; object-fit: contain; }
.actions { max-width: 1100px; margin: 8px auto 16px; padding: 0 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.actions button, .actions a { border: 0; border-radius: 999px; padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; background: #3b5b8a; color: #fff; text-decoration: none; }
.actions .secondary { background: #fff; color: #3b5b8a; border: 1px solid #b9cbe0; }
.sheets { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 0 8px 48px; }

/* A4 page */
.page { width: 210mm; min-height: 297mm; background: #fff; padding: 12mm 13mm 10mm; box-shadow: 0 4px 18px rgb(31 42 68 / 0.12); display: flex; flex-direction: column; position: relative; overflow: hidden; }
.page-head { display: flex; justify-content: space-between; gap: 8mm; font-size: 11pt; color: var(--soft); }
.page-head span { flex: 1; border-bottom: 1px solid var(--line); padding-bottom: 2mm; }
.page h2 { margin: 6mm 0 1mm; font-size: 20pt; display: flex; align-items: center; gap: 3mm; }
.page h2 img { width: 14mm; height: 14mm; }
.instr { margin: 0 0 5mm; font-size: 12.5pt; color: #33415c; }
.body { flex: 1; display: flex; flex-direction: column; gap: 4mm; }
.body > .row, .body > .shape-row, .body > .trace { flex: 1; }
.foot { margin-top: 4mm; font-size: 9pt; color: #8a98ad; text-align: center; }
.row { display: flex; align-items: center; gap: 4mm; border: 1.2px solid #d3e0ec; border-radius: 4mm; padding: 3mm 4mm; }
.objs { display: flex; flex-wrap: wrap; gap: 1.5mm; flex: 1; }
.objs img { width: 18mm; height: 18mm; object-fit: contain; }
.choices { display: flex; gap: 4mm; }
.choices b { width: 13mm; height: 13mm; border: 1.5px solid var(--line); border-radius: 50%; display: grid; place-items: center; font-size: 17pt; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; flex: 1; }
.box { border: 1.2px solid #d3e0ec; border-radius: 4mm; padding: 3mm; display: flex; flex-direction: column; justify-content: space-between; min-height: 70mm; }
.box .objs img { width: 13mm; height: 13mm; }
.write { align-self: flex-end; width: 22mm; height: 18mm; border: 1.5px dashed var(--line); border-radius: 3mm; }
[dir="rtl"] .write { align-self: flex-start; }
.tally-key { display: flex; align-items: center; gap: 4mm; font-size: 11pt; color: var(--soft); background: var(--ice); border-radius: 3mm; padding: 2mm 4mm; }
.tally-line { flex: 0 0 55mm; height: 14mm; border-bottom: 1.5px solid var(--line); }
.trace { display: flex; align-items: center; gap: 3mm; border-bottom: 1px solid #e3ebf3; padding: 1mm 0; }
.trace svg { flex: none; }
.dots { display: flex; gap: 1mm; flex-wrap: wrap; width: 34mm; }
.dots img { width: 6mm; height: 6mm; }
.letters { display: grid; gap: 2mm; }
.letters svg { width: 100%; height: auto; border: 1px solid #e3ebf3; border-radius: 2mm; }
.first .pic { width: 26mm; height: 26mm; object-fit: contain; }
.first .word { font-size: 14pt; flex: 1; }
.shape-row { display: flex; align-items: center; gap: 5mm; border: 1.2px solid #d3e0ec; border-radius: 4mm; padding: 2mm 4mm; }
.shape-row svg { width: 24mm; height: 24mm; }
.shape-row .label { width: 32mm; font-size: 13pt; font-weight: 600; }
.match { flex: 1; display: grid; grid-template-columns: 1fr 30mm 1fr; align-items: stretch; }
.match .col { display: flex; flex-direction: column; justify-content: space-around; gap: 3mm; }
.match .item { display: flex; align-items: center; gap: 3mm; min-height: 30mm; }
.match .item .dot { width: 4mm; height: 4mm; border-radius: 50%; background: var(--ink); flex: none; }
.match .left .item { justify-content: flex-end; }
.match .item img { width: 26mm; height: 26mm; object-fit: contain; }
.match .item .objs { flex: 0 1 auto; max-width: 60mm; }
.match .item .objs img { width: 11mm; height: 11mm; }
.match .item .num, .match .item .word { font-size: 20pt; font-weight: 700; }
.match .item .word { font-size: 16pt; font-weight: 600; }

@media (max-width: 820px) {
  .page { transform-origin: top center; zoom: 0.45; }
}
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .no-print, .bar, .intro, .picker, .actions { display: none !important; }
  .sheets { padding: 0; gap: 0; display: block; }
  .page { box-shadow: none; margin: 0; page-break-after: always; break-after: page; zoom: 1; }
}
