/* ============================================================
   PUZZLE PLATFORM - Print Stylesheet
   ============================================================ */

/* ==================== PAGE SETUP ==================== */
@page {
  size: A4 portrait;
  /* margin: 0 으로 브라우저 기본 머릿말(URL/날짜/제목)/꼬릿말(페이지번호) 완전 제거
     실제 여백은 #print-root padding으로 제어 */
  margin: 0;
}

@media print {

  /* ==================== 화면 요소 숨김 ==================== */
  #app, #site-footer,
  #app-header,
  .modal, #print-modal,
  #sudoku-print-modal, #ng-print-modal,
  #sk-print-modal, #ms-print-modal, #kk-print-modal,
  #toast-container, .modal-overlay, .standalone-view {
    display: none !important;
  }

  /* ==================== print-root 표시 ==================== */
  /* JS가 인쇄 직전 inline style로 display:block + position:fixed(-99999px)를 설정하고,
     @media print에서 아래 규칙이 override하여 정상 레이아웃으로 인쇄됨 */
  #print-root {
    display: block !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    margin: 0 !important;
    /* @page margin:0 이므로 여백을 #print-root padding으로 직접 제어 */
    padding: 15mm !important;
    box-sizing: border-box !important;
    z-index: auto !important;
  }

  html, body {
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body {
    font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    background: #fff !important;
    color: #000;
    font-size: 9pt;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ==================== 인쇄 페이지 ==================== */
  .print-page {
    width: 100%;
    display: flex;
    flex-direction: column;
    /* A4: 297mm 전체 높이 */
    min-height: 297mm;
    /* 빈 페이지 방지: height를 auto로 */
    page-break-after: always;
    break-after: page;
    box-sizing: border-box;
    padding: 5mm 0 5mm;
  }

  /* 마지막 페이지 뒤 빈 페이지 방지 */
  .print-page:last-of-type {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* print-root 마지막 자식 뒤 빈 페이지 방지 */
  #print-root > *:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* ==================== 인쇄 시트 (grid) ==================== */
  /* A4: 297mm - 위(20mm) - 아래(10mm) = 267mm 가용높이
     footer 5mm 제외 → print-sheet = 262mm */
  .print-sheet {
    display: grid;
    gap: 4mm;
    width: 100%;
    flex-shrink: 0;
    box-sizing: border-box;
  }

  /* 1개: 세로 전체 */
  .layout-1 .print-sheet {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: 255mm;
  }

  /* 2개 (세로 2행) */
  .layout-2 .print-sheet {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    height: 255mm;
  }

  /* 4개 (2×2) */
  .layout-4 .print-sheet {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 255mm;
  }

  /* 6개 (2×3) */
  .layout-6 .print-sheet {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    height: 255mm;
  }

  /* ==================== 카드 ==================== */
  .print-card {
    display: flex;
    flex-direction: column;
    border: 1.5pt solid #222;
    border-radius: 1.5mm;
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .answer-card {
    border-color: #666;
  }

  /* ---- 카드 헤더 ---- */
  .pc-header {
    padding: 1.5mm 2.5mm 1mm;
    border-bottom: 1pt solid #444;
    background: #f2f2f2;
  }

  /* 제목 행: 문제번호 + 이름 칸 가로 배치 */
  .pc-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3mm;
    margin-bottom: 1mm;
  }

  .pc-title {
    font-size: 7.5pt;
    font-weight: 700;
    color: #111;
    white-space: nowrap;
  }

  /* 이름 칸 */
  .pc-name-box {
    display: flex;
    align-items: center;
    gap: 1.5mm;
    flex-shrink: 0;
  }

  .pc-name-label {
    font-size: 7pt;
    color: #444;
    white-space: nowrap;
  }

  .pc-name-line {
    width: 28mm;
    border-bottom: 1pt solid #333;
    height: 5mm;
  }

  .pc-meta {
    font-size: 8pt;
    color: #444;
    line-height: 1.6;
    font-weight: 500;
  }

  .pm-seed {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 13pt;
    color: #111;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: #f0f0f0;
    padding: 0.5mm 2mm;
    border-radius: 1mm;
  }

  .pm-mines {
    font-weight: 700;
    color: #C62828;
  }

  .pm-diff {
    font-weight: 700;
    color: #1565C0;
  }

  .pm-size {
    font-weight: 600;
    color: #333;
  }

  /* ---- 카드 보드 영역 ---- */
  .pc-board {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5mm;
    min-height: 0;
    overflow: visible;
  }

  /* ==================== 인쇄 그리드 ==================== */
  .pb-grid {
    display: grid;
    border: 2pt solid #111;
    /* 너비/컬럼은 JS inline style로 설정 */
    margin: 0 auto;
    background: #fff;
  }

  /* 셀 공통 — 크기는 JS inline style로 설정 */
  .pc {
    border: 0.6pt solid #999;   /* 조금 진한 테두리로 간격 식별력 향상 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;            /* 더 두껕게 */
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    background: #fff;
    box-sizing: border-box;
    overflow: hidden;
    line-height: 1;              /* 세로 여백 없애 글자 화면 최대화 */
    padding: 0;                  /* 내부 여백 제거 */
  }

  /* 숫자 공개 칸 — 연한 파랑 배경으로 제공 칸 구분 */
  .pc.revealed {
    background: #e8f4fd;
  }

  /* 빈칸(미공개) — 흰색 (학생이 채울 칸) */
  .pc.empty {
    background: #fff;
  }

  /* 정답 - 지뢰 셀 */
  .pb-grid.ans .pc.mine {
    background: #bdbdbd;  /* 정답지 지뢰: 훨씬 진한 회색 */
  }

  .mine-svg {
    width: 68%;           /* 조금 크게 */
    height: 68%;
    display: block;
    margin: auto;
  }

  .pb-grid.ans .pc.safe {
    background: #fff;
  }

  /* ── 셀 크기 규칙 삭제: 모두 JS inline style로 직접 지정 ──
   * (pb-4, pb-6, pb-8, pb-10, pb-15, pb-20 클래스 불필요)
   */

  /* ==================== 메모 공간 ==================== */
  .pn-area {
    border-top: 0.5pt dashed #bbb;
    padding: 1mm 2.5mm;
  }

  .pn-lines {
    display: flex;
    flex-direction: column;
    gap: 2.5mm;
  }

  .pn-line {
    border-bottom: 0.5pt solid #ccc;
    height: 3.5mm;
  }

  /* ==================== 사용 규칙 태그 (문제 카드) ==================== */
  .pc-rules {
    display: flex;
    align-items: center;
    gap: 1.5mm;
    flex-wrap: wrap;
    margin-top: 1mm;
  }

  .pc-rules-label {
    font-size: 5.5pt;
    color: #777;
    white-space: nowrap;
    margin-right: 0.5mm;
  }

  .pc-rule-tag {
    font-size: 5.5pt;
    font-weight: 700;
    padding: 0.3mm 1.5mm;
    border: 0.4pt solid #aaa;
    border-radius: 1mm;
    color: #333;
    background: #f8f8f8;
    white-space: nowrap;
  }

  /* ==================== 풀이 팁 ==================== */
  .pc-tip {
    padding: 1mm 2.5mm;
    background: #fffde7;
    border-top: 0.5pt dashed #f9a825;
    font-size: 6pt;
    color: #555;
    line-height: 1.4;
  }

  /* 폭탄 카운팅 팁 */
  .pc-bomb-counting-tip {
    padding: 1.5mm 2.5mm;
    background: #FFF8E1;
    border-top: 0.5pt dashed #FFC107;
    font-size: 6.5pt;
    color: #5D4037;
    line-height: 1.4;
  }
  .pc-bomb-counting-tip strong {
    color: #E65100;
    font-weight: 700;
  }

  /* ==================== 정답 페이지 헤더 ==================== */
  .answer-page-header {
    font-size: 8pt;
    font-weight: 700;
    color: #555;
    padding: 0 0 2mm 0;
    border-bottom: 1pt solid #bbb;
    margin-bottom: 3mm;
    /* grid 밖에 위치하므로 grid-column 불필요 */
  }

  /* ==================== 스도쿠 인쇄 그리드 ==================== */
  .sudoku-print-grid {
    display: grid;
    border: 2.5pt solid #111;
    outline: 2.5pt solid #111;
    width: fit-content;
    margin: 0 auto;
    background: #fff;
  }

  /* 4×4 */
  .sp-4 {
    grid-template-columns: repeat(4, 14mm);
  }
  .sp-4 .spc { width: 14mm; height: 14mm; font-size: 12pt; }

  /* 6×6 */
  .sp-6 {
    grid-template-columns: repeat(6, 11mm);
  }
  .sp-6 .spc { width: 11mm; height: 11mm; font-size: 10pt; }

  /* 9×9 */
  .sp-9 {
    grid-template-columns: repeat(9, 9mm);
  }
  .sp-9 .spc { width: 9mm; height: 9mm; font-size: 8.5pt; }

  /* 셀 공통 */
  .spc {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0.4pt solid #aaa;
    font-family: 'JetBrains Mono', monospace, Arial;
    font-weight: 700;
    box-sizing: border-box;
    background: #fff;
  }

  /* 힌트 셀 (주어진 숫자) */
  .spc.spg {
    background: #F0F0F0;
    font-weight: 900;
  }

  /* 정답 채워진 셀 */
  .spc.spa {
    background: #F1F8E9;
  }

  /* 박스 경계 굵은 선 */
  .spc.bt { border-top: 2pt solid #222; }
  .spc.bl { border-left: 2pt solid #222; }
  .spc.bb { border-bottom: 2pt solid #222; }
  .spc.br { border-right: 2pt solid #222; }

  /* 스도쿠 카드 크기 조정 */
  /* 1개 배치 */
  .layout-1 .sp-9 { grid-template-columns: repeat(9, 16mm); }
  .layout-1 .sp-9 .spc { width: 16mm; height: 16mm; font-size: 14pt; }
  .layout-1 .sp-6 { grid-template-columns: repeat(6, 20mm); }
  .layout-1 .sp-6 .spc { width: 20mm; height: 20mm; font-size: 18pt; }
  .layout-1 .sp-4 { grid-template-columns: repeat(4, 28mm); }
  .layout-1 .sp-4 .spc { width: 28mm; height: 28mm; font-size: 24pt; }

  /* 2개 배치 */
  .layout-2 .sp-9 { grid-template-columns: repeat(9, 10mm); }
  .layout-2 .sp-9 .spc { width: 10mm; height: 10mm; font-size: 9pt; }
  .layout-2 .sp-6 { grid-template-columns: repeat(6, 13mm); }
  .layout-2 .sp-6 .spc { width: 13mm; height: 13mm; font-size: 11pt; }
  .layout-2 .sp-4 { grid-template-columns: repeat(4, 18mm); }
  .layout-2 .sp-4 .spc { width: 18mm; height: 18mm; font-size: 15pt; }

  /* 4개 배치 */
  .layout-4 .sp-9 { grid-template-columns: repeat(9, 7mm); }
  .layout-4 .sp-9 .spc { width: 7mm; height: 7mm; font-size: 6.5pt; }
  .layout-4 .sp-6 { grid-template-columns: repeat(6, 9mm); }
  .layout-4 .sp-6 .spc { width: 9mm; height: 9mm; font-size: 8pt; }
  .layout-4 .sp-4 { grid-template-columns: repeat(4, 13mm); }
  .layout-4 .sp-4 .spc { width: 13mm; height: 13mm; font-size: 11pt; }

  /* 6개 배치 (4×4 전용) */
  .layout-6 .sp-4 { grid-template-columns: repeat(4, 12mm); }
  .layout-6 .sp-4 .spc { width: 12mm; height: 12mm; font-size: 10pt; }
  .layout-6 .sp-6 { grid-template-columns: repeat(6, 8mm); }
  .layout-6 .sp-6 .spc { width: 8mm; height: 8mm; font-size: 7pt; }

  /* ==================== 노노그램 인쇄 그리드 ==================== */
  .ngp-grid {
    border: 2pt solid #111;
    background: #fff;
    margin: 0 auto;
  }

  /* 힌트 셀 */
  .ngp-clue {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #EEEEEE;
    border: 0.4pt solid #999;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 700;
    color: #1A237E;
    box-sizing: border-box;
  }
  .ngp-corner {
    background: #E0E0E0;
    border: 0.4pt solid #aaa;
    box-sizing: border-box;
  }
  .ngp-row-clue { background: #F5F5F5; }
  .ngp-col-clue { background: #F5F5F5; }

  /* 데이터 셀 */
  .ngp-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0.4pt solid #bbb;
    box-sizing: border-box;
    background: #fff;
  }
  .ngp-blank  { background: #fff; }
  .ngp-filled { background: #212121; }

  /* 5칸 경계 굵은 선 */
  .ngp-bt { border-top:    1.5pt solid #333 !important; }
  .ngp-bl { border-left:   1.5pt solid #333 !important; }
  .ngp-bb { border-bottom: 1.5pt solid #333 !important; }
  .ngp-br { border-right:  1.5pt solid #333 !important; }

  /* 노노그램 카드 내 보드 패딩 */
  .ng-print-card .pc-board {
    padding: 1.5mm;
  }

  /* ==================== 노노그램 주제 박스 (인쇄용) ==================== */
  .pc-subject-box {
    display: flex;
    align-items: center;
    gap: 2mm;
    background: #F1F8E9;
    border: 0.5pt solid #A5D6A7;
    border-left: 2pt solid #2E7D32;
    border-radius: 1.5mm;
    padding: 1.5mm 3mm;
    margin: 1.5mm 0;
    font-size: 7pt;
    color: #33691E;
  }
  .pc-subject-emoji {
    font-size: 10pt;
    line-height: 1;
  }
  .pc-subject-label {
    font-style: italic;
    color: #558B2F;
  }
  /* 정답 카드의 주제 박스 — 주제명 강조 */
  .pc-subject-answer {
    background: #E8F5E9;
    border-left-color: #1B5E20;
  }
  .pc-subject-name {
    font-weight: 700;
    font-size: 9pt;
    color: #1B5E20;
  }

  /* ==================== 인쇄 저작권 표시 ==================== */
  .print-footer-copy {
    margin-top: 3mm;
    text-align: center;
    font-size: 5.5pt;
    color: #999;
    border-top: 0.4pt solid #ddd;
    padding-top: 1.5mm;
    letter-spacing: 0.02em;
  }

  /* ==================== 학원 로고 푸터 ==================== */
  .print-academy-footer {
    margin-top: 2mm;
    padding-top: 2mm;
    border-top: 0.8pt solid #ccc;
    display: flex;
    align-items: center;
    gap: 3mm;
  }
  .print-academy-footer.align-right  { justify-content: flex-end; }
  .print-academy-footer.align-center { justify-content: center; }
  .print-academy-footer.align-left   { justify-content: flex-start; }
  .print-academy-logo {
    display: block;
    object-fit: contain;
    max-width: 60mm;
  }

  /* ==================== 크로스수학 인쇄 스타일 ==================== */
  .cm-print-card {
    border: 1.5pt solid #999;
    border-radius: 2mm;
    overflow: hidden;
    page-break-inside: avoid;
    background: #fff;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  /* layout-4일 때 카드 크기 제한 */
  .layout-4 .cm-print-card,
  .layout-4 .ng-print-card {
    width: 100%;
    box-sizing: border-box;
  }

  /* 크로스수학 그리드는 이미 인라인 스타일로 처리됨 */

  /* 분수 표시 */
  .cm-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
    font-size: 0.82em;
  }
  .cm-frac-num {
    border-bottom: 1pt solid currentColor;
    padding: 0 1px;
    line-height: 1.2;
  }
  .cm-frac-den {
    padding: 0 1px;
    line-height: 1.2;
  }

  /* ==================== 논리 배열 인쇄 스타일 ==================== */
  /* #print-root 안의 SVG 구슬 색상 강제 출력 */
  #print-root {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  #print-root svg circle,
  #print-root svg text {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  #print-root span[style*="background"] {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ==================== 책자(Booklet) 인쇄 전용 스타일 ==================== */

  /* 색상 강제 출력 (배경색·아이콘 포함) */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 책자 커버 페이지 */
  .cover-page {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 277mm;
    page-break-after: always;
    break-after: page;
    background: #fff;
    text-align: center;
    padding: 20mm 20mm;
  }
  .cover-page h1 {
    font-size: 28pt;
    font-weight: 900;
    color: #1a1a2e;
    margin-bottom: 6mm;
    line-height: 1.3;
  }
  .cover-page .cover-subtitle {
    font-size: 13pt;
    color: #555;
    margin-bottom: 4mm;
  }
  .cover-page .cover-count {
    font-size: 11pt;
    color: #888;
    margin-bottom: 10mm;
  }
  .cover-page .cover-tags {
    display: flex;
    gap: 4mm;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15mm;
  }
  .cover-tag {
    background: #6366f120;
    color: #4f46e5;
    padding: 2.5mm 6mm;
    border-radius: 8mm;
    font-size: 11pt;
    font-weight: 600;
    border: 0.8pt solid #6366f140;
  }
  .cover-page .cover-footer {
    font-size: 8pt;
    color: #aaa;
    margin-top: auto;
    padding-top: 8mm;
  }
  .cover-emoji {
    font-size: 52pt;
    line-height: 1;
    margin-bottom: 6mm;
  }

  /* 책자 정답 페이지 헤더 */
  .answer-page .answer-page-header {
    font-size: 9pt;
    font-weight: 700;
    color: #059669;
    padding: 2mm 0;
    margin-bottom: 3mm;
    border-bottom: 1pt solid #a7f3d0;
  }

  /* 책자 인쇄 카드 — app.html print-card와 동일한 구조 재사용 */
  /* layout별 카드 높이 균등 배분 */
  .layout-1  .print-card { min-height: 250mm; }
  .layout-2  .print-card { min-height: 120mm; }
  .layout-4  .print-card { min-height: 116mm; }
  .layout-6  .print-card { min-height:  74mm; }

  /* 책자 전용: 인쇄 시트 행 높이 자동 균등 */
  .layout-4 .print-sheet { grid-template-rows: 1fr 1fr; }
  .layout-6 .print-sheet { grid-template-rows: repeat(3, 1fr); }

  /* 책자 인쇄 카드 테두리 강조 */
  .print-card {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* 정답 카드 배경 구분 */
  .answer-card {
    background: #f0fff4 !important;
    border-color: #6ee7b7 !important;
  }

  /* 문제 번호 강조 */
  .pc-title {
    font-size: 9pt;
    font-weight: 800;
  }

  /* 인쇄 시 링크·버튼 숨김 */
  a, button, input, select, textarea {
    display: none !important;
  }

  /* SVG mine 아이콘 색상 강제 */
  .pc.mine svg circle { fill: #111 !important; }
  .pc.mine svg line   { stroke: #111 !important; }

  /* ── withUnitSize 기반: 셀 크기는 JS inline style로 완전 제어 ──
   * CSS 클래스로 크기를 덮어쓰지 않음 (pb-N 계열 클래스 없음)
   * 모든 .pc 의 width/height/font-size 는 style 속성으로만 설정
   */

  /* 페이지 번호 (선택적) */
  .print-page-num {
    position: running(pagenum);
    font-size: 7pt;
    color: #aaa;
  }
  @page { @bottom-center { content: counter(page); font-size: 7pt; color: #bbb; } }

  /* ==================== puzzle-new 계열 인쇄 스타일 ==================== */
  /* pn-ph : 페이지 헤더 */
  .pn-ph {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1.5pt solid #334155;
    padding-bottom: 2mm;
    margin-bottom: 4mm;
  }
  .pn-ph-title {
    font-size: 11pt;
    font-weight: 900;
    color: #1e293b;
  }
  .pn-ph-meta {
    font-size: 8pt;
    color: #64748b;
  }

  /* pn-grid2 : 2열 그리드 (6개 배치 시 행간격 줄임) */
  .pn-grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4mm;         /* 열 간격 4mm */
    row-gap: 4mm;     /* 행 간격 4mm */
  }

  /* pn-pc : 개별 퍼즐 카드 */
  .pn-pc {
    border: 0.8pt solid #cbd5e1;
    border-radius: 2mm;
    padding: 2.5mm 3mm 3mm;
    background: #fff;
    break-inside: avoid;
    box-sizing: border-box;
    position: relative;   /* QR absolute 기준점 */
  }

  /* 6개 배치 시 카드 내부 간격 더욱 압축 */
  .pn-print-page .pn-grid2 .pn-pc {
    padding: 2mm 2.5mm 2.5mm;
  }

  /* 문제번호 + QR 한 행 배치 */
  .pn-pc-num-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3mm;
    border-bottom: 0.5pt solid #e5e7eb;
    padding-bottom: 1.5mm;
  }
  .pn-pc-num {
    font-size: 8pt;
    font-weight: 700;
    color: #475569;
  }

  /* 아카리 전구 개수 힌트 (인쇄용) */
  .pn-ak-bulb-hint {
    font-size: 7.5pt;
    color: #1e40af;
    font-weight: 600;
    background: #eff6ff;
    border: 0.5pt solid #bfdbfe;
    border-radius: 1.5mm;
    padding: 1mm 2.5mm;   /* ▼ 세로 padding 압축 */
    margin-bottom: 1.5mm; /* ▼ 압축 */
    display: inline-block;
  }

  /* answer 인쇄 제어 — _doPrint에서 DOM remove/append로 직접 제어 */
  .pn-no-print { display: none !important; }

  /* 인쇄 시 table 셀 테두리 보장 */
  .pn-pc table td, .pn-pc table th {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* ── 켄켄 인쇄 전용 ──────────────────────────────────── */
  /* 1) border-collapse: collapse 강제 → 선 겹침 방지 */
  .pn-pc .puzzle-grid-wrap table,
  .pn-pc table {
    border-collapse: collapse !important;
  }

  .pn-pc .kk-std-layout {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    overflow: visible !important;
  }

  .pn-pc .kk-std-board {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    max-width: 100% !important;
  }

  .pn-pc .kk-print-table {
    table-layout: fixed !important;
    width: auto !important;
    height: auto !important;
    margin: 0 auto !important;
    border-collapse: collapse !important;
  }

  .pn-pc .kk-print-table col {
    width: auto !important;
  }

  .pn-pc .kk-std-answer-wrap:not(.kk-answer-visible) {
    display: none !important;
  }

  /* 2) 인쇄 시 켄켄 셀 크기: layout-2(2칸)=34px, layout-4(4칸)=28px, layout-6(6칸)=24px */
  .pn-pc .kk-interact-cell,
  .pn-pc table td {
    box-sizing: border-box !important;
  }
  /* layout-1: 넉넉하게 */
  .layout-1 .pn-pc .kk-interact-cell,
  .layout-1 .pn-pc .puzzle-grid-wrap table td {
    width: 42px !important; height: 42px !important;
    min-width: 42px !important; max-width: 42px !important;
    min-height: 42px !important; max-height: 42px !important;
    font-size: 18px !important;
  }
  /* layout-2: 2개/페이지 */
  .layout-2 .pn-pc .kk-interact-cell,
  .layout-2 .pn-pc .puzzle-grid-wrap table td {
    width: 36px !important; height: 36px !important;
    min-width: 36px !important; max-width: 36px !important;
    min-height: 36px !important; max-height: 36px !important;
    font-size: 15px !important;
  }
  /* layout-4: 4개/페이지 (켄켄 기본 권장) */
  .layout-4 .pn-pc .kk-interact-cell,
  .layout-4 .pn-pc .puzzle-grid-wrap table td {
    width: 30px !important; height: 30px !important;
    min-width: 30px !important; max-width: 30px !important;
    min-height: 30px !important; max-height: 30px !important;
    font-size: 12px !important;
  }
  /* layout-6: 6개/페이지 */
  .layout-6 .pn-pc .kk-interact-cell,
  .layout-6 .pn-pc .puzzle-grid-wrap table td {
    width: 24px !important; height: 24px !important;
    min-width: 24px !important; max-width: 24px !important;
    min-height: 24px !important; max-height: 24px !important;
    font-size: 10px !important;
  }
  /* 3) 케이지 단서 레이블 크기 조정 */
  .layout-4 .pn-pc .kk-interact-cell span,
  .layout-4 .pn-pc .puzzle-grid-wrap table td span {
    font-size: 7px !important;
    top: 1px !important; left: 1px !important;
  }
  .layout-6 .pn-pc .kk-interact-cell span,
  .layout-6 .pn-pc .puzzle-grid-wrap table td span {
    font-size: 6px !important;
    top: 1px !important; left: 1px !important;
  }
  /* 4) puzzle-grid-wrap 배경/패딩 제거 (인쇄 최적화) */
  .pn-pc .puzzle-grid-wrap {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
  }
  /* ── 켄켄 인쇄 끝 ────────────────────────────────────── */

  /* m10-checker (온라인 채점 영역) 인쇄 숨김 */
  .pn-pc .m10-checker { display: none !important; }
  .pn-pc .m10-print-line { display: block !important; }

  .pn-pc .m10-print-set {
    display: flex !important;
    flex-direction: column !important;
    gap: 2.2mm !important;
    width: 100% !important;
  }

  .pn-pc .m10-print-set-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 2mm !important;
    padding: 2mm 2.4mm !important;
    border: .5pt solid #bfdbfe !important;
    border-radius: 2mm !important;
    background: #eff6ff !important;
  }

  .pn-pc .m10-print-goal {
    display: inline-flex !important;
    align-items: center !important;
    gap: 1.5mm !important;
    white-space: nowrap !important;
  }

  .pn-pc .m10-print-goal-label {
    font-size: 7pt !important;
    font-weight: 900 !important;
    color: #1d4ed8 !important;
  }

  .pn-pc .m10-print-goal strong {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 9mm !important;
    height: 9mm !important;
    border-radius: 50% !important;
    background: #2563eb !important;
    color: #fff !important;
    font-size: 14pt !important;
    font-weight: 950 !important;
    line-height: 1 !important;
  }

  .pn-pc .m10-print-op-cards,
  .pn-pc .m10-print-num-cards {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 1.2mm !important;
  }

  .pn-pc .m10-print-op-card,
  .pn-pc .m10-print-num-card {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    border: .45pt solid #334155 !important;
    background: #fff !important;
    color: #111827 !important;
    font-weight: 900 !important;
    line-height: 1 !important;
  }

  .pn-pc .m10-print-op-card {
    min-width: 6.5mm !important;
    height: 6.5mm !important;
    border-radius: 1.5mm !important;
    font-size: 9pt !important;
  }

  .pn-pc .m10-print-num-card {
    width: 8mm !important;
    height: 8mm !important;
    border-radius: 1.3mm !important;
    font-size: 11pt !important;
    background: #f8fafc !important;
  }

  .pn-pc .m10-print-problems {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1.8mm !important;
  }

  .pn-pc .m10-print-problem {
    border: .45pt solid #cbd5e1 !important;
    border-radius: 2mm !important;
    padding: 2mm !important;
    background: #fff !important;
    break-inside: avoid !important;
  }

  .pn-pc .m10-print-problem-top {
    display: flex !important;
    align-items: center !important;
    gap: 2mm !important;
    margin-bottom: 2mm !important;
  }

  .pn-pc .m10-print-no {
    width: 6mm !important;
    flex: 0 0 6mm !important;
    font-size: 10pt !important;
    font-weight: 950 !important;
    color: #1e293b !important;
  }

  .pn-pc .m10-print-expression {
    display: flex !important;
    align-items: center !important;
    gap: 2mm !important;
  }

  .pn-pc .m10-print-expression span {
    font-size: 7pt !important;
    font-weight: 900 !important;
    color: #64748b !important;
  }

  .pn-pc .m10-print-expression i {
    display: block !important;
    flex: 1 !important;
    height: 8mm !important;
    border-bottom: .6pt solid #334155 !important;
  }

  .layout-4 .pn-pc .m10-print-set-head {
    padding: 1.5mm 1.8mm !important;
  }

  .layout-4 .pn-pc .m10-print-problem {
    padding: 1.5mm !important;
  }

  .layout-4 .pn-pc .m10-print-num-card {
    width: 7mm !important;
    height: 7mm !important;
    font-size: 9.5pt !important;
  }

  .layout-4 .pn-pc .m10-print-expression i {
    height: 6.5mm !important;
  }

  /* QR 섹션 인쇄 숨김 (단일 카드뷰에서는 no-print로 이미 처리) */
  .pn-pc .qr-section { display: none !important; }

  /* ── 인쇄 불필요 요소 숨김 ── */
  /* "유일해 보장" 배지 */
  .pn-pc .pn-badge { display: none !important; }
  /* "클릭: 전구 💡 / ✕ 제외 표시 / 지우기 순환" 안내사 */
  .pn-pc [style*="font-size:11px"][style*="color:#64748b"],
  .pn-pc div[style*="margin-bottom:4px"] { display: none !important; }

  /* ── 인쇄 배경색 초기화: 연한 파란색 완전 제거 ── */
  /* print-root 및 하위 모든 배경 흰색으로 */
  #print-root { background: #fff !important; }
  .pn-print-page { background: #fff !important; }

  /* pn-print-page: A4 1장에 꽉 채우는 방식 (min-height 고정 대신 height 100%) */
  .pn-print-page {
    min-height: 0 !important;       /* print-page의 min-height:297mm 오버라이드 */
    height: calc(297mm - 30mm);     /* @page margin:0 + print-root padding:15mm*2 */
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
  }
  /* 그리드 채우기 */
  .pn-print-page .pn-grid2 {
    flex: 1;
    align-content: stretch;
  }
  .pn-print-page .pn-grid2 .pn-pc {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .pn-pc { background: #fff !important; }
  /* puzzle-grid-wrap / 뷰 래퍼 배경 초기화 */
  .pn-pc .puzzle-grid-wrap { background: #fff !important; }
  .pn-pc .pn-view-wrap     { background: #fff !important; }
  .pn-pc .pn-section       { background: #fff !important; }
  .pn-pc .pn-section-body  { background: #fff !important; }
  /* 빈 셀(ak-interact-cell) 배경 흰색 */
  .pn-pc .ak-interact-cell { background: #fff !important; }
  /* table 배경 흰색 */
  .pn-pc table { background: #fff !important; }
  /* 색상 강제 출력 (벽·숫자 칸 검정색 보장) */
  .pn-pc, .pn-pc * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

  /* ==================== puzzle-new 인쇄 QR 스타일 ==================== */
  /* QR 래퍼: pn-pc-num-row 우측에 flex 배치 (float 제거) */
  .pn-print-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5mm;
    flex-shrink: 0;
  }

  /* QR 코드 박스 크기 고정 — 기본: 20mm, layout-1: 24mm */
  .pn-print-qr-box {
    width: 20mm;
    height: 20mm;
    flex-shrink: 0;
  }
  .pn-print-qr-box img,
  .pn-print-qr-box canvas {
    width: 20mm !important;
    height: 20mm !important;
    display: block;
  }

  /* QR 레이블 */
  .pn-print-qr-label {
    font-size: 5pt;
    color: #888;
    text-align: center;
    white-space: nowrap;
  }

  /* layout-1 : QR 크게 */
  .layout-1 .pn-print-qr-box,
  .pn-print-page.layout-1 .pn-print-qr-box {
    width: 24mm;
    height: 24mm;
  }
  .layout-1 .pn-print-qr-box img,
  .layout-1 .pn-print-qr-box canvas {
    width: 24mm !important;
    height: 24mm !important;
  }

  /* layout-6 : QR */
  .layout-6 .pn-print-qr-box,
  .pn-print-page.layout-6 .pn-print-qr-box {
    width: 20mm;
    height: 20mm;
  }
  .layout-6 .pn-print-qr-box img,
  .layout-6 .pn-print-qr-box canvas {
    width: 20mm !important;
    height: 20mm !important;
  }
  /* layout-6 top-row padding-right도 QR 크기에 맞춰 조정 */
  .layout-6 .pn-pc-top-row {
    padding-right: 23mm;  /* QR(20mm) + 여백 3mm */
  }

  /* layout-6 카드 내부 텍스트·여백 추가 압축 */
  .layout-6 .pn-pc             { padding: 2mm 2.5mm 2.5mm; }  /* 하단 여백 유지 */
  .layout-6 .pn-pc-top-row     { margin-bottom: 0.5mm; }
  .layout-6 .pn-pc-num         { font-size: 7.5pt; margin-bottom: 0.4mm; }
  .layout-6 .pn-pc-meta-row    { gap: 1.5mm; margin-bottom: 0.6mm; }
  .layout-6 .pn-pc-divider     { margin: 0.5mm 0 0.8mm; }
  .layout-6 .pn-ak-bulb-hint   { font-size: 6.5pt; padding: 0.6mm 2mm; margin-bottom: 0.8mm; }

  /* ══════════════════════════════════════════
     pn-pc 신규 카드 헤더 구조 (top-row / meta-row)
     ══════════════════════════════════════════ */

  /* 1행: 이름칸(좌) + QR(우)
     QR은 absolute로 카드 우상단 고정 → top-row 높이가 QR에 종속되지 않음 */
  .pn-pc-top-row {
    display: block;   /* flex 해제 — QR은 absolute */
    margin-bottom: 1mm;
    /* QR이 absolute이므로 우측 공간 확보용 padding-right */
    padding-right: 23mm;  /* 기본 QR(20mm) + 여백 3mm */
  }

  /* 이름 입력 필드 — 이름 레이블 + 밑줄 */
  .pn-pc-top-row .pn-pc-name-field {
    display: flex;
    align-items: center;
    gap: 1.5mm;
  }

  /* QR 래퍼: 카드 우상단 절대 고정 */
  .pn-pc-top-row .pn-print-qr {
    position: absolute;
    top: 2mm;    /* 카드 상단 여백에 맞춤 */
    right: 2.5mm;
  }

  /* 2행: 문제 번호 */
  .pn-pc-num {
    font-size: 8.5pt;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 0.6mm;   /* ▼ 압축 */
  }

  /* 3행: SEED + 난이도 한 줄 */
  .pn-pc-meta-row {
    display: flex;
    align-items: center;
    gap: 2mm;
    margin-bottom: 1mm;   /* ▼ 압축 */
    flex-wrap: wrap;
  }

  /* 난이도 배지 */
  .pn-pc-diff-val {
    font-size: 7pt;
    color: #4f46e5;
    font-weight: 700;
    background: #eef2ff;
    border: 0.5pt solid #c7d2fe;
    padding: 0.5mm 2mm;
    border-radius: 1mm;
    white-space: nowrap;
  }

  /* 헤더/콘텐츠 구분선 */
  .pn-pc-divider {
    border: none;
    border-top: 0.8pt solid #e2e8f0;
    margin: 0.8mm 0 1.2mm;   /* ▼ 압축 */
  }

  /* ── 카드 하단: 이름 / SEED 입력 칸 ── */
  .pn-pc-name-row {
    display: flex;
    align-items: center;
    gap: 4mm;
    margin-top: 3mm;
    padding-top: 2.5mm;
    border-top: 0.5pt solid #cbd5e1;
  }
  .pn-pc-name-field {
    display: flex;
    align-items: center;
    gap: 2mm;
    flex: 1;           /* 이름 칸이 더 넓게 */
  }
  .pn-pc-seed-field {
    display: flex;
    align-items: center;
    gap: 2mm;
    flex-shrink: 0;
  }
  .pn-pc-name-lbl {
    font-size: 6.5pt;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .pn-pc-name-line {
    flex: 1;
    border-bottom: 0.8pt solid #334155;
    min-width: 18mm;
    height: 3mm;       /* ▼ 밑줄 높이 압축 */
  }
  .pn-pc-seed-val {
    font-size: 6.5pt;
    font-weight: 700;
    color: #334155;
    font-family: monospace;
    background: #f1f5f9;
    border: 0.5pt solid #cbd5e1;
    padding: 0.3mm 1.5mm;   /* ▼ 압축 */
    border-radius: 1mm;
    white-space: nowrap;
  }

  /* layout-6 이름줄·SEED 추가 압축 */
  .layout-6 .pn-pc-name-lbl  { font-size: 6pt; }
  .layout-6 .pn-pc-name-line { height: 2.5mm; min-width: 14mm; }
  .layout-6 .pn-pc-seed-val  { font-size: 6pt; padding: 0.3mm 1.2mm; }
  .layout-6 .pn-pc-diff-val  { font-size: 6pt; padding: 0.3mm 1.5mm; }

  .pn-pc-scan-code {
    margin-top: auto;
    padding-top: 0.8mm;
    border-top: 0.35pt solid #e2e8f0;
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 4.7pt;
    line-height: 1.15;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .layout-6 .pn-grid2 {
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 3.2mm 4mm;
  }

  .layout-6 .pn-pc-scan-code {
    font-size: 4.2pt;
    padding-top: 0.45mm;
  }

}

/* ==================== 화면 미리보기 (비인쇄) ==================== */
@media screen {
  /* 책자 생성기 — 화면 미리보기 카드 스타일 */
  .bk-preview-wrap {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
  }
  .bk-preview-page {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
}
