* { box-sizing: border-box; margin: 0; padding: 0; touch-action: manipulation; }
html { font-size: calc(16px * var(--font-scale, 1)); }

/* カード画像などの長押し保存（iOSのコールアウト）・ドラッグ保存を抑止する。
   ※スクリーンショットや画像URL直アクセスは防げない「カジュアル保存」の抑止。 */
img {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Lucide アイコン共通スタイル (.svg-iconで衝突回避) */
.svg-icon {
  display: inline-block;
  width: 1em; height: 1em;
  vertical-align: -0.15em;
  flex-shrink: 0;
}
.svg-icon--gold   { color: var(--amber); }
.svg-icon--ruby   { color: var(--ruby); }
.svg-icon--danger { color: #e74c3c; }
.svg-icon-lg { width: 1.4em; height: 1.4em; }
.svg-icon-xl { width: 2em; height: 2em; vertical-align: middle; }
/* カードテキスト内のステータス記号({E}{I}{L}{S}{W})。縦長グリフを文字高に合わせ横幅は自動。 */
.svg-icon.stat-glyph { width: auto; height: 1em; vertical-align: -0.12em; margin: 0 0.05em; }
:root {
  --bg: #f5f5f7; --surface: #ffffff; --surface2: #ececef; --border: #d8d8dc;
  --text: #1d1d1f; --text2: #6e6e73; --accent: #7c6dfa;
  --amber: #f5a623; --amethyst: #9b59b6; --emerald: #27ae60;
  --ruby: #e74c3c; --sapphire: #2980b9; --steel: #95a5a6;
}
html.dark, body.dark {
  --bg: #0f0f1a; --surface: #1a1a2e; --surface2: #16213e; --border: #2a2a4a;
  --text: #eee; --text2: #aaa;
}
body { background: var(--bg); color: var(--text); font-family: 'Zen Maru Gothic', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif; min-height: 100vh; overflow-x: hidden; overflow-x: clip; overscroll-behavior-x: none; }
#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: var(--surface); border-top: 1px solid var(--border); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { flex: 1; min-width: 0; padding: 10px 2px 14px; background: none; border: none; color: var(--text2); font-size: 0.6rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; white-space: nowrap; overflow: hidden; position: relative; z-index: 1; transition: color 0.3s; }
.nav-btn .icon { font-size: 1.2rem; }
.nav-btn.active { color: var(--accent); }
.page { display: none; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.page.active { display: block; }
/* touch-action: pan-y — カードタブのスワイプはJSで横移動を制御する。これが無いと
   高速な横フリック時にブラウザがネイティブ横スクロール/ラバーバンドを同時に行い、
   ページ全体が横へずれて左右に隙間が出る（passive リスナーでは preventDefault 不可）。
   縦スクロールは許可。モーダルのカルーセル(.modal-carousel-wrap)と同じ対策。 */
#cardGridWrap { overflow: hidden; position: relative; touch-action: pan-y; }
.page-header { background: var(--surface); padding: calc(8px + env(safe-area-inset-top,0px)) 16px 8px; position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.page-header-logo { height: 44px; width: auto; flex-shrink: 0; }
.page-header h1 { flex: 1; text-align: center; font-size: 1rem; }
/* Zen Maru Gothic の数字は下ヒゲ(descender)が無くインクが行ボックスの上半分に寄るため、
   align-items:center だけでは数字がやや上に見える。padding-top をわずかに足して数字を
   少しだけ下げ、光学的に上下中央へ寄せる。背景は border-box の padding 部も塗るため
   pill の見かけ高さ(20px)は変わらない。値は実機(iOS)基準の控えめな補正。
   min-width は常に4桁分(4ch)＋左右padding(7px×2=14px)を確保し、桁数が変わっても
   背景の丸の大きさを4桁時のまま一定に保つ(5桁以上=1万超のときだけ伸びる)。 */
.badge { background: var(--accent); color: #fff; font-size: 0.65rem; padding: 0.5px 7px 0; min-width: calc(4ch + 14px); flex-shrink: 0; height: 20px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.chip { flex-shrink: 0; padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font-size: 0.72rem; cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.amber { border-color: var(--amber); } .chip.amber.active { background: var(--amber); border-color: var(--amber); color: #000; }
.chip.amethyst { border-color: var(--amethyst); } .chip.amethyst.active { background: var(--amethyst); border-color: var(--amethyst); }
.chip.emerald { border-color: var(--emerald); } .chip.emerald.active { background: var(--emerald); border-color: var(--emerald); }
.chip.ruby { border-color: var(--ruby); } .chip.ruby.active { background: var(--ruby); border-color: var(--ruby); }
.chip.sapphire { border-color: var(--sapphire); } .chip.sapphire.active { background: var(--sapphire); border-color: var(--sapphire); }
.chip.steel { border-color: var(--steel); } .chip.steel.active { background: var(--steel); border-color: var(--steel); }
.search-bar { padding: calc(8px + env(safe-area-inset-top,0px)) 12px 8px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 50; }
.menu-btn { flex-shrink: 0; width: 36px; height: 36px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
/* 閉時の画面外配置は left:-280px ではなく transform で行う。負の left/margin は
   iOS Safari で横スクロール領域を作り（fixed 要素は body の overflow-x:clip でクリップ
   されない）、カードタブのスワイプ時に左方向へラバーバンドして左側に隙間が出る原因に
   なる。transform による画面外移動はスクロール領域を作らない。visibility は閉アニメ後に
   hidden にしてレンダリングからも外す（.modal-details-sheet と同じ手法）。 */
#menuDrawer { position: fixed; top: 0; left: 0; width: 280px; height: 100%; background: var(--surface); z-index: 600; transform: translateX(-100%); visibility: hidden; transition: transform 0.25s ease, visibility 0s linear 0.25s; box-shadow: 2px 0 16px rgba(0,0,0,0.4); display: flex; flex-direction: column; }
#menuDrawer.open { transform: translateX(0); visibility: visible; transition: transform 0.25s ease; }
#menuOverlay { display: none; position: fixed; inset: 0; z-index: 590; background: rgba(0,0,0,0.5); }
#menuOverlay.open { display: block; }
.menu-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top,0px)) 16px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.menu-drawer-header span { font-weight: bold; font-size: 0.95rem; }
.menu-close-btn { background: none; border: none; color: var(--text2); font-size: 1.3rem; cursor: pointer; padding: 4px 8px; }
.menu-drawer-body { flex: 1; overflow-y: auto; padding: 12px 0; }
.menu-item { display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 14px 20px; color: var(--text); font-size: 0.92rem; cursor: pointer; border-bottom: 1px solid var(--border); background: none; border-left: none; border-right: none; border-top: none; width: 100%; text-align: left; }
.menu-item:active { background: var(--surface2); }
.menu-item-arrow { color: var(--text2); font-size: 0.8rem; margin-left: auto; }
.menu-item-danger { color: #e74c3c; }
.menu-login-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: calc(100% - 32px); margin: 4px 16px 0; padding: 13px 16px; background: var(--accent); color: #fff; border: none; border-radius: 12px; font-size: 0.92rem; font-weight: 700; cursor: pointer; }
.menu-login-btn:active { opacity: 0.85; }
#menuCloudLoginLabel { white-space: nowrap; overflow: hidden; }
.menu-login-btn.signed-in { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.menu-login-desc { text-align: center; font-size: 0.72rem; color: var(--text2); margin: 6px 16px 0; }
.menu-gap { height: 14px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.subpage-overlay { display: none; position: fixed; inset: 0; z-index: 700; background: var(--bg); flex-direction: column; }
.subpage-overlay.open { display: flex; }
.subpage-header { display: flex; align-items: center; gap: 12px; padding: calc(14px + env(safe-area-inset-top,0px)) 16px 14px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.subpage-back { background: none; border: none; color: var(--text2); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
.subpage-title { font-weight: bold; font-size: 0.95rem; }
.subpage-body { flex: 1; overflow-y: auto; padding: 20px 20px 40px; }
.settings-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; }
.settings-label { font-size: 0.78rem; color: var(--text2); margin-bottom: 12px; font-weight: bold; letter-spacing: 0.04em; }
.settings-pills { display: flex; gap: 0; flex-wrap: nowrap; position: relative; background: var(--surface2); border-radius: 22px; padding: 4px; }
.settings-pill { flex: 1; padding: 8px 16px; background: none; border: none; color: var(--text2); font-size: 0.85rem; cursor: pointer; position: relative; z-index: 1; transition: color 0.3s; text-align: center; }
.settings-pill.active { color: var(--accent); font-weight: 700; }
.disclaimer-section { margin-bottom: 24px; }
.disclaimer-section h3 { font-size: 0.85rem; color: var(--accent); margin: 0 0 8px; }
.disclaimer-section p { font-size: 0.82rem; color: var(--text2); line-height: 1.7; margin: 0; }
/* top は検索バー(.search-bar)の実高に一致させる: 固定分(パディング8+8+下線1 + 入力欄パディング7+7+ボーダー1+1 = 33px) + 文字行(1rem, --font-scale に連動)。
   固定px(旧: 61px)だと検索バー実高(約49px)とズレてスクロール時に隙間ができていた。 */
.view-tab-bar { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: calc(33px + 1rem + env(safe-area-inset-top,0px)); z-index: 49; padding: 4px; }
.view-tab { flex: 1; padding: 8px 4px; background: none; border: none; color: var(--text2); font-size: 0.72rem; cursor: pointer; position: relative; z-index: 1; transition: color 0.3s; }
.view-tab.active { color: var(--accent); font-weight: bold; }
.filter-bar-wrap { position: relative; background: var(--surface); border-bottom: 1px solid var(--border); }
.filter-chip-bar { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filter-chip-bar::-webkit-scrollbar { display: none; }
.filter-chip { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font-size: 0.78rem; cursor: pointer; white-space: nowrap; }
.filter-chip.has-selection { background: rgba(124,109,250,0.10); border-color: var(--accent); color: var(--accent); }
html.dark .filter-chip.has-selection, body.dark .filter-chip.has-selection { background: rgba(124,109,250,0.22); }
.filter-chip.active { border-color: var(--accent); }
.fc-chevron { font-size: 0.7rem; opacity: 0.7; }
.filter-popup { position: absolute; top: 100%; left: 8px; right: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,0.22); max-height: 60vh; overflow-y: auto; z-index: 60; padding: 6px 0; }
.filter-popup[hidden] { display: none; }
.filter-popup-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; width: 100%; background: none; border: none; color: var(--text); font-size: 0.85rem; cursor: pointer; text-align: left; }
.filter-popup-row .fp-icon { width: 24px; height: 24px; flex-shrink: 0; opacity: 0.35; display: flex; align-items: center; justify-content: center; transition: opacity 0.15s; }
.filter-popup-row .fp-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.filter-popup-row .fp-label { flex: 1; }
.filter-popup-row .fp-check { color: var(--accent); opacity: 0; display: inline-flex; align-items: center; }
.filter-popup-row.selected { background: rgba(124,109,250,0.12); color: var(--accent); }
.filter-popup-row.selected .fp-icon { opacity: 1; }
.filter-popup-row.selected .fp-check { opacity: 1; }
/* min-width:0 必須: flex 子の input は既定 min-width:auto(=min-content) で縮みきれず、
   iOS Safari ではテキスト入力が特に縮まないため、右隣の件数バッジと合わせて検索バーが
   数px はみ出す。するとページが横スクロール可能になり、カードタブをスワイプした際に
   左方向へラバーバンドして左側に隙間が出る。min-width:0 で確実に縮め、はみ出しを防ぐ。 */
.search-bar input { width: 100%; min-width: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; color: var(--text); font-size: 0.85rem; }
.search-bar input::placeholder { color: var(--text2); }
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
.card-item { background: var(--surface); border-radius: 8px; overflow: hidden; cursor: pointer; position: relative; border: 2px solid transparent; }
.card-item.owned { border-color: var(--accent); }
.card-item img { width: 100%; aspect-ratio: 429/600; object-fit: cover; display: block; background: var(--surface2); }
.card-item img:not(.img-loaded) { background: linear-gradient(90deg, var(--surface2) 25%, var(--surface) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.card-item img.img-loaded { animation: imgFadeIn 0.2s ease forwards; }
.card-item .card-info { padding: 4px 5px; }
.card-item .card-name { font-size: 0.62rem; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 2px; }
/* 名前テキストは独立spanにし、はみ出しを span 単体で検知できるようにする（_fitCardName 用） */
.card-item .card-name .card-name-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-item .card-sub { font-size: 0.55rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 1px; }
.card-item .own-badge {
  position: absolute;
  top: 0;
  right: 4px;
  width: 22px;
  height: 28px;
  background: transparent;
  border: none;
  padding: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  z-index: 2;
}
.own-badge svg { width: 100%; height: 100%; display: block; }
.own-badge svg path { fill: #1a2347; stroke: #fff; stroke-width: 4; }
.own-badge.foil svg path { stroke: #c9a558; }
.own-badge svg text {
  fill: #fff;
  font-family: 'Zen Maru Gothic', -apple-system, sans-serif;
  font-weight: 700;
  font-size: 32px;
  text-anchor: middle;
}
.img-placeholder { width: 100%; aspect-ratio: 429/600; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 0.55rem; color: #555; text-align: center; padding: 6px; }
.ink-dot { display: inline-flex; align-items: center; width: 16px; height: 16px; margin-right: 0; vertical-align: middle; flex-shrink: 0; }
.ink-dot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.rarity-icon { display: inline-block; width: 10px; height: 10px; margin-right: 1px; vertical-align: middle; flex-shrink: 0; }
.rarity-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.92); align-items: center; justify-content: center; }
/* カード拡大モーダルはデッキ閲覧/編集ページ(z-index:9998/9999)より前面に出す */
#cardModal { z-index: 10001; }
/* カード拡大/デッキカードモーダルは中身の高さを dvh(可視ビューポート)で決めている。
   オーバーレイ枠を position:fixed; inset:0 のままにすると、枠はツールバー格納時の
   大きいレイアウトビューポート基準になり、dvh で伸縮する中身・タッチ座標とズレる。
   その結果「ボタンの少し上を押さないと反応しない」「下端ボタンが押せず固まる」が起きる。
   枠の高さも 100dvh に揃え、見た目・レイアウト・当たり判定を同一の座標系に統一する。
   さらにセーフエリア分を内側に確保して、下端ボタンがツールバー/ホームインジケータの
   下に潜らないようにする。 */
#cardModal, #deckCardModal {
  bottom: auto;
  height: 100vh;   /* dvh 非対応端末向けフォールバック */
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.modal-overlay.open { display: flex; touch-action: none; }
body.modal-open { overflow: hidden; position: fixed; width: 100%; left: 0; right: 0; }
body.modal-open #dbScrollWrap, body.modal-open #dpScrollWrap { overflow: hidden; }
.modal-overlay.open .modal-carousel-wrap { touch-action: pan-y; }
.modal-overlay.open .adv-modal-body { touch-action: pan-y; }
.modal-overlay.open .import-modal-box { touch-action: pan-y; }
.modal-overlay.open .lore-modal-box { touch-action: pan-y; }
.modal { background: transparent; width: 100%; max-width: 420px; padding: 0; display: flex; flex-direction: column; align-items: center; }
/* 右ドック未選択時のプレースホルダ（既定は非表示。PC幅のドックでのみ表示） */
.card-dock-empty { display: none; }
.modal-carousel-wrap { width: 100%; overflow: hidden; margin-bottom: 12px; touch-action: pan-y; position: relative; z-index: 0; }
.modal-carousel { display: flex; width: 300%; transform: translateX(-33.3333%); will-change: transform; }
/* 画像ロード前後で高さが変わるとボタン位置がずれる(タップずれ)ため、スライド枠に
   高さを予約してレイアウトを固定する。画像は枠内で中央配置。 */
.modal-slide { width: 33.3333%; padding: 0 6px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; height: 56vh; height: 56dvh; }
/* opacity に CSS transition は付けない。スワイプ時の画像差し替えで opacity を
   0→1 に戻す際にフェードインが走り、その間背景の黒が透ける(黒フラッシュ)ため。
   奥行きフェードのスワイプ演出は animate() がインラインで transition を明示する。 */
.modal-slide-img { display: block; width: auto; max-width: 100%; height: auto; max-height: 100%; border-radius: 12px; }
/* ロケーションカードは縦長ファイルに横向きの絵柄が入っており文字が横倒しになる。
   右に90度回転して正立させる。占有領域（レイアウト上の高さ）は通常カードのままで、
   transform は描画のみに効くためボタン位置は変わらない。画面幅に収める縮小率
   (--loc-scale) は JS で算出して付与する。 */
.modal-slide-img.is-location { transform-origin: center center; transform: rotate(90deg) scale(var(--loc-scale, 1)); }
.modal-card-meta { font-size: 0.75rem; color: var(--text2); margin-top: 6px; }
/* デッキ編集モーダル等で使う従来カウンタ */
.count-row { display: flex; align-items: center; justify-content: space-between; margin-top: 0; padding: 14px 20px; }
.count-row.count-row-full { padding-top: 46px; padding-bottom: 46px; }
.count-row label { font-size: 0.9rem; }
.count-btns { display: flex; align-items: center; gap: 12px; }
.count-val { font-size: 1.3rem; font-weight: bold; min-width: 24px; text-align: center; }
/* カード詳細モーダルの所持数: アクションバー型カウンタ */
.count-bar { width: 100%; display: flex; gap: 8px; margin-bottom: 8px; }
.count-ctr { flex: 1; display: flex; align-items: center; background: var(--surface); border-radius: 12px; overflow: hidden; height: 56px; }
.count-ctr-btn { width: 50px; height: 100%; font-size: 1.4rem; font-weight: bold; display: flex; align-items: center; justify-content: center; background: transparent; border: none; cursor: pointer; transition: background 0.15s; }
.count-ctr-btn:active { background: rgba(255,255,255,0.06); }
.count-ctr-btn.minus { color: var(--ruby); }
.count-ctr-btn.plus  { color: var(--accent); }
.count-ctr-btn:disabled { color: var(--border); cursor: not-allowed; }
.count-ctr-mid { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.count-ctr-mid .count-val { font-size: 1.25rem; font-weight: bold; min-width: 0; }
.count-ctr-mid .count-ctr-k { font-size: 0.66rem; color: var(--text2); display: inline-flex; align-items: center; gap: 5px; margin-top: 1px; white-space: nowrap; }
.count-ctr-mid .count-ctr-k .count-label { display: inline-flex; align-items: center; gap: 3px; }
.count-ctr-mid .count-ctr-k svg { width: 12px; height: 12px; color: var(--amber); }
/* 参考価格（ノーマル/フォイル ラベルの右に控えめに添える）。価格が無いカードは空で非表示。 */
.count-ctr-mid .count-ctr-k .count-price { font-size: 0.66rem; font-weight: 700; color: var(--gold, #e8c270); font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; text-decoration: none; display: none; align-items: center; gap: 1px; }
.count-ctr-mid .count-ctr-k .count-price.has-price { display: inline-flex; }
.count-ctr-mid .count-ctr-k .count-price .count-price-ext { font-size: 0.85em; color: var(--accent); opacity: 0.8; }
/* カード詳細モーダルの操作アイコンバー（ウィッシュ/お気に入り/閉じる） */
/* 操作行（カウンタ/アクション/詳細トリガー）はカルーセルより前面に置き、
   カード画像エリアの透明部分にタップが吸われてボタンが反応しない問題を防ぐ。 */
.modal .count-bar, .modal .modal-action-icons, .modal .modal-details-trigger, .modal .price-source { position: relative; z-index: 1; }
.modal-action-icons { width: 100%; display: flex; gap: 8px; }
.modal-action-icons .action-icon { flex: 1; padding: 11px 4px; border-radius: 11px; background: var(--surface); border: none; cursor: pointer; color: var(--text2); display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.72rem; transition: transform 0.1s, background 0.15s; }
.modal-action-icons .action-icon:active { transform: scale(0.95); }
.modal-action-icons .action-icon svg { width: 21px; height: 21px; }
.modal-action-icons .action-icon.selected-ruby { color: var(--ruby); background: rgba(231,76,60,0.15); }
.modal-action-icons .action-icon.selected-ruby svg { fill: currentColor; }
.modal-action-icons .action-icon.selected-amber { color: var(--amber); background: rgba(245,166,35,0.15); }
.modal-action-icons .action-icon.selected-amber svg { fill: currentColor; }
/* 詳細トリガー: ピル型（詳細A）。詳細が無いカードは is-empty で領域だけ残す */
.modal-details-trigger { width: 100%; margin-top: 12px; padding: 11px 12px; border: none; cursor: pointer; border-radius: 11px; background: rgba(124,109,250,0.12); color: var(--accent); font-size: 0.85rem; font-weight: 600; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; touch-action: pan-y; }
.modal-details-trigger.is-empty { visibility: hidden; pointer-events: none; }
.modal-details-trigger .modal-details-arrow { display: inline-block; font-size: 1.05rem; line-height: 1; animation: detailsNudge 1.6s ease-in-out infinite; }
.modal-details-trigger .modal-details-label { letter-spacing: 0.04em; }
@keyframes detailsNudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
/* 参考価格の出典ピル（操作ボタンの下＝下部に配置）。1行・控えめ。価格が無いカードは非表示。 */
.price-source { width: 100%; margin-top: 8px; padding: 4px 6px; display: none; align-items: center; justify-content: center; gap: 4px; opacity: 0.55; }
.price-source.has-price { display: flex; }
.price-source .price-source-i { flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--text2); color: var(--text2); font-size: 8px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.price-source .price-source-text { font-size: 0.56rem; letter-spacing: -0.01em; color: var(--text2); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price-source .price-source-text .price-source-shop { font-weight: 600; }
.modal-details-sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 85vh; max-height: 85dvh; background: var(--bg); border-top-left-radius: 18px; border-top-right-radius: 18px; transform: translateY(100%); transition: transform 0.3s ease; z-index: 210; display: flex; flex-direction: column; box-shadow: 0 -8px 24px rgba(0,0,0,0.5); touch-action: none; visibility: hidden; }
.modal-details-sheet.open { transform: translateY(0); visibility: visible; }
.modal-details-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 10px auto 4px; flex-shrink: 0; }
.modal-details-header { padding: 6px 20px 8px; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.modal-details-header h2 { font-size: 1rem; font-weight: bold; color: var(--text); margin: 0; }
.modal-details-close { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: var(--surface); border: none; color: var(--text); width: 32px; height: 32px; border-radius: 50%; font-size: 0.95rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-details-body { flex: 1; overflow-y: auto; padding: 8px 18px 24px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.modal-details-notice { padding: 14px 0; border-bottom: 1px solid var(--border); }
.modal-details-notice-title { color: #e74c3c; font-weight: bold; font-size: 0.95rem; text-align: center; margin-bottom: 8px; }
.modal-details-notice-intro { font-size: 0.85rem; color: var(--text); line-height: 1.6; margin-bottom: 10px; text-align: center; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.modal-details-diff-row { font-size: 0.88rem; line-height: 1.7; color: var(--text); margin: 6px 0; }
.modal-details-diff-label { font-weight: bold; }
.modal-details-diff-label.diff-before { color: var(--text2); }
.modal-details-diff-label.diff-after  { color: #e74c3c; }
.modal-details-diff-text { white-space: pre-wrap; }
.modal-details-diff-arrow { text-align: center; color: var(--text2); margin: 6px 0; font-size: 1rem; }
.modal-details-red { color: #e74c3c; font-weight: bold; }
.modal-details-notice-text { font-size: 0.88rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; }
.modal-details-notice-date { font-size: 0.85rem; color: var(--text2); margin-top: 8px; }
.modal-details-notice-url { font-size: 0.85rem; margin-top: 6px; word-break: break-all; color: var(--text2); }
.modal-details-notice-url a { color: var(--accent); text-decoration: underline; }
.modal-details-faq { padding: 14px 0; border-bottom: 1px solid var(--border); }
.modal-details-faq:last-child { border-bottom: none; }
.modal-details-row { display: flex; align-items: flex-start; gap: 10px; }
.modal-details-row + .modal-details-row { margin-top: 10px; }
.modal-details-badge { flex-shrink: 0; width: 22px; height: 22px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.8rem; color: #fff; line-height: 1; margin-top: 1px; }
.modal-details-badge-q { background: #2c3e80; }
.modal-details-badge-a { background: #c0392b; }
.modal-details-q { flex: 1; min-width: 0; font-weight: bold; font-size: 0.9rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.modal-details-a { flex: 1; min-width: 0; font-size: 0.88rem; line-height: 1.65; color: var(--text2); white-space: pre-wrap; }
.modal-details-meta { font-size: 0.7rem; color: var(--text2); margin-top: 8px; opacity: 0.65; }
.progress-section { padding: 12px; }
.progress-card { background: var(--surface); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.progress-card h3 { font-size: 0.85rem; margin-bottom: 6px; }
.progress-bar-wrap { background: var(--border); border-radius: 4px; height: 6px; }
.progress-bar { background: var(--accent); height: 6px; border-radius: 4px; }
.progress-nums { font-size: 0.7rem; color: var(--text2); margin-top: 4px; text-align: right; }
.deck-list { padding: 10px; padding-top: calc(10px + env(safe-area-inset-top,0px)); }
.deck-card { background: var(--surface); border-radius: 10px; padding: 14px; margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.sleeve-option { width: 56px; height: 77px; border-radius: 5px; object-fit: cover; object-position: center top; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s, opacity 0.15s; opacity: 0.45; }
.sleeve-option.selected { border-color: var(--accent); opacity: 1; }
.sleeve-option-none { width: 56px; height: 77px; border-radius: 5px; background: var(--surface); border: 2px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; opacity: 0.45; transition: opacity 0.15s; }
.sleeve-option-none.selected { border-color: var(--accent); opacity: 1; }
/* 共通スリーブ選択モーダル */
.sleeve-modal-box { background: var(--surface); border-radius: 16px; padding: 16px; width: min(92vw, 420px); max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.sleeve-modal-head { font-size: 0.95rem; font-weight: bold; color: var(--text); margin-bottom: 12px; text-align: center; }
.sleeve-modal-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; overflow-y: auto; padding: 2px; }
.sleeve-modal-btns { display: flex; gap: 8px; margin-top: 14px; }
.sleeve-modal-btns button { flex: 1; padding: 12px; border-radius: 10px; border: none; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.deck-sleeve { width: 48px; height: 66px; border-radius: 5px; object-fit: cover; object-position: center top; flex-shrink: 0; background: var(--surface2); }
.deck-sleeve-placeholder { width: 48px; height: 66px; border-radius: 5px; background: var(--surface2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.deck-card h3 { font-size: 0.9rem; }
.deck-card .deck-meta { font-size: 0.72rem; color: var(--text2); margin-top: 3px; }
.deck-card .deck-count { font-size: 1.1rem; font-weight: bold; color: var(--accent); }
.deck-menu-btn { background: none; border: none; color: var(--text2); font-size: 1.4rem; padding: 6px 12px; cursor: pointer; line-height: 1; flex-shrink: 0; border-radius: 6px; }
.deck-menu-btn:hover, .deck-menu-btn:active { background: var(--surface2); color: var(--text); }
.deck-menu { position: absolute; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.5); padding: 4px; z-index: 1000; min-width: 120px; }
.deck-menu-item { display: block; width: 100%; padding: 10px 16px; background: none; border: none; text-align: left; cursor: pointer; border-radius: 4px; color: var(--text); font-size: 0.9rem; }
.deck-menu-item:hover, .deck-menu-item:active { background: var(--surface); }
.deck-menu-item-danger { color: #e74c3c; }
#deckEditor { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100vw; height: 100vh; z-index: 9999; background: var(--bg); }
#deckEditor.open { display: flex; flex-direction: column; }
body.deck-editing .page, body.deck-editing nav { display: none !important; }
/* デッキ閲覧ページ（レシピ集と同じ閲覧レイアウト） */
#deckViewPage { display: none; position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 9998; background: var(--bg); flex-direction: column; }
#deckViewPage.open { display: flex; }
body.deck-viewing .page, body.deck-viewing nav { display: none !important; }
.dv-header { display:flex; align-items:center; gap:10px; padding:calc(env(safe-area-inset-top,0px) + 12px) 14px 10px; flex-shrink:0; }
.dv-header .dv-back, .db-header .dv-back { background:none; border:none; color:var(--text2); font-size:1.4rem; line-height:1; cursor:pointer; padding:4px 8px; flex-shrink:0; }
.dv-header .dv-back-label { background:none; border:none; color:var(--text2); font-size:0.82rem; line-height:1; cursor:pointer; padding:4px 2px; margin-left:-8px; flex-shrink:0; }
.dv-header .dv-header-spacer { width:36px; flex-shrink:0; }
.dv-header .dv-title { font-size:0.95rem; font-weight:bold; color:var(--text); flex:1; min-width:0; line-height:1.25; text-align:center; }
.dv-actions { display:flex; gap:6px; padding:0 10px 8px; flex-shrink:0; }
/* 4ボタンを同サイズ(等幅)・縦長に。アイコン上＋テキスト下で揃える */
.dv-actions .btn-sm { flex:1 1 0; width:0; min-width:0; padding:10px 2px; font-size:0.62rem; line-height:1.25; background:var(--surface2); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; text-align:center; }
.dv-actions .btn-sm svg { width:16px; height:16px; }
.dv-actions .btn-edit-primary { background:rgba(124,109,250,0.16); color:var(--accent); }
.dv-actions .btn-sm svg { width:14px; height:14px; }
/* ロゴ帯（illuminator風バナー）。ロゴ左・デッキ名中央 */
.dv-logo-band { position:relative; display:flex; align-items:center; justify-content:center; padding:5px 14px; min-height:32px; margin:4px 0 0; background:linear-gradient(90deg, rgba(124,109,250,0.22), rgba(231,76,60,0.18)); }
.dv-logo-band .dv-logo-img { position:absolute; left:14px; top:50%; transform:translateY(-50%); height:22px; width:auto; max-width:40%; object-fit:contain; display:block; }
.dv-logo-band .dv-band-title { font-size:0.95rem; font-weight:bold; color:var(--text); text-align:center; max-width:55%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* セクション境界線 */
#deckViewPage .dstats-summary { border-top:1px solid var(--border); border-bottom:1px solid var(--border); }
.dv-body { border-top:0; }
.dv-body { flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; }
.dv-grid { display:grid; grid-template-columns:repeat(6,1fr); gap:5px; padding:8px 10px calc(env(safe-area-inset-bottom,0px) + 32px); align-content:start; }
.dv-tile { position:relative; aspect-ratio:5/7; border-radius:6px; overflow:hidden; background:transparent; cursor:pointer; }
/* 画像はロード完了までは透明にしてフェードイン。濃色タイルが先に出る「黒フラッシュ」を防ぐ */
.dv-tile img { width:100%; height:100%; object-fit:cover; display:block; opacity:0; transition:opacity 0.18s ease; }
.dv-tile img.dv-loaded { opacity:1; }
/* 数量バッジ: カード最下部中央に小さな丸で枚数のみ */
.dv-tile-qty { position:absolute; left:50%; bottom:3px; transform:translateX(-50%); width:14px; height:14px; border-radius:50%; background:var(--accent); color:#fff; font-size:.52rem; font-weight:bold; display:flex; align-items:center; justify-content:center; box-shadow:0 1px 2px rgba(0,0,0,.5); }
/* ── デッキ価格ページ ── */
#deckPricePage { display:none; position:fixed; inset:0; width:100vw; height:100vh; z-index:9998; background:var(--bg); flex-direction:column; }
#deckPricePage.open { display:flex; }
.dp-summary { display:flex; gap:8px; padding:4px 12px 8px; flex-shrink:0; }
.dp-sum-cell { flex:1; background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:9px 10px; display:flex; flex-direction:column; gap:3px; min-width:0; }
.dp-sum-cell .k { font-size:0.62rem; color:var(--text2); white-space:nowrap; }
.dp-sum-cell .v { font-size:1.15rem; font-weight:800; color:var(--accent); font-variant-numeric:tabular-nums; }
.dp-sum-cell.shortage .v { color:var(--ruby); }
.dp-note { font-size:0.6rem; color:var(--text2); padding:0 12px 6px; flex-shrink:0; line-height:1.4; }
.dp-table-wrap { flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:0 8px calc(env(safe-area-inset-bottom,0px) + 72px); }
.dp-table .dp-price { color:var(--gold, #e8c270); text-decoration:none; white-space:nowrap; font-weight:600; }
.dp-table .dp-price .dp-ext { font-size:0.85em; color:var(--accent); opacity:0.8; margin-left:1px; }
.dp-table { width:100%; border-collapse:collapse; font-size:0.66rem; }
.dp-table thead th { position:sticky; top:0; background:var(--bg); color:var(--text2); font-weight:600; font-size:0.58rem; text-align:right; padding:6px 4px; border-bottom:1px solid var(--border); white-space:nowrap; }
.dp-table thead th.l { text-align:left; }
.dp-table tbody td { padding:6px 4px; border-bottom:1px solid rgba(255,255,255,0.05); text-align:right; font-variant-numeric:tabular-nums; vertical-align:top; }
.dp-table tbody td.l { text-align:left; }
.dp-table .c-id { color:var(--text2); white-space:nowrap; font-size:0.6rem; }
.dp-table .c-name { color:var(--text); font-weight:600; line-height:1.25; }
.dp-table .c-ver { color:var(--text2); font-size:0.58rem; line-height:1.2; }
.dp-table .c-short { color:var(--ruby); font-weight:700; }
.dp-table .c-na { color:var(--text2); }
.dp-table tbody tr.owned-ok td { opacity:0.55; }
.btn-sm { padding: 5px 10px; border-radius: 8px; border: none; cursor: pointer; font-size: 0.75rem; font-weight: bold; background: var(--surface2); color: var(--text); white-space: nowrap; }
.btn-save { background: var(--accent); color: #fff; }
.btn-back { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
#loadingOverlay { display: flex; position: fixed; inset: 0; z-index: 300; background: rgba(15,15,26,0.92); flex-direction: column; align-items: center; justify-content: center; gap: 12px; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s ease, visibility 0s 0.25s; }
#loadingOverlay.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.25s ease, visibility 0s 0s; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes imgFadeIn { from { opacity: 0; } to { opacity: 1; } }
#loadProgress { font-size: 0.85rem; color: var(--text2); }
#cacheInfo { font-size: 0.72rem; color: #555; margin-top: 4px; }
#prefetchBar { display:none; position:fixed; bottom: calc(58px + env(safe-area-inset-bottom)); left:0; right:0; z-index:99; background:var(--surface); border-top:1px solid var(--border); padding:4px 12px; font-size:0.68rem; color:var(--text2); }
#prefetchBarInner { height:3px; background:var(--accent,#7c6dfa); border-radius:2px; margin-top:3px; transition:width 0.3s; width:0%; }
#dialogModal { z-index: 10000; }
.dialog-box { background: var(--surface2); border-radius: 14px; padding: 24px 20px 16px; width: calc(100% - 48px); max-width: 300px; box-shadow: 0 4px 24px rgba(0,0,0,0.5); }
.dialog-msg { margin: 0 0 20px; color: var(--text); font-size: 0.92rem; line-height: 1.55; white-space: pre-wrap; }
.dialog-btns { display: flex; gap: 10px; }
.dialog-btns button { flex: 1; padding: 10px; border-radius: 8px; font-size: 0.9rem; cursor: pointer; border: none; }
.dialog-btn-cancel { background: var(--surface); border: 1px solid var(--border) !important; color: var(--text2); }
.dialog-btn-ok { background: var(--accent); color: #fff; }
/* 詳細検索モーダル */
.adv-modal-box { background: var(--surface); width: 100%; border-radius: 16px 16px 0 0; max-height: 85vh; display: flex; flex-direction: column; }
.adv-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.adv-modal-header span { font-weight: bold; font-size: 0.95rem; }
.adv-modal-header button { background: none; border: none; color: var(--text2); font-size: 1.2rem; cursor: pointer; }
.adv-modal-body { overflow-y: auto; flex: 1; padding-bottom: 8px; }
.adv-modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface); display: flex; gap: 8px; }
.adv-modal-footer button:first-child { padding: 13px 16px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; color: var(--text2); font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
.adv-modal-footer button:last-child { flex: 1; padding: 13px; background: var(--accent); border: none; border-radius: 10px; color: #fff; font-size: 0.95rem; font-weight: bold; cursor: pointer; }
.adv-section { padding: 14px 20px; }
.adv-section + .adv-section { border-top: 1px solid var(--border); }
.adv-label { font-size: 0.72rem; color: var(--text2); margin-bottom: 8px; font-weight: bold; }
.adv-label-val { color: var(--accent); }
.adv-row { display: flex; gap: 8px; flex-wrap: wrap; }
.adv-toggle { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font-size: 0.8rem; cursor: pointer; }
.adv-toggle.active { background: rgba(124,109,250,0.2); border-color: var(--accent); color: var(--accent); }
.adv-chip { padding: 10px 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font-size: 0.78rem; cursor: pointer; white-space: nowrap; overflow: hidden; }
/* 長いラベル（ストーリーボーン等）はセル幅に収まるよう文字を縮めて1行を維持 */
.adv-grid-3 .adv-chip.adv-chip-long, .adv-grid-2 .adv-chip.adv-chip-long { font-size: 0.66rem; letter-spacing: -0.02em; padding-left: 4px; padding-right: 4px; }
.adv-chip.active { background: rgba(124,109,250,0.2); border-color: var(--accent); color: var(--accent); }
.adv-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.adv-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.adv-grid-3 .adv-chip, .adv-grid-2 .adv-chip { width: 100%; text-align: center; }
/* 能力: 関連カードも含めるトグル */
.adv-kw-related { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; cursor: pointer; }
.adv-kw-related-txt { font-size: 0.82rem; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.adv-kw-related-sub { font-size: 0.68rem; color: var(--text2); }
.adv-switch { position: relative; flex-shrink: 0; width: 44px; height: 26px; }
.adv-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.adv-switch-track { position: absolute; inset: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: 13px; transition: background 0.2s, border-color 0.2s; }
.adv-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: var(--text2); border-radius: 50%; transition: transform 0.2s, background 0.2s; }
.adv-switch input:checked + .adv-switch-track { background: rgba(124,109,250,0.3); border-color: var(--accent); }
.adv-switch input:checked + .adv-switch-track::after { transform: translateX(18px); background: var(--accent); }
.adv-icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); justify-items: center; row-gap: 8px; }
.adv-collapse-hdr { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: inherit; text-align: left; margin-bottom: 0; }
.adv-collapse-ttl { display: inline-flex; align-items: center; gap: 8px; }
.adv-sec-count { display: none; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 0.66rem; font-weight: bold; line-height: 1; }
.adv-sec-count.show { display: inline-flex; }
.adv-collapse-chevron { font-size: 0.7rem; margin-left: 8px; transition: transform 0.2s; display: inline-block; flex-shrink: 0; }
/* 適用中の条件チップバー（案A） */
.adv-applied-wrap { padding: 12px 20px 0; display: flex; align-items: center; gap: 8px; }
.adv-applied { flex: 1; min-width: 0; display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; min-height: 32px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.adv-applied::-webkit-scrollbar { display: none; }
.adv-applied .adv-applied-empty { font-size: 0.74rem; color: var(--text2); white-space: nowrap; }
.adv-applied .adv-applied-tag { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 16px; background: rgba(124,109,250,0.18); border: 1px solid var(--accent); color: var(--accent); font-size: 0.74rem; font-weight: bold; cursor: pointer; white-space: nowrap; }
.adv-applied .adv-applied-tag .rm { opacity: 0.7; font-size: 0.7rem; }
.adv-applied .adv-applied-tag:active { transform: scale(0.94); }
.adv-applied-clear { flex-shrink: 0; font-size: 0.74rem; color: var(--text2); text-decoration: underline; cursor: pointer; white-space: nowrap; padding: 6px 2px; background: none; border: none; }
.adv-collapse-hdr.open .adv-collapse-chevron { transform: rotate(180deg); }
.adv-collapse-body { display: none; margin-top: 8px; }
.adv-collapse-body.open { display: block; }
.adv-icon-wrap { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid transparent; transition: border-color 0.15s, background 0.15s, opacity 0.15s; cursor: pointer; opacity: 0.35; }
.adv-icon-wrap.active { border-color: var(--accent); background: rgba(124,109,250,0.2); opacity: 1; }
.adv-icon-dot { width: 32px; height: 32px; }
.adv-icon-dot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.adv-icon-span { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; }
.adv-icon-span img { width: 100%; height: 100%; object-fit: contain; display: block; }
.adv-input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 12px; font-size: 0.85rem; box-sizing: border-box; }
.adv-select { width: 100%; padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 0.85rem; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M0 0l6 8 6-8z' fill='%23aaa'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
.adv-slider-row { display: flex; gap: 8px; align-items: center; }
.adv-slider-num { font-size: 0.75rem; color: var(--text2); text-align: center; }
.adv-slider-num.lo { width: 16px; }
.adv-slider-num.hi { width: 20px; }
.adv-slider-nums { position: relative; height: 20px; margin-top: 2px; }
.adv-slider-val { position: absolute; transform: translateX(-50%); font-size: 0.75rem; color: var(--text2); white-space: nowrap; }
.adv-slider-reset-btn { display: block; width: 100%; background: none; border: none; color: var(--text2); font-size: 0.78rem; cursor: pointer; text-decoration: underline; padding: 6px 0 2px; text-align: center; }
.adv-slider-track { flex: 1; position: relative; height: 44px; display: flex; align-items: center; }
.adv-slider-track-bg { position: absolute; left: 0; right: 0; height: 4px; background: var(--border); border-radius: 2px; }
.adv-slider-fill { position: absolute; height: 4px; background: var(--accent); border-radius: 2px; }
.adv-slider-input { position: absolute; width: 100%; height: 4px; margin: 0; outline: none; appearance: none; -webkit-appearance: none; background: transparent; pointer-events: none; z-index: 2; }
.adv-slider-input::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); cursor: pointer; pointer-events: auto; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.25); }
.adv-slider-input::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); cursor: pointer; pointer-events: auto; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.25); }
/* インポートモーダル */
.import-modal-box { background: var(--surface); border-radius: 14px; padding: 20px; width: 90%; max-width: 360px; max-height: 80vh; overflow-y: auto; }
.import-modal-box textarea { width: 100%; height: 80px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px; font-size: 0.8rem; resize: none; box-sizing: border-box; }
/* ロアカウンター（対面レイアウト） */
#pageLore { padding-bottom: 0; }
#pageLore.active { display: flex; flex-direction: column; height: calc(100vh - 58px); overflow: hidden; }
/* 対戦タブ（対戦開始前はナビバーを表示、AI対戦中のみフルスクリーン） */
#pageBattle { padding-bottom: 0; position: relative; }
#pageBattle.active { display: flex; flex-direction: column; height: calc(100vh - 58px); height: calc(100dvh - 58px); overflow: hidden; }
#pageBattle.battle-active { height: 100vh; overflow: visible; }
#pageBattle.battle-active > .page-header { display: none; }
.page-header-label { font-size: 0.82rem; color: var(--text2); font-weight: bold; flex-shrink: 0; }
.lore-top, .lore-bottom { flex: 1; display: flex; min-height: 0; gap: 1px; background: var(--border); overflow: hidden; }
/* 上側プレイヤー(画面最上部)はステータスバー(時計/ノッチ)に被らないよう安全余白を確保 */
.lore-top { padding-top: env(safe-area-inset-top,0px); }
.lore-middle { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 10px 0; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 1; }
.lore-mid-row { display: flex; align-items: center; justify-content: space-evenly; width: 100%; }
.lore-mid-btn { width: 62px; height: 62px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 1.7rem; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
.lore-dice-result { font-size: 0.82rem; text-align: center; color: var(--text); font-weight: bold; }
/* ロアカウンター モーダル */
.lore-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.72); display: flex; align-items: center; justify-content: center; z-index: 250; touch-action: none; }
.lore-modal-box { background: var(--surface2); border-radius: 20px; padding: 28px 24px 20px; width: 82%; max-width: 320px; text-align: center; border: 1px solid var(--border); max-height: 85vh; overflow-y: auto; }
.lore-modal-icon { font-size: 2rem; margin-bottom: 10px; }
.lore-modal-title { font-size: 0.95rem; font-weight: bold; margin-bottom: 20px; color: var(--text); }
.lore-modal-desc { font-size: 0.72rem; color: var(--text2); margin: -10px 0 16px; line-height: 1.6; }
.lore-modal-btns { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; flex-wrap: wrap; }
.lore-modal-btns:not(.lore-modal-btns-col) > .btn { flex: 1; min-width: 0; }
.lore-modal-btns-col { flex-direction: column; gap: 10px; }
/* AIの戦い方モーダル: 「コントロール」が3等分幅に収まるよう、選択肢だけ文字・余白を詰める */
#b-aistyle-dlg .lore-modal-btns { gap: 6px; }
#b-aistyle-dlg .b-aistyle-opt { font-size: 0.72rem; padding: 11px 4px; }
.lore-player-face { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; background: color-mix(in srgb, var(--player-color, var(--bg)) 50%, var(--bg)); position: relative; overflow: hidden; }
.lore-hit-area { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.lore-hit-left { left: 0; }
.lore-hit-right { left: 50%; }
.lore-face-content { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 8px; pointer-events: none; position: relative; z-index: 2; }
.lore-rotated { transform: rotate(180deg); }
.lore-face-header { display: flex; align-items: center; gap: 6px; }
.lore-face-name { font-size: 0.85rem; font-weight: bold; color: #fff; }
.lore-face-won { font-size: 0.72rem; background: var(--player-color); color: #fff; padding: 2px 7px; border-radius: 10px; }
.lore-dice-badge { font-size: 0.75rem; color: rgba(255,255,255,0.7); }
.lore-dice-badge.lore-first { color: #4ade80; font-weight: bold; }
.lore-dice-badge.lore-tied { color: var(--amber); font-weight: bold; }
.lore-dice-badge.lore-dice-rolling .svg-icon,
#loreDiceBtn.is-rolling .svg-icon { animation: lore-dice-tumble 0.16s ease-in-out infinite; }
@keyframes lore-dice-tumble {
  0%   { transform: rotate(-15deg); }
  50%  { transform: rotate(15deg); }
  100% { transform: rotate(-15deg); }
}
.lore-face-counter { display: flex; align-items: center; gap: 12px; }
.lore-face-btn { width: 54px; height: 54px; border-radius: 50%; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; border: 2px solid; flex-shrink: 0; }
.lore-face-dec { background: transparent; color: #fff; border-color: #fff; }
.lore-face-inc { background: transparent; color: #fff; border-color: #fff; }
.lore-face-val-wrap { text-align: center; min-width: 60px; }
.lore-face-val { font-size: 3.8rem; font-weight: bold; line-height: 1; color: #fff; display: block; }
.lore-face-target { font-size: 0.78rem; color: rgba(255,255,255,0.6); }
.lore-multi .lore-face-btn { width: 44px; height: 44px; font-size: 1.2rem; }
.lore-multi .lore-face-val { font-size: 2.6rem; }
.lore-multi .lore-face-name { font-size: 0.78rem; }

/* ─── Deck Ink Picker (#dip) ─── */
#dip { display:none; flex-direction:column; align-items:center; padding:16px; overflow-y:auto; flex:1; }
#dip.active { display:flex; }
.dip-header { display:flex; align-items:center; gap:10px; width:100%; margin-bottom:16px; }
.dip-title { font-size:0.85rem; color:var(--text2); }
.dip-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; width:100%; max-width:360px; margin-bottom:16px; }
.dip-btn { background:var(--surface2); border:2px solid var(--border); border-radius:12px; padding:12px 6px; cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:6px; transition:border-color 0.15s,background 0.15s; }
.dip-btn.selected { border-color:var(--accent); background:rgba(124,109,250,0.15); }
.dip-icon { width:44px; height:44px; object-fit:contain; display:block; }
.dip-name { font-size:0.72rem; color:var(--text); }
.dip-selection { font-size:0.9rem; font-weight:bold; color:var(--accent); min-height:24px; margin-bottom:16px; letter-spacing:0.05em; }
.dip-choose-btn { padding:12px 40px; background:var(--accent); color:#fff; border:none; border-radius:10px; font-size:1rem; font-weight:bold; cursor:pointer; letter-spacing:0.08em; }
.dip-choose-btn:disabled { opacity:0.35; cursor:default; }

/* ─── Deck Builder (#dbView) ─── */
#dbView { display:none; flex-direction:column; flex:1; min-height:0; }
#dbView.active { display:flex; }
.db-header { display:flex; align-items:center; gap:10px; padding:calc(env(safe-area-inset-top,0px) + 12px) 14px 10px; flex-shrink:0; }
.db-search-input { flex:1; background:var(--surface2); border:1px solid var(--border); border-radius:6px; padding:5px 10px; color:var(--text); font-size:0.82rem; }
#dbAdvBtn { position:fixed; bottom:16px; right:16px; width:52px; height:52px; border-radius:50%; background:var(--accent); border:none; color:#fff; font-size:1.4rem; cursor:pointer; box-shadow:0 2px 8px rgba(0,0,0,0.4); z-index:10000; display:flex; align-items:center; justify-content:center; }
/* position:fixed is the only reliable way to scroll inside a fixed overlay on iOS Safari */
#dbScrollWrap { position:fixed; top:calc(env(safe-area-inset-top,0px) + 56px); left:0; right:0; bottom:0; overflow-y:scroll; -webkit-overflow-scrolling:touch; }
.db-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; padding:10px 10px 80px; }
/* デッキビルダー: 未追加は半透明、追加済みは紫枠なしで不透明 */
#dbGrid .card-item { opacity: 0.45; transition: opacity 0.15s; }
#dbGrid .card-item.in-deck { opacity: 1; border-color: transparent !important; }
.db-badge { position:absolute; top:4px; left:4px; background:rgba(124,109,250,0.9); color:#fff; font-size:0.65rem; font-weight:bold; padding:2px 5px; border-radius:6px; pointer-events:none; z-index:1; }
.db-count { position:absolute; bottom:34px; left:50%; transform:translateX(-50%); font-size:0.8rem; font-weight:bold; color:#fff; background:rgba(124,109,250,0.9); padding:1px 6px; border-radius:6px; z-index:1; pointer-events:none; white-space:nowrap; }
.db-minus { position:absolute; bottom:34px; left:4px; width:26px; height:26px; border-radius:50%; background:rgba(231,76,60,0.85); color:#fff; border:none; font-size:1rem; cursor:pointer; display:flex; align-items:center; justify-content:center; font-weight:bold; z-index:1; }
.db-plus { position:absolute; bottom:34px; right:4px; width:26px; height:26px; border-radius:50%; background:rgba(124,109,250,0.85); color:#fff; border:none; font-size:1rem; cursor:pointer; display:flex; align-items:center; justify-content:center; font-weight:bold; z-index:1; }
.db-plus:disabled { opacity:0.3; cursor:default; }
.db-footer { position:fixed; bottom:0; left:0; right:0; background:var(--surface); border-top:1px solid var(--border); display:flex; align-items:center; gap:8px; padding:8px 12px calc(8px + env(safe-area-inset-bottom)); z-index:200; }
.db-footer-ink { display:flex; align-items:center; gap:2px; flex-shrink:0; }
.db-footer-ink img { width:24px; height:24px; object-fit:contain; }
.db-footer-name { flex:1; font-size:0.78rem; color:var(--text2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.db-show-btn { flex-shrink:0; margin-left:auto; padding:8px 14px; background:rgba(124,109,250,0.16); color:var(--accent); border:none; border-radius:8px; font-size:0.82rem; font-weight:bold; cursor:pointer; white-space:nowrap; }

/* ─── Deck Stats (#dpStats) ─── */
#dpStats { display:none; flex-direction:column; flex:1; min-height:0; }
#dpStats.active { display:flex; }
.dstats-header { display:flex; align-items:center; gap:6px; padding:8px 10px; background:var(--surface); border-bottom:1px solid var(--border); flex-shrink:0; flex-wrap:wrap; }
.dstats-name-input { flex:1; min-width:0; background:var(--surface2); border:1px solid var(--border); border-radius:6px; padding:5px 10px; color:var(--text); font-size:0.85rem; }
.dstats-actions { display:flex; gap:6px; padding:8px 10px; background:var(--surface); border-bottom:1px solid var(--border); flex-shrink:0; }
.dstats-actions .btn-sm { flex:1; font-size:0.75rem; background:var(--surface2); }
.dstats-sleeve-picker { display:none; padding:8px 12px; background:var(--surface2); border-bottom:1px solid var(--border); flex-shrink:0; }
.dstats-sleeve-picker.open { display:block; }
.dstats-body { flex:1; min-height:0; }
/* position:fixed scroll — same iOS Safari fix as #dbScrollWrap */
#dpScrollWrap { position:fixed; top:88px; left:0; right:0; bottom:0; overflow-y:scroll; -webkit-overflow-scrolling:touch; }
/* ── Summary: top-row (chart|4-type) + bottom-row (ink|🎵◇) ── */
.dstats-summary { display:flex; flex-direction:column; gap:3px; padding:6px 10px; background:var(--bg); }
.dstats-top-row { display:flex; gap:6px; align-items:stretch; }
.dstats-bottom-row { display:flex; gap:6px; align-items:stretch; }
/* Cost chart: fills left side of top-row */
.dstats-cost-chart { width:42%; flex-shrink:0; min-width:0; background:var(--surface); border:1px solid var(--border); border-radius:6px; padding:5px 6px; display:flex; flex-direction:column; justify-content:flex-end; }
.dstats-cost-counts { display:flex; gap:2px; margin-bottom:1px; }
.dstats-cost-count { flex:1; font-size:0.48rem; color:var(--text2); text-align:center; }
.dstats-cost-bars { display:flex; align-items:flex-end; gap:2px; height:52px; }
.dstats-cost-bar { flex:1; background:var(--accent); border-radius:2px 2px 0 0; min-height:0; }
.dstats-cost-labels { display:flex; gap:2px; margin-top:1px; }
.dstats-cost-label { flex:1; font-size:0.48rem; color:var(--text2); text-align:center; }
/* Type grids: right side, both rows same width for column alignment */
.dstats-grid { display:grid; grid-template-columns:1fr 1fr; grid-auto-rows:1fr; gap:3px; flex:1; min-width:0; }
/* 🎵/◇ はアイテム/ロケと同じ幅に揃える（種類グリッドと同じ flex:1 側へ） */
.dstats-grid-extra { display:grid; grid-template-columns:1fr 1fr; grid-auto-rows:1fr; gap:3px; flex:1; min-width:0; }
/* セル: ラベル左・数字右の1行 */
.dstats-cell { background:var(--surface); border:1px solid var(--border); border-radius:6px; padding:5px 8px; display:flex; flex-direction:row; align-items:center; gap:6px; min-width:0; }
.dstats-cell-label { font-size:0.6rem; color:var(--text2); display:flex; align-items:center; gap:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.dstats-cell-label img { width:11px; height:11px; object-fit:contain; flex-shrink:0; }
.dstats-cell-val { font-size:0.88rem; font-weight:bold; color:var(--text); margin-left:auto; }
/* Ink row: left side of bottom-row — total box + ink cells */
/* 合計+アメジスト+ルビーは左側(コストチャート下)の狭い幅に。合計を少し広く。 */
.dstats-ink-row { width:42%; flex-shrink:0; min-width:0; display:flex; gap:3px; align-items:stretch; }
.dstats-ink-row .dstats-cell { flex:1; }
.dstats-ink-row .dstats-total-box { flex:1.35; }
.dstats-total-box { flex:1; min-width:0; display:flex; align-items:center; justify-content:center; padding:5px 8px; background:var(--surface); border:1px solid var(--border); border-radius:6px; }
.dstats-total-num { font-size:0.88rem; font-weight:bold; color:var(--accent); white-space:nowrap; }
.dstats-card-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; padding:6px 10px 80px; }

/* ─── レスポンシブ: タブレット(600px+) ─── */
@media (min-width: 600px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; gap: 10px; }
}

/* ─── レスポンシブ: PC・サイドバーナビ(960px+) ─── */
@media (min-width: 960px) {
  /* サイドバー */
  #nav { position: fixed; left: 0; top: 0; bottom: 0; right: auto; width: 200px; flex-direction: column; justify-content: flex-start; border-top: none; border-right: 1px solid var(--border); padding-top: 8px; }
  #nav::before { content: 'Loreca'; display: block; padding: 16px 20px 20px; font-size: 1.1rem; font-weight: bold; color: var(--accent); border-bottom: 1px solid var(--border); margin-bottom: 8px; letter-spacing: 0.05em; }
  .nav-btn { padding: 12px 20px; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 0.88rem; border-bottom: 1px solid var(--border); border-left: 3px solid transparent; }
  .nav-btn .icon { font-size: 1.1rem; }
  .nav-btn.active { border-left-color: var(--accent); }
  /* コンテンツエリア */
  .page { margin-left: 200px; padding-bottom: 0; }
  #pageLore.active { height: 100vh; }
  #pageBattle.active { height: 100vh; }
  /* カードグリッド */
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important; }
  /* FAB・プリフェッチバーの位置調整 */
  #advSearchBtn { bottom: 16px; }
  #dbAdvBtn { bottom: 16px; }
  #prefetchBar { left: 200px; bottom: 0; }
  /* 詳細検索モーダルをPC向けに中央配置 */
  .adv-modal-box { border-radius: 16px; max-width: 620px; width: 90%; }
}

/* ─── PC幅(1100px+): カード画面の右側にカード詳細を常設（ドック）─── */
/* スマホ・タブレットは従来どおりオーバーレイのカード詳細モーダル。 */
@media (min-width: 1100px) {
  /* 一覧側は右パネル分の幅を空ける（パネルは position:fixed で重ねる） */
  #pageCards.active { padding-right: 420px; }
  /* カード詳細モーダルを右ドックパネルに切り替え（暗幕オーバーレイにしない） */
  #cardModal.card-dock {
    display: flex;
    flex-direction: column; /* .modal-overlay 既定の row を上書き。縦並びにして縦中央揃えを効かせる */
    top: 0; right: 0; bottom: 0; left: auto;
    width: 400px;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    align-items: stretch;
    justify-content: center; /* カード詳細を縦中央に揃える */
    padding: 0;
    z-index: 150; /* サイドバーより前面・全画面系モーダル(z>=200)より背面 */
  }
  #cardModal.card-dock .modal {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 100%; /* 内容が長い時はパネル内だけでスクロール */
    overflow-y: auto;
    align-items: stretch;
    padding: 16px 18px calc(env(safe-area-inset-bottom, 0px) + 16px);
  }
  /* ドック内のカード画像。横幅(パネル幅)が上限になるので、高さは余裕を持たせて幅で決める */
  #cardModal.card-dock .modal-slide { height: 52vh; }
  /* 詳細検索FAB(🔍)が右ドックパネルの裏に隠れないよう、パネルの左側へ寄せる。
     インラインstyleの right:16px を上書きするため !important が必要。 */
  #advSearchBtn { right: 436px !important; }
  /* 未選択ならプレースホルダ、選択中はモーダル内容を表示 */
  #cardModal.card-dock:not(.has-card) > .modal { display: none; }
  #cardModal.card-dock:not(.has-card) > .card-dock-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; width: 100%; height: 100%; padding: 24px;
    color: var(--text2); text-align: center; font-size: 0.85rem; line-height: 1.7;
  }
  #cardModal.card-dock:not(.has-card) > .card-dock-empty svg { width: 40px; height: 40px; opacity: 0.5; }
  #cardModal.card-dock.has-card > .card-dock-empty { display: none; }
}

/* ─── 3ペイン(≥1280px): 左に詳細検索を常設・右にカード詳細・ナビは隠す ───
   body.cards-3pane は JS が「カード画面 かつ 幅1280px以上」のときだけ付与する。
   左ナビは普段隠し、カーソルを左端に寄せる(.nav-peek)とオーバーレイで出現。 */
body.cards-3pane #nav {
  transform: translateX(-100%);
  transition: transform 0.18s ease;
  z-index: 300; /* 出現時は左フィルタ(140)・右詳細(150)より前面に重ねる */
}
body.cards-3pane.nav-peek #nav { transform: none; }
/* カード画面の本体: ナビ分の左マージンを消し、左フィルタ/右詳細の幅を確保 */
body.cards-3pane #pageCards.active {
  margin-left: 0;
  padding-left: 320px;
  padding-right: 420px;
}
/* 詳細検索モーダルを左ドックパネルへ。インラインの z-index/align-items を !important で上書き */
body.cards-3pane #advSearchModal.adv-dock {
  display: flex;
  flex-direction: column;
  top: 0; right: auto; bottom: 0; left: 0;
  width: 320px;
  height: 100vh;
  border-right: 1px solid var(--border);
  border-radius: 0;
  align-items: stretch !important;
  justify-content: flex-start;
  z-index: 140 !important;
  padding: 0;
}
body.cards-3pane #advSearchModal.adv-dock .adv-modal-box {
  width: 100%; max-width: none; height: 100%;
  border-radius: 0; max-height: none; box-shadow: none;
}
/* ドックでは閉じる(×)は不要（常設パネルのため） */
body.cards-3pane #advSearchModal.adv-dock #advClose { display: none; }
/* 3ペイン中は🔍FABは不要（フィルタが常設されているため隠す） */
body.cards-3pane #advSearchBtn { display: none !important; }
/* ドックでは結果が即反映されるので「結果を表示」ボタンは不要。リセットを全幅に。 */
body.cards-3pane #advSearchModal.adv-dock #advApply,
body.deck-3pane  #advSearchModal.adv-dock #advApply { display: none; }
body.cards-3pane #advSearchModal.adv-dock #advReset2,
body.deck-3pane  #advSearchModal.adv-dock #advReset2 { flex: 1; }

/* ─── デッキ編集の3ペイン(≥1280px): 左に詳細検索・右にカード詳細 ───
   body.deck-3pane は JS が「デッキ編集のカードプール表示中 かつ 幅1280px以上」のときだけ付与。
   #deckEditor が全画面オーバーレイ(z9999)なので、ドックはそれより前面(10000/10001)に重ね、
   上部ヘッダー(戻る/デッキを見る)を隠さないようヘッダー下(56px)から配置する。 */
body.deck-3pane #dbScrollWrap { left: 320px; right: 400px; }
body.deck-3pane .db-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* カード画面と同じカードサイズ */
}
body.deck-3pane #advSearchModal.adv-dock {
  display: flex;
  flex-direction: column;
  top: calc(env(safe-area-inset-top, 0px) + 56px);
  right: auto; bottom: 0; left: 0;
  width: 320px;
  height: auto;
  border-right: 1px solid var(--border);
  border-radius: 0;
  align-items: stretch !important;
  justify-content: flex-start;
  z-index: 10000 !important; /* deckEditor(9999) より前面 */
  padding: 0;
}
body.deck-3pane #advSearchModal.adv-dock .adv-modal-box {
  width: 100%; max-width: none; height: 100%;
  border-radius: 0; max-height: none; box-shadow: none;
}
body.deck-3pane #advSearchModal.adv-dock #advClose { display: none; }
/* カード詳細の右ドックを deckEditor より前面・ヘッダー下に */
body.deck-3pane #cardModal.card-dock {
  top: calc(env(safe-area-inset-top, 0px) + 56px);
  height: auto;
  z-index: 10001;
}
/* 左に詳細検索が常設されるのでヘッダーの🔍は不要 */
body.deck-3pane #dbAdvBtn { display: none; }

/* ─── デッキ編集の統計(#dpStats) の3ペイン(≥1280px) ───
   左カラム(#dpStatsLeftDock)に「戻る/操作(スリーブ以外)/デッキ名/統計/スリーブ選択」を集約してスクロール。
   中央=カードグリッドを画面最上部から全高表示。右=カード詳細を全高表示。
   ※左カラムへの要素移動はJS(enter/exitDpStatsThreePane)で行う。 */
#dpStatsLeftDock { display: none; }
body.dpstats-3pane #dpStatsLeftDock {
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; width: 320px; bottom: 0;
  overflow-y: auto; z-index: 10000; /* deckEditor(9999) より前面 */
  background: var(--bg); border-right: 1px solid var(--border);
}
body.dpstats-3pane #dpStatsLeftDock .dstats-summary { border: 0; }
/* スリーブ選択ブロック */
body.dpstats-3pane #dpStatsLeftDock .dvp-title {
  font-weight: bold; font-size: 0.8rem; color: var(--text);
  padding: 8px 10px 4px; border-top: 1px solid var(--border);
}
body.dpstats-3pane #dpStatsSleeveDock .sleeve-dock-grid {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 4px 10px 24px;
}
/* 中央: カードグリッドを最上部から全高(左320/右400) */
body.dpstats-3pane #dpScrollWrap { top: 0; left: 320px; right: 400px; }
body.dpstats-3pane .dstats-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
/* 右: カード詳細ドックを最上部から全高・deckEditorより前面に */
body.dpstats-3pane #cardModal.card-dock { top: 0; height: 100vh; z-index: 10001; }
/* スリーブは左に常時表示するので操作バーの「スリーブを選ぶ」は隠す */
body.dpstats-3pane #statsSleeveBtn { display: none; }

/* ─── デッキ閲覧(#deckViewPage) の3ペイン(≥1280px) ───
   左カラム(#deckViewLeftDock)に「戻る/操作/デッキ名/統計/デッキ価格」を集約してスクロール。
   中央=カードグリッドを画面最上部から全高表示。右=カード詳細を全高表示。
   ※左カラムへの要素移動はJS(enter/exitDeckViewThreePane)で行う。 */
#deckViewLeftDock { display: none; }
body.deckview-3pane #deckViewLeftDock {
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; width: 320px; bottom: 0;
  overflow-y: auto; z-index: 10000; /* deckViewPage(9998) より前面 */
  background: var(--bg); border-right: 1px solid var(--border);
}
/* 左カラム内: 統計の枠線は不要、価格ブロックの体裁 */
body.deckview-3pane #deckViewLeftDock .dstats-summary { border: 0; }
body.deckview-3pane #deckViewLeftDock .dvp-title {
  font-weight: bold; font-size: 0.8rem; color: var(--text);
  padding: 8px 10px 4px; border-top: 1px solid var(--border);
}
body.deckview-3pane #deckViewLeftDock .dp-summary { padding: 4px 10px 6px; flex-wrap: wrap; }
body.deckview-3pane #deckViewLeftDock .dp-note { padding: 0 10px 6px; }
body.deckview-3pane #deckViewLeftDock .dp-table { padding: 0 6px 24px; }
/* 中央: カードグリッドを最上部から全高(左320/右400) */
body.deckview-3pane #deckViewCapture {
  position: fixed; top: 0; left: 320px; right: 400px; bottom: 0;
}
body.deckview-3pane #deckViewCapture .dv-body {
  position: static; height: 100%; margin: 0; flex: 1;
}
body.deckview-3pane #deckViewGrid {
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
}
/* 右: カード詳細ドックを最上部から全高・deckViewPageより前面に */
body.deckview-3pane #cardModal.card-dock { top: 0; height: 100vh; z-index: 10001; }
/* 価格は左に常時表示するのでヘッダーの「デッキ価格」ボタンは隠す */
body.deckview-3pane #deckViewPriceBtn { display: none; }

#gridSentinel { height: 1px; grid-column: 1 / -1; }
#toastContainer { position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 9999; pointer-events: none; align-items: center; }
.toast { padding: 10px 20px; border-radius: 8px; font-size: 0.875rem; color: #fff; max-width: 320px; text-align: center; animation: toastIn 0.25s ease; transition: opacity 0.4s ease; white-space: pre-wrap; }
.toast-hide { opacity: 0; }
.toast-error { background: #c0392b; }
.toast-warn  { background: #e67e22; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── ホームダッシュボード（B3） ─── */
#pageHome { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
/* Hero バナー（旧 home-greeting を置き換え） */
.home-hero {
  position: relative;
  margin: 12px 14px 16px;
  border-radius: 20px;
  overflow: hidden;
  padding: 32px 24px 28px;
  text-align: center;
  background:
    radial-gradient(ellipse at 25% 20%, rgba(124, 109, 250, 0.45), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(155, 89, 182, 0.30), transparent 55%),
    linear-gradient(135deg, #1a0f3d 0%, #0a0620 55%, #1f1845 100%);
  box-shadow: 0 4px 20px rgba(20, 10, 50, 0.35);
}
.home-hero-stars {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 28%, rgba(255,255,255,0.85), transparent 60%),
    radial-gradient(1.5px 1.5px at 88% 18%, rgba(255,255,255,0.7), transparent 60%),
    radial-gradient(1px 1px at 22% 78%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(2px 2px at 72% 62%, rgba(255,255,255,0.7), transparent 60%),
    radial-gradient(1px 1px at 50% 12%, rgba(255,255,255,0.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 95% 75%, rgba(255,255,255,0.6), transparent 60%),
    radial-gradient(1px 1px at 8% 55%, rgba(255,255,255,0.5), transparent 60%);
}
.home-hero-content { position: relative; z-index: 1; }
.home-hero-logo {
  height: 64px; width: auto;
  filter: drop-shadow(0 0 16px rgba(255, 215, 80, 0.35));
  margin-bottom: 14px;
}
.home-hero-title {
  color: #fff;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
}
.home-hero-subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.85rem;
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.04em;
}
/* ライトモードの Hero：濃紺の塊が浮くため、淡いラベンダー（CTAと同系）に置き換える。
   ダークは現状維持（html.dark には適用しない）。文字は濃い紫、星は紫の薄い輝きに。 */
html:not(.dark) .home-hero {
  background:
    radial-gradient(ellipse at 25% 20%, rgba(124, 109, 250, 0.18), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(155, 89, 182, 0.14), transparent 55%),
    linear-gradient(135deg, #ece7ff 0%, #f4ecff 55%, #e7e0ff 100%);
  box-shadow: 0 4px 18px rgba(124, 109, 250, 0.16);
}
html:not(.dark) .home-hero-title { color: #4a3b9e; }
html:not(.dark) .home-hero-subtitle { color: #7a6fae; }
html:not(.dark) .home-hero-stars {
  background-image:
    radial-gradient(2px 2px at 12% 28%, rgba(124,109,250,0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 88% 18%, rgba(124,109,250,0.38), transparent 60%),
    radial-gradient(1px 1px at 22% 78%, rgba(124,109,250,0.30), transparent 60%),
    radial-gradient(2px 2px at 72% 62%, rgba(124,109,250,0.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 95% 75%, rgba(124,109,250,0.30), transparent 60%);
}
.home-widget { margin: 0 16px 12px; background: var(--surface); border-radius: 14px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; }
.home-widget:active { transform: scale(0.99); }
.home-progress-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.home-progress-title { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.home-progress-pct { color: var(--text2); font-size: 0.85rem; }
.home-progress-banner { display: block; width: 100%; border-radius: 8px; margin: 8px 0 10px; }
.home-progress-nums { font-size: 0.78rem; color: var(--text2); text-align: right; margin-top: 6px; }
.home-progress-track { background: var(--border); border-radius: 6px; height: 8px; overflow: hidden; }
.home-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #a78bfa); border-radius: 6px; transition: width 0.4s; }
.home-cta { display: flex; align-items: center; justify-content: center; gap: 12px; width: calc(100% - 32px); margin: 4px 16px 16px; padding: 22px 16px; background: linear-gradient(135deg, var(--accent), #a78bfa); color: #fff; border: none; border-radius: 16px; font-size: 1.1rem; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px rgba(124,109,250,0.3); }
.home-cta:active { transform: scale(0.98); }
/* コレクションボード／スキャンで登録を横並びに */
.home-cta-row { display: flex; gap: 10px; margin: 4px 16px 16px; }
.home-cta-row .home-cta { flex: 1; width: auto; margin: 0; flex-direction: column; gap: 8px; padding: 18px 8px; font-size: 0.95rem; text-align: center; }
.home-cta-row .home-cta .cta-text { line-height: 1.25; }
/* ライトモードでは CTA を淡いラベンダー（カウンターのプレイヤー面 .lore-player-face と同じ色味）に
   して主張を抑える。ダークは従来の鮮やかなグラデのまま（html.dark には適用しない）。 */
html:not(.dark) .home-cta { background: color-mix(in srgb, var(--accent) 50%, var(--bg)); box-shadow: 0 4px 12px rgba(124,109,250,0.18); }
.home-cta .cta-icon { font-size: 1.4rem; }
.home-section-title { padding: 8px 16px 6px; font-size: 0.85rem; font-weight: 600; color: var(--text2); }
.home-quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 16px 16px; }
.home-quick-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.home-quick-btn:active { transform: scale(0.96); }
.home-quick-btn .qb-icon { font-size: 1.4rem; }
.home-quick-btn .qb-label { font-size: 0.72rem; white-space: nowrap; }
.home-recent-scroll { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 16px 16px; scrollbar-width: none; }
.home-recent-scroll::-webkit-scrollbar { display: none; }
.home-recent-card { flex-shrink: 0; width: 80px; aspect-ratio: 429/600; border-radius: 8px; overflow: hidden; background: var(--surface2); cursor: pointer; }
.home-recent-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.home-recent-empty { padding: 24px 16px; text-align: center; color: var(--text2); font-size: 0.85rem; width: 100%; }
/* よく使われるカード */
.home-pop-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px 6px; font-size: 0.85rem; font-weight: 600; color: var(--text2); }
.home-see-all { background: none; border: none; color: var(--accent); font-size: 0.78rem; font-weight: 600; cursor: pointer; font-family: inherit; padding: 4px 2px; -webkit-tap-highlight-color: transparent; }
/* ホームのカードは最近見たカードと同じ .home-recent-scroll / .home-recent-card を流用 */
/* すべて見る（インクごと一覧） */
#homePopularBody { padding: 8px 12px env(safe-area-inset-bottom); }
.hpa-sec { margin-bottom: 14px; }
.hpa-head { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 700; color: var(--text); margin: 8px 2px; }
.hpa-head img { width: 20px; height: 20px; }
.hpa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.hpa-card { cursor: pointer; }
.hpa-thumb { position: relative; aspect-ratio: 429/600; border-radius: 6px; overflow: hidden; background: var(--surface2); }
.hpa-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hpa-name { font-size: 0.6rem; color: var(--text2); margin-top: 2px; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

/* ─── スプラッシュ画面（A1） ─── */
.splash-screen { position: fixed; inset: 0; z-index: 9999; background: linear-gradient(135deg, #6b46c1 0%, #4338ca 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; transition: opacity 0.4s; }
.splash-screen.hidden { opacity: 0; pointer-events: none; }
.splash-logo { font-size: 48px; font-weight: 700; letter-spacing: 4px; margin-bottom: 8px; animation: splashLogoPop 0.6s ease-out; }
.splash-tagline { font-size: 14px; opacity: 0.9; letter-spacing: 2px; margin-bottom: 40px; }
.splash-dots { display: flex; gap: 8px; }
.splash-dots span { width: 8px; height: 8px; background: #fff; border-radius: 50%; opacity: 0.5; animation: splashDot 1.2s infinite; }
.splash-dots span:nth-child(2) { animation-delay: 0.15s; }
.splash-dots span:nth-child(3) { animation-delay: 0.3s; }
.splash-dots span:nth-child(4) { animation-delay: 0.45s; }
@keyframes splashLogoPop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes splashDot { 0%, 100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }

/* ─── タブスライドピル インジケーター（控えめなアクセント色） ─── */
.lg-indicator {
  position: absolute;
  background: rgba(124, 109, 250, 0.10);
  transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 0;
  pointer-events: none;
  left: 0;
  width: 0;
}
.view-tab-bar .lg-indicator { top: 4px; bottom: 4px; border-radius: 14px; }
#nav .lg-indicator { top: 6px; bottom: calc(6px + env(safe-area-inset-bottom)); border-radius: 12px; }
.settings-pills .lg-indicator { top: 4px; bottom: 4px; border-radius: 18px; }

html.dark .lg-indicator,
body.dark .lg-indicator {
  background: rgba(124, 109, 250, 0.22);
}

/* ============================================ */
/*  Loreca 統一ボタンシステム (4 Tier + Icon)    */
/* ============================================ */
.btn {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  transition: background 0.2s, border-color 0.2s, color 0.2s,
              transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Tier 1: Primary */
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: #6a5bd9; }

/* Tier 2: Choice */
.btn-choice {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-choice.selected,
.btn-choice.active {
  background: rgba(124,109,250,0.12);
  border-color: var(--accent);
  color: var(--accent);
}
html.dark .btn-choice.selected,
html.dark .btn-choice.active,
body.dark .btn-choice.selected,
body.dark .btn-choice.active {
  background: rgba(124,109,250,0.22);
}

/* Tier 3: Secondary */
.btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Tier 4: Ghost */
.btn-ghost {
  background: none;
  color: var(--text2);
  padding: 10px 14px;
  font-weight: 600;
}
.btn-ghost:active { color: var(--text); }
.btn-ghost.accent { color: var(--accent); }

/* Danger 変種 */
.btn-danger { background: var(--ruby); color: #fff; }
.btn-danger:active { background: #c0392b; }

/* Size 修飾子（.btn と組み合わせ時のみ作用。既存 .btn-sm に影響しない） */
.btn.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: 10px; }
.btn.btn-lg { padding: 14px 22px; font-size: 1rem; border-radius: 14px; }
.btn-block { width: 100%; }

/* ============================================ */
/*  円形 Icon ボタン                              */
/* ============================================ */
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s, color 0.2s,
              transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.icon-btn.primary:active { background: #6a5bd9; }
.icon-btn.danger {
  background: var(--ruby); border-color: var(--ruby); color: #fff;
}
.icon-btn.danger:active { background: #c0392b; }
.icon-btn.selected {
  background: rgba(124,109,250,0.12); border-color: var(--accent); color: var(--accent);
}
html.dark .icon-btn.selected, body.dark .icon-btn.selected {
  background: rgba(124,109,250,0.22);
}
.icon-btn.selected-ruby {
  background: rgba(231,76,60,0.14); border-color: var(--ruby); color: var(--ruby);
}
.icon-btn.selected-ruby svg { fill: currentColor; }
.icon-btn.selected-amber {
  background: rgba(245,166,35,0.14); border-color: var(--amber); color: var(--amber);
}
.icon-btn.selected-amber svg { fill: currentColor; }
.icon-btn.sm { width: 32px; height: 32px; font-size: 0.9rem; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.lg { width: 48px; height: 48px; font-size: 1.4rem; }
.icon-btn.lg svg { width: 24px; height: 24px; }

/* ═══════════════ コレクションボード ═══════════════ */
#collectionBoardPage{padding:0;overflow:hidden;background:
 radial-gradient(70% 45% at 50% 14%,rgba(124,109,250,.42),transparent 62%),
 radial-gradient(55% 45% at 82% 82%,rgba(40,150,170,.34),transparent 60%),
 radial-gradient(48% 38% at 14% 72%,rgba(180,120,255,.30),transparent 62%),
 linear-gradient(180deg,#1b1440,#0c0a22 55%,#06050f)}
:root{--cb-filigree:repeating-linear-gradient(45deg,transparent 0 13px,rgba(201,165,88,.12) 13px 14px,transparent 14px 27px),repeating-linear-gradient(-45deg,transparent 0 13px,rgba(201,165,88,.12) 13px 14px,transparent 14px 27px)}
.cb-fx{position:absolute;inset:0;z-index:0;pointer-events:none;overflow:hidden}
.cb-star{position:absolute;border-radius:50%;background:#fff;animation:cbTw 3.5s ease-in-out infinite}
@keyframes cbTw{0%,100%{opacity:.2}50%{opacity:.9}}
.cb-mote{position:absolute;border-radius:50%;background:radial-gradient(circle,#ffe9a8,rgba(255,233,168,0));animation:cbDrift linear infinite}
@keyframes cbDrift{0%{transform:translateY(20px);opacity:0}10%{opacity:.9}90%{opacity:.7}100%{transform:translateY(-60vh);opacity:0}}
.cb-top{position:relative;z-index:2;flex:none;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;padding:calc(env(safe-area-inset-top) + 12px) 14px 4px}
.cb-back{justify-self:start;background:none;border:none;color:#cfc8ee;font-size:1.5rem;cursor:pointer;width:40px;height:40px;line-height:1}
.cb-title{justify-self:center;text-align:center;white-space:nowrap;font-weight:800;letter-spacing:.1em;font-size:1rem;background:linear-gradient(90deg,#c9a558,#fff,#c9a558);-webkit-background-clip:text;background-clip:text;color:transparent}
.cb-edit-toggle{justify-self:end;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.22);color:#cfc8ee;border-radius:999px;padding:7px 16px;font-size:.8rem;cursor:pointer}
.cb-shelves{position:relative;z-index:1;flex:1;min-height:0;display:flex;flex-direction:column;justify-content:space-evenly;gap:6px;padding:0 12px calc(env(safe-area-inset-bottom) + 10px)}
.cb-shelf{position:relative;display:flex;flex-direction:column;justify-content:flex-end}
.cb-row{display:grid;grid-template-columns:1fr 1fr 1fr;gap:12px;padding:0 4px;align-items:end}
.cb-case{position:relative;border-radius:13px;padding:13px;cursor:pointer;background:linear-gradient(150deg,rgba(225,232,244,.30),rgba(150,162,186,.14) 52%,rgba(210,222,240,.24));border:1px solid rgba(255,255,255,.34);box-shadow:0 8px 16px rgba(0,0,0,.5),inset 0 1px 0 rgba(255,255,255,.5),inset 0 -8px 18px rgba(120,140,200,.12);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);transition:transform .15s}
.cb-case:active{transform:scale(.96)}
.cb-scr{position:absolute;width:11px;height:11px;border-radius:50%;background:radial-gradient(circle at 34% 30%,#fff,#aeb6c4 55%,#5c6470);box-shadow:0 1px 2px rgba(0,0,0,.45),0 0 0 1px rgba(0,0,0,.12)}
.cb-scr.cb-a{top:5px;left:5px}.cb-scr.cb-b{top:5px;right:5px}.cb-scr.cb-c{bottom:5px;left:5px}.cb-scr.cb-d{bottom:5px;right:5px}
.cb-card{position:relative;aspect-ratio:429/600;border-radius:6px;overflow:hidden;box-shadow:0 4px 10px rgba(0,0,0,.55),0 0 0 1px rgba(0,0,0,.25)}
.cb-card img{width:100%;height:100%;object-fit:cover;display:block}
.cb-shine{position:absolute;inset:0;mix-blend-mode:screen;pointer-events:none;background:linear-gradient(115deg,transparent 38%,rgba(255,255,255,.55) 48%,rgba(190,170,255,.5) 52%,transparent 64%);transform:translateX(-130%);animation:cbSweep var(--dur,7s) ease-in-out var(--dl,0s) infinite}
@keyframes cbSweep{0%{transform:translateX(-130%)}20%{transform:translateX(130%)}100%{transform:translateX(130%)}}
.cb-sheen{position:absolute;inset:0;border-radius:13px;pointer-events:none;background:linear-gradient(125deg,rgba(255,255,255,.4),transparent 30%,transparent 72%,rgba(255,255,255,.18))}
.cb-twink{position:absolute;top:14%;right:18%;color:#fff;font-size:.7rem;pointer-events:none;opacity:0;text-shadow:0 0 6px #fff,0 0 12px #c9a558;animation:cbTk var(--tdur,9s) ease-in-out var(--tdl,0s) infinite}
@keyframes cbTk{0%,94%,100%{opacity:0;transform:scale(.4)}97%{opacity:1;transform:scale(1.1)}}
/* 空き枠: アクリルケース(.cb-case)の枠サイズ(padding:13 + 内側aspect 429/600)に合わせる */
.cb-empty{background:rgba(255,255,255,.035);border-color:transparent;box-shadow:none;-webkit-backdrop-filter:none;backdrop-filter:none}
.cb-empty-inner{aspect-ratio:429/600;border-radius:6px;border:1.6px dashed rgba(255,255,255,.3);display:flex;align-items:center;justify-content:center}
.cb-plus{font-size:2rem;line-height:1;color:#c9a558}
.cb-remove{display:none;position:absolute;top:-7px;right:-7px;width:24px;height:24px;border-radius:50%;background:#e74c3c;border:2px solid #fff;color:#fff;font-size:.78rem;align-items:center;justify-content:center;cursor:pointer;z-index:3;box-shadow:0 2px 6px rgba(0,0,0,.5)}
#collectionBoardPage.cb-editing .cb-case:not(.cb-empty) .cb-remove{display:flex}
.cb-ledge{position:relative;height:22px;margin:8px 0 0;border-radius:3px;flex:none;background:var(--cb-filigree),linear-gradient(180deg,#4a3a66 0%,#3a2c52 34%,#281d3c 64%,#1a1230 100%);box-shadow:0 16px 22px rgba(0,0,0,.55),0 0 20px rgba(124,109,250,.22),inset 0 -2px 4px rgba(0,0,0,.4)}
.cb-ledge::before{content:"";position:absolute;left:0;right:0;top:0;height:5px;border-radius:3px 3px 0 0;background:linear-gradient(180deg,#f6e6ad,#c9a558 46%,#7e6228);box-shadow:inset 0 1px 0 rgba(255,246,214,.8),0 0 10px rgba(201,165,88,.5)}
.cb-ledge::after{content:"";position:absolute;left:7%;right:7%;top:6px;height:2px;border-radius:2px;background:linear-gradient(90deg,transparent,rgba(180,150,255,.9),rgba(255,240,200,.95),rgba(120,200,255,.9),transparent);box-shadow:0 0 8px rgba(170,150,255,.85);animation:cbEdge 4s ease-in-out infinite}
@keyframes cbEdge{0%,100%{opacity:.7}50%{opacity:1}}
/* 拡大ビュー */
.cb-viewer{position:absolute;inset:0;z-index:20;display:none;overflow:hidden}
.cb-viewer.show{display:block}
.cb-v-bg{position:absolute;inset:0;background:radial-gradient(72% 50% at 50% 15%,rgba(150,124,232,.42),transparent 62%),radial-gradient(150% 105% at 50% 40%,transparent 42%,rgba(5,4,14,.78) 100%),linear-gradient(180deg,#221852,#150e36 46%,#0a0820 78%,#06040f)}
.cb-v-rays{position:absolute;left:50%;top:24%;width:190vmax;height:190vmax;transform:translate(-50%,-50%);background:conic-gradient(from 0deg,rgba(255,242,214,.06),transparent 22%,rgba(170,150,255,.05) 48%,transparent 72%,rgba(255,242,214,.06));mix-blend-mode:screen;filter:blur(42px);opacity:.85;animation:cbSpin 72s linear infinite}
@keyframes cbSpin{to{transform:translate(-50%,-50%) rotate(360deg)}}
.cb-neb{position:absolute;border-radius:50%;filter:blur(46px);mix-blend-mode:screen;pointer-events:none}
.cb-n1{width:70vmax;height:70vmax;left:-18%;top:-8%;background:radial-gradient(closest-side,rgba(130,90,255,.55),transparent);animation:cbFl1 20s ease-in-out infinite}
.cb-n2{width:62vmax;height:62vmax;right:-20%;top:4%;background:radial-gradient(closest-side,rgba(40,180,210,.5),transparent);animation:cbFl2 26s ease-in-out infinite}
.cb-n3{width:54vmax;height:54vmax;left:30%;top:30%;background:radial-gradient(closest-side,rgba(201,165,88,.34),transparent);animation:cbFl1 32s ease-in-out infinite reverse}
@keyframes cbFl1{0%,100%{transform:translate(0,0)}50%{transform:translate(8%,6%)}}
@keyframes cbFl2{0%,100%{transform:translate(0,0)}50%{transform:translate(-9%,7%)}}
.cb-vfx{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.cb-v-aura{position:absolute;left:50%;top:34%;width:78%;height:46%;transform:translate(-50%,-50%);pointer-events:none;mix-blend-mode:screen;background:radial-gradient(closest-side,rgba(255,238,196,.38),rgba(190,160,255,.12) 52%,transparent 72%);animation:cbAura 5.5s ease-in-out infinite}
@keyframes cbAura{0%,100%{opacity:.55;transform:translate(-50%,-50%) scale(1)}50%{opacity:1;transform:translate(-50%,-50%) scale(1.08)}}
.cb-pedestal{position:absolute;left:0;right:0;bottom:0;height:36%}
.cb-ped-top{position:absolute;left:0;right:0;top:0;height:30%;background:linear-gradient(180deg,#5a486f 0%,#42345c 50%,#322546 100%);box-shadow:inset 0 2px 0 rgba(255,255,255,.16)}
.cb-ped-top::after{content:"";position:absolute;left:0;right:0;top:0;height:6px;background:linear-gradient(180deg,#f6e6ad,#c9a558 50%,#7e6228);box-shadow:0 0 14px rgba(201,165,88,.6)}
.cb-ped-edge{position:absolute;left:0;right:0;top:30%;height:3px;background:linear-gradient(90deg,transparent,rgba(180,150,255,.9),rgba(255,240,200,.95),rgba(120,200,255,.9),transparent);box-shadow:0 0 12px rgba(170,150,255,.9);z-index:1;animation:cbEdge 4s ease-in-out infinite}
.cb-ped-face{position:absolute;left:0;right:0;top:calc(30% + 3px);bottom:0;background:radial-gradient(85% 130% at 50% -12%,rgba(150,128,215,.16),transparent 58%),linear-gradient(180deg,#2a2042 0%,#1c1432 46%,#100a24 100%);box-shadow:inset 0 -18px 34px rgba(0,0,0,.55)}
.cb-ped-face::before{content:"";position:absolute;left:0;right:0;top:18%;height:1px;background:linear-gradient(90deg,transparent,rgba(201,165,88,.4),transparent)}
.cb-pedestal::before{content:"";position:absolute;left:0;right:0;top:-26px;height:26px;background:linear-gradient(180deg,transparent,rgba(0,0,0,.4));pointer-events:none}
.cb-bigcase{position:absolute;left:50%;top:45%;transform:translate(-50%,-50%);width:76vw;max-width:340px;border-radius:20px;padding:7.5%;z-index:2;background:linear-gradient(150deg,rgba(232,238,250,.5),rgba(155,168,192,.3) 50%,rgba(216,228,246,.42));border:1px solid rgba(255,255,255,.55);box-shadow:0 36px 60px rgba(0,0,0,.55),inset 0 2px 0 rgba(255,255,255,.7),inset 0 -14px 32px rgba(120,140,200,.2);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);animation:cbPop .32s cubic-bezier(.2,.9,.2,1);-webkit-box-reflect:below 8px linear-gradient(transparent 58%,rgba(255,255,255,.10))}
@keyframes cbPop{from{opacity:0;transform:translate(-50%,-47%) scale(.92)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}
.cb-bigcase .cb-scr{width:18px;height:18px}
.cb-bigcase .cb-scr.cb-a{top:13px;left:13px}.cb-bigcase .cb-scr.cb-b{top:13px;right:13px}.cb-bigcase .cb-scr.cb-c{bottom:13px;left:13px}.cb-bigcase .cb-scr.cb-d{bottom:13px;right:13px}
.cb-v-close{position:absolute;left:50%;bottom:calc(env(safe-area-inset-bottom) + 26px);transform:translateX(-50%);width:54px;height:54px;border-radius:50%;background:rgba(255,255,255,.5);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.6);font-size:1.4rem;color:#3a3550;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 8px 20px rgba(0,0,0,.3);z-index:3}
/* ピッカー */
.cb-picker{position:absolute;inset:0;z-index:30;display:none;flex-direction:column;background:rgba(8,7,20,.97);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}
.cb-picker.show{display:flex}
.cb-picker-head{flex:none;display:flex;align-items:center;gap:8px;padding:calc(env(safe-area-inset-top) + 12px) 14px 10px}
.cb-picker-head input{flex:1;min-width:0;background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:10px 14px;color:var(--text);font-size:.9rem}
.cb-picker-head button{flex:none;width:42px;height:42px;border-radius:10px;background:var(--surface2);border:1px solid var(--border);color:var(--text);font-size:1rem;cursor:pointer}
.cb-picker-grid{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding-bottom:calc(env(safe-area-inset-bottom) + 20px)}
.cb-picker-grid .card-grid{padding-top:6px}
.cb-pick{aspect-ratio:429/600;border-radius:8px;overflow:hidden;cursor:pointer;background:var(--surface2);box-shadow:0 4px 10px rgba(0,0,0,.4);transition:transform .12s}
.cb-pick:active{transform:scale(.95)}
.cb-pick img{width:100%;height:100%;object-fit:cover;display:block}
.cb-pick-empty{grid-column:1/-1;text-align:center;color:var(--text2);padding:40px 0;font-size:.85rem}
/* スクロールしても常時表示される詳細検索の🔍ボタン(カードタブの advSearchBtn と同様) */
.cb-picker-fab{position:absolute;bottom:calc(env(safe-area-inset-bottom) + 20px);right:18px;width:52px;height:52px;border-radius:50%;background:var(--accent);border:none;color:#fff;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 14px rgba(0,0,0,.45);z-index:5;cursor:pointer}
.cb-picker-fab:active{transform:scale(.95)}
.cb-picker-fab svg{width:24px;height:24px}
/* 詳細検索モーダルをコレクションボード(サブページ z700)より手前に表示 */
.modal-overlay.cb-front{z-index:760}
