/* M75 ACE CARDS — 視覺規範（依 E:\tmp\ace-ui-mock\ace.css）
   原則：紙底、墨線、1px 細線分層；顏色只有 9 個 token；圓角一個值；不用陰影、漸層、發光。
   結構：1 變數與基底 · 2 按鈕與表單 · 3 頂端列 · 4 卡面元件 · 5 一般頁面（大廳、規則、檢視）· 6 對戰 · 7 彈窗 · 8 組牌器共用提示*/

/* ── 1. 變數與基底 ───────────────────────── */
:root {
  --paper: #E6DFCC;   /* 頁面底色 */
  --card: #F3EEE1;    /* 卡面、輸入框、可操作面的底 */
  --plate: #D8CFB6;   /* 整頁唯一的色塊：戰場圖板、照片底 */
  --ink: #20231B;     /* 主文字、卡框、主要按鈕底 */
  --ink2: #55534A;    /* 次要文字、標籤 */
  --rule: #A49D87;    /* 1px 分隔線、停用狀態 */
  --blue: #24486C;    /* 我方 */
  --red: #9A2E1D;     /* 敵方、傷害、危險操作 */
  --ochre: #9A680C;   /* 目前選取、輪到你、焦點 */

  --r: 2px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --t11: 11px; --t13: 13px; --t15: 15px; --t18: 18px; --t24: 24px; --t32: 32px;

  --sans: "Barlow Semi Condensed", "Noto Sans TC", "Noto Sans JP", "Microsoft JhengHei", sans-serif;
  --k: 1;             /* 卡片縮放：手機 1、桌機 1.32 */
  --cw: 74px; --ch: 122px;
  --nav-h: 48px;
}
html:lang(ja) { --sans: "Barlow Semi Condensed", "Noto Sans JP", "Noto Sans TC", "Yu Gothic", sans-serif; }
@media (min-width: 1024px) { :root { --k: 1.3; --cw: 98px; --ch: 156px; --nav-h: 52px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 400 var(--t15)/1.45 var(--sans);
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ol, ul, dl { margin: 0; }
button, input, select, summary { font: inherit; color: inherit; }
img { display: block; }
table { border-collapse: collapse; }
:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.lbl { font-size: var(--t11); font-weight: 600; color: var(--ink2); letter-spacing: .04em; }
.mut { color: var(--ink2); }
.hostile { color: var(--red); }
.friendly { color: var(--blue); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ac-ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.ac-main { min-height: calc(100vh - var(--nav-h)); }
.ac-view { display: none; }
.ac-view.is-active { display: block; }

/* ── 2. 按鈕與表單 ───────────────────────── */
.btn {
  min-height: 44px; padding: 0 var(--s4);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  border: 1px solid var(--ink); border-radius: var(--r);
  background: transparent; color: var(--ink);
  font: 600 var(--t15)/1 var(--sans); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--card); }
.btn:active { background: var(--plate); }
.btn-p { background: var(--ink); color: var(--card); }
.btn-p:hover { background: #393D2F; }
.btn-p:active { background: #000; }
.btn-d { border-color: var(--red); color: var(--red); }
.btn-d:hover { background: var(--card); }
.btn-d.fill { background: var(--red); color: var(--card); }
.btn[disabled] { border-color: var(--rule); color: #7F7967; background: transparent; cursor: default; }
.btn-p[disabled] { background: var(--rule); color: var(--paper); }
.btn-sm { min-height: 40px; padding: 0 var(--s3); font-size: var(--t13); }
.btn-txt { border-color: transparent; padding: 0 var(--s2); }
.btn-txt:hover { background: transparent; text-decoration: underline; }

.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: var(--r); }
.seg > button { white-space: nowrap; min-height: 40px; min-width: 44px; padding: 0 var(--s3); display: flex; align-items: center; justify-content: center; border: 0; background: transparent; font-size: var(--t13); font-weight: 600; cursor: pointer; }
.seg > button + button { border-left: 1px solid var(--ink); }
.seg > .is-active { background: var(--ink); color: var(--card); }

.field, .ac-input, .ac-select {
  min-height: 44px; border: 1px solid var(--ink); border-radius: var(--r); background: var(--card);
  padding: 0 var(--s3); font-size: var(--t15); color: var(--ink);
}
.ac-input::placeholder { color: var(--ink2); }
.ac-select { padding-right: var(--s2); }

/* ── 3. 頂端列 ───────────────────────────── */
.ac-topbar { position: sticky; top: 0; z-index: 20; background: var(--paper); }
.nav { height: var(--nav-h); display: flex; align-items: center; gap: var(--s5); padding: 0 var(--s5); border-bottom: 1px solid var(--ink); background: var(--paper); }
.nav a { color: inherit; text-decoration: none; }
.brand { font-weight: 700; letter-spacing: .08em; font-size: var(--t15); white-space: nowrap; }
.tabs { display: flex; gap: var(--s1); height: 100%; }
.tabs button { display: flex; align-items: center; padding: 0 var(--s3); border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: transparent; color: var(--ink2); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.is-active { color: var(--ink); border-bottom-color: var(--ink); }
.nav .end { margin-left: auto; display: flex; align-items: center; gap: var(--s3); flex: none; }
@media (min-width: 1024px) and (max-width: 1279px) { .nav { gap: var(--s3); padding: 0 var(--s4); } .brand { display: none; } .tabs button { padding: 0 var(--s2); } } /* 1024 寬：品牌字樣讓位，日文分頁與語言鈕才排得下 */

.ac-vol { position: relative; }
.ac-vol > summary { list-style: none; cursor: pointer; }
.ac-vol > summary::-webkit-details-marker { display: none; }
.ac-vol-panel { position: absolute; right: 0; top: calc(100% + 4px); width: 240px; z-index: 30; background: var(--card); border: 1px solid var(--ink); border-radius: var(--r); padding: var(--s3); display: grid; gap: var(--s2); }
.ac-vol-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: var(--s2); font-size: var(--t13); font-weight: 600; min-height: 40px; }
.ac-vol-row input { width: 100%; accent-color: var(--ink); }

.mbar { display: none; height: var(--nav-h); align-items: center; border-bottom: 1px solid var(--ink); padding-right: 2px; background: var(--paper); }
.mbar .ib { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--ink); }
.mbar .ttl { flex: 1; min-width: 0; font-weight: 700; font-size: var(--t15); line-height: 1.15; }
.mbar .ttl small { display: block; font-size: var(--t11); color: var(--ink2); font-weight: 600; }
.mbar .ttl span { display: block; overflow: hidden; white-space: nowrap; }

@media (max-width: 1023px) {
  .mbar { display: flex; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: var(--nav-h); height: auto; flex-direction: column; align-items: stretch; gap: 0; padding: 0 var(--s4) var(--s3); }
  .is-menu-open .nav { display: flex; }
  .nav .ac-home, .nav .brand { display: none; }
  .tabs { flex-direction: column; height: auto; gap: 0; }
  .tabs button { min-height: 44px; margin: 0; border-bottom: 1px solid var(--rule); border-left: 3px solid transparent; }
  .tabs button.is-active { border-bottom-color: var(--rule); border-left-color: var(--ochre); }
  .nav .end { margin: var(--s3) 0 0; flex-wrap: wrap; }
  .ac-vol-panel { right: auto; left: 0; }
}

/* ── 4. 卡面元件 ─────────────────────────── */
.c { position: relative; display: flex; flex-direction: column; background: var(--card); color: var(--ink); border: 1px solid var(--ink); border-radius: var(--r); overflow: hidden; text-align: left; flex: none; font-family: inherit; padding: 0; }
.c > * { flex: none; }
.c.own { border-top: 3px solid var(--blue); }
.c.enemy { border-top: 3px solid var(--red); }
.c-img { position: relative; background: var(--plate); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.c-img img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.72) sepia(.12) contrast(1.03); }
.c-img.fit img { object-fit: contain; }
.c-img.line { background: var(--card); display: flex; align-items: center; justify-content: center; }
.c-img.line svg { width: 92%; height: auto; }
.wl { stroke: var(--ink); stroke-width: 1.1; fill: var(--card); stroke-linejoin: round; }
.wl .c2 { fill: none; }
.cls { display: inline-block; border: 1px solid var(--ink); border-radius: var(--r); padding: 0 3px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.rdr { flex: none; stroke: var(--ink); fill: none; stroke-width: 1.5; stroke-linecap: round; }
.cost { flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--ink); color: var(--card); font-weight: 700; border-radius: var(--r); }
.cost.no { background: transparent; color: var(--ink2); box-shadow: inset 0 0 0 1px var(--rule); }

/* 小卡（手牌／場上） */
.c-sm { width: var(--cw); height: var(--ch); font-size: calc(11px * var(--k)); line-height: 1.2; cursor: pointer; }
.c-sm .hd { display: flex; align-items: center; gap: calc(3px * var(--k)); height: calc(18px * var(--k)); padding: 0 calc(3px * var(--k)); }
.c-sm .hd .cls { font-size: calc(11px * var(--k)); }
.c-sm .hd .op { margin-left: auto; font-weight: 600; white-space: nowrap; }
.c-sm .hd .cost { min-width: calc(18px * var(--k)); height: calc(16px * var(--k)); font-size: calc(14px * var(--k)); }
.c-sm .c-img { height: calc(42px * var(--k)); }
.c-sm .nm { padding: calc(2px * var(--k)) calc(3px * var(--k)) 0; font-weight: 600; font-size: calc(12px * var(--k)); white-space: nowrap; overflow: hidden; }
.c-sm .kw { padding: 0 calc(3px * var(--k)); white-space: nowrap; overflow: hidden; color: var(--ink2); font-weight: 600; }
.c-sm .kw .g { background: var(--ink); color: var(--card); padding: 0 2px; border-radius: var(--r); }
.c-sm .kw s { opacity: .6; }
.c-sm .kw .warn { color: var(--red); }
.c-img .tag { position: absolute; left: 0; top: 0; background: var(--ink); color: var(--card); font-weight: 600; padding: 0 3px; line-height: 1.35; }
.c-img .ldp { position: absolute; right: 0; bottom: 0; display: flex; gap: 2px; padding: 2px 3px; background: var(--card); border-top: 1px solid var(--ink); border-left: 1px solid var(--ink); }
.c-img .ldp i { width: calc(7px * var(--k)); height: calc(7px * var(--k)); border: 1px solid var(--ink); }
.c-img .ldp i.on { background: var(--ink); }
.ft { margin-top: auto; display: flex; border-top: 1px solid var(--rule); height: calc(22px * var(--k)); }
.ft > span { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 2px; padding-top: calc(2px * var(--k)); }
.ft > span + span { border-left: 1px solid var(--rule); }
.ft b { font-weight: 500; color: var(--ink2); font-size: calc(11px * var(--k)); }
.ft i { font-style: normal; font-weight: 700; font-size: calc(17px * var(--k)); line-height: 1; }
.ft i.dmg { color: var(--red); }
.ft i.buf { color: var(--blue); }
.c-sm.txt .nm { white-space: normal; line-height: 1.2; padding-top: calc(4px * var(--k)); }
.c-sm.txt .tg { margin-top: auto; padding: 0 calc(3px * var(--k)) calc(2px * var(--k)); color: var(--ink2); font-weight: 600; }
.c-sm.txt .typ { padding: calc(3px * var(--k)); border-top: 1px solid var(--rule); font-weight: 600; color: var(--ink2); }
.c-sm.cm .hd { background: var(--ink); color: var(--card); }
.c-sm.cm .hd .cost { background: var(--card); color: var(--ink); }
.c-sm.cm .hd .cost.no { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 1px var(--paper); }

/* 有照片的指令／反制卡（.pic）：小卡的費用方塊疊在照片左上角，文字區才放得下；中卡照片縮短、內文改 4 行 */
.c-sm.txt.pic .hd { position: absolute; left: 0; top: 0; z-index: 1; height: auto; padding: 2px; background: none; }
.c-sm.txt.pic .c-img { height: calc(34px * var(--k)); border-top: 0; }
.c-sm.txt.pic .nm { padding-top: calc(2px * var(--k)); }
.c-md.txt.pic .c-img { height: 60px; }
.c-md.txt.pic .tx { -webkit-line-clamp: 4; padding-top: 5px; }
.c-md.txt.pic .trg { margin-top: 4px; padding-bottom: 3px; }
.cr { margin-top: 10px; font-size: var(--t11); line-height: 1.45; color: var(--ink2); overflow-wrap: anywhere; }
.cr a { color: inherit; text-decoration: underline; }

/* 場上狀態 */
.c.sel { outline: 3px solid var(--ochre); outline-offset: 1px; }
.c.tgt { outline: 2px solid var(--red); outline-offset: 1px; }
.c.na { opacity: .42; }
.c.spent .c-img img { opacity: .45; }
.fc { position: absolute; left: 0; right: 0; bottom: 0; height: calc(22px * var(--k)); display: flex; align-items: center; justify-content: center; gap: 4px; background: var(--red); color: var(--card); font-weight: 700; font-size: calc(13px * var(--k)); z-index: 2; }
.fc.self { background: var(--ink); }

/* 中卡（卡池、換牌） */
.c-md { width: 164px; height: 250px; font-size: var(--t13); line-height: 1.3; }
.c-md .hd { display: flex; gap: var(--s2); padding: 6px 6px 4px; min-height: 50px; }
.c-md .hd .cost { width: 26px; height: 26px; font-size: 17px; }
.c-md .hd .nm { font-weight: 600; font-size: var(--t15); line-height: 1.15; }
.c-md .hd .sub { font-size: var(--t11); color: var(--ink2); font-weight: 600; margin-top: 2px; }
.c-md .c-img { height: 74px; }
.c-md .mk { display: flex; align-items: center; gap: 6px; padding: 5px 6px 0; font-size: var(--t11); font-weight: 600; color: var(--ink2); }
.c-md .mk .cls { color: var(--ink); }
.c-md .tx { padding: 4px 6px 0; font-size: 12px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.c-md .ft { height: 30px; }
.c-md .ft i { font-size: 19px; }
.c-md .ft b { font-size: var(--t11); }
.c-md.txt .tx { -webkit-line-clamp: 7; font-size: var(--t13); padding-top: 8px; }
.c-md.txt .trg { margin: 6px 6px 0; padding: 0 0 5px; border-bottom: 1px solid var(--rule); font-size: 12px; font-weight: 600; }
.c-md.cm .hd { background: var(--ink); color: var(--card); }
.c-md.cm .hd .sub { color: var(--plate); }
.c-md.cm .hd .cost { background: var(--card); color: var(--ink); }
.ft-t > span { justify-content: flex-start; align-items: center; padding: 0 6px; font-weight: 600; font-size: 12px; gap: 6px; }
.c-md .cnt { position: absolute; right: 0; bottom: 30px; background: var(--ink); color: var(--card); font-weight: 700; font-size: var(--t13); padding: 1px 6px; }

/* 大卡（檢視） */
.c-lg { width: 100%; max-width: 380px; font-size: var(--t15); }
.c-lg .hd { display: flex; gap: var(--s3); padding: var(--s3); }
.c-lg .hd .cost { width: 36px; height: 36px; font-size: 22px; }
.c-lg .hd h2 { font-size: var(--t24); line-height: 1.1; font-weight: 700; }
.c-lg .hd .sub { font-size: var(--t13); color: var(--ink2); font-weight: 600; margin-top: 3px; }
.c-lg .c-img { height: 190px; }
.c-lg.cm .hd { background: var(--ink); color: var(--card); }
.c-lg.cm .hd .sub { color: var(--plate); }
.c-lg.cm .hd .cost { background: var(--card); color: var(--ink); }
.sg { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--ink); }
.sg > div { padding: 6px var(--s3) 8px; border-left: 1px solid var(--rule); }
.sg > div:first-child { border-left: 0; }
.c-lg > .hd + .sg { border-top: 1px solid var(--ink); }
.sg b { display: block; font-size: var(--t11); color: var(--ink2); font-weight: 600; }
.sg i { font-style: normal; font-weight: 700; font-size: 26px; line-height: 1.05; }
.sg i small { font-size: var(--t15); font-weight: 600; }
.sec { padding: var(--s3); border-bottom: 1px solid var(--rule); }
.sec:last-child { border-bottom: 0; }
.sec h4 { font-size: var(--t11); font-weight: 700; color: var(--ink2); letter-spacing: .04em; margin-bottom: 4px; }
.sec p.trg { font-weight: 600; margin-bottom: 4px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px var(--s3); font-size: var(--t13); }
dl.kv dt { color: var(--ink2); }
dl.kv dd { margin: 0; font-weight: 600; }
dl.kwd { margin-top: var(--s2); font-size: var(--t13); }
dl.kwd dt { font-weight: 700; display: inline; }
dl.kwd dt .rdr { vertical-align: -2px; }
dl.kwd dd { display: inline; margin: 0 0 0 var(--s2); }
dl.kwd div + div { margin-top: 4px; }

/* 檢視區整包：大卡＋可掛武器＋規格＋連結 */
.cview { display: grid; gap: var(--s4); align-content: start; }
.cview .cx { display: grid; gap: 0; }
.cview .cx .sec { padding-left: 0; padding-right: 0; }
.cview .cx .sec:first-child { padding-top: 0; }
.cview .cl { font-size: var(--t13); line-height: 1.7; }
.tscroll { overflow-x: auto; }
table.ld { width: 100%; font-size: var(--t13); }
table.ld th { text-align: left; font-size: var(--t11); color: var(--ink2); font-weight: 600; padding: 3px 4px; border-bottom: 1px solid var(--ink); white-space: nowrap; }
table.ld td { padding: 5px 4px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.ld td.n, table.ld th.n { text-align: right; font-weight: 700; }
table.ld th.n { font-weight: 600; }
table.ld .wpn { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 130px; }
table.ld .wpn svg { width: 48px; height: 12px; flex: none; }
.lnk { display: inline-flex; align-items: center; gap: var(--s1); min-height: 44px; font-weight: 700; color: var(--ink); text-decoration: underline; }

/* ── 5. 一般頁面（大廳、規則速查、檢視） ───────── */
.page { max-width: 1360px; margin: 0 auto; padding: var(--s5); }
.ph { display: flex; align-items: baseline; gap: var(--s3); border-bottom: 1px solid var(--ink); padding-bottom: var(--s2); margin-bottom: var(--s4); }
.ph h1 { font-size: var(--t24); font-weight: 700; line-height: 1.15; }
.ph .mut { font-size: var(--t13); }
@media (max-width: 1023px) { .page { padding: var(--s4); } .ph { display: none; } }
h2.sh { font-size: var(--t11); font-weight: 700; color: var(--ink2); letter-spacing: .04em; border-bottom: 1px solid var(--ink); padding-bottom: 4px; margin: 0; }
h2.sh.gap { margin-top: var(--s5); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-bottom: 1px solid var(--rule); min-height: 44px; }
.rows > li > label { display: grid; grid-template-columns: 22px 1fr auto; column-gap: var(--s2); align-items: start; padding: 10px 0; cursor: pointer; }
.rows > li:has(:focus-visible) { outline: 2px solid var(--ochre); outline-offset: -2px; }
.rows input:focus-visible ~ .rd { outline: 2px solid var(--ochre); outline-offset: 2px; } /* 不支援 :has() 時的後備 */
.rows .rd { width: 18px; height: 18px; border: 1px solid var(--ink); border-radius: 50%; margin-top: 2px; position: relative; }
.rows li.on .rd::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--ink); }
.rows li.on { box-shadow: inset 3px 0 0 var(--ochre); padding-left: var(--s2); margin-left: calc(-1 * var(--s2)); }
.rows .t { font-weight: 700; font-size: var(--t15); line-height: 1.25; }
.rows .d { font-size: var(--t13); color: var(--ink2); }
.rows .tag { font-size: var(--t11); font-weight: 700; color: var(--ink2); white-space: nowrap; padding-top: 3px; }
.rows .tag.bad { color: var(--red); }
.row-btns { display: flex; gap: var(--s2); margin-top: 10px; }

.kvt { width: 100%; margin-top: var(--s3); font-size: var(--t13); }
.kvt td { padding: 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.kvt td:first-child { color: var(--ink2); width: 96px; padding-right: var(--s2); }
.kvt td b { font-size: var(--t15); }
.kvt td:first-child b { color: var(--ink); font-size: var(--t13); }
.lb { display: grid; grid-template-columns: minmax(0, 1fr); }
.lb .col + .col { margin-top: var(--s5); }
.lb .brief .photo { aspect-ratio: 16 / 7; margin-top: 10px; background: var(--plate); border: 1px solid var(--ink); }
.lb .brief .photo img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.72) sepia(.12) contrast(1.03); }
.lb .brief .cap { font-size: var(--t11); color: var(--ink2); font-weight: 600; margin-top: 4px; }
.lb .brief h3 { font-size: var(--t24); font-weight: 700; line-height: 1.15; margin-top: var(--s3); }
.lb .brief .desc { margin-top: 4px; }
.lb .go { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--ink); padding: 10px 0 12px; margin-top: var(--s4); display: flex; align-items: center; gap: var(--s3); }
.lb .go .btn { flex: 1; }
.lb .go .mut { font-size: var(--t13); white-space: pre-line; }
@media (min-width: 1024px) {
  .lb { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr); gap: 0 40px; }
  .lb .col + .col { margin-top: 0; }
  .lb .go { position: static; }
  .lb .go .btn { flex: none; min-width: 220px; }
}

/* 規則速查 */
.rl { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 48px; }
.rl .toc, .rl .leg { display: none; }
.rl .toc ol { list-style: none; padding: 0; font-size: var(--t13); }
.rl .toc li { border-bottom: 1px solid var(--rule); }
.rl .toc a { display: flex; gap: var(--s2); min-height: 40px; align-items: center; color: var(--ink); text-decoration: none; }
.rl .toc a b { width: 22px; color: var(--ink2); }
.rl .toc li.on a { font-weight: 700; box-shadow: inset 3px 0 0 var(--ochre); padding-left: var(--s2); }
.rl article { max-width: 70ch; }
.rl .jump { width: 100%; margin-bottom: var(--s2); }
.rl section { display: grid; grid-template-columns: 34px minmax(0, 1fr); padding: 14px 0; border-bottom: 1px solid var(--rule); scroll-margin-top: calc(var(--nav-h) + var(--s2)); }
.rl section .no { font-size: var(--t24); font-weight: 700; line-height: 1; color: var(--ink2); }
.rl section h3 { font-size: var(--t18); font-weight: 700; margin-bottom: 4px; }
.rl section p { font-size: var(--t15); line-height: 1.65; }
.rl .rt { margin-top: 10px; font-size: var(--t13); width: 100%; }
.rl .rt th { text-align: left; font-size: var(--t11); color: var(--ink2); border-bottom: 1px solid var(--ink); padding: 4px 8px 4px 0; }
.rl .rt td { border-bottom: 1px solid var(--rule); padding: 6px 8px 6px 0; }
.rl .leg .bg { background: var(--plate); padding: 14px; margin-top: 10px; display: flex; justify-content: center; }
.rl .leg ol { margin: 10px 0 0; padding-left: 20px; font-size: var(--t13); }
.rl .leg li { padding: 5px 0; border-bottom: 1px solid var(--rule); }
.rl .leg li b { font-weight: 700; }
@media (min-width: 1024px) {
  .rl { grid-template-columns: 220px minmax(0, 1fr) 300px; }
  .rl .toc, .rl .leg { display: block; align-self: start; position: sticky; top: calc(var(--nav-h) + var(--s4)); }
  .rl .jump { display: none; }
  .rl .leg .bg { --k: 1.6; --cw: 118px; --ch: 195px; }
}

/* ── 6. 對戰 ─────────────────────────────── */
.bt { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "ebar" "board" "pbar" "ctx" "foot" "insp" "log"; align-content: start; }
.ebar, .pbar { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s3); }
.ebar { grid-area: ebar; min-height: 46px; border-bottom: 1px solid var(--ink); }
.pbar { grid-area: pbar; min-height: 56px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.hq { position: relative; display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: end; min-height: 40px; padding: 2px 4px; border-radius: var(--r); }
.hq .lbl { grid-column: 1 / 3; }
.hq .v { font-size: 22px; font-weight: 700; line-height: 1; color: var(--ink); }
.hq .v small { font-size: var(--t13); font-weight: 600; color: var(--ink2); }
.hq .ticks { width: 76px; align-self: center; }
.hq.enemy { color: var(--red); cursor: pointer; }
.hq.own { color: var(--blue); }
.hq.is-targetable { outline: 2px solid var(--red); outline-offset: 0; }
.ticks { display: flex; gap: 1px; height: 8px; }
.ticks i { flex: 1; border: 1px solid currentColor; min-width: 3px; }
.ticks i.on { background: currentColor; }
.pips { display: flex; gap: 3px; }
.pips i { width: 9px; height: 14px; border: 1px solid var(--ink); }
.pips i.on { background: var(--ink); }
.pips i.lock { border-color: var(--rule); opacity: .6; }
.st-row { display: flex; gap: var(--s3); margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.stat .v { font-weight: 700; font-size: var(--t15); }
.kr { display: flex; flex-direction: column; gap: 2px; }
.kr .top { display: flex; align-items: baseline; gap: 6px; }
.kr .v { font-weight: 700; font-size: var(--t18); line-height: 1; }
.kr .v small { font-size: var(--t13); font-weight: 600; }
.pbar .btn { margin-left: auto; }

.board { grid-area: board; background: var(--plate); padding: 6px var(--s2) 8px; }
.lane + .lane { margin-top: 6px; }
.lane .lh { display: flex; align-items: baseline; gap: var(--s2); height: 17px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; font-size: var(--t11); font-weight: 700; color: var(--ink2); }
.lane .lh .r { margin-left: auto; font-weight: 600; }
.lane .lh .ctl { color: var(--blue); }
.lane.ectl .lh .ctl { color: var(--red); }
.lane.front .lh { border-bottom: 2px solid var(--blue); }
.lane.front.ectl .lh { border-bottom-color: var(--red); }
.lane.front:not(.own-ctl):not(.ectl) .lh { border-bottom: 1px solid var(--rule); }
.slots { display: flex; justify-content: center; gap: 5px; min-height: var(--ch); }
.slot { width: var(--cw); height: var(--ch); flex: none; position: relative; border: 1px dashed var(--rule); border-radius: var(--r); }
.slot.mv { border: 1px solid var(--ochre); background-color: rgba(154, 104, 12, .14); cursor: pointer; }
.slot.mv span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; font-size: var(--t11); font-weight: 700; padding: 4px; }
.lane.front.is-move-target { cursor: pointer; }

.ctx { grid-area: ctx; padding: var(--s2) var(--s3) 0; min-width: 0; }
.hand-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s3); font-size: var(--t13); margin-bottom: 6px; }
.hand-h .turn { font-weight: 700; color: var(--blue); }
.hand-h .turn.is-enemy { color: var(--red); }
.hand-h .hint { margin-left: auto; color: var(--ink2); font-size: var(--t13); font-weight: 600; text-align: right; }
.hand-h .hint.is-warn, .hand-h .hint.is-enemy { color: var(--red); }
@media (max-width: 1023px) { .hand-h > #ac-turn-badge { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
.hand { --hn: 2; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, min(calc(var(--cw) + 6px), calc((100% - var(--cw)) / (var(--hn) - 1)))); padding-right: 0; margin-right: -8px; min-height: var(--ch); } /* 手牌多時列寬縮小讓卡片疊放，最後一張仍完整落在欄內 */
.hand .c-sm .ft { justify-content: flex-start; }
.hand .c-sm .ft > span { flex: none; padding: 0 3px; }
.hand .c-sm .ft > span + span { border-left: 0; }
.hand .c-sm:hover, .hand .c-sm:focus-visible, .hand .c-sm.sel { z-index: 3; }
.foot { grid-area: foot; display: flex; justify-content: flex-end; padding: var(--s3); }

.rail { display: contents; }
.rail > .insp { grid-area: insp; padding: 0 var(--s3); border-top: 1px solid var(--ink); min-width: 0; }
.insp-toggle { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 0; border: 0; background: transparent; text-align: left; font-weight: 700; font-size: var(--t13); cursor: pointer; }
.insp-toggle .mut { font-weight: 600; }
.insp:not(.is-open) .insp-body { display: none; }
.insp-body { padding-bottom: var(--s3); }
.rail > .pnl { grid-area: ctx; padding: var(--s2) var(--s3) var(--s3); min-width: 0; }
@media (max-width: 1023px) { .bt.has-pnl > .ctx { display: none; } } /* 手機：面板取代手牌；桌機：手牌留在左下，面板在右欄 */
.pnl-h { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s2); min-height: 40px; border-bottom: 1px solid var(--ink); }
.rail .pnl-h h3 { font-size: var(--t15); font-weight: 700; color: var(--ink); letter-spacing: 0; border: 0; padding: 0; }
.pnl-h .mut { font-size: var(--t13); }
.pnl-h .btn { margin-left: auto; }
.acts { display: grid; grid-template-columns: 1fr 1fr; }
.act { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; column-gap: 6px; min-height: 52px; padding: 4px 6px 4px 4px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--ink); text-align: left; cursor: pointer; font-family: inherit; }
.act:nth-child(odd) { border-right: 1px solid var(--rule); }
.act svg.wl-s { width: 44px; height: 14px; }
.act .an { display: block; font-weight: 700; font-size: var(--t13); line-height: 1.15; overflow-wrap: anywhere; }
.act .ad { display: block; font-size: var(--t11); color: var(--ink2); font-weight: 600; line-height: 1.25; }
.act .cost { width: 26px; height: 26px; font-size: 15px; }
.act .gun { font-size: var(--t11); font-weight: 700; border: 1px solid var(--ink); width: 40px; text-align: center; padding: 1px 0; white-space: nowrap; }
.act.on { box-shadow: inset 0 0 0 2px var(--ochre); background: var(--card); }
.act.off .an { color: var(--ink2); }
.act.used .an { text-decoration: line-through; }
.act.used .ad { color: var(--ink2); }
.act[aria-disabled="true"] { cursor: default; }
.acts.one { grid-template-columns: 1fr; }
.acts.one .act { border-right: 0; }
.cf { display: flex; align-items: center; gap: var(--s2); padding-top: var(--s2); }
.cf .sum { flex: 1; min-width: 0; font-size: var(--t13); line-height: 1.3; }
.cf .sum b { font-weight: 700; }
.cf .sum .warn { color: var(--red); font-weight: 700; }
.pnl .hs { margin-top: var(--s2); font-size: var(--t13); font-weight: 700; }
.pnl .hx { margin-top: 4px; font-size: var(--t13); line-height: 1.4; }
.hq.is-picked { outline: 3px solid var(--ochre); outline-offset: 0; }
.btn .k { padding-left: var(--s2); border-left: 1px solid currentColor; font-weight: 700; }
.rail > .log { grid-area: log; padding: var(--s3); }
.rail .pinbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: var(--t11); font-weight: 600; color: var(--ink2); min-height: 40px; }
.rail .pinbar h3 { border: 0; padding: 0; }
@media (max-width: 1023px) { .rail .pinbar h3 { display: none; } .rail .pinbar { justify-content: flex-end; } }
.rail .insp .c-lg { max-width: none; }
.c-lg .sec table.ld { margin-top: 2px; }
table.ld tr.used td { color: var(--ink2); }
table.ld tr.used .wpn span { text-decoration: line-through; }
.ld-note { margin-top: 4px; font-size: var(--t13); color: var(--ink2); font-weight: 600; }
.rail .pinbar .is-pinned { color: var(--ink); }
.rail h3 { font-size: var(--t11); color: var(--ink2); font-weight: 700; letter-spacing: .04em; border-bottom: 1px solid var(--ink); padding-bottom: 4px; }
.ac-battle-log { font-size: var(--t13); }
.ac-log-item { padding: 4px 0; border-bottom: 1px solid var(--rule); }
.ac-log-item.kind-turn { font-weight: 700; color: var(--ink2); }
.ac-log-item.kind-destroy, .ac-log-item.kind-aa { color: var(--red); }

.ac-float-num { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 4; padding: 0 6px; background: var(--ink); color: var(--card); font-weight: 700; font-size: var(--t18); animation: acFadeOut .9s ease-out forwards; pointer-events: none; }
.ac-float-num.is-heal { background: var(--blue); }
@keyframes acFadeOut { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }

@media (min-width: 1024px) {
  .bt { grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: "ebar rail" "board rail" "pbar rail" "ctx rail"; height: calc(100vh - var(--nav-h)); }
  .ebar, .pbar { padding: 0 var(--s5); }
  .ebar { min-height: 50px; }
  .board { padding: 8px var(--s5) 10px; }
  .lane { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; }
  .lane .lh { flex-direction: column; align-items: flex-start; height: auto; border: 0; margin: 0; font-size: var(--t13); gap: 2px; }
  .lane .lh .r { margin-left: 0; }
  .lane.front .lh, .lane.front.ectl .lh { border: 0; }
  .lane.front .slots { border-top: 2px solid var(--blue); border-bottom: 2px solid var(--blue); padding: 6px 0; }
  .lane.front.ectl .slots { border-color: var(--red); }
  .lane.front:not(.own-ctl):not(.ectl) .slots { border-color: var(--rule); }
  .slots { gap: 10px; }
  .hand { grid-auto-columns: minmax(0, min(calc(var(--cw) + 10px), calc((100% - var(--cw)) / (var(--hn) - 1)))); margin-right: 0; }
  .hand .c-sm .ft { justify-content: stretch; }
  .hand .c-sm .ft > span { flex: 1; padding: 0; }
  .hand .c-sm .ft > span + span { border-left: 1px solid var(--rule); }
  .ctx { padding: 8px var(--s5) var(--s3); overflow-y: auto; }
  .rail { grid-area: rail; display: flex; flex-direction: column; border-left: 1px solid var(--ink); overflow-y: auto; min-height: 0; min-width: 0; }
  .rail > .pnl { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--ink); flex: none; }
  .rail > .insp { padding: var(--s4); border-top: 0; border-bottom: 1px solid var(--ink); flex: none; }
  .insp-toggle { display: none; }
  .insp:not(.is-open) .insp-body { display: block; }
  .insp-body { padding-bottom: 0; }
  .rail > .log { padding: var(--s3) var(--s4); flex: 1; }
  .rail > .foot { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--ink); padding: var(--s2) var(--s4); justify-content: flex-start; flex: none; }
}

/* 低矮的桌機視窗（1024×768、1366×768）：縮小卡片，三條戰線與手牌才放得進一屏；窄的再縮右欄與戰線標籤欄 */
@media (min-width: 1024px) and (max-height: 860px) { :root { --k: 1.05; --cw: 78px; --ch: 128px; } .slots { gap: 8px; } }
@media (min-width: 1024px) and (max-width: 1279px) {
  .bt { grid-template-columns: minmax(0, 1fr) 340px; }
  .ebar, .pbar { padding: 0 var(--s4); }
  .board { padding: 8px var(--s4) 10px; }
  .lane { grid-template-columns: 110px minmax(0, 1fr); }
  .ctx { padding: 8px var(--s4) var(--s3); }
}

/* ── 7. 彈窗 ─────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(32, 35, 27, .62); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.dlg { background: var(--paper); border-top: 1px solid var(--ink); width: 100%; max-height: 100vh; overflow-y: auto; padding: var(--s4) var(--s4) var(--s5); }
.dlg h2 { font-size: var(--t24); font-weight: 700; line-height: 1.1; }
.dlg .lead { color: var(--ink2); font-size: var(--t15); margin-top: 4px; }
.dlg .acts-row { display: flex; gap: var(--s2); margin-top: var(--s4); }
.dlg .acts-row .btn { flex: 1; }
@media (min-width: 1024px) {
  .scrim { align-items: center; }
  .dlg { width: auto; min-width: 520px; max-width: 820px; max-height: 94vh; border: 1px solid var(--ink); border-radius: var(--r); padding: var(--s5); }
  .dlg .acts-row .btn { flex: none; min-width: 160px; }
}
.mgs { display: grid; grid-template-columns: repeat(2, 164px); gap: 12px 16px; justify-content: center; margin-top: 14px; }
.mg { padding: 0; border: 0; background: transparent; cursor: pointer; text-align: center; }
.mg .mg-l { display: block; font-size: var(--t13); font-weight: 700; padding: 5px 0; color: var(--ink2); }
.mg.on .c { outline: 2px solid var(--red); outline-offset: 1px; }
.mg.on .c > * { opacity: .55; }
.mg.on .mg-l { color: var(--red); }
@media (min-width: 1024px) { .mgs { grid-template-columns: repeat(4, 164px); } }
.dlg.rs h2 { font-size: var(--t32); }
.dlg.rs table { width: 100%; margin-top: var(--s4); font-size: var(--t15); }
.dlg.rs td { padding: 7px 0; border-bottom: 1px solid var(--rule); }
.dlg.rs td.n { text-align: right; font-weight: 700; }
.dlg.rs th { text-align: right; font-size: var(--t11); color: var(--ink2); padding-bottom: 4px; border-bottom: 1px solid var(--ink); }
.dlg.rs th:first-child { text-align: left; }
@media (min-width: 1024px) { .dlg.rs { width: 560px; } }

/* ── 8. 組牌器共用的表單與提示（組牌器自己的版面在 deck.css） ── */
.ac-toast { position: fixed; left: 50%; bottom: var(--s4); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--card); padding: var(--s3) var(--s4); border-radius: var(--r); font-weight: 600; max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: reduce) {
  .ac-float-num { animation-duration: .01s; animation-delay: .9s; }
}

/* ── 9. 帳號區塊（頂端列）與戰績頁（records.js） ── */
.ac-acct > summary { gap: 6px; max-width: 200px; }
.ac-acct-av { width: 24px; height: 24px; border-radius: var(--r); background: var(--plate); }
.ac-acct-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ac-acct-panel { width: auto; min-width: 180px; }
.rec-intro { max-width: 70ch; }
.rec-intro p { margin-top: var(--s2); }
.rec-intro .row-btns, .rec-msg .row-btns { margin-top: var(--s3); }
.rec-msg { padding: var(--s4) 0; }
.rec-note { font-size: var(--t13); margin-top: 6px; }
/* 總覽沿用大卡的 .sg 數字格：手機 3 欄兩列（第一列底下一條整寬細線）、桌機 5 欄一列 */
.rec-sum { grid-template-columns: repeat(3, 1fr); margin-bottom: var(--s2); }
.rec-sum > div, .rec-kl > div { padding-left: var(--s3); }
.rec-sum > div:nth-child(3n + 1), .rec-kl > div:first-child { border-left: 0; padding-left: 0; }
.rec-sum > div:nth-child(-n + 3) { border-bottom: 1px solid var(--rule); }
.rec-kl { grid-template-columns: 1fr 1fr; border-bottom-color: var(--rule); }
.rec-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5) 40px; margin-top: var(--s5); }
.rec-t { margin-top: 2px; }
table.rec-t td { border-bottom: 0; }
table.rec-t tbody tr { border-bottom: 1px solid var(--rule); } /* 底線畫在整列：表格落在小數座標時，逐格底線會在欄間錯開 1px */
.rec-t th.rec-wr, .rec-t td.rec-wr { width: 124px; padding-left: var(--s3); white-space: nowrap; }
.rec-t td.rec-wr b { display: inline-block; min-width: 4ch; text-align: right; font-weight: 700; }
.rec-bar { display: inline-block; vertical-align: middle; width: 64px; height: 8px; margin-right: 6px; border: 1px solid var(--blue); }
.rec-bar i { display: block; height: 100%; background: var(--blue); }
.rec-bar.ink { border-color: var(--ink); }
.rec-bar.ink i { background: var(--ink); }
.rec-dk { display: block; font-weight: 600; }
.rec-nat { display: block; font-size: var(--t11); font-weight: 600; }
.rec-recent td.res b { font-weight: 700; }
.rec-recent td.res .mut { font-size: var(--t11); font-weight: 600; }
.rec-recent td.n { font-weight: 600; white-space: nowrap; }
.rec-k { display: none; }
@media (min-width: 1024px) {
  .rec-sum { grid-template-columns: repeat(5, 1fr); }
  .rec-sum > div:nth-child(n) { border-bottom: 0; }
  .rec-sum > div:nth-child(4) { border-left: 1px solid var(--rule); padding-left: var(--s3); }
  .rec-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, .9fr); }
}
@media (max-width: 1023px) {
  .rec-recent thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rec-recent, .rec-recent tbody { display: block; }
  .rec-recent tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s3); padding: 8px 0; border-bottom: 1px solid var(--rule); }
  .ac-acct-panel { position: static; margin-top: var(--s1); } /* 手機選單裡直接展開，不蓋住選單下緣 */
  .rec-t th.rec-wr, .rec-t td.rec-wr { width: 96px; padding-left: var(--s2); }
  .rec-bar { width: 40px; } /* 窄螢幕把寬度讓給牌組名稱 */
  table.rec-recent td { border: 0; padding: 0; }
  table.rec-recent td.n { text-align: left; font-weight: 600; }
  table.rec-recent td.when { order: -1; margin-left: auto; color: var(--ink2); font-size: var(--t13); }
  table.rec-recent td.res { order: -2; }
  table.rec-recent td.opp, table.rec-recent td.dk { flex-basis: 100%; }
  table.rec-recent td.dk { color: var(--ink2); font-size: var(--t13); }
  .rec-k { display: inline; color: var(--ink2); font-size: var(--t11); }
}

/* ── 10. 線上對戰（ui.js 的大廳面板、斷線橫幅；戰績頁的模式標記） ── */
.ac-mode { margin-bottom: var(--s4); }
.pvp p { margin-top: var(--s2); }
.pvp .pvp-code { margin-top: var(--s2); font-size: var(--t32); font-weight: 700; line-height: 1.1; letter-spacing: .12em; }
.pvp .pvp-row { display: flex; gap: var(--s2); margin-top: var(--s2); }
.pvp .pvp-row .ac-input { flex: 1; min-width: 0; }
.pvp .pvp-in { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.pvp .pvp-err { color: var(--red); font-weight: 700; }
.pvp .pvp-sp { margin-top: var(--s5); }
@media (min-width: 1024px) { #ac-col-pvp { grid-column: 2 / span 2; max-width: 560px; } }
.ac-pvp-banner { position: sticky; top: var(--nav-h); z-index: 15; padding: var(--s2) var(--s4); background: var(--card); border-bottom: 1px solid var(--red); color: var(--red); font-size: var(--t13); font-weight: 700; text-align: center; }
@media (min-width: 1024px) { .bt { height: calc(100vh - var(--nav-h) - var(--bn, 0px)); } } /* 橫幅顯示時從戰場高度扣掉（ui.js 設 --bn） */
.rec-mode { font-size: var(--t11); margin-right: 4px; }
