/* ===================================================================
   ガイドブック（仕様書 4.7）。本文は今のガイドブック（public/guide-*.html）をそのまま読み込み、
   js/guide/guide.js が組み立てた部品（.ulb 盤面図・.talk 吹き出し・.box 囲み など）に新しい見た目を当てる。
   PC: 左に目次（280px）、右に記事（800px）。スマホ: 目次はスレートの帯に折りたたむ。
   =================================================================== */
/* はじめてのルール（チュートリアル）への入口 */
.guide-tutorial {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding: 14px 16px;
  background: var(--aqua-pale); box-shadow: inset 4px 0 0 var(--aqua); color: inherit; text-decoration: none;
}
.guide-tutorial:hover { background: var(--aqua-increase); }
.guide-tutorial-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--aqua); color: #fff; }
.guide-tutorial-text { display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; }
.guide-tutorial .guide-tutorial-text strong { color: var(--ink); background: none; padding: 0; }
.guide-tutorial-text span { font-size: 13.5px; color: var(--text-sub); }
.toc-cover.toc-tutorial { display: flex; align-items: center; gap: 6px; color: var(--aqua-text); font-weight: 700; }

.guide-layout { display: grid; grid-template-columns: 280px minmax(0, 800px); gap: 32px; align-items: start; justify-content: center; }

/* 目次 */
.guide-toc-card { position: sticky; top: calc(var(--header-h) + 24px); max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto; }
.toc-toggle { display: none; }
.toc-part { border-top: 1px solid var(--line-light); }
.toc-part > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-weight: 700; color: var(--ink); font-size: 14px;
}
.toc-part > summary::-webkit-details-marker { display: none; }
.toc-part > summary svg { transition: transform 0.15s ease; }
.toc-part[open] > summary svg { transform: rotate(180deg); }
.toc-list { list-style: none; padding: 0 0 8px; }
.toc-list a, .toc-cover {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 6px; align-items: baseline;
  padding: 8px 16px; color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.5;
}
.toc-cover { display: block; font-weight: 700; color: var(--ink); }
.toc-list a:hover, .toc-cover:hover { background: var(--bg); }
.toc-list a[aria-current="page"], .toc-cover[aria-current="page"] { background: var(--aqua); color: #fff; }
.toc-list .no { font-family: 'Open Sans', sans-serif; font-weight: 700; color: var(--text-sub); }
.toc-list a[aria-current="page"] .no { color: #fff; }

/* 記事 */
.guide-article { background: var(--surface); box-shadow: var(--shadow-card); padding: 40px 48px 48px; line-height: 1.9; font-size: 16px; min-width: 0; }
.guide-article h1 { font-size: 36px; margin: 10px 0 12px; }
.guide-article h2 { font-size: 22px; margin: 44px 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--line-light); scroll-margin-top: calc(var(--header-h) + 16px); }
.guide-article h3 { font-size: 17px; margin: 28px 0 8px; }
.guide-article p { margin: 12px 0; }
.guide-article ul, .guide-article ol { margin: 10px 0 10px 1.4em; }
.guide-article li { margin: 4px 0; }
.guide-article strong { color: var(--ink); background: linear-gradient(transparent 64%, var(--aqua-increase) 64%); }
.guide-chapter-label { display: inline-block; background: var(--aqua); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 10px; letter-spacing: 0.05em; }
.guide-lead { color: var(--text-sub); font-size: 16px; }
.guide-article .kifu {
  font-family: 'Open Sans', ui-monospace, monospace; font-size: 0.92em; font-weight: 600; color: var(--ink);
  background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); padding: 0.05em 0.4em; white-space: nowrap;
}
.guide-article a { color: var(--aqua-text); }
.guide-error { padding: 12px; box-shadow: inset 0 0 0 2px var(--red-text); color: var(--red-text); font-size: 13px; }

/* この部の目次（ルール編のページ内） */
.guide-page-toc { background: var(--bg); padding: 16px 20px; margin: 20px 0; }
.guide-page-toc > p { margin: 0 0 6px; font-weight: 700; color: var(--ink); font-size: 14px; }
.guide-page-toc ol { margin: 0 0 0 1.4em; columns: 2; column-gap: 32px; font-size: 14px; }

/* 表紙の目次 */
.guide-toc-part h2 { border-bottom: 0; margin-bottom: 8px; }
.guide-toc { list-style: none; margin: 0 !important; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.guide-toc li { margin: 0 !important; }
.guide-toc a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px;
  background: var(--bg); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px;
}
.guide-toc a:hover { background: var(--aqua-pale); }
.toc-no { width: 28px; height: 28px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--slate); color: #fff; font-family: 'Open Sans', sans-serif; font-size: 13px; font-weight: 700; }

/* 囲み（用語・ルール・ポイント・よくある失敗・コラム） */
.box { background: var(--aqua-pale); box-shadow: inset 4px 0 0 var(--aqua); padding: 14px 18px 14px 22px; margin: 20px 0; }
.box > :last-child { margin-bottom: 0; }
.box ul, .box ol { margin-left: 1.2em; }
.box-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: #fff; background: var(--aqua); padding: 3px 10px; margin-bottom: 4px; }
.box-title svg { width: 16px; height: 16px; }
.box.caution { background: #FDF0F3; box-shadow: inset 4px 0 0 var(--red-text); }
.box.caution .box-title { background: var(--red-text); }
.box.column, .box.rule { background: var(--bg); box-shadow: inset 4px 0 0 var(--slate); }
.box.column .box-title, .box.rule .box-title { background: var(--slate); }

/* 問題 */
.quiz { background: var(--bg); padding: 16px 20px; margin: 24px 0; box-shadow: inset 0 3px 0 var(--slate); }
.quiz-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); }
.quiz details { margin-top: 10px; }
.quiz summary { cursor: pointer; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px; background: var(--slate); color: #fff; font-weight: 700; font-size: 14px; list-style: none; }
.quiz summary::-webkit-details-marker { display: none; }
.quiz details[open] summary { background: var(--aqua); }
.quiz-answer { padding-top: 6px; }

/* 盤面図 */
figure.ulb { margin: 20px auto; width: 300px; max-width: 100%; }
figure.ulb figcaption { font-size: 13.5px; color: var(--text-sub); line-height: 1.6; margin-top: 8px; text-align: center; }
.ulb-info { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-sub); margin: 0 0 6px; }
.ulb-turn { font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 4px; }
.ulb-hands { display: inline-flex; align-items: center; gap: 4px; }
.ulb-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.ulb-dot.white { background: var(--piece-w-top); box-shadow: inset 0 0 0 1px var(--piece-w-edge); }
.ulb-dot.black { background: var(--piece-b-top); box-shadow: inset 0 0 0 1px var(--piece-b-edge); }
.ulb-hands .ulb-dot { margin-left: 6px; }
.ulb-frame {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); grid-template-rows: 20px auto;
  grid-template-areas: "corner files" "ranks board"; background: var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.ulb-frame > span { grid-area: corner; background: var(--aqua); }
.ulb-files { grid-area: files; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--aqua); }
.ulb-ranks { grid-area: ranks; display: grid; grid-template-rows: repeat(4, 1fr); }
.ulb-board { grid-area: board; position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ulb-files span, .ulb-ranks span { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; line-height: 1; }
.ulb-files span { color: #fff; }
.ulb-ranks span { color: var(--text-sub); }
.ulb-board .cell { cursor: default; }
.ulb-board .cell.light { background: var(--surface); }
.ulb-board .cell.dark { background: var(--checker); }
.ulb-board .cell.increased { background: var(--aqua-increase); }
.ulb-board .cell.decreased { background: var(--red-decrease); }
.ulb-mark { position: absolute; inset: 0; pointer-events: none; }
.ulb-mark.focus { box-shadow: inset 0 0 0 3px var(--slate); z-index: 50; }
.ulb-mark.good { box-shadow: inset 0 0 0 3px var(--aqua); z-index: 50; }
.ulb-mark.bad { box-shadow: inset 0 0 0 3px var(--red-bad); z-index: 50; }
.ulb-mark.reach { background: rgba(251, 221, 227, 0.75); z-index: 0; }
.ulb-mark.area { background: rgba(210, 236, 248, 0.75); z-index: 0; }
.ulb-label {
  position: absolute; top: 4px; right: 4px; z-index: 65; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--slate); color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px #fff;
}
.ulb-arrows { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }
.ulb-arrow { fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: 0.92; }
.ulb-arrow.move { stroke: var(--aqua); }
.ulb-arrow.good { stroke: var(--aqua-text); }
.ulb-arrow.bad { stroke: var(--red-bad); }
.ulb-arrow.alt { stroke: var(--slate); stroke-dasharray: 14 12; opacity: 0.7; }
.ulb-arrowhead.move { fill: var(--aqua); }
.ulb-arrowhead.good { fill: var(--aqua-text); }
.ulb-arrowhead.bad { fill: var(--red-bad); }
.ulb-arrowhead.alt { fill: var(--slate); }

/* 前 → 後・2つを比べる */
.ulb-pair { display: flex; justify-content: center; align-items: center; gap: 12px 20px; margin: 24px 0; padding: 20px; background: var(--bg); flex-wrap: wrap; }
.ulb-pair figure.ulb { margin: 0; width: 240px; }
.ulb-pair.compare { align-items: flex-start; }
.ulb-pair-arrow { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--slate); }
.ulb-pair-arrow svg { width: 26px; height: 26px; }
.ulb-pair-arrow .kifu { font-size: 12.5px; }

/* めくる盤面 */
.ulb-seq-view { width: 320px; }
.ulb-seq-nav { display: flex; justify-content: center; align-items: stretch; margin-top: 10px; background: var(--slate); }
.ulb-seq-nav button { width: var(--tap); min-height: var(--tap); border: 0; background: none; color: #fff; display: flex; align-items: center; justify-content: center; }
.ulb-seq-nav button:disabled { opacity: 0.35; }
.ulb-seq-count { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; font-family: 'Open Sans', sans-serif; }

/* 文中の小さな積み重ね */
.stk { display: inline-block; vertical-align: -6px; }
.stk .coin-box { width: 24px; height: 26px; }

/* 表 */
.guide-table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 16px 0; }
.guide-table th, .guide-table td { border-bottom: 1px solid var(--line-light); padding: 8px 10px; text-align: left; }
.guide-table th { background: var(--bg); color: var(--ink); }
.overflow-x-auto { overflow-x: auto; }

/* 前後の章 */
.guide-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; }
.guide-pager a {
  display: flex; align-items: center; gap: 6px; min-height: 56px; padding: 10px 16px; text-decoration: none; font-weight: 700; line-height: 1.4;
  color: var(--slate); box-shadow: inset 0 0 0 2px var(--slate); background: var(--surface);
}
.guide-pager a:last-child { justify-content: flex-end; text-align: right; background: var(--aqua); color: #fff; box-shadow: none; }
.guide-pager a:only-child { grid-column: 2; }
.guide-pager svg { width: 18px; height: 18px; flex: none; }

@media (max-width: 1023px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-toc-card { position: static; max-height: none; }
}
@media (max-width: 767px) {
  .guide-layout { gap: 12px; }
  .guide-toc-card .card-head { display: none; }
  .toc-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px;
    padding: 0 16px; border: 0; background: var(--slate); color: #fff; font-weight: 700; font-size: 14px; text-align: left;
  }
  .toc-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .guide-toc-card:not(.open) .toc-body { display: none; }
  .guide-toc-card.open .toc-toggle svg { transform: rotate(180deg); }
  .guide-article { padding: 24px 16px 32px; font-size: 15px; }
  .guide-article h1 { font-size: 26px; }
  .guide-article h2 { font-size: 19px; margin-top: 36px; }
  .guide-page-toc ol { columns: 1; }
  .guide-toc { grid-template-columns: minmax(0, 1fr); }
  .ulb-pair { flex-direction: column; padding: 16px 8px; }
  .ulb-pair-arrow svg { transform: rotate(90deg); }
  .guide-pager { grid-template-columns: minmax(0, 1fr); }
  .guide-pager a:only-child { grid-column: 1; }
}

/* 盤面図の中の重なり（矢印・印・文字）を図の中だけで閉じる。ヘッダーより手前に出ないように */
.ulb-frame, .ulb-board { isolation: isolate; }
