/* 四三ページ（2026-11-10 asopiko 版）。設計稿 ShisanA / ShisanAS / ShisanAM / ShisanASM / ShisanASM2。
   部品（箱・札・図・釦）は asopiko.css、ここは首屏カードの並びと出題区の見た目だけ。色は --ap-*。 */

.sp-main { max-width: 1040px; margin: 0 auto; padding: 0 40px; box-sizing: border-box; }

/* ── 首屏カード：左に盤、右に説明。高さを揃える ── */
.sp-primer {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 457px minmax(0, 1fr);
  gap: 30px;
  align-items: stretch;
}
/* 見る / 解くの部品は同じ枠に重ね、隠す側は見えないだけにする（display は保つ）。
   カードの高さ・盤の位置がモードや形で変わらない */
.sp-primer__left { display: grid; grid-template-areas: "chips" "board" "nav"; grid-template-rows: auto auto 1fr; justify-items: center; row-gap: 14px; align-content: start; }
.sp-primer__left > .ap-chips { grid-area: chips; justify-self: stretch; align-self: start; }
.sp-primer__left > .sp-board { grid-area: board; }
.sp-primer__left > .sp-nav { grid-area: nav; align-self: start; }
.sp-primer__right { display: grid; grid-template-rows: auto 1fr; row-gap: 12px; min-width: 0; align-content: start; }
.sp-primer__right > .sp-watch, .sp-primer__right > .sp-solve { grid-area: 2 / 1; }
/* 左（チップ・盤・釦）は両モードで同じ枠に重ね、盤の位置を変えない。
   右の説明は各モードの高さのまま（外れた側は畳む）。タブはカードの上端なので、切り替えで動くのは下端だけ */
.sp-primer__left > [data-mode-off] { visibility: hidden; }
.sp-primer__right > [data-mode-off] { display: none !important; }
.sp-board { position: relative; display: grid; place-items: center; width: 457px; height: 457px; }
.sp-board svg { display: block; }
.sp-nav { display: flex; gap: 12px; }
.sp-nav .ap-btn { min-height: 40px; padding: 7px 16px; font-size: 12.5px; box-shadow: 0 2px 0 var(--ap-ink); }

.sp-watch { display: flex; flex-direction: column; gap: 12px; }
.sp-kicker { margin: 6px 0 0; font-size: 12px; font-weight: 900; color: var(--ap-cta); letter-spacing: .08em; }
.sp-watch h2, .problem-ask h2 { margin: 0; font-size: 18px; font-weight: 900; line-height: 1.4; color: var(--ap-ink); text-align: left; }
.sp-lead { margin: 0; font-size: 14px; line-height: 1.95; color: var(--ap-sub); }
.sp-lead strong { color: var(--ap-ink); }
.sp-shapehead { display: flex; align-items: baseline; justify-content: space-between; margin-top: 4px; }
.sp-shapehead strong { font-size: 15px; font-weight: 900; }
.sp-shapehead span { font-size: 12px; color: var(--ap-muted); font-variant-numeric: tabular-nums; }

/* ── 解く側（出題区）── */
.sp-board__inner { position: relative; }
.board-hits { position: absolute; left: 0; top: 0; }
.board-hit {
  position: absolute;
  width: var(--hit, 28px);
  height: var(--hit, 28px);
  transform: translate(-50%, -50%);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.board-hit:disabled { cursor: default; }

.sp-solve { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; }
.sp-solve [data-problem-ask] { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; }
.problem-progress { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.problem-progress__row { display: flex; align-items: center; justify-content: space-between; }
.problem-count { margin: 0; font-size: 12px; font-weight: 900; color: var(--ap-cta); letter-spacing: .04em; }
.problem-count__of, .problem-progress__label { color: var(--ap-cta); font-size: 12px; font-weight: 900; }
.turn-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 4px; border-radius: 999px;
  background: var(--ap-ink); color: var(--ap-surface);
  font-size: 12px; font-weight: 900;
}
.turn-badge i { width: 14px; height: 14px; border-radius: 50%; background: var(--stone-black); box-shadow: inset 0 0 0 1px var(--mini-edge); }
.problem-meter { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 5px; }
.problem-meter span { height: 6px; border-radius: 999px; background: var(--ap-line); }
.problem-meter span.is-on { background: var(--ap-cta); }
[data-problem-ask][hidden] { display: none !important; }
.problem-ask { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.problem-ask p { margin: 0; font-size: 14px; line-height: 1.95; color: var(--ap-sub); }
.problem-alert { margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--ap-ng-bg); color: var(--ap-ng-ink); font-size: 13px; font-weight: 700; }

.problem-checks { padding: 12px 14px; border-radius: 14px; background: var(--ap-soft); display: flex; flex-direction: column; gap: 8px; }
.problem-checks > strong { font-size: 13px; }
.problem-check { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--ap-surface); font-size: 12px; color: var(--ap-sub); }
.problem-check i { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ap-accent); color: var(--ap-on-fill); font-style: normal; font-size: 11px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; }
.problem-check b { display: block; font-size: 13.5px; color: var(--ap-ink); }

.problem-script { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ap-muted); }
.problem-moves { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ap-ink); font-variant-numeric: tabular-nums; }
.problem-moves .is-dim { color: var(--ap-faint); }

/* 選択中の表示は盤の下（見る側の前後釦と同じ枠）に出す。右の説明の高さを変えない */
.sp-primer__left > .problem-pick {
  grid-area: nav; align-self: start;
  display: flex; align-items: center; gap: 14px;
  min-height: 40px; box-sizing: border-box; padding: 0 16px;
  border: 2px solid var(--ap-ink); border-radius: 999px; background: var(--ap-tag-yellow);
  font-size: 13px; font-weight: 700; color: var(--ap-ink);
}
.problem-pick__name { display: flex; align-items: center; gap: 8px; }
.problem-pick__name i { width: 18px; height: 18px; border-radius: 50%; background: var(--stone-black); opacity: .5; box-shadow: 0 0 0 2px var(--ap-surface), 0 0 0 4px var(--ap-brand-red); }
.problem-pick__hint { font-size: 12px; color: var(--ap-muted); }

.problem-actions { display: flex; gap: 8px; }
.problem-actions button {
  height: 48px; padding: 0 18px;
  border: 2px solid var(--ap-ink); border-radius: 999px;
  background: var(--ap-surface); box-shadow: 0 2px 0 var(--ap-ink);
  color: var(--ap-ink); font-family: var(--ap-font); font-size: 13px; font-weight: 900;
  cursor: pointer;
}
.problem-actions button.is-primary {
  flex: 1 1 auto; order: -1;
  background: var(--ap-cta); color: var(--ap-on-fill);
  box-shadow: 0 4px 0 var(--ap-ink); font-size: 15px;
}
.problem-actions button:disabled { opacity: .45; cursor: default; }
.problem-actions button:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }

/* 答えたあとの解説（電脳版は右の欄にそのまま出す）*/
.problem-sheet { display: flex; flex-direction: column; gap: 10px; }
.problem-sheet[hidden] { display: none; }
.problem-sheet__grip { display: none; }
.problem-sheet__head { display: flex; align-items: center; gap: 10px; }
.problem-sheet__mark { padding: 3px 12px; border-radius: 999px; background: var(--ap-ok-bg); color: var(--ap-ok-ink); font-size: 13px; font-weight: 900; }
.problem-sheet__mark::before { content: '○ 正解'; }
.sp-primer[data-phase="wrong"] .problem-sheet__mark { background: var(--ap-ng-bg); color: var(--ap-ng-ink); }
.sp-primer[data-phase="wrong"] .problem-sheet__mark::before { content: '✗ もう一度'; }
.problem-sheet h2, .problem-sheet .problem-sheet__title { margin: 0; font-size: 18px; font-weight: 900; }
.problem-sheet p { margin: 0; font-size: 13.5px; line-height: 1.85; color: var(--ap-sub); }
.problem-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ap-muted); }
.problem-legend span { display: flex; align-items: center; gap: 5px; }
.problem-legend i { display: inline-block; }
.legend-four { width: 22px; height: 10px; border-radius: 5px; background: var(--band-four); }
.legend-three { width: 22px; height: 10px; border-radius: 5px; border: 2px dashed var(--shu); box-sizing: border-box; }
.legend-last { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--shu); box-sizing: border-box; }
.problem-scrim { display: none; }

/* ── まとめと本文 ── */
.sp-conds { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.sp-conds > strong { font-size: 14px; }
.sp-conds__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sp-cond { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--ap-surface); }
.sp-cond__no { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ap-accent); color: var(--ap-on-fill); font-size: 12px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; }
.sp-cond > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.sp-cond strong { font-size: 13.5px; }
.sp-cond span span { font-size: 12.5px; color: var(--ap-sub); line-height: 1.7; }

.sp-note { font-size: 12px !important; color: var(--ap-muted) !important; line-height: 1.85 !important; margin-top: 10px !important; }
.ap-box .ap-figrow { margin: 14px 0 0; }
.ap-box .ap-fig .board-fig { width: 100%; max-width: 201px; height: auto; }

.sp-shapes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sp-shape {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px 16px;
  border: 2px solid var(--ap-ink); border-radius: 16px;
  background: var(--ap-surface); box-shadow: var(--ap-solid-shadow);
}
.sp-shape h3 { margin: 0; font-size: 15px; font-weight: 900; }
.sp-shape__pair { display: flex; align-items: center; justify-content: center; gap: 12px; }
.sp-shape__pair .board-fig { width: 145px; max-width: 42%; height: auto; }
.sp-shape__arrow { font-size: 16px; font-weight: 900; }
.sp-shape p { margin: 0; font-size: 13.5px; line-height: 1.7; }
.sp-shape .ap-mark { align-self: flex-start; font-size: 12.5px; padding: 3px 10px; }
.sp-shape .ap-btn { align-self: flex-start; min-height: 36px; font-size: 12.5px; }

.ap-table th[scope="row"] { font-weight: 900; color: var(--ap-ink); }

/* ── 手機版（ShisanAM / ShisanASM / ShisanASM2）── */
@media (max-width: 767px) {
  .sp-main { padding: 0 12px; }
  .sp-primer { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
  .sp-primer__left, .sp-primer__right { display: contents; }
  .sp-primer [data-mode-off] { display: none !important; }
  .sp-board { width: 323px; height: 323px; }
  .sp-primer .ap-seg { order: 1; }
  .sp-primer__left > .ap-chips { order: 2; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .sp-primer__left > .ap-chips .ap-chip { flex: none; }
  .sp-solve { order: 2; }
  .sp-board { order: 3; align-self: center; }
  .sp-nav { order: 4; justify-content: center; }
  .sp-watch { order: 5; }
  .sp-primer .ap-seg > button { height: 36px; font-size: 12.5px; }
  /* 解く側：見出し → 盤 → 条件 → 下端の操作帯 */
  .sp-solve { display: contents; }
  .problem-progress { order: 2; }
  .sp-solve [data-problem-ask] { display: contents; }
  .problem-ask { order: 2; }
  .problem-ask p { min-height: 5.85em; } /* 問題文は 3 行分取る：問題を替えても盤が上下しない */
  .problem-alert { order: 4; }
  .problem-checks { order: 4; flex-direction: row; flex-wrap: wrap; gap: 6px; padding: 0; background: transparent; }
  .problem-checks > strong { display: none; }
  .problem-check { padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--ap-soft); color: var(--ap-ink); font-weight: 900; }
  .problem-check span { font-size: 0; }
  .problem-check b { display: inline; font-size: 12px; color: var(--ap-ink); }
  .problem-check i { width: 18px; height: 18px; font-size: 10px; }
  .problem-script { display: none; }
  .problem-pick, .sp-solve [data-problem-actions] { order: 6; }
  .sp-primer__left > .problem-pick { grid-area: auto; align-self: stretch; min-height: 0; border: 0; border-radius: 0; justify-content: space-between; font-weight: 400; }
  .problem-pick { margin: 0 -14px; padding: 12px 14px 0; border-top: 2px solid var(--ap-ink); background: var(--ap-cream); }
  .sp-solve [data-problem-actions] {
    position: sticky; bottom: 0; z-index: 5;
    margin: 0 -14px -14px; padding: 10px 14px 16px;
    background: var(--ap-cream); border-radius: 0 0 16px 16px;
  }
  .problem-actions button { height: 48px; padding: 0 14px; font-size: 12.5px; }
  .problem-actions button.is-primary { order: 1; font-size: 15px; }
  .problem-sheet {
    order: 7;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 71;
    max-height: 70vh; overflow: auto;
    padding: 10px 18px 26px;
    background: var(--ap-surface);
    border-top: 2px solid var(--ap-ink);
    border-radius: 22px 22px 0 0;
  }
  .problem-sheet__grip { display: block; align-self: center; width: 44px; height: 5px; border-radius: 999px; background: var(--ap-line); }
  .problem-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 70; background: var(--ap-scrim); }
  .sp-conds__grid { grid-template-columns: 1fr; gap: 8px; }
  .sp-shapes { grid-template-columns: 1fr; gap: 12px; }
  .sp-shape__pair .board-fig { width: 121px; }
  .ap-box .ap-figrow { flex-direction: column; }
  .ap-box .ap-figrow .ap-fig { flex-direction: row; padding: 10px; text-align: left; }
  .ap-box .ap-figrow .ap-fig > .ap-mark { position: static; order: 2; align-self: flex-start; }
  .ap-box .ap-figrow .ap-fig .board-fig { width: 119px; flex: none; }
  .ap-box .ap-figrow .ap-fig figcaption { text-align: left; order: 3; }
}
.ap-titleline .sp-jump { margin-left: auto; font-size: 13px; }
.sp-conds > p { margin: 8px 0 0; }
.sp-watch .sp-note { margin: -6px 0 0 !important; }
.ap-fig figcaption b { display: block; margin-bottom: 4px; font-size: 13px; color: var(--ap-ink); }
.ap-fig figcaption a { display: block; margin-top: 6px; font-weight: 900; color: var(--ap-accent); }
