:root {
  color-scheme: light;
  --ink: #1f2330;
  --muted: #6a7384;
  --paper: #f6f1e7;
  --panel: #fffdf9;
  --line: #d9d3c4;
  --line-strong: #b8b09f;
  --accent: #e8763a;
  --accent-dark: #b65621;
  --highlight: #fff2d4;
  --block: #2a2f3c;
  font-family: "Outfit", Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Force backgrounds (block cells, ID badge, etc.) to actually render when printing.
   Without this, Chrome strips backgrounds unless the user enables "Background graphics". */
html {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(232, 118, 58, 0.1), transparent 36%),
    linear-gradient(225deg, rgba(80, 140, 200, 0.1), transparent 42%),
    var(--paper);
  color: var(--ink);
  padding: 20px;
}

.toolbar {
  max-width: 880px;
  margin: 0 auto 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 2px 0 var(--accent-dark);
  font-family: inherit;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}

.btn.ghost:hover {
  color: var(--ink);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}

.toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.sheet {
  max-width: 880px;
  margin: 0 auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 42px rgba(44, 36, 24, 0.12);
  padding: 32px 40px 24px;
}

.sheet-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: flex-start;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.head-titles {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sheet h1 {
  margin: 0 0 6px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.sheet-meta {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 600;
}

.instructions {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  max-width: 36ch;
}

.head-id {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.head-id-label {
  font-size: 0.6rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.head-id-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.grid-section {
  display: flex;
  justify-content: center;
  margin: 6px 0 22px;
}

.cw-print-board {
  display: grid;
  gap: 0;
  background: #000;
  padding: 1.5px;
  border-radius: 2px;
}

.pcell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: white;
  border: 1px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink);
}

.pcell.block {
  background: #000;
}

.pnum {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 0.58rem;
  font-weight: 700;
  color: #000;
  line-height: 1;
}

.pletter {
  font-size: 1.4rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

.clues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 32px;
}

.clue-col h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.clue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.clue-list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 6px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 0.9rem;
  line-height: 1.4;
  break-inside: avoid;
}

.clue-list .num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.sheet-footer {
  margin-top: 22px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.sheet-error {
  max-width: 880px;
  margin: 40px auto;
  padding: 18px;
  background: rgba(217, 80, 67, 0.08);
  border: 1px solid rgba(217, 80, 67, 0.4);
  color: #b03b30;
  border-radius: 10px;
  text-align: center;
}

@media (max-width: 640px) {
  .sheet-header {
    grid-template-columns: 1fr;
  }
  .head-id {
    align-items: flex-start;
  }
  .clues {
    grid-template-columns: 1fr;
  }
  .sheet {
    padding: 22px;
  }
}

/* ---------- Print ---------- */

@media print {
  @page {
    size: letter;
    margin: 0.5in;
  }

  body {
    background: white;
    padding: 0;
    color: black;
  }

  .no-print {
    display: none !important;
  }

  .sheet {
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    max-width: 100%;
  }

  .sheet-header {
    border-color: black;
    padding-bottom: 10px;
    margin-bottom: 12px;
  }

  .sheet h1 {
    font-size: 1.35rem;
  }

  .instructions {
    color: #444;
    font-size: 0.82rem;
  }

  .head-id-code {
    color: #666;
  }

  .grid-section {
    margin: 0 0 14px;
  }

  .cw-print-board {
    background: #000;
  }

  .pcell {
    background: white;
    border-color: #000;
  }

  .pcell.block {
    /* Medium gray — clearly "off-grid" without burning a ton of toner. */
    background: #6b6b6b;
  }

  .pnum {
    color: #000;
    font-size: 7pt;
  }

  .pletter {
    color: #000;
    font-size: 16pt;
  }

  .clue-col h2 {
    border-color: black;
  }

  .clue-list li {
    font-size: 0.85rem;
    padding: 2px 0;
  }

  .sheet-footer {
    border-color: #999;
    font-size: 0.65rem;
  }
}
