:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1d1f21; --muted: #5f6368; --line: #dcdcd7;
  --accent: #b3261e; --accent-soft: #fbe9e7; --link: #1a5fb4; --note-bg: #fff8e1; --note-line: #e6c55a;
  --warn-bg: #fdecea; --warn-line: #e57373;
  --q-common: #6b6b6b; --q-uncommon: #2e7d32; --q-rare: #1565c0; --q-epic: #6a1b9a; --q-legendary: #e65100;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --panel: #1e2125; --text: #e6e6e3; --muted: #a0a4a8; --line: #33373c;
    --accent: #ef7b70; --accent-soft: #3a2421; --link: #8ab4f8; --note-bg: #2f2a1a; --note-line: #8a7330;
    --warn-bg: #3a1f1f; --warn-line: #a35050;
    --q-common: #b0b0b0; --q-uncommon: #81c784; --q-rare: #64b5f6; --q-epic: #ce93d8; --q-legendary: #ffb74d;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --panel: #1e2125; --text: #e6e6e3; --muted: #a0a4a8; --line: #33373c;
  --accent: #ef7b70; --accent-soft: #3a2421; --link: #8ab4f8; --note-bg: #2f2a1a; --note-line: #8a7330;
  --warn-bg: #3a1f1f; --warn-line: #a35050;
  --q-common: #b0b0b0; --q-uncommon: #81c784; --q-rare: #64b5f6; --q-epic: #ce93d8; --q-legendary: #ffb74d;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.7; font-size: 16px;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.site-header { background: var(--panel); border-bottom: 1px solid var(--line); }
.site-header .inner, main, .site-footer .inner { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.site-header .inner { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding-top: 10px; padding-bottom: 10px; }
.site-title { font-weight: 700; font-size: 1.1rem; color: var(--text); }
/* サイト名は空白の位置だけで折り返す（「非公式デー／タwiki」のように語の途中で切れないように） */
.site-title, .site-name { word-break: keep-all; overflow-wrap: anywhere; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 0.95rem; align-self: center; }
/* メニュー：「データ」「仕組み」「読み物」の3つのグループ。押すと一覧が開く（<details> なので、スクリプトがなくても動く） */
.nav-group { position: relative; }
.nav-group > summary { list-style: none; cursor: pointer; padding: 4px 10px; border-radius: 6px; color: var(--link); font-weight: 600; white-space: nowrap; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after { content: "▾"; margin-left: 4px; font-size: 0.8em; }
.nav-group > summary:hover, .nav-group[open] > summary { background: var(--accent-soft); }
.nav-group.current > summary { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.nav-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 14em; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }
/* 右側の2つは、一覧を右端にそろえて画面の外にはみ出さないようにする */
.nav-systems .nav-menu, .nav-reading .nav-menu { left: auto; right: 0; }
.nav-menu a { display: block; padding: 7px 10px; border-radius: 6px; white-space: nowrap; }
.nav-menu a:hover { background: var(--accent-soft); text-decoration: none; }
.nav-menu a[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.notice { background: var(--accent-soft); color: var(--text); font-size: 0.85rem; }
.notice .inner { max-width: 960px; margin: 0 auto; padding: 6px 16px; }
main { padding-top: 20px; padding-bottom: 40px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; line-height: 1.3; }
h2 { font-size: 1.2rem; margin: 32px 0 10px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
h3 { font-size: 1.05rem; margin: 22px 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.hero { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.hero img { width: auto; max-width: min(220px, 100%); height: auto; image-rendering: auto; }  /* 元の大きさより大きくしない（ぼやけ防止） */
.hero .body { flex: 1 1 280px; min-width: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; padding: 0; list-style: none; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: 0.85rem; background: var(--bg); }
.q-Common { color: var(--q-common); border-color: currentColor; }
.q-Uncommon { color: var(--q-uncommon); border-color: currentColor; }
.q-Rare { color: var(--q-rare); border-color: currentColor; }
.q-Epic { color: var(--q-epic); border-color: currentColor; }
.q-Legendary { color: var(--q-legendary); border-color: currentColor; }
.summary { margin: 6px 0 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: none; }
th { background: var(--bg); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.kv th { width: 40%; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: " ⇅"; color: var(--muted); font-size: 0.8em; }
th.sorted-asc::after { content: " ▲"; color: var(--text); }
th.sorted-desc::after { content: " ▼"; color: var(--text); }
.note, .warn { border-left: 4px solid var(--note-line); background: var(--note-bg); padding: 8px 12px; margin: 12px 0; border-radius: 4px; font-size: 0.92rem; }
.warn { border-left-color: var(--warn-line); background: var(--warn-bg); }
.tag-est { display: inline-block; font-size: 0.75rem; padding: 0 6px; border-radius: 4px; border: 1px solid var(--note-line); background: var(--note-bg); margin-left: 4px; vertical-align: 1px; white-space: nowrap; }
.tag-derived { display: inline-block; font-size: 0.75rem; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; vertical-align: 1px; white-space: nowrap; }
ul.plain { padding-left: 1.2em; margin: 6px 0; }
/* 一覧表：文字を折り返さず、表の枠の中だけ横にスクロールする */
table.list th, table.list td { white-space: nowrap; }
table.list td:first-child { min-width: 12em; }
img.thumb { height: 28px; width: auto; max-width: 64px; object-fit: contain; vertical-align: middle; margin-right: 8px; }
.enemy-chips { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.enemy-chip { white-space: nowrap; }
.enemy-chip img.thumb { margin-right: 4px; }
.small { font-size: 0.8rem; }
.site-nav a { white-space: nowrap; }
.muted { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card img { width: 100%; max-height: 90px; object-fit: contain; }
/* 図鑑の画像（マップ・ストーリー） */
.codex-photos { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 4px; }
.codex-photos figure { margin: 0; flex: 1 1 260px; max-width: 420px; }
.codex-photos img { width: 100%; height: auto; max-height: 340px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #000; }
.codex-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.codex-gallery figure { margin: 0; text-align: center; }
.codex-gallery img { width: 100%; height: auto; border-radius: 8px; }
.codex-gallery figcaption { font-size: 0.85rem; margin-top: 4px; }
.site-footer { border-top: 1px solid var(--line); background: var(--panel); font-size: 0.85rem; color: var(--muted); }
.site-footer .inner { padding-top: 14px; padding-bottom: 20px; }
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 0 8px; cursor: pointer; font: inherit; font-size: 0.85rem; margin-left: auto; }
@media (max-width: 600px) {
  body { font-size: 15px; }
  h1 { font-size: 1.35rem; }
  table.kv th { width: 50%; }
}
/* 読み物ページ（ゲーム説明・ストーリー）の表：見出しの列を細くし、スマホでは縦に並べる */
table.prose th { width: 28%; }
@media (max-width: 600px) {
  table.prose, table.prose tbody, table.prose tr, table.prose th, table.prose td { display: block; width: auto; }
  table.prose th { border-bottom: none; padding-bottom: 0; }
}
/* ネタバレの折りたたみ：初期状態は閉じていて、ボタンを押すと全文が出る */
details.spoiler { border: 1px dashed var(--line); border-radius: 8px; background: var(--panel); margin: 8px 0 16px; }
details.spoiler > summary { cursor: pointer; padding: 10px 14px; list-style: none; font-weight: 600; color: var(--link); }
details.spoiler > summary::-webkit-details-marker { display: none; }
details.spoiler > summary::before { content: "▶ "; font-size: 0.8em; }
details.spoiler[open] > summary::before { content: "▼ "; }
details.spoiler .spoiler-hide, details.spoiler[open] .spoiler-show { display: none; }
details.spoiler[open] .spoiler-hide { display: inline; }
details.spoiler .spoiler-body { padding: 0 14px 6px; border-top: 1px dashed var(--line); }
button.spoiler-all { background: var(--accent-soft); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; }
/* 画面には出さず、読み上げソフトにだけ伝える文字 */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* キーボード操作中に、選んでいる場所を分かりやすくする */
a:focus-visible, button:focus-visible, input:focus-visible, th.sortable:focus-visible, summary:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 3px; }
/* サイト内検索（ヘッダー） */
.site-search { position: relative; flex: 1 1 220px; max-width: 340px; }
.site-search input, .search-page-form input { width: 100%; font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.search-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); max-height: 70vh; overflow-y: auto; }
.search-results li a { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; color: var(--text); }
.search-results li.active a, .search-results li a:hover { background: var(--accent-soft); text-decoration: none; }
.search-results .search-more a { color: var(--link); font-size: 0.85rem; border-top: 1px solid var(--line); }
.search-results .search-empty { padding: 6px 12px; color: var(--muted); }
.search-kind { color: var(--muted); font-size: 0.8rem; white-space: nowrap; margin-left: 8px; }
.search-page-form { display: flex; gap: 8px; max-width: 520px; margin: 12px 0; }
.search-page-form button, .col-toggle { font: inherit; font-size: 0.9rem; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; cursor: pointer; }
ul.search-page-list { padding-left: 1.2em; }
ul.search-page-list li { margin: 4px 0; }
/* 一覧表：名前の列を左に固定して、横に動かしても名前が見えるようにする */
table.list th:first-child, table.list td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
table.list th:first-child { background: var(--bg); }
.col-toggle-row { display: none; margin: 8px 0; }
@media (max-width: 600px) {
  /* ヘッダー：題名と表示切替を1行目、検索欄を2行目、メニュー（3つのグループ）を3行目 */
  .site-header .inner { gap: 8px 12px; }
  .site-search { order: 3; flex: 1 1 100%; max-width: none; }
  .site-nav { order: 4; width: 100%; flex-wrap: nowrap; gap: 6px; }
  .nav-group { flex: 1 1 0; }
  .nav-group > summary { text-align: center; border: 1px solid var(--line); padding: 6px 8px; }
  .nav-systems .nav-menu { left: 50%; right: auto; transform: translateX(-50%); }
  .theme-toggle { order: 2; align-self: flex-start; }
  .site-title { flex: 1 1 0; min-width: 0; font-size: 1rem; line-height: 1.35; }
  /* トップページのカード：スマホでは2列にして、縦に長くなりすぎないようにする */
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 10px 12px; }
  /* 一覧表：名前の列を細くして折り返し、最初は主な列だけ表示する */
  table.list td:first-child { min-width: 8.5em; max-width: 11em; white-space: normal; }
  table.list img.thumb { height: 22px; max-width: 36px; margin-right: 6px; }
  table.list .opt { display: none; }
  .table-wrap.show-all table.list .opt { display: table-cell; }
  .col-toggle-row { display: block; }
}
/* クラスの一覧：基本クラスの下に専門クラスを並べる */
.class-tree { display: grid; gap: 14px; }
.class-branch { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel); }
.class-subs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 8px; padding-left: 18px; border-left: 3px solid var(--line); }
.class-card { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 6px; border-radius: 8px; }
.class-card:hover { background: var(--accent-soft); text-decoration: none; }
.class-card img { width: 56px; height: auto; flex: none; }
.class-card.base img { width: 72px; }
.class-card span { display: flex; flex-direction: column; }
/* 一覧表の中の説明文は折り返す */
table.list td.wrap { white-space: normal; min-width: 16em; }
h2 img.thumb { vertical-align: -4px; }
/* スマホ：クラス・スキルの表はカード状に並べる（名前と数値を上に、説明を下に） */
@media (max-width: 600px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 8px 10px; }
  table.stack tr:last-child { border-bottom: none; }
  table.stack td, table.stack td:first-child { display: inline-block; border: none; padding: 2px 10px 2px 0; position: static; box-shadow: none; background: none; min-width: 0; max-width: none; white-space: nowrap; text-align: left; }
  table.stack td:first-child { display: block; font-weight: 600; }
  table.stack td[data-label]::before { content: attr(data-label) "："; color: var(--muted); font-size: 0.85em; }
  table.stack td.wrap { display: block; white-space: normal; min-width: 0; }
  table.stack td.empty { display: none; }
}
