/* =====================================================================
   ゲームの手引き（ボタン図鑑）… rules.html の「ゲームの手引き」タブ
   ・中身は assets/guide/content.html（rules.js が読み込む）、画像は assets/guide/images/
   ・色はサイトの色（--text・--muted・--line・--accent・--panel）をそのまま使い、
     手引きだけで使う色（--g-…）をモードごと（ナイト＝何も付かない／ライト／リーフ）に決める
   ===================================================================== */
.guide-root {
  --g-line-strong: rgba(190, 199, 255, 0.28);
  --g-panel-solid: var(--m-panel-solid, #14182f);
  --g-accent-text: var(--m-accent-text, #11152e);
  --g-accent-soft: rgba(174, 188, 255, 0.14);
  --g-sub-bg: rgba(0, 0, 0, 0.24);
  --g-shot-bg: rgba(7, 8, 18, 0.9);
  --g-row-hover: rgba(174, 188, 255, 0.06);
  --g-active-bg: rgba(174, 188, 255, 0.12);
  --g-note-bg: rgba(192, 133, 40, 0.14);
  --g-note-text: #ffe6b7;
  --g-note-line: rgba(241, 202, 129, 0.28);
  --g-top: 52px;
}
html[data-chat-skin="light"] .guide-root {
  --g-line-strong: rgba(54, 58, 104, 0.26);
  --g-accent-soft: rgba(68, 72, 109, 0.1);
  --g-sub-bg: rgba(54, 58, 104, 0.05);
  --g-shot-bg: #dce1f2;
  --g-row-hover: rgba(68, 72, 109, 0.05);
  --g-active-bg: rgba(68, 72, 109, 0.1);
  --g-note-bg: rgba(241, 202, 129, 0.18);
  --g-note-text: #6e4c11;
  --g-note-line: rgba(192, 133, 40, 0.3);
}
html[data-chat-skin="leaf"] .guide-root {
  --g-line-strong: rgba(63, 57, 62, 0.26);
  --g-accent-soft: rgba(73, 65, 72, 0.09);
  --g-sub-bg: rgba(188, 202, 197, 0.42);
  --g-shot-bg: #bccbc5;
  --g-row-hover: rgba(73, 65, 72, 0.05);
  --g-active-bg: rgba(73, 65, 72, 0.1);
  --g-note-bg: rgba(255, 255, 255, 0.45);
  --g-note-text: #4d454b;
  --g-note-line: rgba(63, 57, 62, 0.22);
}

/* 手引きのタブを開いているときは、図と説明を横に並べられるよう少し広げる */
body.rules-page.is-guide-tab .rules-main { width: min(100% - 28px, 1440px); }
/* ルールブックのタブを出さない設定のとき（手引きだけのページ） */
body.rules-page.no-rules-tabs .rules-content-tabs { display: none; }
.rules-content-tabs.is-single { grid-template-columns: minmax(0, 1fr); }
.rules-tab-note { margin-left: 0.4em; font-size: 0.72em; opacity: 0.75; }

.guide-root[hidden] { display: none !important; }
.guide-loading { color: var(--muted); }
.guide-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 20px; align-items: start; }
.guide-root .rules-document.g-main { min-width: 0; padding: clamp(18px, 2.4vw, 30px); }

/* ----- 左の目次 ----- */
/* リンクの色は、背景モードのリンク色（chat-modes-pages.css）より強く指定する */
.g-side { position: sticky; top: var(--g-top); max-height: calc(100vh - var(--g-top) - 12px); overflow-y: auto; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-family: var(--font-sans); font-weight: 500; }
.g-view { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; margin-bottom: 10px; border: 1px solid var(--g-line-strong); border-radius: 999px; background: var(--g-sub-bg); }
.g-view button { appearance: none; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 700 0.76rem/1.4 var(--font-sans); padding: 6px 4px; cursor: pointer; }
.g-view button[aria-pressed="true"] { background: var(--accent); color: var(--g-accent-text); }
.g-tools { display: grid; gap: 6px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 0.76rem; color: var(--muted); }
.g-tools label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.g-search { width: 100%; padding: 7px 11px; border: 1px solid var(--g-line-strong); border-radius: 10px; background: var(--g-panel-solid); color: var(--text); font: 500 0.8rem/1.4 var(--font-sans); }
.g-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.g-side summary { cursor: pointer; padding: 2px 4px 8px; color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; }
.g-toc, .g-toc ul { list-style: none; margin: 0; padding: 0; }
.g-toc > li + li { margin-top: 2px; }
.guide-root .g-toc a { color: inherit; }
.guide-root .g-toc > li > a { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border-radius: 9px; font-size: 0.8rem; font-weight: 700; line-height: 1.35; text-decoration: none; transition: background-color 0.15s ease; }
.guide-root .g-toc > li > a::after { content: "▸"; flex: none; font-size: 0.7rem; color: var(--muted); transition: transform 0.15s ease; }
.guide-root .g-toc > li > a:hover { background: var(--g-row-hover); }
.guide-root .g-toc > li.is-active > a { background: var(--accent); color: var(--g-accent-text); }
.guide-root .g-toc > li.is-active > a::after { transform: rotate(90deg); color: var(--g-accent-text); }
.g-toc > li > ul { display: none; margin: 4px 0 6px; padding: 4px 6px; border-radius: 8px; background: var(--g-sub-bg); }
.g-toc > li.is-active > ul, .guide-root.show-all-secs .g-toc > li > ul { display: grid; gap: 2px; }
.guide-root .g-toc ul a { display: block; padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; line-height: 1.4; color: var(--muted); text-decoration: none; }
.guide-root .g-toc ul a:hover, .guide-root .g-toc ul a.is-current { background: var(--g-active-bg); color: var(--text); font-weight: 700; }

/* ----- 本文 ----- */
.g-main { font-family: var(--font-sans); font-weight: 450; line-height: 1.65; }
.guide-root .g-main a { color: inherit; }
.g-breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--muted); font: 500 0.78rem/1.4 var(--font-sans); }
.g-breadcrumb .current { color: var(--text); font-weight: 700; }
.guide-root:not(.show-all-secs) .g-sec { display: none; }
.guide-root:not(.show-all-secs) .g-sec.is-active-sec { display: block; }
.guide-root.show-all-secs .g-sec { display: block; margin-bottom: 48px; }
.guide-root.show-all-secs .g-pager, .guide-root.show-all-secs .g-breadcrumb { display: none; }
.g-sec > h2 { margin: 0 0 8px; padding: 0; border: 0; background: transparent; font-family: var(--font-serif); font-size: 1.45rem; font-weight: 700; letter-spacing: 0.03em; }
.g-intro { margin: 0 0 20px; color: var(--muted); font-size: 0.9rem; }

/* 第0章：図説・4ステップ */
.g-flow-box { margin: 0 0 24px; padding: 20px; border: 1px solid var(--g-line-strong); border-radius: var(--radius); background: var(--g-sub-bg); }
.g-flow-title { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-family: var(--font-sans); font-size: 1.05rem; font-weight: 700; }
.g-flow-title::before { content: ""; width: 8px; height: 8px; background: var(--accent); transform: rotate(45deg); }
.g-diagram { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.g-diag-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px 14px; border: 1px solid var(--g-line-strong); border-radius: 12px; background: var(--panel); }
.g-diag-card:not(:last-child)::after { content: "▶"; position: absolute; top: 50%; right: -11px; z-index: 2; color: var(--accent); font-size: 0.8rem; transform: translateY(-50%); }
.g-diag-head { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 0.9rem; font-weight: 800; line-height: 1.3; }
.g-diag-icon { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; background: var(--g-active-bg); color: var(--accent); }
.g-diag-icon svg { width: 22px; height: 22px; }
.g-diag-sub { margin: 0; color: var(--text); font-size: 0.78rem; line-height: 1.5; }
.g-diag-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 6px; }
.guide-root .g-diag-tags a { padding: 2px 9px; border: 1px solid var(--g-line-strong); border-radius: 999px; background: var(--g-active-bg); color: var(--text); font-size: 0.72rem; font-weight: 700; text-decoration: none; transition: all 0.15s ease; }
.guide-root .g-diag-tags a:hover { border-color: var(--accent); background: var(--accent); color: var(--g-accent-text); }
.g-step-list { display: grid; gap: 12px; }
.g-step-item { display: flex; align-items: flex-start; gap: 18px; padding: 16px 20px; border: 1px solid var(--g-line-strong); border-radius: 12px; background: var(--panel); }
.g-step-visual { display: flex; flex: none; align-items: center; gap: 12px; padding-top: 2px; }
.g-step-visual .g-no { min-width: 24px; height: 24px; border-radius: 6px; font-size: 0.8rem; }
.g-step-icon { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--g-active-bg); color: var(--accent); }
.g-step-icon svg { width: 30px; height: 30px; stroke-width: 1.85; }
.g-step-body { flex: 1; min-width: 0; }
.g-step-item h4 { margin: 0 0 6px; color: var(--text); font-size: 0.98rem; font-weight: 700; line-height: 1.4; }
.g-step-item p { margin: 0; color: var(--text); font-size: 0.85rem; line-height: 1.65; }

/* 各画面の説明（左に図・右に番号つきの説明） */
.g-fig { display: grid; grid-template-columns: minmax(0, 58%) minmax(300px, 42%); column-gap: 20px; row-gap: 10px; align-items: start; margin: 0 0 28px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--g-sub-bg); }
.guide-root[data-view="sp"] .g-fig { grid-template-columns: 340px minmax(0, 1fr); }
.g-sec .g-fig:last-of-type { margin-bottom: 0; }
.g-fig > h3, .g-fig > .g-lead, .g-fig > h4, .g-fig > .g-table.g-tags { grid-column: 1 / -1; }
.g-fig h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--font-serif); font-size: 1.12rem; font-weight: 700; }
.g-lead { margin: 0 0 4px; color: var(--muted); font-size: 0.86rem; }
.g-fig > .g-shot { position: sticky; top: var(--g-top); grid-column: 1; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--g-shot-bg); text-align: center; line-height: 0; }
.g-fig:has(.g-tags) > .g-shot { position: static; }
.g-shot img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; }
.g-shot img.v-sp { max-width: 340px; }
.g-fig > .g-shot + .g-table:not(.g-tags) { grid-column: 2; margin-top: 0; }
.g-table:not(.g-tags) { width: 100%; border-collapse: separate; }
.g-table:not(.g-tags) tbody { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.g-table:not(.g-tags) tr { display: flex; flex-direction: column; gap: 4px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); transition: border-color 0.15s ease, background-color 0.15s ease; }
.g-table:not(.g-tags) tr:hover { border-color: var(--g-line-strong); background: var(--g-panel-solid); }
.g-table:not(.g-tags) th, .g-table:not(.g-tags) td { display: block; width: 100%; padding: 0; border: 0; text-align: left; }
.g-table:not(.g-tags) th { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 700; line-height: 1.35; }
.g-table:not(.g-tags) td { padding-left: 28px; color: var(--text); font-size: 0.82rem; font-weight: 450; line-height: 1.55; }
.g-no { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--g-accent-text); font-size: 0.73rem; font-weight: 700; }
.g-no-none { background: var(--g-line-strong); color: var(--text); }
.g-name { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--g-accent-soft); color: var(--text); font-weight: 700; }
.g-fig h4 { margin: 18px 0 6px; padding: 0; border: 0; color: var(--text); font-family: var(--font-serif); font-size: 1rem; font-weight: 700; }
.g-table.g-tags { width: 100%; max-width: 780px; margin-top: 4px; overflow: hidden; border: 1px solid var(--line); border-collapse: collapse; border-radius: 12px; background: var(--panel); font-size: 0.86rem; }
.g-table.g-tags tr { border-bottom: 1px solid var(--line); }
.g-table.g-tags tr:last-child { border-bottom: 0; }
.g-table.g-tags tr:hover { background: var(--g-row-hover); }
.g-table.g-tags th, .g-table.g-tags td { padding: 9px 14px; font-family: var(--font-sans); text-align: left; vertical-align: middle; }
.g-table.g-tags th { width: 260px; border-right: 1px solid var(--line); color: var(--text); font-weight: 700; }
.g-table.g-tags td { color: var(--muted); }
.g-tags code { display: inline-block; padding: 2px 8px; border: 1px solid var(--g-line-strong); border-radius: 6px; background: var(--g-note-bg); color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.86rem; }

/* 補足・制作メモ・ページ送り */
.g-note, .g-out { display: block; margin-top: 5px; font-size: 0.78rem; }
.g-note { padding: 4px 10px; border: 1px solid var(--g-note-line); border-radius: 6px; background: var(--g-note-bg); color: var(--g-note-text); }
.g-out { color: var(--muted); }
.g-todo ul { margin: 0; padding-left: 1.3em; color: var(--g-note-text); font: 450 0.88rem/1.7 var(--font-sans); }
/* 制作メモ（※要確認）と、その一覧の章は運営だけに出す（運営は「隠す」で消せる） */
.guide-root:not(.is-staff) .g-note,
.guide-root:not(.is-staff) .g-todo,
.guide-root:not(.is-staff) .g-toc-todo,
.guide-root:not(.is-staff) .g-staff-only,
.guide-root.hide-notes .g-note,
.guide-root.hide-notes .g-todo,
.guide-root.hide-notes .g-toc-todo { display: none !important; }
.g-nohit { margin: 30px 0; color: var(--muted); text-align: center; }
.g-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.g-pager button { appearance: none; padding: 8px 18px; border: 1px solid var(--g-line-strong); border-radius: 999px; background: var(--g-sub-bg); color: var(--text); font: 700 0.84rem/1.4 var(--font-sans); cursor: pointer; transition: all 0.15s ease; }
.g-pager button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent); color: var(--g-accent-text); }
.g-pager button:disabled { opacity: 0.35; cursor: default; }

.guide-root[data-view="pc"] .v-sp, .guide-root[data-view="sp"] .v-pc, .guide-root[data-view="pc"] .only-sp, .guide-root[data-view="sp"] .only-pc { display: none !important; }
.guide-root .is-hidden-by-search { display: none !important; }

@media (max-width: 1024px) {
  .g-diagram { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-fig, .guide-root[data-view="sp"] .g-fig { grid-template-columns: 1fr; }
  .g-fig > .g-shot { position: static; }
  .g-fig > .g-shot + .g-table:not(.g-tags) { grid-column: 1; margin-top: 12px; }
}
@media (max-width: 960px) {
  .g-diagram { grid-template-columns: 1fr; gap: 16px; }
  .g-diag-card:not(:last-child)::after { content: "▼"; top: auto; right: 50%; bottom: -15px; transform: translateX(50%); }
}
@media (max-width: 800px) {
  .guide-layout { grid-template-columns: 1fr; }
  .g-side { position: static; max-height: none; }
  .g-step-item { flex-direction: column; gap: 10px; }
  .g-table.g-tags th, .g-table.g-tags td { display: block; width: 100%; border-right: 0; }
  .g-table.g-tags th { padding-bottom: 2px; }
  .g-table.g-tags td { padding-top: 2px; }
}
@media (max-width: 720px) {
  .guide-root .rules-document.g-main { padding: 16px; }
}
