/* ===== 色・サイズの基本設定（ライト／ダーク） ===== */
:root {
  --bg: #f3f8f6;
  --bg-grad: radial-gradient(1200px 500px at 0% 0%, #e3f5ec 0%, rgba(227,245,236,0) 60%), radial-gradient(900px 400px at 100% 0%, #e8f0fb 0%, rgba(232,240,251,0) 60%);
  --surface: #ffffff;
  --surface-2: #f1f4f3;
  --text: #17201c;
  --muted: #66716c;
  --border: #e1e8e5;
  --accent: #17a06b;
  --accent-strong: #0e8a5a;
  --accent-soft: #e4f6ee;
  --accent-text: #ffffff;
  --blue: #2f6fe4;
  --blue-soft: #e8f0fd;
  --danger: #d64545;
  --up: #d64545;
  --down: #17a06b;
  --warn-bg: #fff4d6;
  --warn-text: #7a5300;
  --best-bg: #e4f6ee;
  --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 14px rgba(16, 40, 30, .06);
  --radius: 16px;
  --tier1: #1f63d6;
  --tier2: #4b9bf0;
  --tier3: #2cc6a0;
  --tier4: #8fd96b;
  --tier0: #c9d1cd;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --bg-grad: radial-gradient(1200px 500px at 0% 0%, #12271e 0%, rgba(18,39,30,0) 60%), radial-gradient(900px 400px at 100% 0%, #141d2c 0%, rgba(20,29,44,0) 60%);
    --surface: #18201d;
    --surface-2: #222b28;
    --text: #e7eeeb;
    --muted: #9aa8a2;
    --border: #2c3733;
    --accent: #2fc283;
    --accent-strong: #3fd694;
    --accent-soft: #173a2b;
    --accent-text: #06140e;
    --blue: #6d9cff;
    --blue-soft: #1a2740;
    --danger: #ff7a6b;
    --up: #ff7a6b;
    --down: #3fd694;
    --warn-bg: #3a3017;
    --warn-text: #ffd27a;
    --best-bg: #173a2b;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --tier0: #3a4541;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }

/* ===== ヘッダー ===== */
.appbar {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; flex: 1 1 auto; }
.brand-logo { width: 44px; height: 44px; flex: 0 0 44px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 24px; font-weight: 800; letter-spacing: .01em; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; gap: 4px; position: relative; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none; background: transparent;
  display: grid; place-items: center; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }
.menu {
  position: absolute; right: 0; top: 48px; z-index: 40; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column;
}
.menu a { padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
.menu a:hover { background: var(--surface-2); }

/* ===== メインメニュー（丸いボタン） ===== */
.navpills {
  position: sticky; top: 0; z-index: 30;
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(var(--bg) 70%, rgba(0,0,0,0));
}
.navpills a {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 46px; border-radius: 12px; text-decoration: none;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.navpills a svg { width: 20px; height: 20px; flex: 0 0 20px; }
.navpills a.active { background: var(--accent); color: var(--accent-text); box-shadow: 0 4px 12px rgba(23,160,107,.3); }
@media (max-width: 520px) {
  .navpills { gap: 6px; }
  .navpills a { flex-direction: column; gap: 2px; height: 54px; font-size: 11px; }
}

.view {
  max-width: 1200px; margin: 0 auto;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 32px);
  outline: none;
}

/* ===== 共通部品 ===== */
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }
.bold { font-weight: 700; }
.shrink0 { flex: 0 0 auto; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; font-size: 15px; font-weight: 600; white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.outline { border-color: var(--accent); color: var(--accent-strong); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { min-height: 160px; resize: vertical; }
input[type="number"] { width: 72px; text-align: center; }
label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 14px; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.badge {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); vertical-align: middle;
}
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }

pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
.notice { background: var(--warn-bg); color: var(--warn-text); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; }

.card-img {
  width: 100%; aspect-ratio: 488 / 680; object-fit: cover; border-radius: 4.75% / 3.5%;
  background: var(--surface-2); display: block;
}

/* ===== 検索結果 ===== */
.card-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 8px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; text-align: left; box-shadow: var(--shadow);
}
.card-tile .name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.card-tile .sub { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* 絞り込み（色・タイプ・種族） */
.filters summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; list-style: none; }
.filters summary::-webkit-details-marker { display: none; }
.filters summary .badge { margin-left: auto; }
.filters[open] summary { margin-bottom: 12px; }
.filter-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.inline-select { width: auto; min-height: 36px; padding: 4px 10px; font-size: 14px; }
.chk { position: relative; display: inline-flex; cursor: pointer; }
.chk input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chk span {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface); user-select: none;
}
.chk input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.chk input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chk.mana span::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); }
.chk.mana-w span::before { background: #f8f3d8; }
.chk.mana-u span::before { background: #3f84d1; }
.chk.mana-b span::before { background: #3b3533; }
.chk.mana-r span::before { background: #e0533d; }
.chk.mana-g span::before { background: #2f9a5a; }
.chk.mana-c span::before { background: #c9c3bd; }
.chk.mana-m span::before { background: conic-gradient(#f8f3d8 0 20%, #3f84d1 0 40%, #3b3533 0 60%, #e0533d 0 80%, #2f9a5a 0); }
.chk.legend span { border-style: dashed; }

.chk.legal span { border-color: var(--blue); color: var(--blue); }
.chk.legal input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.subtype-search { margin: 8px 0; }

/* ===== デッキビルダー（デッキ編集＋カードリスト＋カード詳細） ===== */
.view.wide { max-width: 1680px; padding-bottom: 8px; }
.builder {
  display: grid; gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, var(--deck-fr, 1fr)) auto minmax(0, var(--list-fr, 1fr));
  height: 70vh;
}
.builder[data-split="list"] { --deck-fr: .55fr; --list-fr: 1.45fr; }
.builder[data-split="deck"] { --deck-fr: 1.45fr; --list-fr: .55fr; }
.builder { position: relative; }
.builder > * { min-width: 0; min-height: 0; }
.deck-pane, .detail-pane { overflow: auto; overscroll-behavior: contain; }
.deck-pane { container: deck / inline-size; }
.deck-pane > .panel + .panel { margin-top: 12px; }
/* 左の詳細列（PCの幅だけ）。「◀ 詳細を隠す」で隠し、「▶ 詳細」で戻す */
.detail-col { display: none; flex-direction: column; gap: 6px; }
.detail-col .detail-pane { flex: 1 1 auto; min-height: 0; }
.detail-hide { align-self: flex-start; }
.detail-tab {
  display: none; position: absolute; left: 0; top: 0; bottom: 0; width: 26px; z-index: 5;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: 12px; font-weight: 700; writing-mode: vertical-rl; letter-spacing: .1em;
}
.detail-tab:hover { color: var(--accent-strong); border-color: var(--accent); }
.split-btn {
  display: flex; align-items: center; justify-content: center; height: 26px; margin: -4px 0;
  border: none; background: transparent; color: var(--muted); cursor: pointer;
}
.split-btn svg { width: 22px; height: 22px; }

@media (min-width: 720px) {
  .builder { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); gap: 14px; }
  .split-btn { display: none; }
}
@media (min-width: 1100px) {
  .builder { grid-template-columns: 280px minmax(0, 1fr) 380px; }
  .detail-col { display: flex; }
  .builder[data-detail="hidden"] { grid-template-columns: minmax(0, 1fr) 380px; padding-left: 34px; }
  .builder[data-detail="hidden"] .detail-col { display: none; }
  .builder[data-detail="hidden"] .detail-tab { display: block; }
}

/* カードリスト */
.list-pane { display: flex; flex-direction: column; gap: 8px; padding: 12px; overflow: hidden; }
.list-search { display: flex; gap: 8px; }
.search-box {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.search-box svg { width: 20px; height: 20px; color: var(--muted); flex: 0 0 20px; }
.search-box input { border: none; min-height: 42px; padding: 0; background: transparent; }
.search-box input:focus { outline: none; }
.search-box:focus-within { outline: 2px solid var(--accent); border-color: transparent; }
.view-toggle { width: 60px; padding: 0; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.list-tools { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.list-tools .btn { min-height: 40px; padding: 4px 10px; font-size: 14px; }
.list-tools .sort-btn { appearance: none; -webkit-appearance: none; text-align: center; text-align-last: center; width: 100%; }
.fbadge { background: var(--accent); color: var(--accent-text); border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.list-info { gap: 8px; align-items: baseline; }
.list-target { flex: 0 0 auto; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.list-status { margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 719px) {
  .list-pane { gap: 6px; padding: 10px; }
  .list-search .search-box input { min-height: 38px; }
  .view-toggle { width: 48px; min-height: 40px; }
  .list-tools .btn { min-height: 36px; font-size: 13px; }
}
.list-results { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 2px 4px 8px; }

.lgrid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.ltile { position: relative; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--surface-2); outline: none; }
.ltile img { width: 100%; aspect-ratio: 488 / 680; object-fit: cover; display: block; }
.ltile .lname { font-size: 11px; font-weight: 600; padding: 3px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ltile .cnt {
  position: absolute; right: 4px; top: 4px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px;
  background: #1c2420; color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; border: 2px solid #fff;
}
.ltile .ov {
  position: absolute; left: 0; right: 0; top: 0; aspect-ratio: 488 / 680;
  display: none; flex-direction: column; justify-content: space-between; gap: 4px; padding: 6px;
  background: linear-gradient(rgba(8, 20, 14, .35), rgba(8, 20, 14, .65));
}
@media (hover: hover) and (pointer: fine) {
  .ltile:hover .ov, .ltile:focus-within .ov { display: flex; }
}
.ltile.selected .ov { display: flex; }
.ltile.selected, .ltile:focus-visible { outline: 3px solid var(--accent); }
.ov .add-btn {
  border: none; border-radius: 8px; padding: 7px 4px; font-size: 12px; font-weight: 800; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.ov .add-btn:disabled { background: #6f7975; cursor: default; }
.ov .reason, .reason-inline { font-size: 11px; font-weight: 700; }
.ov .reason { color: #fff; background: rgba(214, 69, 69, .92); text-align: center; border-radius: 6px; padding: 2px 4px; }
.reason-inline { color: var(--danger); }
.ov .qtybar { background: rgba(255, 255, 255, .95); border-radius: 8px; border-top: none; overflow: hidden; }
.ov .qtybar button { color: #111; height: 30px; }
.q-num { display: grid; place-items: center; font-weight: 800; }
.ov .q-num { color: #111; background: #e9eeec; }
.qtybar button:disabled { opacity: .3; cursor: default; }

.llist { display: flex; flex-direction: column; }
.lrow {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 108px; gap: 8px; align-items: center;
  padding: 6px 2px; border-bottom: 1px solid var(--border); cursor: pointer; outline: none;
}
.lrow .thumb { width: 44px; border-radius: 3px; display: block; }
.lrow .name { font-weight: 700; font-size: 13px; line-height: 1.3; }
.lrow .sub { font-size: 11px; color: var(--muted); }
.lrow .qtybar { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lrow .qtybar button { height: 30px; }
.lrow .q-num { background: var(--surface-2); }
.cnt-inline { font-size: 11px; font-weight: 800; color: var(--accent-strong); margin-left: 4px; }

/* カード詳細 */
.card-detail .big-img { max-width: 100%; }
.detail-pane .card-detail .big-img { max-width: 240px; }
.cd-name { margin: 6px 0 0; font-size: 18px; }
.cd-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; font-size: 13px; }
.cd-text { background: var(--surface-2); border-radius: 10px; padding: 10px; font-size: 13px; line-height: 1.65; font-family: inherit; margin: 8px 0; }
.cd-legal { font-size: 13px; font-weight: 700; margin: 8px 0; }
.cd-legal.ok { color: var(--accent-strong); }
.cd-legal.ng { color: var(--danger); }
.cd-qty { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
.store-prices.one-col { grid-template-columns: 1fr; }

/* ===== デッキ一覧 ===== */
.deck-list-item { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.deck-list-item .meta { font-size: 13px; color: var(--muted); }
.deck-thumb { width: 56px; flex: 0 0 56px; }

/* ===== デッキ編集：上部 ===== */
.deck-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.deck-info { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: center; }
.deck-cover {
  width: 76px; height: 76px; border-radius: 12px; object-fit: cover; object-position: 50% 18%;
  background: var(--surface-2); box-shadow: var(--shadow);
}
.deck-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.deck-title h2 { margin: 0; font-size: 22px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-title .icon-btn { width: 34px; height: 34px; color: var(--blue); }
.deck-title .icon-btn svg { width: 20px; height: 20px; }
.deck-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 4px; }
.fmt-pill {
  width: auto; min-height: 30px; padding: 2px 28px 2px 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: var(--blue-soft); color: var(--blue); border: 1px solid transparent; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}

.total-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--surface);
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
}
.total-card .label { font-size: 13px; color: var(--muted); font-weight: 600; grid-column: 1; }
.total-card .value { font-size: 32px; font-weight: 800; letter-spacing: .01em; line-height: 1.15; grid-column: 1; }
.total-card .value .yen { font-size: .7em; margin-right: 4px; }
.total-card .change { font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.total-card .change .up { color: var(--up); font-weight: 700; }
.total-card .change .down { color: var(--down); font-weight: 700; }
.total-card .refresh {
  grid-column: 2; grid-row: 1 / 3; width: 48px; height: 48px; border-radius: 50%;
  border: none; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; cursor: pointer;
}
.total-card .refresh svg { width: 24px; height: 24px; }
.total-card .refresh.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.total-card .progress { grid-column: 1 / -1; margin-top: 6px; }

@container deck (min-width: 640px) {
  .deck-head { grid-template-columns: 1fr minmax(280px, 340px); align-items: center; }
  .deck-info { grid-template-columns: 96px 1fr; }
  .deck-cover { width: 96px; height: 96px; }
}

/* ===== デッキ編集：ゾーンのタブ・ツールバー ===== */
.zone-tabs { display: flex; border-bottom: 1px solid var(--border); margin-top: 16px; overflow-x: auto; scrollbar-width: none; }
.zone-tabs button {
  flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 10px; border: none; background: none; cursor: pointer; color: var(--muted);
  font-weight: 700; font-size: 15px; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.zone-tabs button svg { width: 20px; height: 20px; }
.zone-tabs button.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.zone-tabs .count { font-size: 12px; padding: 1px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.zone-tabs button.active .count { background: var(--accent); color: var(--accent-text); }

.toolbar { display: flex; justify-content: flex-end; gap: 8px; margin: 12px 0; align-items: center; }
.toolbar .sort { width: auto; min-height: 40px; font-weight: 600; font-size: 14px; padding: 6px 12px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { width: 44px; height: 40px; border: none; background: none; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.seg button svg { width: 20px; height: 20px; }
.seg button.active { background: var(--accent); color: var(--accent-text); }

/* ===== デッキ編集：小さいカード（画像＋枚数＋価格。−／＋はホバー・タップで出す） ===== */
@container deck (max-width: 599px) {
  .deck-pane .panel { padding: 12px; }
}
.mgrid { display: grid; gap: 10px 8px; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
.mtile { cursor: pointer; outline: none; min-width: 0; }
.mimg { position: relative; }
.mimg img { width: 100%; aspect-ratio: 488 / 680; object-fit: cover; border-radius: 5px; display: block; box-shadow: 0 1px 4px rgba(0,0,0,.25); background: var(--surface-2); }
.mimg .n {
  position: absolute; right: -3px; bottom: -3px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px;
  background: #1c2420; color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface);
}
.mimg .mwarn {
  position: absolute; left: 2px; top: 2px; font-size: 11px; padding: 0 4px; border-radius: 5px;
  background: var(--warn-bg); color: var(--warn-text); font-weight: 800;
}
.mimg .mzone {
  position: absolute; left: 2px; bottom: 2px; font-size: 10px; padding: 0 4px; border-radius: 4px;
  background: var(--blue); color: #fff; font-weight: 700;
}
.mov {
  position: absolute; inset: 0; display: none; flex-direction: column; justify-content: space-between; align-items: flex-end;
  padding: 3px; border-radius: 5px; background: rgba(8, 20, 14, .45);
}
@media (hover: hover) and (pointer: fine) {
  .mtile:hover .mov, .mtile:focus-within .mov { display: flex; }
}
.mtile.selected .mov { display: flex; }
.mtile.selected .mimg img, .mtile:focus-visible .mimg img { outline: 3px solid var(--accent); }
.mov .more {
  width: 24px; height: 24px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.95); color: #333; font-weight: 800; font-size: 11px; display: grid; place-items: center;
}
.mov .qtybar { width: 100%; background: rgba(255,255,255,.96); border-radius: 6px; border-top: none; overflow: hidden; }
.mov .qtybar button { height: 26px; font-size: 15px; color: #111; }
.mov .q-num { color: #111; background: #e9eeec; font-size: 13px; }
.mprice { font-size: 11px; font-weight: 800; text-align: center; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mprice.none { color: var(--muted); font-weight: 600; }
.mprice.starter { color: var(--blue); }
.qtybar { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--border); }
.qtybar button { height: 34px; border: none; background: none; font-size: 18px; cursor: pointer; color: var(--text); }
.qtybar button:active { background: var(--surface-2); }
.qtybar .num { display: grid; place-items: center; font-weight: 800; background: var(--surface-2); }

/* 一覧表示 */
.dlist { display: flex; flex-direction: column; }
.deck-line {
  display: grid; grid-template-columns: 48px 1fr auto auto; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.deck-line:last-child { border-bottom: none; }
.deck-line .thumb { width: 48px; border-radius: 3px; cursor: zoom-in; }
.deck-line .name { font-weight: 700; line-height: 1.3; }
.deck-line .warns { margin-top: 2px; display: flex; gap: 4px; flex-wrap: wrap; }
.deck-line .lprice { font-weight: 800; text-align: right; min-width: 64px; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty .btn { min-height: 32px; width: 32px; padding: 0; }
.qty .num { min-width: 22px; text-align: center; font-weight: 700; }

/* スターター按分 */
.starter-badge { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.formula { font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.deck-line .formula { margin-top: 2px; color: var(--blue); }
.purchase { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.purchase-input { width: 110px !important; min-height: 32px !important; padding: 2px 8px !important; text-align: right !important; }
.price-input { text-align: right; }
.starter-link { color: var(--blue); border-color: var(--blue-soft); background: var(--blue-soft); }
.starter-panel { margin-top: 12px; }
.starter-panel summary { cursor: pointer; font-weight: 800; font-size: 16px; margin-bottom: 8px; }
.starter-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.starter-row:last-of-type { border-bottom: none; margin-bottom: 8px; }
.formula-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.formula-row { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
/* 統率者分析（TopDeck.gg の採用率） */
.cmd-layout { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .cmd-layout { grid-template-columns: 340px minmax(0, 1fr); align-items: start; } }
.cmd-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow: auto; overscroll-behavior: contain; }
.cmd-row {
  display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border-radius: 10px;
  border: 1px solid transparent; background: var(--surface-2); cursor: pointer; color: var(--text);
}
.cmd-row.active { border-color: var(--accent); background: var(--accent-soft); }
.cmd-row > span:last-child { white-space: nowrap; }
.rate-list { display: flex; flex-direction: column; }
.rate-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rate-row .thumb { width: 52px; border-radius: 4px; display: block; }
.rate-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 4px 0; }
.rate-bar > div { height: 100%; background: var(--accent); }
.rate-badge {
  position: absolute; left: 4px; top: 4px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 800;
  background: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.rate-inline { color: var(--accent-strong); font-weight: 800; margin-left: 6px; font-size: 12px; }
.list-extra { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.credit { text-align: center; }

.starter-link { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.catalog-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; overscroll-behavior: contain; }
.catalog-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.catalog-row .overlap { color: var(--accent-strong); font-weight: 700; }
.tiny { font-size: 11px; }
.cd-starter { background: var(--blue-soft); border-radius: 10px; padding: 8px 10px; margin: 8px 0; color: var(--blue); }

/* 下の操作ボタン */
.actionbar {
  position: sticky; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 16px -16px 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: linear-gradient(transparent, var(--surface) 30%);
  border-radius: 0 0 var(--radius) var(--radius);
}
.actionbar .btn { min-height: 48px; }
.actionbar select.btn { appearance: none; -webkit-appearance: none; text-align: center; text-align-last: center; }
@container deck (max-width: 599px) {
  /* 狭いとき：4つのボタンを1行に並べる（文字は短く） */
  .actionbar { grid-template-columns: 1fr 1fr 1fr 1.25fr; gap: 6px; margin: 12px -12px 0; padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px); }
  .actionbar .btn { min-height: 46px; padding: 4px; font-size: 12px; gap: 3px; flex-direction: column; border-radius: 10px; }
  .actionbar .btn svg { width: 18px; height: 18px; }
  .actionbar .long { display: none; }
}
@container deck (min-width: 600px) {
  .actionbar { grid-template-columns: auto auto auto 1fr; margin: 16px 0 0; padding: 10px 0; }
  .actionbar .short { display: none; }
}

/* 価格の内訳 */
.breakdown summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-weight: 800; font-size: 17px; }
.breakdown summary::-webkit-details-marker { display: none; }
.breakdown summary svg { width: 22px; height: 22px; }
.breakdown summary .chev { margin-left: auto; transition: transform .2s; }
.breakdown[open] summary .chev { transform: rotate(180deg); }
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 14px 0 10px; background: var(--surface-2); gap: 2px; }
.bar > div { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend span.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.t1 { background: var(--tier1); } .t2 { background: var(--tier2); } .t3 { background: var(--tier3); } .t4 { background: var(--tier4); } .t0 { background: var(--tier0); }

/* ===== 価格比較 ===== */
.totals { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.total-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.total-box .label { font-size: 12px; color: var(--muted); }
.total-box .value { font-size: 18px; font-weight: 800; }
.total-box .note { font-size: 11px; color: var(--muted); }
.total-box.best { background: var(--best-bg); border-color: transparent; }

.price-card { display: grid; grid-template-columns: 72px 1fr; gap: 12px; }
.price-card .thumb { width: 72px; border-radius: 4px; }
.store-prices { display: grid; gap: 4px 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: 6px; }
.store-price {
  display: flex; justify-content: space-between; gap: 8px; font-size: 14px;
  padding: 5px 10px; border-radius: 8px; background: var(--surface-2);
}
.store-price.best { background: var(--best-bg); font-weight: 700; }
.store-price .none { color: var(--muted); }
.store-price .detail { font-size: 11px; color: var(--muted); }

.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ===== ダイアログ・トースト ===== */
dialog {
  border: none; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog .dlg-body { padding: 16px; overflow: auto; max-height: calc(100vh - 130px); }
dialog .dlg-actions { padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); flex-wrap: wrap; }
dialog .big-img { width: 100%; max-width: 320px; display: block; margin: 0 auto 12px; border-radius: 4.75% / 3.5%; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  background: #1c2420; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; }
