@media print {
  /* ============================================================
     PRINT COLOR ACCURACY
     ============================================================ */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ============================================================
     LAYOUT
     ============================================================ */
  body {
    background: #fff;
    height: auto;
    overflow: visible;
    font-size: 12px;
  }

  .layout {
    display: block;
    height: auto;
  }

  .main {
    padding: 12mm 14mm;
    overflow: visible;
  }

  /* ============================================================
     HIDE ELEMENTS
     ============================================================ */
  .no-print,
  .sidebar {
    display: none !important;
  }

  /* ============================================================
     SHOW PRINT-ONLY ELEMENTS
     ============================================================ */
  .print-only {
    display: block !important;
  }

  /* Always show crossword output */
  #crossword-output {
    display: block !important;
  }

  /* ============================================================
     PAGE BREAK BEFORE SOLUTION PAGE
     ============================================================ */
  .page-break {
    display: block;
    page-break-before: always;
    break-before: page;
  }

  /* Solution page: print if visible */
  #solution-page:not(.hidden) {
    display: block !important;
  }

  /* ============================================================
     GRID: SMALLER CELLS FOR A4
     ============================================================ */
  :root {
    --cell: 26px;
  }

  .cw-table {
    background: #c8a07a !important;
    box-shadow: none !important;
    padding: 4px !important;
  }

  .cell-white {
    border-color: #c8a07a !important;
  }

  .cell-black {
    background: #2d1f14 !important;
    border-color: #2d1f14 !important;
  }

  .cell-solution {
    background: #fce9b4 !important;
  }

  .cell-white {
    background: #fffdf9 !important;
  }

  .cell-letter {
    font-size: 12px;
  }

  .cell-clue-num {
    font-size: 6px;
  }

  .cell-sol-num {
    font-size: 6px;
  }

  /* ============================================================
     LAYOUT: GRID AND CLUES SIDE BY SIDE
     ============================================================ */
  .cw-layout {
    flex-wrap: nowrap;
    gap: 24px;
    align-items: flex-start;
  }

  .cw-grid-area {
    flex-shrink: 0;
  }

  .cw-clues-area {
    flex: 1;
    min-width: 0;
  }

  /* ============================================================
     CLUE LISTS
     ============================================================ */
  .clue-list {
    gap: 3px;
  }

  .clue-item {
    font-size: 11px;
    gap: 5px;
    line-height: 1.35;
  }

  .clue-item__num {
    font-size: 11px;
    min-width: 20px;
  }

  .clue-group__title {
    font-size: 10px;
    margin-bottom: 8px;
    padding-bottom: 5px;
  }

  .clue-group {
    gap: 16px;
  }

  /* ============================================================
     SOLUTION WORD LINE
     ============================================================ */
  .sol-line {
    margin-top: 12px;
  }

  .sol-line__label {
    font-size: 12px;
  }

  .sol-box__num {
    font-size: 8px;
  }

  .sol-box__line {
    width: 20px;
  }

  /* ============================================================
     PREVENT PAGE BREAKS
     ============================================================ */
  .cw-table,
  .clue-group {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* ============================================================
     STATUS BAR AND ACTION BUTTONS
     ============================================================ */
  .status-bar,
  .action-bar {
    display: none !important;
  }
}
