:root {
  --ink: #111;
  --muted: #5b6370;
  --line: #222;
  --soft-line: #c9c9c9;
  --paper: #fff;
  --blue: #244e77;
  --quote-cell-w: 24px;
  --quote-cell-h: 25px;
  --clue-cell-w: 20px;
  --clue-cell-h: 22px;
  --key-cell-w: 20px;
  --key-cell-h: 22px;
  --space-cell-w: 11px;
  --cell-label-font: 5.5px;
  --quote-punct-font: 15px;
  --quote-break-font: 16px;
  --clue-font: 11px;
  --clue-gap: 8px;
  --quote-word-gap: 5px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: #e9eef3;
  font-family: Georgia, "Times New Roman", serif;
}

.print-page {
  width: min(8.5in, calc(100% - 24px));
  min-height: 11in;
  margin: 18px auto;
  padding: .42in .45in;
  background: var(--paper);
  box-shadow: 0 10px 35px rgba(0,0,0,.18);
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  border-bottom: 2px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.brand {
  font: 800 15px/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--blue);
}

h1 {
  margin: 4px 0 3px;
  font-size: 25px;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.meta,
.section-head p,
.print-footer {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.25;
}

.print-controls {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 6px;
  align-items: center;
  font: 13px system-ui, -apple-system, "Segoe UI", sans-serif;
}
.size-controls {
  display: inline-grid;
  grid-template-columns: 28px minmax(42px, auto) 28px;
  align-items: center;
  gap: 3px;
  justify-self: start;
}
.size-controls button {
  min-width: 28px;
  padding-inline: 0;
  font-size: 16px;
  line-height: 1;
}
#sizeLabel {
  font: 700 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--muted);
  text-align: center;
}

.print-controls label {
  grid-column: 1 / -1;
  font-weight: 700;
  color: var(--muted);
}

.print-controls select {
  grid-column: 1 / -1;
  max-width: 245px;
  padding: 5px;
}

.print-controls button,
.print-controls a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid #9aa8b8;
  border-radius: 6px;
  background: #f7f8fa;
  color: #13263b;
  text-decoration: none;
  font: 700 12px system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 5px 9px;
}

.print-section {
  margin-top: 10px;
  break-inside: avoid;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--soft-line);
  padding-bottom: 3px;
}

.section-head p {
  margin: 0;
  text-align: right;
}

.print-quote {
  line-height: 1.75;
  font-size: 0;
}

.quote-word {
  display: inline-block;
  white-space: nowrap;
  margin-right: var(--quote-word-gap);
  vertical-align: middle;
}

.quote-punct {
  display: inline-block;
  font-size: var(--quote-punct-font);
  margin: 0 2px;
  vertical-align: middle;
}

.quote-break {
  display: inline-block;
  font-size: var(--quote-break-font);
  font-weight: 700;
  margin: 0 8px;
  color: #555;
}

.print-cell {
  display: inline-block;
  position: relative;
  width: var(--clue-cell-w);
  height: var(--clue-cell-h);
  border: 1.35px solid var(--line);
  margin: 1px;
  background: #fff;
  vertical-align: middle;
}

.quote-cell {
  width: var(--quote-cell-w);
  height: var(--quote-cell-h);
}
.quote-space-cell {
  display: inline-block;
  width: var(--space-cell-w);
  height: var(--quote-cell-h);
  margin: 1px 4px 1px 1px;
  background: #111;
  border: 1.35px solid #111;
  vertical-align: middle;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.clue-cell {
  width: var(--clue-cell-w);
  height: var(--clue-cell-h);
}

.key-cell {
  width: var(--key-cell-w);
  height: var(--key-cell-h);
}

.cell-id {
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  font: var(--cell-label-font)/1 Arial, Helvetica, sans-serif;
  color: #222;
  text-align: center;
  white-space: nowrap;
  letter-spacing: -.08em;
  transform: scaleX(.88);
  transform-origin: center top;
}
.cell-id .letter-id {
  color: #222;
}
.cell-id .clue-id,
.clue-number,
.key-id {
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.key-section {
  margin-top: 9px;
}

.print-key {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.clues-section {
  margin-top: 12px;
}

.print-clues {
  columns: 2;
  column-gap: 18px;
  column-rule: 1px solid #ddd;
}

.print-clue {
  break-inside: avoid;
  margin: 0 0 var(--clue-gap);
  font-size: var(--clue-font);
  line-height: 1.22;
}

.clue-text {
  margin-bottom: 2px;
}

.answer-row {
  line-height: 1.55;
  white-space: normal;
}

.print-footer {
  margin-top: 12px;
  border-top: 1px solid #bbb;
  padding-top: 5px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

@page {
  size: letter;
  margin: .35in;
}

@media print {
  body {
    background: #fff;
  }

  .print-page {
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .print-controls {
    display: none;
  }

  .print-header {
    margin-bottom: 8px;
  }

  .print-section {
    margin-top: 8px;
  }

  .print-clues {
    column-gap: 16px;
  }

  .print-cell {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

@media screen and (max-width: 760px) {
  .print-page {
    width: min(100% - 14px, 8.5in);
    padding: 18px 14px;
  }

  .print-header,
  .section-head {
    display: block;
  }

  .section-head p {
    text-align: left;
    margin-top: 3px;
  }

  .print-controls {
    margin-top: 12px;
  }
  .size-controls {
    justify-self: stretch;
  }

  .print-clues {
    columns: 1;
  }
}
