:root {
  --bg: #14131a;
  --panel: #1d1c25;
  --panel-2: #262532;
  --line: #34323f;
  --text: #e9e6f0;
  --muted: #9a96a8;
  --gold: #d9b35b;
  --gold-dim: #8f7640;
  --good: #4fb37a;
  --warn: #e0a83a;
  --bad: #e0614a;
  --radius: 10px;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #2a2340 0%, transparent 60%), var(--bg);
  color: var(--text);
  display: flex; flex-direction: column;
  font-size: 14px;
}
a { color: var(--gold); }
button {
  font: inherit; color: inherit; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px;
}
button:hover { border-color: var(--gold-dim); }
button.primary { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 700; }
button.ghost { background: transparent; }
button.link { background: none; border: none; color: var(--gold); padding: 0 4px; text-decoration: underline; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-dim); outline-offset: 0; }
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; }
.spacer { flex: 1; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: rgba(20, 19, 26, .85); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { color: var(--gold); font-size: 18px; }
.brand-name { font-weight: 800; letter-spacing: .04em; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.deck-meta { display: flex; gap: 8px; flex: 1; min-width: 300px; }
.deck-name { flex: 1; min-width: 140px; font-weight: 700; }
.actions { display: flex; gap: 6px; }
.menu { position: relative; }
.menu-pop {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.45); z-index: 30;
}
.menu-pop.open { display: block; }
.menu-pop button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 8px 10px; }
.menu-pop button:hover { background: var(--panel-2); }
.menu-label { color: var(--muted); font-size: 11px; padding: 8px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; }
.saved-row { display: flex; align-items: center; }
.saved-row button:first-child { flex: 1; }
.saved-row .del { width: auto; color: var(--muted); }

/* ---- layout ---- */
.layout {
  flex: 1; display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(260px, 1fr) minmax(360px, 1.5fr) minmax(300px, 1.1fr);
  min-height: 0;
}
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr 1fr; } .search-panel { grid-column: 1 / -1; } }
@media (max-width: 720px) { .layout { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; overflow: auto; min-height: 0; max-height: calc(100vh - 120px);
}
.panel h2 { font-size: 13px; letter-spacing: .08em; color: var(--gold); margin: 6px 0 10px; text-transform: uppercase; }
.panel h2 + h2, .panel > div + h2, .panel > ul + h2 { margin-top: 20px; }

/* ---- search ---- */
.search-box { position: relative; }
.search-row { display: flex; gap: 6px; }
.search-row input { flex: 1; min-width: 0; }
.only-touch { display: none; }
.menu-pop .mobile-new { display: none; }
.tabbar, .zoom-actions { display: none; }
.r-add { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; opacity: 0; transition: opacity .12s; }
.result:hover .r-add { opacity: 1; }
.r-add button { padding: 2px 6px; font-size: 11px; background: rgba(20,19,26,.85); }
.autocomplete {
  list-style: none; margin: 4px 0 0; padding: 4px; position: absolute; left: 0; right: 0; z-index: 10;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; max-height: 260px; overflow: auto;
}
.autocomplete:empty { display: none; }
.autocomplete li { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.autocomplete li:hover, .autocomplete li.active { background: var(--line); }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 8px; }
.result {
  position: relative; border-radius: 6px; overflow: hidden; cursor: pointer; border: 1px solid transparent;
  background: var(--panel-2); aspect-ratio: 488 / 680;
}
.result:hover { border-color: var(--gold); transform: translateY(-1px); }
.result img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result .noimg { padding: 8px; font-size: 12px; }
.result .r-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 11px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
}

/* ---- deck ---- */
.deck-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.deck-head h2 { margin: 6px 0; }
.count { color: var(--text); font-size: 15px; margin-left: 6px; }
.count.side { color: var(--muted); font-size: 12px; }
.count-sep { color: var(--muted); margin: 0 4px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; border-radius: 0; background: transparent; padding: 4px 10px; font-size: 12px; }
.seg-btn.active { background: var(--gold); color: #1a1408; font-weight: 700; }
.group { margin-bottom: 10px; }
.group-head {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700;
  padding: 4px 0; border-bottom: 1px solid var(--line); margin-bottom: 2px;
}
.group-head .dot { width: 10px; height: 10px; border-radius: 50%; }
.group-head .n { color: var(--muted); font-weight: 400; }
.row {
  display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 8px;
  padding: 3px 4px; border-radius: 6px;
}
.row:hover { background: var(--panel-2); }
.row.missing .name { color: var(--bad); text-decoration: underline wavy; }
.qty { display: flex; align-items: center; gap: 2px; }
.qty button { padding: 0 6px; line-height: 20px; border-radius: 5px; font-size: 13px; }
.qty span { min-width: 18px; text-align: center; font-weight: 700; }
.name { cursor: default; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name small { color: var(--muted); margin-left: 6px; }
.meta { display: flex; align-items: center; gap: 6px; }
.mana { display: inline-flex; gap: 1px; }
.mana img { width: 14px; height: 14px; }
.chips { display: flex; gap: 3px; cursor: pointer; }
.chip {
  font-size: 10px; padding: 1px 6px; border-radius: 999px; color: #fff; white-space: nowrap;
  opacity: .9; border: 1px solid rgba(255,255,255,.15);
}
.chip.manual { box-shadow: 0 0 0 1px var(--gold); }
.move { font-size: 11px; padding: 0 6px; color: var(--muted); }
.side-title { font-size: 12px; color: var(--muted); margin: 16px 0 4px; letter-spacing: .08em; }
.empty { color: var(--muted); padding: 20px 4px; text-align: center; font-size: 13px; }

/* ---- role popover ---- */
.role-pop {
  position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 10px; width: 220px; box-shadow: 0 14px 32px rgba(0,0,0,.5);
}
.role-pop h4 { margin: 0 0 6px; font-size: 13px; }
.role-pop label { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; cursor: pointer; }
.role-pop .sw { width: 10px; height: 10px; border-radius: 3px; }
.role-pop .pop-actions { display: flex; justify-content: space-between; margin-top: 8px; }
.role-pop .pop-actions button { font-size: 12px; padding: 4px 8px; }
.role-pop .pop-now { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line, rgba(255,255,255,.12)); font-size: 12px; }
/* チップが2段以上に折り返しても重ならないよう、行の間隔をとる */
.role-pop .pop-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.role-pop .pop-now .chip { margin: 0; display: inline-flex; align-items: center; line-height: 1.3; }
.role-pop .pop-now .chip.cat { font-weight: 700; }
.role-pop .pop-manual { margin-left: 6px; color: var(--gold); }
.role-pop .pop-edit { margin-top: 8px; font-size: 12px; }
.role-pop .pop-edit > summary { cursor: pointer; color: var(--muted); padding: 2px 0; list-style: none; }
.role-pop .pop-edit > summary::-webkit-details-marker { display: none; }
.role-pop .pop-edit > summary::before { content: '▸ '; }
.role-pop .pop-edit[open] > summary::before { content: '▾ '; }
.role-pop .pop-edit[open] > summary { margin-bottom: 4px; }
.role-pop .pop-reset { margin-top: 8px; }
.role-pop .pop-reset button { font-size: 12px; padding: 4px 8px; }

/* ---- analysis ---- */
.role-bars { display: flex; flex-direction: column; gap: 6px; }
.rb { display: grid; grid-template-columns: 96px 1fr 70px; align-items: center; gap: 8px; font-size: 12px; }
.rb-track { position: relative; height: 14px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.rb-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.rb-target { position: absolute; top: 0; bottom: 0; background: rgba(217,179,91,.18); border-left: 1px dashed var(--gold); border-right: 1px dashed var(--gold); }
.rb-val { text-align: right; font-variant-numeric: tabular-nums; }
.rb-val .t { color: var(--muted); }
.stack { display: flex; height: 18px; border-radius: 5px; overflow: hidden; margin-bottom: 10px; }
.stack div { height: 100%; }
.curve { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 14px; }
.cbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.cbar .b { width: 100%; background: linear-gradient(var(--gold), var(--gold-dim)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.cbar .v { font-size: 11px; margin-bottom: 2px; }
.cbar .l { font-size: 11px; color: var(--muted); margin-top: 4px; }
.colors { display: flex; flex-direction: column; gap: 6px; }
.crow { display: grid; grid-template-columns: 22px 1fr 1fr; gap: 8px; align-items: center; font-size: 12px; }
.crow img { width: 18px; height: 18px; }
.cbarh { height: 10px; background: var(--panel-2); border-radius: 3px; position: relative; }
.cbarh div { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.cbarh span { position: absolute; right: 4px; top: -15px; font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.advice { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.advice li { padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.5; border-left: 3px solid; background: var(--panel-2); }
.advice li.good { border-color: var(--good); }
.advice li.warn { border-color: var(--warn); }
.advice li.bad { border-color: var(--bad); }
.advice li.info { border-color: var(--gold); }
.advice li.adv-head { background: none; border: none; padding: 8px 2px 0; font-size: 12px; color: var(--gold); font-weight: 700; }
.advice li.adv-head:first-child { padding-top: 0; }
.advice li.adv-extra { background: none; border: none; padding: 8px 0 0; }
.advice li.adv-extra summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.advice li.adv-extra .advice { margin-top: 6px; }
.advice li.adv-extra .advice li { color: var(--muted); }
.key-btn { background: none; border: none; padding: 0 4px; color: var(--muted); font-size: 15px; line-height: 1; }
.key-btn.on { color: var(--gold); }

/* ---- 上位デッキとの比較 ---- */
.meta-controls { display: flex; gap: 6px; margin-bottom: 8px; }
.meta-controls select { flex: 1; min-width: 0; }
.meta-info { font-size: 13px; }
.meta-detect, .meta-group { margin: 4px 0; line-height: 1.5; }
.warn-text { color: var(--warn); }
.meta-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.meta-table th { text-align: left; color: var(--muted); font-weight: 400; border-bottom: 1px solid var(--line); padding: 3px 4px; }
.meta-table td { padding: 4px; border-bottom: 1px solid var(--line); }
.meta-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meta-table tr.low td:nth-child(2) { color: var(--bad); font-weight: 700; }
.mana-sim { margin-top: 10px; }
.mana-sim h3 { font-size: 12px; color: var(--muted); font-weight: 400; margin: 10px 0 2px; }
.mana-sim .sim-table th, .mana-sim .sim-table td { text-align: right; font-variant-numeric: tabular-nums; }
.mana-sim .sim-table th:first-child, .mana-sim .sim-table td:first-child { text-align: left; white-space: nowrap; }
.mana-sim .sim-scroll { overflow-x: auto; }
.mana-sim .key-table td:first-child { white-space: normal; min-width: 7em; }
.mana-sim .sim-table td, .mana-sim .sim-table th { padding: 4px 3px; }
.mana-sim .big { font-size: 15px; font-weight: 700; color: var(--gold); }
.meta-table tr.high td:nth-child(2) { color: var(--warn); font-weight: 700; }
.meta-table tr.near td:nth-child(2) { color: var(--gold); }
.meta-table tr.ok td:nth-child(2) { color: var(--good); }
.meta-keys summary { cursor: pointer; color: var(--gold); font-size: 12px; padding: 4px 0; }
.meta-keys ul { list-style: none; margin: 4px 0; padding: 0; }
.meta-keys li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.meta-keys .kc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-keys .kc-roles { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 3px; }

/* ---- misc ---- */
.statusbar {
  display: flex; align-items: center; gap: 12px; padding: 6px 16px; border-top: 1px solid var(--line);
  font-size: 12px; background: var(--panel);
}
.preview { position: fixed; z-index: 60; pointer-events: none; }
.preview img { width: 244px; border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.6); display: block; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(640px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-body { padding: 16px 18px; }
.dialog-body h3 { margin: 0 0 4px; }
.dialog-body textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
/* ---- タップ拡大 ---- */
.zoom {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.82);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px;
}
.zoom[hidden] { display: none; }
.zoom img { width: min(86vw, 360px); border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.zoom-actions { display: flex; gap: 8px; }
.zoom-actions button { min-height: 44px; padding: 0 16px; font-size: 15px; }

/* ---- タッチ端末 ---- */
@media (hover: none) {
  .only-touch { display: block; }
  .only-desktop { display: none; }
  .r-add { opacity: 1; position: static; padding: 4px; background: var(--panel-2); justify-content: stretch; }
  .r-add button { flex: 1; min-height: 34px; font-size: 12px; padding: 0 2px; white-space: nowrap; background: var(--panel); }
  .result { aspect-ratio: auto; display: flex; flex-direction: column; }
  .result img { aspect-ratio: 488 / 680; height: auto; }
  .result .r-name { position: static; background: none; padding: 4px 6px 0; }
  .result:hover { transform: none; }
  .preview { display: none !important; }
  .name { cursor: pointer; }
}

/* ---- スマホ幅 ---- */
@media (max-width: 720px) {
  /* 下に固定したタブバー（52px）＋ステータスバー（約28px）＋ゆとり16px の分だけ余白を空ける */
  /* body の高さを画面に固定していると下の余白がスクロール範囲に入らないので、内容に合わせて伸びるようにする */
  html, body { height: auto; min-height: 100%; }
  body { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; } /* iOSの自動ズーム防止 */
  /* backdrop-filter があると fixed の基準がヘッダーになるので外す */
  .topbar { gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); backdrop-filter: none; background: var(--bg); }
  .brand-sub { display: none; }
  .deck-meta { min-width: 0; flex: 1 1 100%; flex-wrap: wrap; order: 3; }
  .deck-name { flex-basis: 100%; }
  .deck-meta select { flex: 1; min-width: 0; }
  .actions { margin-left: auto; }
  .actions button { white-space: nowrap; padding: 6px 9px; }
  #btnNew { display: none; }
  .menu-pop { position: fixed; left: 10px; right: 10px; top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); min-width: 0; max-height: 60vh; overflow: auto; }
  .menu-pop button { min-height: 44px; }
  .menu-pop .mobile-new { display: block; }

  .layout { display: block; padding: 8px; }
  .panel { display: none; max-height: none; overflow: visible; border-radius: 12px; padding-bottom: 20px; }
  .panel.active { display: block; }

  .row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "qty name" "meta meta"; row-gap: 4px; padding: 6px 2px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .row .qty { grid-area: qty; }
  .row .name { grid-area: name; white-space: normal; }
  .row .meta { grid-area: meta; flex-wrap: wrap; padding-left: 2px; }
  .qty button { min-width: 34px; min-height: 34px; font-size: 16px; }
  .chips { flex-wrap: wrap; }
  .chip { font-size: 11px; padding: 3px 8px; }
  .move { min-height: 30px; margin-left: auto; }
  .rb { grid-template-columns: 78px minmax(0, 1fr) 64px; }
  .results { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  .role-pop { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .role-pop label { padding: 8px 0; font-size: 15px; }
  .role-pop .pop-actions button, .role-pop .pop-reset button { min-height: 44px; padding: 0 16px; font-size: 14px; }
  .role-pop .pop-edit > summary { min-height: 36px; display: flex; align-items: center; }

  .statusbar { position: fixed; left: 0; right: 0; bottom: calc(52px + env(safe-area-inset-bottom)); padding: 4px 10px; font-size: 11px; z-index: 15; }
  .statusbar #apiStats, .statusbar .muted:last-child { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button { flex: 1; height: 52px; border: none; border-radius: 0; background: none; color: var(--muted); font-size: 14px; }
  .tabbar button.active { color: var(--gold); font-weight: 700; box-shadow: inset 0 2px 0 var(--gold); }
  .badge { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 11px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .dialog-body textarea { height: 40vh; }
}

.toast {
  position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--panel-2); border: 1px solid var(--gold-dim); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 80vw;
}

/* ---- 効果タグ ---- */
.tag-list { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.tag { display: flex; gap: 6px; align-items: baseline; }
.tag-kind { font-size: 10px; padding: 0 6px; border-radius: 999px; white-space: nowrap; }
.tag.rep .tag-kind { background: #c4569a; color: #fff; }
.tag.once .tag-kind { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
/* 能力の種類（呪文・起動型・誘発型・常在型） */
.tag.k-spell .tag-kind { background: #5a6fd6; color: #fff; }
.tag.k-activated .tag-kind { background: #c08a2e; color: #fff; }
.tag.k-triggered .tag-kind { background: #c4569a; color: #fff; }
.tag.k-static .tag-kind { background: #2f8f8f; color: #fff; }
.tag.k-fast .tag-kind { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.role-pop { max-height: 80vh; overflow: auto; }

/* ---- 大カテゴリ／小カテゴリ ---- */
.cat-detail { border-bottom: 1px solid var(--line); padding: 3px 0; }
.cat-detail > summary { list-style: none; cursor: pointer; }
.cat-detail > summary::-webkit-details-marker { display: none; }
.cat-detail > summary .rb > span:first-child::before { content: '▸ '; color: var(--muted); }
.cat-detail[open] > summary .rb > span:first-child::before { content: '▾ '; }
.rb.sub { padding-left: 14px; opacity: .9; font-size: 11px; }
.rb.sub .rb-track { height: 9px; }
.meta-table tr.cat td { border-top: 1px solid var(--line); }
.meta-table tr.sub td:first-child { padding-left: 14px; color: var(--muted); }
.pop-cat { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pop-cat select { width: 100%; }
.pop-note { font-size: 11px; margin-bottom: 6px; }
.pop-group { margin-top: 6px; }
.pop-group-head { font-size: 11px; font-weight: 700; margin-bottom: 2px; }
.role-pop { width: 260px; }
.chip.cat-chip { font-weight: 700; }
.role-pop .pop-cat { align-items: stretch; }
.tag-detail { font-size: 11px; color: var(--muted); margin-top: 1px; }
.tag > span:last-child { display: flex; flex-direction: column; }

/* ---- コンボ ---- */
.combo-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.combo-list li { padding: 8px 10px; background: var(--panel-2); border-radius: 8px; }
.combo-ok { color: var(--good); font-weight: 700; margin-left: 4px; }
.combo-miss { color: var(--warn); margin-left: 4px; font-size: 12px; }
.meta-table tr.c-low td:last-child { color: var(--bad); font-weight: 700; }
.meta-table tr.c-near td:last-child { color: var(--warn); }
.meta-table tr.c-ok td:last-child { color: var(--good); }

/* 変身後（手札から唱えられない面）の役割・タグ */
.chip.back { background: transparent !important; border: 1px dashed var(--muted); color: var(--muted); }
.tag.back { opacity: .6; }

/* 上位デッキへの対策 */
.match-box .mu { border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 12px; }
.match-box .mu-head { display: flex; gap: 8px; align-items: baseline; }
.match-box .mu-threats { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.match-box .mu-t { border-radius: 6px; padding: 2px 6px; background: var(--panel-2); border-left: 3px solid var(--good); }
.match-box .mu-t.c-near { border-color: var(--warn); }
.match-box .mu-t.c-low { border-color: var(--bad); }
.match-box details.mu > summary { list-style: none; cursor: pointer; }
.match-box details.mu > summary::-webkit-details-marker { display: none; }
.match-box .mu-toggle { margin-left: auto; font-size: 11px; }
.match-box .mu-toggle::after { content: '対処札を見る ▾'; }
.match-box details.mu[open] .mu-toggle::after { content: '閉じる ▴'; }
.match-box .mu-body { margin-top: 6px; padding: 8px; background: var(--panel-2); border-radius: 8px; line-height: 1.6; }
.match-box .mu-sub { margin-top: 6px; color: var(--gold); font-size: 11px; }
.match-box .mu-list { margin: 2px 0 0; padding-left: 1.2em; }
.match-box .bad-t { color: var(--bad); }
.bd-row { font-size: 12px; line-height: 1.6; margin: 2px 0; }
.bd-more summary { font-size: 12px; cursor: pointer; color: var(--text); }

/* ---------- ウェブマップ ---------- */
.map-wrap { display: flex; flex-direction: column; gap: 6px; }
.map-tools { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.map-type { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.map-type.none { opacity: .4; cursor: default; }
.map-sw { display: inline-block; width: 16px; height: 4px; border-radius: 2px; }
.map-reset { font-size: 12px; padding: 3px 10px; }
.map-btns { display: flex; gap: 6px; align-items: center; }
.map-node.img .map-card-bg { fill: #111; }
.map-node.img .map-bar { fill: rgba(10, 12, 18, .88); }
.map-node.img .map-bar-text { font-size: 10px; fill: var(--text); }
.map-node.img .map-badge { fill: rgba(10, 12, 18, .82); }
.map-node.img .map-qty { font-size: 11px; }
.map-node.img .map-star { font-size: 10px; fill: var(--gold); }
.map-node image { pointer-events: none; }
.map-svg { -webkit-touch-callout: none; width: 100%; height: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; user-select: none; -webkit-user-select: none; }
.map-edge { fill: none; stroke-width: 1.8; opacity: .75; transition: opacity .12s; }
.map-node { cursor: grab; touch-action: none; transition: opacity .12s; }
.map-node:active { cursor: grabbing; }
.map-node text { fill: var(--text); font-size: 12px; pointer-events: none; }
.map-node .map-qty { fill: var(--gold); font-weight: 700; }
.map-note { fill: var(--muted); font-size: 11px; }
.map-svg.focus .map-edge { opacity: .08; }
.map-svg.focus .map-edge.on { opacity: 1; stroke-width: 2.6; }
.map-svg.focus .map-node { opacity: .3; }
.map-svg.focus .map-node.on { opacity: 1; }
.map-list { font-size: 12px; }
.map-list summary { cursor: pointer; color: var(--muted); }
.map-list-group { margin: 6px 0 0 4px; display: flex; flex-direction: column; gap: 2px; }
.map-list-head { font-weight: 700; }
@media (pointer: coarse) { .map-type { padding: 4px 0; } .map-reset { padding: 6px 12px; } }
.legal-warn { border: 1px solid var(--warn); border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13px; color: var(--warn); }
.legal-warn .hint { margin: 4px 0 0; }
