/* CPZ-01 範囲1: 盤面を最初の画面へ・マスの大きさ・操作の手がかり */

/* 盤面の見出し(盤面のすぐ上) */
.cpz-board-head { text-align: center; margin: 0 0 12px; scroll-margin-top: var(--cpz-header-h, 0px); }
.cpz-board-head h2 { font-size: 1.25rem; font-weight: 800; color: #1e1b4b; margin: 0; }
.dark .cpz-board-head h2 { color: #e0e7ff; }
.cpz-board-head p { margin: 4px 0 0; font-size: .9rem; color: #4b5563; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.cpz-board-head .cpz-choose { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; color: #3730a3; font-weight: 700; text-decoration: underline; }
#main { scroll-margin-top: var(--cpz-header-h, 0px); }

/* 盤面: マスの大きさは --cell(JS が枠の幅と文字の大きさから計算)。はみ出す分は枠の中だけで横に動かす */
.cpz-board-col { width: 100%; max-width: 100%; min-width: 0; }
#crosswordGrid { display: block !important; background: none !important; padding: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    max-width: 100% !important; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; margin: 0 auto; }
#crosswordGrid .crossword-grid { display: grid; gap: 1px; padding: 1px; background: #111827; width: max-content; margin: 0 auto;
    grid-template-columns: repeat(var(--size, 9), var(--cell, 36px)) !important; border-radius: 6px; max-width: none; overflow: visible; }
#crosswordGrid .crossword-cell { width: var(--cell, 36px) !important; height: var(--cell, 36px) !important; display: block; position: relative; box-sizing: border-box; transition: background-color .2s; /* 大きさは動かさない(切り替えの直後に測れるように) */ }
#crosswordGrid .cell-input { display: block; width: 100%; height: 100%; padding: 0; font-size: calc(var(--cell, 36px) * .56); line-height: var(--cell, 36px); }
#crosswordGrid .cell-number { font-size: max(9px, calc(var(--cell, 36px) * .3)); line-height: 1; top: 1px; left: 2px; pointer-events: none; }
/* フォーカス中のマス: 太い枠と背景(白との差 3:1 以上) */
#crosswordGrid .crossword-cell:focus-within { outline: 3px solid #1d4ed8; outline-offset: -3px; z-index: 2; }
#crosswordGrid .cell-input:focus { background: #fde68a; color: #111827; outline: none; }
.dark #crosswordGrid .cell-input:focus { background: #fde68a; color: #111827; }
/* 誤りのマス: 色だけでなく斜線と「×」 */
#crosswordGrid .crossword-cell.cpz-wrong { background-image: repeating-linear-gradient(45deg, rgba(220, 38, 38, .22) 0 4px, transparent 4px 8px); }
#crosswordGrid .crossword-cell.cpz-wrong::after { content: "×"; position: absolute; right: 1px; bottom: 0; font-size: max(10px, calc(var(--cell, 36px) * .32)); font-weight: 900; color: #b91c1c; line-height: 1; pointer-events: none; }
.cpz-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.cpz-scroll-hint { text-align: center; font-size: .85rem; color: #4b5563; margin: 6px 0 0; }
.cpz-current-clue { margin: 10px auto 0; max-width: 560px; padding: 10px 14px; border-radius: 10px; background: #eef2ff; color: #1e1b4b; font-size: 1rem; font-weight: 600; text-align: left; min-height: 44px; box-sizing: border-box; }
.dark .cpz-current-clue { background: #312e81; color: #e0e7ff; }
.cpz-notice { margin: 10px auto 0; max-width: 560px; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 10px; background: #fff7ed; border: 2px solid #c2410c; color: #7c2d12; font-weight: 700; }
.cpz-notice[hidden] { display: none; }
.cpz-notice span { flex: 1 1 auto; min-width: 0; }
.cpz-notice button { flex: 0 0 44px; width: 44px !important; margin: 0 !important; padding: 0 !important; min-width: 44px; min-height: 44px; font-size: 1.2rem; color: #7c2d12; background: none; border: none; cursor: pointer; }

/* スマホ: ヘッダーを低くし、盤面を広く使う */
@media (max-width: 767px) {
    header.sticky .py-4 { padding-top: 4px !important; padding-bottom: 4px !important; }
    header.sticky .max-w-7xl { padding-top: 0 !important; padding-bottom: 0 !important; }
    header.sticky button { margin: 0 !important; }
    #main { padding: 12px 12px 24px !important; }
}

/* タップ領域 44px 以上(盤面のマスと文中のリンクは除く) */
header a, header button, nav a, #mobileMenu a, #mobileMenu button, #fontSizeMenu button { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
#fontSizeMenu button { width: 100%; justify-content: flex-start; }
#main button, #main select, #successModal button, aside button, aside a { min-height: 44px; }
.clue-item { min-height: 44px; }
/* ブロック・インラインブロックのリンクとボタン(min-height は文中のリンクには効かない) */
a, button, select, summary { min-height: 44px; min-width: 44px; align-content: center; box-sizing: border-box; }
a.js-track-affiliate { display: inline-flex; align-items: center; }
/* マスの入力欄: ページ共通の「入力欄は高さ44px」を外す(行の間に黒い帯ができていた)。文字は16px以上(iPhoneで拡大されない) */
#crosswordGrid .crossword-grid { grid-auto-rows: var(--cell, 36px); }
#crosswordGrid .cell-input { min-height: 0 !important; min-width: 0 !important; height: 100% !important; margin: 0 !important; font-size: max(16px, calc(var(--cell, 36px) * .56)) !important; }
