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

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

body {
  font-family: "BIZ UDPGothic", "Noto Sans CJK JP", sans-serif;
  color: #1f2421;
  background-color: #e5e0d8;
  line-height: 1.45;
}

h1, h2, h3, .editorial-heading {
  font-family: "Noto Serif CJK JP", "IPAMincho", serif;
}

.balanced-heading {
  text-wrap: balance;
}

p, li, .pretty-copy {
  text-wrap: pretty;
}

.a4-page {
  width: 210mm;
  height: 297mm;
  padding: 11mm 14mm 15mm 14mm;
  margin: 0 auto;
  background-color: #fdfbf7;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  page-break-after: always;
  break-after: page;
  overflow: hidden;
}

.a4-page:last-child {
  page-break-after: auto;
  break-after: auto;
}

@media screen {
  .a4-page {
    margin: 8mm auto;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  }
}

/* 昭和グラフ誌風 二重飾り枠ヘッダー */
.masthead {
  border-top: 2.5px solid var(--theme-color, #1e3a5f);
  border-bottom: 1px solid var(--theme-color, #1e3a5f);
  padding: 2.2mm 0 2mm 0;
  position: relative;
}

.masthead::after {
  content: "";
  display: block;
  border-bottom: 2px solid var(--theme-color, #1e3a5f);
  margin-top: 1.5mm;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8.8pt;
  color: #4a453e;
  margin-bottom: 1.5mm;
}

.facility-stamp {
  font-weight: 700;
  color: var(--theme-color, #1e3a5f);
  background: #f0ebe1;
  padding: 0.8mm 3mm;
  border-left: 3px solid var(--accent-color, #8b2635);
  font-size: 9.2pt;
  white-space: nowrap;
  flex-shrink: 0;
}

.masthead-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.issue-badge {
  background-color: var(--theme-color, #1e3a5f);
  color: #ffffff;
  font-family: "Noto Serif CJK JP", serif;
  padding: 1.8mm 3.5mm;
  font-size: 10.5pt;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.masthead-title-group {
  flex: 1;
  min-width: 0;
  padding: 0 3.5mm;
}

.series-kicker {
  font-size: 8pt;
  color: var(--accent-color, #8b2635);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.issue-title {
  font-size: 14pt;
  font-weight: 700;
  color: #1a1816;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.name-box-group {
  display: flex;
  gap: 2.5mm;
  align-items: stretch;
  flex-shrink: 0;
}

.user-name-box {
  border: 1.5px solid #2d3748;
  background: #ffffff;
  width: 46mm;
  height: 11mm;
  padding: 1mm 2mm;
  font-size: 8pt;
  color: #4a5568;
  display: flex;
  align-items: flex-start;
}

/* セクション見出し */
.section-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 3mm;
  background-color: #f2ede4;
  border-left: 5px solid var(--theme-color, #1e3a5f);
  border-bottom: 1px solid #c8bfb0;
  padding: 2mm 3.5mm;
  margin-bottom: 2.2mm;
}

.section-banner h2 {
  font-size: 11.4pt;
  color: #1a1816;
  font-weight: 700;
}

.badge-pill {
  background: var(--accent-color, #8b2635);
  color: #ffffff;
  font-size: 8pt;
  font-weight: 700;
  padding: 0.8mm 2.5mm;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.instruction-text {
  font-size: 10.2pt;
  color: #2d2926;
  margin-bottom: 2.5mm;
  padding: 0 1mm;
}

/* P1 大マス数独・計算グリッド */
.puzzle-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 1mm 0;
}

.sudoku-grid {
  border: 3px solid #1a1816;
  border-collapse: collapse;
  background: #ffffff;
}

.sudoku-grid td {
  width: 17.6mm;
  height: 17.6mm;
  border: 1px solid #7c756b;
  text-align: center;
  vertical-align: middle;
  font-size: 21pt;
  font-weight: 700;
  font-family: "BIZ UDPGothic", "Noto Sans CJK JP", sans-serif;
}

.sudoku-grid td.given-cell {
  background-color: #f3efe8;
  color: #1a1816;
}

.sudoku-grid td.empty-cell {
  background-color: #ffffff;
  color: var(--accent-color, #8b2635);
}

.sudoku-grid td.border-right-thick {
  border-right: 2.8px solid #1a1816;
}

.sudoku-grid tr.border-bottom-thick td {
  border-bottom: 2.8px solid #1a1816;
}

/* 百ます計算グリッド */
.calc-grid {
  border: 3px solid #1a1816;
  border-collapse: collapse;
  background: #ffffff;
}

.calc-grid th, .calc-grid td {
  width: 17.6mm;
  height: 17.2mm;
  border: 1px solid #7c756b;
  text-align: center;
  vertical-align: middle;
  font-size: 19pt;
  font-weight: 700;
}

.calc-grid th {
  background-color: #e9e2d6;
  color: var(--theme-color, #1e3a5f);
}

.calc-grid th.op-corner {
  background-color: var(--theme-color, #1e3a5f);
  color: #ffffff;
  font-size: 22pt;
}

/* P1 下部メモ＆数字チェック枠 */
.p1-bottom-card {
  border: 1.5px solid #9c9283;
  background-color: #f7f4ed;
  padding: 3mm 4mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4mm;
}

.number-checklist {
  display: flex;
  gap: 2mm;
  margin-top: 1.5mm;
}

.num-chip {
  width: 9mm;
  height: 9mm;
  border: 1.2px solid #4a453e;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12pt;
  font-weight: 700;
}

/* P2 3種課題カード */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 2.8mm;
}

.quiz-card {
  border: 1.2px solid #b5ab9c;
  background: #ffffff;
  padding: 2.8mm 3.8mm;
}

.quiz-q-row {
  display: flex;
  gap: 2.5mm;
  align-items: baseline;
  margin-bottom: 2mm;
}

.q-tag {
  background: var(--theme-color, #1e3a5f);
  color: #ffffff;
  font-family: "Noto Serif CJK JP", serif;
  font-size: 9pt;
  font-weight: 700;
  padding: 0.5mm 2.2mm;
  white-space: nowrap;
}

.quiz-question {
  font-size: 10.8pt;
  font-weight: 700;
  color: #1a1816;
}

.choices-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5mm;
  padding-left: 1mm;
}

.choice-box {
  border: 1.2px solid #7c756b;
  background: #faf8f4;
  padding: 1.8mm 2.5mm;
  font-size: 10.5pt;
  font-weight: 700;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3mm;
}

.mini-task-card {
  border: 1.2px solid #b5ab9c;
  background: #ffffff;
  padding: 2.8mm 3mm;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.proverb-phrase {
  font-size: 11.5pt;
  font-weight: 700;
  color: #1a1816;
  margin: 1.5mm 0;
}

.write-box {
  border-bottom: 2px solid #1a1816;
  height: 9.5mm;
  margin-top: 2mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 8.5pt;
  color: #6b6358;
  padding: 0 1.5mm;
}

/* P3 職員控え＆記録転記コメント */
.p3-layout {
  display: grid;
  grid-template-columns: 88mm 1fr;
  gap: 5mm;
  flex: 1;
  margin: 2mm 0;
}

.mini-sudoku-grid {
  border: 2px solid #1a1816;
  border-collapse: collapse;
  background: #ffffff;
  margin: 1.5mm auto;
}

.mini-sudoku-grid td, .mini-sudoku-grid th {
  width: 8.6mm;
  height: 8.6mm;
  border: 0.8px solid #8c857b;
  text-align: center;
  font-size: 10.5pt;
  font-weight: 700;
}

.mini-sudoku-grid td.ans-highlight {
  color: var(--accent-color, #8b2635);
  background-color: #fff5f5;
}

.mini-sudoku-grid td.border-right-thick {
  border-right: 2.2px solid #1a1816;
}

.mini-sudoku-grid tr.border-bottom-thick td {
  border-bottom: 2.2px solid #1a1816;
}

.record-box {
  border: 1.5px solid var(--theme-color, #1e3a5f);
  background: #ffffff;
  padding: 3mm 3.5mm;
  margin-bottom: 2.8mm;
}

.record-box h4 {
  font-size: 9.5pt;
  color: var(--theme-color, #1e3a5f);
  border-bottom: 1px dashed #b5ab9c;
  padding-bottom: 1mm;
  margin-bottom: 1.5mm;
}

.record-copy-text {
  font-size: 9.2pt;
  line-height: 1.52;
  color: #1f2421;
}

/* P4 朝の会10分雑談ネタ帳 */
.topic-card {
  border: 1.5px solid #8c8273;
  background: #ffffff;
  padding: 3.5mm 4.5mm;
  margin-bottom: 3mm;
}

.topic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid var(--theme-color, #1e3a5f);
  padding-bottom: 1.5mm;
  margin-bottom: 2mm;
}

.topic-title {
  font-size: 11.8pt;
  font-weight: 700;
  color: var(--theme-color, #1e3a5f);
}

.topic-body {
  font-size: 9.8pt;
  line-height: 1.58;
  color: #24211e;
  margin-bottom: 2.2mm;
}

.talk-prompt-box {
  background-color: #f5efe4;
  border-left: 4px solid var(--accent-color, #8b2635);
  padding: 2mm 3mm;
  font-size: 9.6pt;
  font-weight: 700;
  color: #3b1d16;
}

/* フッター（下端余白15mm基準） */
.page-footer {
  border-top: 1.2px solid #8c8273;
  padding-top: 2mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8.2pt;
  color: #524c44;
}
