/*
 * Shared print layout for foldbook (web/index.html). Single source of truth
 * for the 2x4 A4 grid and the per-column text rotation.
 */

@page {
  size: A4 portrait;
  margin: 0;
}

/* Two-sided printing: the front sheet (pages 1-8) and back sheet (pages
   9-16) must land on separate physical print pages so a duplex printer puts
   them on opposite sides of the same sheet of paper. */
@media print {
  .sheet-group.back {
    break-before: page;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.sheet {
  width: 210mm;
  height: 297mm;
  display: grid;
  grid-template-columns: 105mm 105mm;
  grid-template-rows: repeat(4, 74.25mm);
  overflow: hidden;
}

.cell {
  position: relative;
  width: 105mm;
  height: 74.25mm;
  overflow: hidden;
  border: 0.2mm dashed #999;
  /* Print fix: .cell-inner is laid out unrotated (74.25 x 105mm) and only
     then rotated, so in the bottom row (D) its untransformed box sticks
     ~15mm past the bottom of the A4 page. Chrome's print fragmentation works
     on that untransformed box and splits it at the page edge, so long text on
     pages 3/4 (11/12) came out shifted, clipped and overlapping in the PDF.
     Containment makes each cell monolithic, so nothing inside gets split. */
  contain: strict;
}

/* The sheet is folded along every grid line except one: a physical cut runs
   along the middle of the vertical line between the two columns, but only
   across the two middle rows (B, C) — i.e. between B1|B2 and C1|C2. DOM
   order within .sheet is A1,A2,B1,B2,C1,C2,D1,D2, so those are children
   3-6. Everywhere else (including the rest of that same vertical line, in
   rows A and D) stays a dashed fold line. */
.sheet .cell:nth-child(3),
.sheet .cell:nth-child(5) {
  border-right-style: solid;
}

.sheet .cell:nth-child(4),
.sheet .cell:nth-child(6) {
  border-left-style: solid;
}

.cell-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 74.25mm;
  height: 105mm;
  display: flex;
  flex-direction: column;
  transform-origin: center center;
}

.col-1 .cell-inner {
  transform: translate(-50%, -50%) rotate(90deg);
}

.col-2 .cell-inner {
  transform: translate(-50%, -50%) rotate(270deg);
}

.cell-label {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.2mm;
  color: #666;
  text-align: center;
  padding: 0 2mm 5mm 2mm;
}

.cell-content {
  flex: 1 1 auto;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.6mm;
  line-height: 1.3;
  padding: 2mm 5mm 3mm 5mm;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: inherit;
  width: 100%;
}

/* Block elements produced by the markdown-lite renderer (bold/italic/lists). */
.cell-content p {
  margin: 0 0 2mm 0;
}

.cell-content ul,
.cell-content ol {
  margin: 0 0 2mm 0;
  padding-left: 4mm;
}

.cell-content li {
  margin: 0;
}

.cell-content p:last-child,
.cell-content ul:last-child,
.cell-content ol:last-child {
  margin-bottom: 0;
}

/* Text colors: {red}text{/red} in the page markdown (see web/app.js).
   Dark enough to stay readable in print, distinct enough to tell apart. */
.ink-red { color: #d32f2f; }
.ink-orange { color: #e8710a; }
.ink-yellow { color: #c79100; }
.ink-green { color: #2e7d32; }
.ink-blue { color: #1565c0; }
.ink-purple { color: #7b1fa2; }
.ink-pink { color: #d81b60; }
.ink-gray { color: #808080; }

/* Pipe tables (| a | b |). */
.cell-content .md-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 2mm 0;
  white-space: normal;
}

.cell-content .md-table th,
.cell-content .md-table td {
  border: 0.2mm solid #999;
  padding: 0.5mm 1mm;
  height: 1.5em;
  text-align: left;
  vertical-align: top;
  /* The page sets overflow-wrap:anywhere, which also lets the table
     algorithm squeeze a column down to one letter ("Na|me"). break-word
     wraps between words first and splits a word only if it alone is
     wider than the page. */
  overflow-wrap: break-word;
}

.cell-content .md-table th {
  background: #eee;
  font-weight: bold;
}

/* A picture on a line of its own: page width at most, and in the page's
   flex column it shrinks (keeping its proportions) rather than overflow. */
.cell-content .md-img {
  display: block;
  flex: 0 1 auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: 0 auto 2mm auto;
}

.cell-content .md-table:last-child,
.cell-content .md-img:last-child {
  margin-bottom: 0;
}

/* A "---" divider splits a cell into a CSS grid of equal-height, bordered
   rows — the exact same technique used to divide the sheet into its 8
   pages (.sheet is display:grid with grid-auto-rows/grid-template-rows;
   .cell gets a dashed border). Used by the Week template (one row per
   day), but works in any cell. */
.cell-content .row-grid {
  display: grid;
  grid-auto-rows: 1fr;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.cell-content .row-cell {
  border: 0.2mm dashed #999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cell-content .row-cell p,
.cell-content .row-cell ul,
.cell-content .row-cell ol {
  margin: 0;
}

/* Page presets ({{grid}}, {{calendar 2026-11}}, ... — see web/app.js). A
   preset fills whatever height is left below the page's text: the rendered
   page (.cell-print) is a flex column. */
.cell-content .preset {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  white-space: normal;
}

.cell-content p + .preset,
.cell-content ul + .preset,
.cell-content ol + .preset {
  margin-top: 1mm;
}

.cell-content .preset-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Calendar: a title, then a 7-column grid whose day rows share the
   remaining height. */
.cell-content .preset-calendar {
  display: flex;
  flex-direction: column;
}

.cell-content .cal-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

.cell-content .cal-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 0.2mm solid #999;
  border-left: 0.2mm solid #999;
}

.cell-content .cal-head,
.cell-content .cal-day {
  border-right: 0.2mm solid #999;
  border-bottom: 0.2mm solid #999;
  padding: 0.6mm 0.8mm;
  font-size: 2.2mm;
  line-height: 1;
}

.cell-content .cal-head {
  text-align: center;
  font-weight: bold;
  background: #eee;
}

.cell-content .cal-weekend {
  color: #b03030;
}

.cell-content .cal-empty {
  background: #f6f6f6;
}

/* A month (title + grid) is itself a flex column; the 3-month and year
   views stack or tile several of them. */
.cell-content .cal-month {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cell-content .cal-months {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2.5mm;
}

.cell-content .cal-view-3months .cal-title {
  font-size: 2.8mm;
  margin-bottom: 1mm;
}

.cell-content .cal-view-3months .cal-head,
.cell-content .cal-view-3months .cal-day {
  font-size: 2mm;
  padding: 0.3mm 0.6mm;
}

/* Year: 12 small months, 3 x 4, without cell borders. */
.cell-content .cal-year {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2mm 3mm;
}

.cell-content .cal-view-year .cal-month .cal-title {
  font-size: 2.3mm;
  margin-bottom: 0.6mm;
}

.cell-content .cal-view-year .cal-grid {
  border: none;
}

.cell-content .cal-view-year .cal-head,
.cell-content .cal-view-year .cal-day {
  border: none;
  background: none;
  padding: 0;
  font-size: 1.75mm;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-content .cal-view-year .cal-head {
  font-weight: bold;
}

/* Week: one row per day to write in. */
.cell-content .cal-week {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  border-top: 0.2mm solid #999;
}

.cell-content .cal-wday {
  border-bottom: 0.2mm solid #999;
  padding: 0.8mm 0.5mm;
  font-size: 2.5mm;
  font-weight: bold;
  line-height: 1;
}

/* Checklist: fixed 7mm rows; auto-fill creates only as many tracks as fit
   whole, the surplus rows go into 0-height implicit tracks and are
   clipped, so the page never ends on a half-cut row. */
.cell-content .preset-checklist {
  display: grid;
  grid-template-rows: repeat(auto-fill, 7mm);
  grid-auto-rows: 0;
}

.cell-content .check-row {
  overflow: hidden;
}

.cell-content .check-line {
  height: 7mm;
  display: flex;
  align-items: flex-end;
  padding-bottom: 1mm;
  border-bottom: 0.2mm solid #a5a5a5;
}

.cell-content .check-box {
  width: 3.4mm;
  height: 3.4mm;
  border: 0.3mm solid #555;
  border-radius: 0.4mm;
}

/* Wheel of life: SVG in viewBox units (~0.2mm each at full page width). */
.cell-content .preset-wheel text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  fill: #222;
}

/* Mandala to color: its title (with the seed), then the drawing. */
.cell-content .preset-mandala {
  display: flex;
  flex-direction: column;
}

.cell-content .mandala-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

.cell-content .preset-mandala .preset-svg {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

/* Sudoku: a title (level, seed), then the puzzles in one SVG, 10 units a
   cell. */
.cell-content .preset-sudoku {
  display: flex;
  flex-direction: column;
}

.cell-content .sudoku-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

.cell-content .preset-sudoku .preset-svg {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.cell-content .preset-sudoku text {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 6.4px;
  fill: #222;
  text-anchor: middle;
  dominant-baseline: central;
}

.cell-content .preset-sudoku .sudoku-num {
  font-size: 4px;
  fill: #888;
  text-anchor: start;
  dominant-baseline: auto;
}

.cell-content .sudoku-thin {
  stroke: #9a9a9a;
  stroke-width: 0.35;
}

.cell-content .sudoku-thick {
  stroke: #222;
  stroke-width: 1;
}

/* Yatzy score sheet: a label column (with a grey scoring hint) and one
   column per player; the rows share the page height. */
.cell-content .preset-yatzy {
  display: flex;
  flex-direction: column;
}

.cell-content .yatzy-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

.cell-content .yatzy-table {
  flex: 1 1 auto;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.3mm;
  line-height: 1.1;
}

.cell-content .yatzy-label-col {
  width: 34%;
}

.cell-content .yatzy-table th,
.cell-content .yatzy-table td {
  border: 0.2mm solid #999;
  padding: 0 0.8mm;
  text-align: left;
  font-weight: normal;
  vertical-align: middle;
}

.cell-content .yatzy-hint {
  display: block;
  font-size: 1.6mm;
  color: #999;
}

.cell-content .yatzy-names th {
  height: 6mm;
  color: #666;
}

.cell-content .yatzy-sum th,
.cell-content .yatzy-sum td {
  background: #f0f0f0;
}

.cell-content .yatzy-total th,
.cell-content .yatzy-total td {
  background: #e4e4e4;
  font-weight: bold;
  border-top: 0.4mm solid #444;
}

/* Shared titles of the newer presets. */
.cell-content .eis-title,
.cell-content .jr-title,
.cell-content .maze-title,
.cell-content .exp-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

/* Eisenhower matrix: axis labels on top and on the left, 2 x 2 boxes. */
.cell-content .preset-eisenhower,
.cell-content .preset-journal,
.cell-content .preset-maze,
.cell-content .preset-expenses {
  display: flex;
  flex-direction: column;
}

.cell-content .eis-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 4.5mm 1fr 1fr;
  grid-template-rows: auto 1fr 1fr;
  gap: 1mm;
  font-family: Arial, Helvetica, sans-serif;
}

.cell-content .eis-axis {
  font-size: 2.3mm;
  font-weight: bold;
  color: #666;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cell-content .eis-side {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-content .eis-side span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.cell-content .eis-q {
  border: 0.3mm solid #888;
  border-radius: 1mm;
  padding: 1mm 1.2mm;
}

.cell-content .eis-q-title {
  font-size: 2.4mm;
  font-weight: bold;
}

.cell-content .eis-q1 {
  border-color: #222;
  border-width: 0.5mm;
}

/* Journal: labelled writing lines that share the page height. */
.cell-content .jr-date,
.cell-content .exp-names {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 2mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.6mm;
  margin-bottom: 2mm;
}

.cell-content .jr-blank {
  flex: 1 1 auto;
  height: 4mm;
  border-bottom: 0.2mm solid #888;
}

.cell-content .jr-label {
  flex: 0 0 auto;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.6mm;
  font-weight: bold;
  margin-top: 1.5mm;
}

.cell-content .jr-lines {
  display: flex;
  flex-direction: column;
}

.cell-content .jr-lines:nth-of-type(odd),
.cell-content .jr-lines {
  flex: 1 1 0;
  min-height: 0;
}

.cell-content .jr-line {
  flex: 1 1 0;
  min-height: 0;
  border-bottom: 0.2mm solid #a5a5a5;
  display: flex;
  align-items: flex-end;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.4mm;
  color: #888;
  padding-bottom: 0.4mm;
}

.cell-content .mood-faces {
  flex: 0 0 auto;
  width: 60%;
  margin: 1.5mm auto 0;
  fill: none;
  stroke: #444;
  stroke-width: 0.4;
  stroke-linecap: round;
}

.cell-content .mood-faces .mood-eye {
  fill: #444;
  stroke: none;
}

/* Decision: the topic, then pros and cons side by side. */
.cell-content .preset-decision {
  display: flex;
  flex-direction: column;
}

.cell-content .dec-topic {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

.cell-content .dec-blank-topic {
  font-size: 3mm;
}

.cell-content .dec-cols {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3mm;
}

.cell-content .dec-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cell-content .dec-head {
  flex: 0 0 auto;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.8mm;
  font-weight: bold;
  text-align: center;
  padding-bottom: 1mm;
  border-bottom: 0.4mm solid #444;
}

.cell-content .dec-col .jr-lines {
  flex: 1 1 auto;
}

/* Maze: the drawing scales to the page. */
.cell-content .preset-maze .preset-svg {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

/* Shared expenses: the spending table takes the free height, the balance
   table and the hint sit under it. */
.cell-content .exp-names {
  flex-wrap: wrap;
  gap: 1mm 3mm;
}

.cell-content .exp-name {
  flex: 1 1 40%;
  display: flex;
  align-items: baseline;
  gap: 1mm;
}

.cell-content .exp-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.1mm;
  line-height: 1.1;
}

.cell-content .exp-main {
  flex: 1 1 auto;
}

.cell-content .exp-balance {
  flex: 0 0 auto;
  margin-top: 2mm;
}

.cell-content .exp-table th,
.cell-content .exp-table td {
  border: 0.2mm solid #999;
  padding: 0.3mm 0.6mm;
  text-align: center;
  font-weight: normal;
  overflow: hidden;
}

.cell-content .exp-table th {
  background: #eee;
  color: #444;
}

.cell-content .exp-balance td,
.cell-content .exp-balance th {
  height: 4.6mm;
}

.cell-content .exp-what {
  width: 34%;
}

.cell-content .exp-amount {
  width: 17%;
}

.cell-content .exp-paid {
  width: 15%;
}

.cell-content .exp-tick span {
  display: inline-block;
  width: 2.4mm;
  height: 2.4mm;
  border: 0.2mm solid #888;
  border-radius: 0.3mm;
  vertical-align: middle;
}

.cell-content .exp-hint {
  flex: 0 0 auto;
  margin-top: 1mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.8mm;
  color: #888;
  line-height: 1.25;
}

/* 100 hours / 100 days tracker: Start/End fields, then a 10 x 10 grid (one
   cell per hour or day) to shade in with a pencil. The SVG uses ~mm
   viewBox units. */
.cell-content .preset-tracker {
  display: flex;
  flex-direction: column;
}

.cell-content .tracker-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

.cell-content .tracker-fields {
  flex: 0 0 auto;
  margin-bottom: 3mm;
  font-size: 2.9mm;
  line-height: 1.6;
}

.cell-content .tracker-field {
  display: flex;
  align-items: baseline;
  gap: 2mm;
}

.cell-content .tracker-label {
  width: 13mm;
  color: #666;
}

.cell-content .tracker-value {
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.cell-content .tracker-blank {
  flex: 1 1 auto;
  height: 4.5mm;
  border-bottom: 0.2mm solid #888;
}

.cell-content .tracker-grid {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.cell-content .tracker-cells {
  fill: none;
  stroke: #8a8a8a;
  stroke-width: 0.2;
}

.cell-content .tracker-cells .tracker-mark-outline {
  stroke: #222;
  stroke-width: 0.45;
}

.cell-content .tracker-mark-line {
  stroke: #222;
  stroke-width: 0.7;
}

/* Hints are pale enough to disappear under pencil shading. */
.cell-content .tracker-hint {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.7px;
  fill: #a8a8a8;
  text-anchor: middle;
}

.cell-content .tracker-hint-tight {
  font-size: 1.35px;
}

.cell-content .tracker-mark {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.5px;
  font-weight: bold;
  fill: #555;
}

.cell-content .tracker-mark-mid {
  text-anchor: middle;
}

/* QR code / barcode: an optional caption, the code centred, its text
   under it. The barcode has a fixed size in mm (see renderBarcode); the QR
   code takes the room left, up to 55 mm. */
.cell-content .preset-code {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2mm;
}

.cell-content .code-caption {
  font-weight: bold;
  font-size: 4mm;
  text-align: center;
}

.cell-content .code-svg {
  display: block;
  flex: 0 0 auto;
}

.cell-content .code-qr {
  flex: 0 1 auto;
  width: 55mm;
  max-width: 100%;
  min-height: 0;
}

.cell-content .code-text {
  font-family: "Courier New", monospace;
  font-size: 3mm;
  letter-spacing: 0.3mm;
  text-align: center;
  overflow-wrap: anywhere;
}

.cell-content .code-text-qr {
  font-size: 2.4mm;
  letter-spacing: 0;
}

.cell-content .code-message {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.8mm;
  color: #888;
  text-align: center;
}

/* In case of emergency: each row is a label on the left and a value on
   a line (or tick boxes) on the right. */
.cell-content .preset-ice {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: Arial, Helvetica, sans-serif;
}

.cell-content .ice-title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: bold;
  font-size: 3.6mm;
  text-align: center;
}

.cell-content .ice-tag {
  display: inline-block;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.6mm;
  color: #c62828;
  border: 0.3mm solid #c62828;
  border-radius: 0.6mm;
  padding: 0 0.8mm;
  vertical-align: 0.3mm;
}

.cell-content .ice-row {
  display: grid;
  grid-template-columns: 20mm 1fr;
  column-gap: 2mm;
  align-items: end;
}

.cell-content .ice-label {
  font-size: 2.3mm;
  line-height: 1.15;
  color: #555;
  padding-bottom: 0.6mm;
}

.cell-content .ice-value {
  min-height: 5.5mm;
  border-bottom: 0.25mm solid #888;
  display: flex;
  align-items: flex-end;
  font-size: 3.2mm;
  line-height: 1.2;
  padding-bottom: 0.4mm;
  overflow-wrap: anywhere;
}

.cell-content .ice-row-boxes {
  align-items: start;
}

.cell-content .ice-row-boxes .ice-label {
  padding-top: 0.4mm;
}

.cell-content .ice-row-boxes .ice-value {
  border-bottom: 0;
  min-height: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 0.8mm;
  padding-bottom: 0;
}

.cell-content .ice-filled {
  font-weight: bold;
}

.cell-content .ice-detail {
  min-height: 5mm;
  border-bottom: 0.25mm solid #888;
  display: flex;
  align-items: flex-end;
  font-size: 3.2mm;
  padding-bottom: 0.4mm;
}

.cell-content .ice-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8mm 1.8mm;
  font-size: 2.6mm;
}

.cell-content .ice-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.8mm;
  white-space: nowrap;
}

.cell-content .ice-opt .check-box {
  width: 2.8mm;
  height: 2.8mm;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* A tick, as text so it prints without background graphics. */
.cell-content .check-box.checked::after {
  content: "\2713";
  font-size: 2.8mm;
  font-weight: bold;
  line-height: 1;
}

.cell-content .ice-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3mm;
}

.cell-content .ice-sign .ice-row {
  grid-template-columns: auto 1fr;
}

/* Crosswords and word searches: a title, then the grid scaled to the
   page; clues as two numbered lists. */
.cell-content .preset-puzzle {
  display: flex;
  flex-direction: column;
}

.cell-content .puzzle-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 2mm;
}

.cell-content .preset-puzzle .puzzle-svg {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.cell-content .puzzle-svg rect {
  fill: #fff;
  stroke: #222;
  stroke-width: 0.5;
}

.cell-content .puzzle-svg .cw-num {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.8px;
  fill: #222;
}

.cell-content .puzzle-svg .cw-letter,
.cell-content .puzzle-svg .fw-letter {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 6.4px;
  text-anchor: middle;
  fill: #222;
}

.cell-content .puzzle-svg .fw-frame {
  fill: none;
  stroke: #888;
  stroke-width: 0.4;
}

.cell-content .puzzle-svg .fw-band {
  stroke: #bdbdbd;
  stroke-width: 7.6;
  stroke-linecap: round;
  fill: none;
}

.cell-content .fw-hint {
  flex: 0 0 auto;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.3mm;
  color: #555;
  text-align: center;
  margin-bottom: 1.5mm;
}

.cell-content .fw-words {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6mm 2mm;
  margin-top: 2mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.5mm;
}

.cell-content .puzzle-clues {
  font-size: 2.6mm;
  line-height: 1.25;
}

.cell-content .cw-head {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  font-size: 2.8mm;
  margin: 1.5mm 0 0.8mm;
}

.cell-content .cw-clues {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cell-content .cw-clues li {
  margin: 0 0 0.6mm;
}

/* Answers printed upside down, so they aren't read by accident. */
.cell-content .puzzle-flip {
  transform: rotate(180deg);
}

/* Chess: a title, the board (square, as large as the page allows), the
   "position after" line and the moves in two columns; or the ideas. */
.cell-content .preset-chess {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cell-content .chess-title {
  flex: 0 0 auto;
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 1.5mm;
}

.cell-content .chess-eco {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: normal;
  font-size: 2.3mm;
  color: #777;
}

.cell-content .chess-board {
  display: block;
  flex: 0 1 auto;
  width: 100%;
  min-height: 0;
  max-height: 58mm;
}

.cell-content .chess-position .chess-board {
  flex: 1 1 auto;
  max-height: none;
}

.cell-content .chess-board .chess-dark {
  fill: #c8c8c8;
}

.cell-content .chess-board .chess-frame {
  fill: none;
  stroke: #333;
  stroke-width: 1.2;
}

.cell-content .chess-board .chess-coord {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  fill: #555;
  text-anchor: middle;
}

.cell-content .chess-caption {
  font-weight: bold;
  font-size: 3.4mm;
  text-align: center;
  margin-bottom: 1.5mm;
}

.cell-content .chess-after {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.3mm;
  color: #666;
  margin: 1mm 0 1.2mm;
}

.cell-content .chess-moves {
  align-self: stretch;
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 3mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.7mm;
  line-height: 1.35;
}

.cell-content .chess-long .chess-moves {
  font-size: 2.4mm;
}

.cell-content .chess-moves li {
  break-inside: avoid;
}

.cell-content .chess-ideas {
  align-items: stretch;
}

.cell-content .chess-head {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  font-size: 2.8mm;
  margin-top: 1.5mm;
}

.cell-content .chess-text {
  margin: 0.6mm 0 0;
  font-size: 2.9mm;
  line-height: 1.3;
}

/* Score sheet: player lines, then two tables of 20 moves. */
.cell-content .preset-scoresheet {
  display: flex;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
}

.cell-content .ss-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1mm 3mm;
  margin-bottom: 2mm;
}

.cell-content .ss-field {
  display: flex;
  align-items: flex-end;
  gap: 1mm;
  font-size: 2.3mm;
  color: #555;
}

.cell-content .ss-line {
  flex: 1 1 auto;
  border-bottom: 0.25mm solid #888;
  height: 4mm;
}

.cell-content .ss-tables {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2mm;
}

.cell-content .ss-table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  font-size: 2.2mm;
}

.cell-content .ss-table th,
.cell-content .ss-table td {
  border: 0.2mm solid #999;
  padding: 0 0.6mm;
  text-align: left;
}

.cell-content .ss-table th {
  font-weight: bold;
  color: #444;
}

.cell-content .ss-table td:first-child {
  width: 4mm;
  color: #777;
  text-align: right;
}
