.spire-puzzle-worksheet {
  display: none;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  body[data-spire-print-mode="puzzle-worksheet"] {
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  body[data-spire-print-mode="puzzle-worksheet"] > *:not(.spire-puzzle-worksheet) {
    display: none !important;
  }

  body[data-spire-print-mode="puzzle-worksheet"] > .spire-puzzle-worksheet {
    display: grid !important;
  }

  .spire-puzzle-worksheet {
    width: 281mm;
    height: 194mm;
    grid-template-rows: 22mm minmax(0, 1fr) 5mm;
    gap: 2mm;
    color: #000000;
    background: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .spire-puzzle-worksheet__brand {
    display: grid !important;
    grid-template-columns: 40mm minmax(0, 1fr) 65mm;
    align-items: center;
    gap: 4mm;
    border-bottom: 0;
  }

  .spire-puzzle-worksheet__brand > img {
    width: 36mm !important;
  }

  .spire-puzzle-worksheet__heading {
    min-width: 0;
    text-align: center;
  }

  .spire-puzzle-worksheet__heading h2 {
    margin: 0;
    color: #102131;
    font-size: 17pt;
    line-height: 1.05;
  }

  .spire-puzzle-worksheet__heading p {
    margin: 1.2mm 0 0;
    color: #34495a;
    font-size: 8.5pt;
    font-weight: 700;
    line-height: 1.15;
  }

  .spire-puzzle-worksheet__pupil {
    display: grid;
    gap: 3mm;
  }

  .spire-puzzle-worksheet__field {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: end;
    gap: 2mm;
    font-size: 8.5pt;
    font-weight: 700;
  }

  .spire-puzzle-worksheet__field-line {
    min-width: 0;
    height: 4mm;
    border-bottom: 0.4mm solid #102131;
  }

  .spire-puzzle-worksheet__grid {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 3mm;
  }

  .spire-puzzle-worksheet__card {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: center;
    justify-items: center;
    gap: 1mm;
    padding: 2mm;
    border: 0.45mm solid #657786;
    border-radius: 2mm;
    background: #ffffff;
    break-inside: avoid;
  }

  .spire-puzzle-worksheet__card h3 {
    justify-self: start;
    margin: 0;
    color: #102131;
    font-size: 9pt;
    line-height: 1;
  }

  .spire-puzzle-worksheet__result-line {
    justify-self: stretch;
    margin: 0;
    color: #102131;
    font-size: 8.5pt;
    font-weight: 700;
    line-height: 1;
  }

  .spire-puzzle-worksheet__copyright {
    display: block !important;
    margin: 0;
    align-self: end;
    text-align: right;
  }

  .spire-puzzle-worksheet .arithmagon-board {
    --zoom: 0.42 !important;
    width: 760px;
    height: 510px;
    transform: scale(var(--zoom));
    transform-origin: center;
    margin: -75px -215px;
  }

  .spire-puzzle-worksheet .arithmagon-board .node-input {
    color: #000000;
    border-color: #000000;
    box-shadow: none;
    background: #ffffff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .spire-puzzle-worksheet .arithmagon-board .connector-layer line {
    stroke: #657786;
    stroke-width: 5;
  }

  .spire-puzzle-worksheet .dot-board {
    --zoom: 1 !important;
    width: min(100%, 96mm);
    height: min(100%, 64mm);
    align-self: center;
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr)) minmax(6mm, 0.55fr);
    grid-template-rows: repeat(var(--rows), minmax(0, 1fr)) minmax(6mm, 0.55fr);
    gap: 0.6mm;
    transform: none;
  }

  .spire-puzzle-worksheet .dot-board .grid-cell,
  .spire-puzzle-worksheet .dot-board .target-cell {
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border-width: 0.35mm;
    border-radius: 1mm;
    box-shadow: none;
    font-size: 9pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .spire-puzzle-worksheet .dot-board .grid-cell {
    border-color: #657786;
    background: #ffffff;
  }

  .spire-puzzle-worksheet .dot-board .target-cell {
    border-color: #102131;
    background: #eef4f8;
    color: #102131;
    font-weight: 800;
  }

  .spire-puzzle-worksheet .ops-board {
    --zoom: 1 !important;
    width: min(100%, 108mm);
    height: min(100%, 66mm);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(13mm, 1.3fr);
    grid-template-rows: repeat(5, minmax(0, 1fr)) minmax(8mm, 0.75fr);
    gap: 0.6mm;
    transform: none;
  }

  .spire-puzzle-worksheet .ops-board .tile,
  .spire-puzzle-worksheet .ops-board .result-tile,
  .spire-puzzle-worksheet .ops-board .blank-tile {
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border-radius: 1mm;
    box-shadow: none;
    font-size: 9pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .spire-puzzle-worksheet .ops-board .digit-tile {
    border: 0.35mm solid #102131;
    background: #ffffff;
  }

  .spire-puzzle-worksheet .ops-board .digit-tile.revealed {
    background: #eef4f8;
  }

  .spire-puzzle-worksheet .ops-board .operator-tile {
    font-size: 11pt;
  }

  .spire-puzzle-worksheet .ops-board .result-tile {
    border: 0.35mm solid #102131;
    background: #eef4f8;
    color: #102131;
  }

  .spire-puzzle-worksheet .sums-board {
    --zoom: 1 !important;
    width: min(100%, 105mm);
    height: min(100%, 60mm);
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
    gap: 1mm;
  }

  .spire-puzzle-worksheet .sums-board .sums-cell {
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    border: 0.4mm solid #102131;
    border-radius: 1mm;
    box-shadow: none;
    background: #ffffff;
  }
}
