/* 主題：中古手抄本 / 西方奇幻。羊皮紙（淺色）與鐵與夜（深色），
   家族色（--banner 旗幟、--trim 飾邊、--house-accent 互動色）由 app.js 依目前陣營寫入 :root。 */
:root {
  --banner: #3b3428; --trim: #d8c79f;
  --house-accent: #7a5a1e; --house-accent-dark: #d4af5a;

  --bg: #eadfc6; --surface: #f7efdc; --surface-2: #ecdfc2; --text: #2b2117; --muted: #6f5f49;
  --line: #ccb68a; --line-soft: #e2d3b0; --gold: #a07a26; --gold-soft: #c9a75a;
  --accent: var(--house-accent); --accent-ink: #fbf6ea;
  --ok: #2f6b2f; --warn: #9a5a0c; --bad: #9b1c1c; --info: var(--house-accent);
  --bar: #1b1814; --bar-ink: #f1e6cc;
  --shadow: 0 1px 2px #3b2a1022, 0 4px 14px #3b2a1014;
  --radius: 6px;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", "MingLiU", serif;
  --display: "Cinzel", "Noto Serif TC", "Songti TC", serif;
  --paper: radial-gradient(120% 80% at 10% 0%, #f6edd7 0%, transparent 60%),
           radial-gradient(90% 70% at 100% 100%, #d9c7a0 0%, transparent 70%),
           linear-gradient(#eadfc6, #e4d6b8);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13110e; --surface: #1d1a15; --surface-2: #29241c; --text: #ece2cb; --muted: #a8987b;
    --line: #4a3f2c; --line-soft: #2f291f; --gold: #c9a24a; --gold-soft: #8d7234;
    --accent: var(--house-accent-dark); --accent-ink: #15120d;
    --ok: #7fc07f; --warn: #e0a84a; --bad: #e87a6e;
    --bar: #0c0b09; --shadow: 0 1px 2px #0008, 0 6px 18px #0006;
    --paper: radial-gradient(120% 80% at 10% 0%, #221e17 0%, transparent 60%),
             radial-gradient(90% 70% at 100% 100%, #0e0d0a 0%, transparent 70%),
             linear-gradient(#16130f, #100e0b);
  }
}
:root[data-theme="dark"] {
  --bg: #13110e; --surface: #1d1a15; --surface-2: #29241c; --text: #ece2cb; --muted: #a8987b;
  --line: #4a3f2c; --line-soft: #2f291f; --gold: #c9a24a; --gold-soft: #8d7234;
  --accent: var(--house-accent-dark); --accent-ink: #15120d;
  --ok: #7fc07f; --warn: #e0a84a; --bad: #e87a6e;
  --bar: #0c0b09; --shadow: 0 1px 2px #0008, 0 6px 18px #0006;
  --paper: radial-gradient(120% 80% at 10% 0%, #221e17 0%, transparent 60%),
           radial-gradient(90% 70% at 100% 100%, #0e0d0a 0%, transparent 70%),
           linear-gradient(#16130f, #100e0b);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  min-height: 100vh; background: var(--paper); background-attachment: fixed; color: var(--text);
  font: 16px/1.6 var(--serif);
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }

/* ---------- 頂部：鐵框旗幟 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  color: var(--bar-ink); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--banner) 70%, transparent), transparent 75%),
    linear-gradient(#24201a, var(--bar));
  border-bottom: 1px solid var(--gold);
  box-shadow: 0 1px 0 #0006, 0 3px 0 -1px color-mix(in srgb, var(--gold) 45%, transparent), 0 6px 14px #0004;
}
.topbar h1 {
  font: 700 18px/1.2 var(--display); letter-spacing: .06em; margin: 0; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000a;
}
.topbar .back { color: inherit; text-decoration: none; font-size: 28px; line-height: 1; padding: 0 4px 4px 0; }
.topbar select {
  background: #0004; color: inherit; border: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
  border-radius: 4px; padding: 4px 6px;
}
.topbar select option { color: #111; }
.crest {
  flex: none; width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 1.5px var(--gold), 0 0 0 3px #0008, 0 2px 6px #000a;
}
.crest[hidden] { display: none; }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }

/* ---------- 底部導覽 ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: linear-gradient(var(--bar), #000); border-top: 1px solid var(--gold);
  box-shadow: 0 -3px 0 -1px color-mix(in srgb, var(--gold) 40%, transparent);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 8px;
  text-decoration: none; color: #b5a786;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs a span { font: 600 12px/1 var(--display); letter-spacing: .12em; }
.tabs a.active { color: var(--gold); text-shadow: 0 0 8px color-mix(in srgb, var(--gold) 50%, transparent); }

/* ---------- 搜尋與篩選 ---------- */
.search {
  width: 100%; padding: 11px 14px 11px 40px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 16px; color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a07a26' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E") 12px 50% / 18px no-repeat;
  box-shadow: inset 0 1px 3px #0001;
}
.search:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 3px;
  padding: 5px 13px; font-size: 14px; letter-spacing: .05em; cursor: pointer; color: var(--muted);
}
.chip.on {
  background: linear-gradient(color-mix(in srgb, var(--banner) 88%, #fff 12%), var(--banner));
  color: #f6ecd2; border-color: var(--gold); font-weight: 700;
  box-shadow: inset 0 0 0 1px #0005, 0 1px 3px #0003;
}
/* 第一排（陣營）用較大的旗幟樣式 */
.chips.houses .chip { font-family: var(--display); font-size: 15px; padding: 6px 16px; }

/* ---------- 清單 ---------- */
.list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.item {
  position: relative; display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px var(--line-soft);
  transition: transform .12s ease, box-shadow .12s ease;
}
.item:active { transform: scale(.99); }
@media (hover: hover) { .item:hover { border-color: var(--gold-soft); } }
.item .t { font-weight: 700; font-size: 16.5px; line-height: 1.35; }
.item .t .alt { font-weight: 400; }
.item .s { color: var(--muted); font-size: 13px; }
.item .stats-line { color: var(--text); opacity: .8; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.badge {
  display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 3px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-soft);
}
.badge.fix { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }

/* ---------- 內容卡片（羊皮紙面板） ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-top: 12px;
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px var(--line-soft);
}
.card h2 { margin: 0 0 2px; font: 700 23px/1.3 var(--display); letter-spacing: .04em; }
.card h3 {
  display: flex; align-items: center; gap: 10px; margin: 0 0 8px;
  font: 700 14px/1.3 var(--display); letter-spacing: .14em; color: var(--gold);
}
.card h3::before, .card h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-soft)); }
.card h3::after { background: linear-gradient(90deg, var(--gold-soft), transparent); }
.alt { color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 4px; padding: 6px; text-align: center;
}
.stat b { display: block; font: 700 21px/1.2 var(--display); }
.stat small { color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.ability { padding: 9px 0; border-top: 1px solid var(--line-soft); }
.ability:first-of-type { border-top: 0; padding-top: 0; }
.ability .n { font-weight: 700; color: var(--accent); }
.orig { color: var(--muted); font-size: 14px; margin-top: 4px; border-left: 2px solid var(--gold-soft); padding-left: 8px; }
.missing { color: var(--warn); font-size: 12px; }

.fixbox { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.fixbox .was { text-decoration: line-through; color: var(--muted); }
.fixbox .now { color: var(--ok); font-weight: 600; }
.src { color: var(--muted); font-size: 12px; }

.rich p { margin: 0 0 8px; }
.rich ul { margin: 0 0 8px; padding-left: 20px; }
.rich li::marker { color: var(--gold); }

details.card > summary { cursor: pointer; font-weight: 700; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "❧ "; color: var(--gold); }
details.card[open] > summary { margin-bottom: 8px; }

.seg {
  display: flex; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 5px;
  padding: 3px; margin-bottom: 10px;
}
.seg button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 3px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px #0003, inset 0 -2px 0 var(--accent); }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 4px; padding: 8px 14px; cursor: pointer;
  min-width: 44px; min-height: 44px;
}
.btn.primary { background: linear-gradient(color-mix(in srgb, var(--banner) 85%, #fff 15%), var(--banner)); color: #f6ecd2; border-color: var(--gold); }
.btn:disabled { opacity: .4; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

textarea { width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 4px; padding: 8px; background: var(--surface-2); }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.hint { color: var(--muted); font-size: 13px; }
mark { background: color-mix(in srgb, var(--gold) 35%, transparent); color: inherit; border-radius: 2px; }

/* ---------- 編成 ---------- */
.tabs a[hidden] { display: none; }
.btn.wide, .army-new { width: 100%; margin-top: 10px; }
.army-pts { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.army-pts b { font: 700 24px/1 var(--display); color: var(--gold); }
.army-pts small { color: var(--muted); margin-left: 2px; }
.army-pts.over b { color: var(--bad); }
.army-name { font: 700 19px/1.3 var(--display); border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); padding: 4px 0; }
.bar { height: 6px; margin-top: 10px; background: var(--surface-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--line-soft); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.bar.over > i { background: var(--bad); }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.issues ul { margin: 0; padding-left: 18px; }
.issues li { margin: 3px 0; font-size: 14px; }
.issues li.error { color: var(--bad); }
.issues li.warn { color: var(--warn); }
.issues.good p { margin: 0; color: var(--ok); font-weight: 700; }
.arow { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.arow-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
  padding: 6px 8px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--surface-2); }
.arow-main .t { font-weight: 700; }
.arow-main .s { color: var(--muted); font-size: 12.5px; }
.thumb.sm { width: 44px; height: 44px; }
.acost { flex: none; text-align: center; min-width: 34px; }
.acost b { font: 700 18px/1 var(--display); color: var(--gold); display: block; }
.acost small { display: block; font-size: 10.5px; color: var(--ok); white-space: nowrap; }
.cmd-badge { font-size: 11px; font-weight: 700; padding: 1px 6px; margin-right: 6px; border-radius: 3px; background: var(--accent); color: var(--accent-ink); vertical-align: 2px; }
.warn-t { color: var(--warn) !important; }
.xbtn { flex: none; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.aunit { padding: 4px 0 8px; border-bottom: 1px dashed var(--line-soft); }
.aatt { margin-left: 22px; position: relative; }
.aatt::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 50%; width: 9px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.addatt { margin: 6px 0 0 22px; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 4px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.field { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.field input { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: var(--text); font-size: 15px; }
.pick-panel { max-height: 85vh; display: flex; flex-direction: column; }
.pick-panel .list.pick { overflow-y: auto; flex: 1; min-height: 120px; }
.pick-item { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.pick-item:disabled { opacity: .45; }
.army-tools { margin-top: 14px; }

/* ---------- 圖片 ---------- */
img.cardimg { display: block; width: 100%; height: auto; border-radius: 6px; margin-top: 8px; cursor: zoom-in; box-shadow: 0 2px 10px #0005; }
.item.withthumb { display: flex; gap: 12px; align-items: center; }
.thumb { flex: none; width: 64px; height: 64px; object-fit: cover; object-position: 30% 30%; border-radius: 6px; background: var(--surface-2); }
.thumb.face {
  object-position: center; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--gold-soft), 0 0 0 4px var(--surface), 0 0 0 5px var(--line), 0 2px 6px #0004;
}
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: #000e; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 8px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: calc(100% - 40px); object-fit: contain; }
.lightbox .hint { color: #ccc; }

/* ---------- 首頁：跨遊戲的中性「遊戲庫」風格（不套任何遊戲的主題） ---------- */
:root[data-view="home"] {
  --sans: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --bg: #0c0e12; --text: #ece9e2; --muted: #9a9890;
}
:root[data-view="home"] body {
  font-family: var(--sans); color: var(--text);
  background: radial-gradient(90% 50% at 50% 0%, #1d2330 0%, transparent 70%), linear-gradient(#0f1217, #0a0b0e);
}
:root[data-view="home"] .topbar { display: none; }
/* A.R.I.A. 標誌區：黃銅（奇幻）＋青色訊號光（科幻） */
:root[data-view="home"] { --brass: #e2c072; --brass-deep: #b98a35; --signal: #7fd4e6; }
:root[data-view="home"] body {
  background:
    radial-gradient(60% 34% at 50% 9%, #7fd4e61a 0%, transparent 70%),
    radial-gradient(90% 50% at 50% 0%, #1d2330 0%, transparent 70%),
    linear-gradient(#0f1217, #0a0b0e);
}
.aria-hero { text-align: center; padding: 30px 0 6px; }
.aria-sigil { width: 112px; height: 112px; margin: 0 auto 12px; filter: drop-shadow(0 0 14px #7fd4e622) drop-shadow(0 6px 14px #000a); }
.aria-sigil svg { width: 100%; height: 100%; overflow: visible; }
.aria-sigil .ring-ticks { fill: none; stroke: url(#ariaBrass); stroke-width: 2.4; stroke-dasharray: 1.2 4.2; opacity: .7; }
.aria-sigil .ring { fill: #0b0d12; stroke: url(#ariaBrass); stroke-width: 3; }
.aria-sigil .ring-cyan { fill: none; stroke: var(--signal); stroke-width: 1; opacity: .45; }
.aria-sigil .glyph { fill: url(#ariaBrass); }
.aria-sigil .beacon { fill: var(--signal); }
.aria-sigil .sweep { transform-origin: 60px 60px; animation: aria-sweep 6s linear infinite; }
.aria-sigil .beacon { animation: aria-blink 3s ease-in-out infinite; }
@keyframes aria-sweep { to { transform: rotate(360deg); } }
@keyframes aria-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .aria-sigil .sweep, .aria-sigil .beacon { animation: none; } }
.aria-word {
  margin: 0; font: 700 34px/1.1 var(--display); letter-spacing: .22em; padding-left: .22em;
  background: linear-gradient(#f6e3a8, var(--brass) 55%, var(--brass-deep)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px #000c);
}
.aria-full {
  margin: 8px 0 0; font: 600 12.5px/1.4 "Rajdhani", var(--sans); letter-spacing: .2em; text-transform: uppercase; color: #8f96a3;
}
.aria-full b { color: var(--signal); font-weight: 700; text-shadow: 0 0 8px #7fd4e666; }
.aria-full i { font-style: normal; color: var(--brass); }
.aria-greet { margin: 16px 0 0; font-size: 15px; color: var(--text); letter-spacing: .06em; }
.aria-desc { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.hub-sec {
  display: flex; align-items: center; gap: 8px; margin: 24px 2px 0;
  font: 700 13px/1 var(--sans); letter-spacing: .16em; color: var(--muted);
}
.hub-sec::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, #e2c07255, transparent); }
.hub-sec span { font-size: 11px; letter-spacing: 0; padding: 2px 7px; border-radius: 10px; background: #ffffff12; color: #cfccc4; }
.games { gap: 12px; }
.game-tile {
  --g-banner: #2a2f3a; --g-accent: #c9a24a;
  position: relative; display: flex; align-items: stretch; min-height: 168px; overflow: hidden;
  border-radius: 14px; text-decoration: none; color: #f4f1ea; font-family: var(--sans);
  background: linear-gradient(110deg, color-mix(in srgb, var(--g-banner) 85%, #000) 0%, var(--g-banner) 60%, color-mix(in srgb, var(--g-banner) 75%, #000) 100%);
  border: 1px solid #ffffff14; box-shadow: 0 8px 22px #0009, inset 0 1px 0 #ffffff12;
  transition: transform .15s ease, box-shadow .15s ease;
}
.game-tile::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 3px 3px 0; background: var(--g-accent); z-index: 2; }
.game-tile:active { transform: scale(.985); }
@media (hover: hover) { a.game-tile:hover { transform: translateY(-2px); box-shadow: 0 12px 28px #000b, inset 0 1px 0 #ffffff1a; } }
.game-art {
  position: absolute; right: 0; top: 0; height: 100%; width: 66%; object-fit: cover; object-position: 60% 30%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 50%); mask-image: linear-gradient(90deg, transparent 0%, #000 50%);
}
.game-mono {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%); width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center; font: 800 38px/1 var(--sans); color: var(--g-accent);
  border: 2px solid color-mix(in srgb, var(--g-accent) 60%, transparent); opacity: .85;
}
.game-text { position: relative; z-index: 1; padding: 18px 18px 16px 22px; max-width: 70%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.game-name { font: 800 20px/1.3 var(--sans); letter-spacing: .02em; text-shadow: 0 2px 6px #000d; }
.game-name2 { display: block; font-size: 15px; font-weight: 700; opacity: .92; }
.game-en { font: 700 10.5px/1.45 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--g-accent); text-shadow: 0 1px 4px #000d; }
.game-sub { font-size: 12.5px; color: #d9d5cc; margin-top: 6px; text-shadow: 0 1px 4px #000d; }
.game-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.game-tags span {
  font-size: 11px; padding: 2px 9px; border-radius: 20px; background: #0000005c; color: #ece7db;
  border: 1px solid #ffffff1f; backdrop-filter: blur(3px);
}
.game-tile.planned { min-height: 132px; cursor: default; }
.game-tile.planned .game-art { filter: saturate(.7) brightness(.8); }
.game-tile.planned:active { transform: none; }
.soon {
  position: absolute; top: 12px; right: 12px; z-index: 2; font-size: 11px; letter-spacing: .12em; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; background: #000000a0; color: var(--g-accent);
  border: 1px solid color-mix(in srgb, var(--g-accent) 55%, transparent);
}

/* 清單的其他語言名稱：獨立一行、單行截斷，避免把卡名擠成多行 */
.item .en {
  font: 600 11.5px/1.4 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--gold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 1px;
}

/* ---------- 卡牌詳細頁 ---------- */
.hero { padding: 16px; }
.hero-top { display: flex; align-items: center; gap: 14px; }
.hero-face { width: 76px; height: 76px; }
.hero h2 { font-size: 22px; line-height: 1.25; text-wrap: balance; }
.hero-sub { color: var(--accent); font-weight: 700; font-size: 15px; letter-spacing: .04em; }
.hero-en { font: 600 12px/1.5 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin-top: 2px; }
.seal {
  flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--banner) 70%, #fff 30%), var(--banner) 70%);
  color: #f6ecd2; box-shadow: 0 0 0 2px var(--gold), 0 0 0 4px var(--surface), 0 0 0 5px var(--line), 0 2px 6px #0005;
}
.seal b { font: 700 22px/1 var(--display); }
.seal small { font-size: 10px; letter-spacing: .15em; opacity: .85; margin-top: 2px; }
.hero-kind {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 14px;
}
.hero-kind > * + *::before { content: "◆"; color: var(--gold-soft); font-size: 8px; margin-right: 10px; vertical-align: 2px; }
.hero-kind a { color: var(--accent); font-weight: 700; text-decoration: none; border-bottom: 1px dotted currentColor; }
.hero-kind .badge::before { display: none; }
.statrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; margin-top: 12px; }
.statrow .stat { padding: 8px 4px 6px; background: linear-gradient(var(--surface-2), var(--surface)); }

.cardview { padding: 10px; }
.imgwrap { position: relative; }
.imgwrap .cardimg { margin: 0; }
.imgtools { display: flex; justify-content: flex-end; gap: 2px; margin-top: 6px; }
.imgbtn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 8px; border-radius: 4px; cursor: pointer;
  border: 0; background: transparent; color: var(--muted); font-size: 13px; letter-spacing: .04em;
}
.imgbtn:active { background: var(--surface-2); }
@media (hover: hover) { .imgbtn:hover { color: var(--accent); } }
.imgbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.imgbtn[hidden] { display: none; }

.attack { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.attack:first-of-type { border-top: 0; padding-top: 2px; }
.atk-icon {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--gold-soft);
}
.atk-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.atk-name { font-weight: 700; }
.atk-kind { font-size: 12.5px; color: var(--muted); }
.atk-hit { flex: none; text-align: center; line-height: 1; }
.atk-hit b { display: block; font: 700 20px/1 var(--display); }
.atk-hit small { font-size: 10.5px; color: var(--muted); letter-spacing: .1em; }
.dice { flex: none; display: flex; gap: 4px; }
.dice span {
  min-width: 26px; height: 28px; padding: 0 4px; border-radius: 5px; display: grid; place-items: center;
  font: 700 16px/1 var(--display); color: #fff; text-shadow: 0 1px 1px #0006; box-shadow: inset 0 -2px 0 #0003;
}
.d-full { background: #4e8a35; } .d-mid { background: #d4861c; } .d-low { background: #b33228; }
.dice-note { margin: 8px 0 0; }
.dice-note span { padding: 0 6px; border-radius: 3px; color: #fff; font-size: 12px; }

.head-row { margin-bottom: 4px; }
.head-row h3 { margin-bottom: 0; }
.origlabel { flex: none; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.origlabel input { accent-color: var(--accent); }
.rich.lead { padding: 8px 12px; background: var(--surface-2); border-left: 3px solid var(--gold-soft); border-radius: 3px; margin: 6px 0 4px; }
.rich.lead p:last-child { margin-bottom: 0; }
.ability .n { font-size: 16.5px; margin-bottom: 2px; }
.ability .rich b { color: var(--text); }

.provenance { margin: 14px 2px 0; padding-top: 10px; border-top: 1px dashed var(--line); }
.provenance .src { margin-top: 4px; }
.tabs[hidden], select[hidden], .back[hidden] { display: none; }

/* ---------- 能力類型標籤（指令 / 回應 / 常駐 / 攻擊 / 能量） ---------- */
.abtag {
  display: inline-block; vertical-align: 2px; margin-left: 6px; padding: 0 7px; border-radius: 3px;
  font: 700 11px/1.7 system-ui, sans-serif; letter-spacing: .06em; color: #fff; background: #5b6472;
}
.abtag[data-t="指令"] { background: #2f4fa8; }
.abtag[data-t="回應"] { background: #d0621c; }
.abtag[data-t="常駐"] { background: #2f8a4c; }
.abtag[data-t="攻擊"] { background: #b8282e; }
.abtag[data-t^="能量"] { background: #e0b12a; color: #2a2000; }
.atk-val { min-width: 34px; }

/* ---------- 科幻 / 機甲風格（資料包 style: "scifi"，例如鋼彈 Assemble） ---------- */
:root[data-style="scifi"] {
  --serif: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --display: "Rajdhani", system-ui, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --radius: 3px;
  --gold: var(--trim); --gold-soft: color-mix(in srgb, var(--trim) 55%, transparent);
}
:root[data-style="scifi"][data-theme="dark"], :root[data-style="scifi"]:not([data-theme]) {
  --bg: #0a0d13; --surface: #111723; --surface-2: #19202e; --text: #e4e9f1; --muted: #8a95a8;
  --line: #263044; --line-soft: #1b2232; --bar: #070a10; --bar-ink: #e9eef6;
  --shadow: 0 1px 0 #ffffff08 inset, 0 6px 16px #0008;
  --paper:
    linear-gradient(color-mix(in srgb, var(--trim) 5%, transparent) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, color-mix(in srgb, var(--trim) 5%, transparent) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(100% 60% at 50% 0%, color-mix(in srgb, var(--banner) 55%, transparent) 0%, transparent 70%),
    linear-gradient(#0c1018, #07090e);
}
:root[data-style="scifi"] .topbar {
  background: linear-gradient(100deg, color-mix(in srgb, var(--banner) 90%, #000) 0%, var(--bar) 80%);
  border-bottom: 2px solid var(--trim); box-shadow: 0 4px 14px #000a;
}
:root[data-style="scifi"] .topbar h1 { font-family: var(--display); letter-spacing: .08em; text-shadow: none; }
:root[data-style="scifi"] .crest { border-radius: 6px; box-shadow: 0 0 0 1.5px var(--trim), 0 2px 6px #000a; }
:root[data-style="scifi"] .tabs { background: linear-gradient(#0c1018, #05070b); border-top: 2px solid var(--trim); box-shadow: none; }
:root[data-style="scifi"] .tabs a { color: #7d889b; }
:root[data-style="scifi"] .tabs a span { font-family: var(--display); letter-spacing: .14em; }
:root[data-style="scifi"] .tabs a.active { color: var(--trim); text-shadow: 0 0 10px color-mix(in srgb, var(--trim) 60%, transparent); }

/* 切角面板 */
:root[data-style="scifi"] .item,
:root[data-style="scifi"] .card {
  border-radius: 2px; box-shadow: var(--shadow);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
  border-left: 3px solid color-mix(in srgb, var(--trim) 70%, transparent);
}
:root[data-style="scifi"] .item .t { font-family: var(--serif); letter-spacing: .02em; }
:root[data-style="scifi"] .item .en { font-family: var(--display); font-size: 12.5px; letter-spacing: .1em; color: var(--trim); }
:root[data-style="scifi"] .card h2 { font-family: var(--serif); font-weight: 800; letter-spacing: .02em; }
:root[data-style="scifi"] .card h3 {
  justify-content: flex-start; font-family: var(--display); font-size: 15px; letter-spacing: .2em; color: var(--trim);
}
:root[data-style="scifi"] .card h3::before { flex: none; width: 4px; height: 14px; background: var(--trim); }
:root[data-style="scifi"] .card h3::after { background: linear-gradient(90deg, var(--line), transparent); }
:root[data-style="scifi"] .hero-en { font-family: var(--display); font-size: 13px; letter-spacing: .12em; color: var(--trim); }
:root[data-style="scifi"] .hero-sub { color: var(--accent); }
:root[data-style="scifi"] .hero-kind > * + *::before { content: "/"; color: var(--line); font-size: 13px; vertical-align: 0; }
:root[data-style="scifi"] .stat, :root[data-style="scifi"] .statrow .stat {
  border-radius: 2px; background: linear-gradient(var(--surface-2), var(--surface)); border-color: var(--line);
  border-top: 2px solid color-mix(in srgb, var(--trim) 60%, transparent);
}
:root[data-style="scifi"] .stat b, :root[data-style="scifi"] .atk-hit b { font-family: var(--display); font-size: 24px; }
:root[data-style="scifi"] .atk-icon { border-radius: 3px; box-shadow: inset 0 0 0 1px var(--line); }
:root[data-style="scifi"] .atk-icon svg { stroke: var(--trim); }

/* 篩選按鈕：硬朗的方角 */
:root[data-style="scifi"] .chip { border-radius: 2px; font-family: var(--serif); letter-spacing: .06em; background: var(--surface); }
:root[data-style="scifi"] .chips.houses .chip { font-family: var(--serif); font-size: 14px; }
:root[data-style="scifi"] .chip.on {
  background: linear-gradient(color-mix(in srgb, var(--banner) 80%, #fff 8%), var(--banner));
  border-color: var(--trim); color: #fff; box-shadow: inset 0 -2px 0 var(--trim);
}
:root[data-style="scifi"] .search { border-radius: 2px; background-color: var(--surface); }
:root[data-style="scifi"] .thumb.face { box-shadow: 0 0 0 2px var(--trim), 0 0 0 4px var(--surface), 0 0 0 5px var(--line); }
:root[data-style="scifi"] .rich.lead { border-left-color: var(--trim); border-radius: 0; }
:root[data-style="scifi"] details.card > summary::before { content: "▸ "; color: var(--trim); }
:root[data-style="scifi"] .badge { border-radius: 2px; }
.abtag[data-t="反應"] { background: #d0621c; }
.abtag[data-t="被動"] { background: #2f8a4c; }
.atk-fx { font-size: 13.5px; margin-top: 3px; color: var(--text); opacity: .9; }
.atk-fx .lbl { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 5px; margin-right: 4px; border-radius: 3px; background: var(--surface-2); color: var(--muted); }
.atk-fx .lbl.crit { background: #e0b12a; color: #2a2000; }
.attack { flex-wrap: wrap; }
.atk-fxs { flex-basis: 100%; padding-left: 46px; margin-top: 2px; }

/* ---------- 單位更新紀錄（時間軸） ---------- */
.history { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.history > li { position: relative; padding: 0 0 12px 12px; }
.history > li:last-child { padding-bottom: 0; }
.history > li::before {
  content: ""; position: absolute; left: -23px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 0 0 2px var(--gold);
}
.history > li:first-child::before { background: var(--gold); }
.h-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.h-ver { font-weight: 700; color: var(--accent); }
.h-date { font-size: 12px; color: var(--muted); }
.history .rich ul { margin-bottom: 4px; }
/* 更新紀錄：預設收合，摘要列顯示最近一次 */
details.hist > summary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
details.hist > summary .hist-t { font-weight: 700; }
details.hist > summary .hist-latest { font-size: 12.5px; font-weight: 400; color: var(--muted); }
details.hist[open] > summary { margin-bottom: 12px; }

/* ---------- 關鍵字說明（點粗體關鍵字） ---------- */
.kw { cursor: pointer; text-decoration: underline dotted color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 3px; }
.kw-sheet { position: fixed; inset: 0; z-index: 60; background: #0008; display: flex; align-items: flex-end; justify-content: center; }
.kw-panel {
  width: 100%; max-width: 560px; max-height: 70vh; overflow: auto; background: var(--surface); color: var(--text);
  border-top: 2px solid var(--gold); border-radius: 12px 12px 0 0; padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px #0008; animation: kw-up .16s ease-out;
}
@keyframes kw-up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.kw-name { font: 700 18px/1.3 var(--display); color: var(--accent); margin-bottom: 6px; }
.kw-name span { font: 600 12px/1 var(--serif); color: var(--muted); margin-left: 8px; letter-spacing: .06em; }
.kw-panel .btn { width: 100%; margin-top: 12px; }
/* 能力 / 武器名稱下方的原文名稱 */
.n-en { font: 600 11.5px/1.35 var(--display); letter-spacing: .06em; color: var(--muted); margin: -1px 0 4px; }
.attack .n-en { margin-bottom: 0; }
.hub-foot { text-align: center; margin: 26px 0 6px; font-size: 13px; }
.hub-foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.search-cond { font-size: 12.5px; color: var(--muted); margin: 6px 2px 0; }
.search-cond:empty { display: none; }
.search-cond .badge { margin-right: 2px; }
.badge.kwtag { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
/* 可用戰術卡 */
.tac-grp + .tac-grp { margin-top: 10px; }
.tac-h { font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.tacs { display: flex; flex-wrap: wrap; gap: 6px; }
.tac {
  display: inline-flex; align-items: center; gap: 2px; padding: 4px 9px 4px 3px; border-radius: 3px; font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text); text-decoration: none;
}
.tac .abtag { margin: 0 5px 0 0; vertical-align: 0; }
.hero-line { font-size: 13px; color: var(--muted); margin-top: 1px; }
.badge.trait { color: var(--text); border-color: color-mix(in srgb, var(--trim, var(--gold)) 45%, transparent); }

/* 篩選列：固定一行，左右滑動 / 拖曳；放不下時兩端顯示 ‹ › 箭頭 */
.chips { flex-wrap: nowrap; overflow-x: auto; scroll-behavior: smooth; }
[data-q][role="button"] { cursor: pointer; }
.hero-line [data-q] { text-decoration: underline dotted; text-underline-offset: 3px; }
@media (pointer: fine) { .chips { cursor: grab; } }
.chips.dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }
.chips.dragging .chip { pointer-events: none; }
.chip-arrow {
  position: sticky; z-index: 2; flex: none; width: 30px; align-self: stretch; border: 0; padding: 0; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--accent);
}
.chip-arrow.l { left: 0; margin-right: -4px; background: linear-gradient(90deg, var(--bg) 55%, transparent); text-align: left; }
.chip-arrow.r { right: 0; margin-left: auto; background: linear-gradient(270deg, var(--bg) 55%, transparent); text-align: right; }
.chip-arrow[hidden] { display: none; }

/* ---------- 蘭尼斯特：深紅錦緞與金飾（呼應卡面的紅底金框） ---------- */
:root[data-house="lannister"] {
  --bg: #1d0a0c; --surface: #2c1013; --surface-2: #3b161a; --text: #f4e7c9; --muted: #cfae8a;
  --line: #7d5b25; --line-soft: #4d1e21; --gold: #dcb253; --gold-soft: #a07c33;
  --accent: #e9b955; --accent-ink: #1d0a0c; --info: #e9b955;
  --ok: #a6d494; --warn: #f0c060; --bad: #ff9a88;
  --bar: #240709; --bar-ink: #f6e3b4;
  --shadow: 0 1px 2px #0009, 0 6px 18px #0007;
  --paper:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cg fill='none' stroke='%23dcb253' stroke-opacity='.07' stroke-width='1'%3E%3Cpath d='M22 2 42 22 22 42 2 22Z'/%3E%3Cpath d='M22 12c4 4 6 7 0 10-6-3-4-6 0-10Zm0 20c4-4 6-7 0-10-6 3-4 6 0 10Z'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 44px 44px,
    radial-gradient(120% 70% at 50% 0%, #5a1418 0%, transparent 65%),
    radial-gradient(90% 70% at 100% 100%, #12050600 0%, #120506 80%),
    linear-gradient(#2a0c0f, #170708);
}
:root[data-house="lannister"] .topbar {
  background:
    linear-gradient(90deg, #8a1a1a 0%, color-mix(in srgb, #8a1a1a 40%, transparent) 70%, transparent),
    linear-gradient(#3a0d10, var(--bar));
}
:root[data-house="lannister"] .tabs { background: linear-gradient(#300a0d, #120405); }
:root[data-house="lannister"] .tabs a { color: #c49b86; }
:root[data-house="lannister"] .chip.on {
  background: linear-gradient(#f0cd77, #c99a3a); color: #2a0b0d; border-color: #f6dc95;
  box-shadow: inset 0 0 0 1px #fff5, 0 1px 4px #0006;
}
:root[data-house="lannister"] .item,
:root[data-house="lannister"] .card {
  background: linear-gradient(#321216, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px color-mix(in srgb, var(--gold) 28%, transparent);
}
:root[data-house="lannister"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dcb253' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* ---------- 自由民：霜雪與獸骨（淺色；呼應卡面的石褐邊框與長城以北的冰原） ---------- */
:root[data-house="free-folk"] {
  --bg: #e6ebec; --surface: #f6f3ea; --surface-2: #ebe5d6; --text: #2a251f; --muted: #6b6152;
  --line: #b9ab8f; --line-soft: #ddd3bf; --gold: #8a7752; --gold-soft: #b3a27c;
  --accent: #3f6a82; --accent-ink: #f6f3ea; --info: #3f6a82;
  --ok: #3d6b3a; --warn: #9a5a0c; --bad: #9b2c1c;
  --bar: #2b241d; --bar-ink: #efe7d4;
  --shadow: 0 1px 2px #2b241d22, 0 4px 14px #2b241d18;
  --paper:
    radial-gradient(1.2px 1.2px at 20px 30px, #ffffffcc 50%, transparent 51%) 0 0 / 70px 70px,
    radial-gradient(1px 1px at 55px 10px, #ffffffaa 50%, transparent 51%) 0 0 / 90px 90px,
    radial-gradient(120% 60% at 50% 0%, #f7fbfc 0%, transparent 70%),
    radial-gradient(90% 70% at 100% 100%, #c9d5d9 0%, transparent 70%),
    linear-gradient(#e9eef0, #dde5e7);
}
:root[data-house="free-folk"] .topbar {
  background:
    linear-gradient(90deg, #5f4e3a 0%, color-mix(in srgb, #5f4e3a 40%, transparent) 70%, transparent),
    linear-gradient(#3a3027, var(--bar));
  border-bottom-color: #c9bb9b;
}
:root[data-house="free-folk"] .tabs { background: linear-gradient(#3a3027, #1d1813); border-top-color: #c9bb9b; }
:root[data-house="free-folk"] .tabs a { color: #b8ab92; }
:root[data-house="free-folk"] .tabs a.active { color: #e8f1f4; text-shadow: 0 0 8px #9cc4d880; }
:root[data-house="free-folk"] .chip.on {
  background: linear-gradient(#4f7f99, #2f5569); color: #f4f8fa; border-color: #a9c7d6;
  box-shadow: inset 0 0 0 1px #ffffff33, 0 1px 3px #0003;
}
:root[data-house="free-folk"] .item,
:root[data-house="free-folk"] .card {
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #d7ccb4;
}
:root[data-house="free-folk"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233f6a82' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* ---------- 守夜人：黑衣、鐵灰與長城冰光（深色；呼應卡面的鐵灰編織邊框） ---------- */
:root[data-house="nights-watch"] {
  --bg: #0d0f12; --surface: #181b20; --surface-2: #22262d; --text: #e6e9ee; --muted: #9aa3ae;
  --line: #3b424c; --line-soft: #262b32; --gold: #b9c4cf; --gold-soft: #6d7884;
  --accent: #9fd0ea; --accent-ink: #0d0f12; --info: #9fd0ea;
  --ok: #8fc79a; --warn: #e3b25e; --bad: #ef8a7e;
  --bar: #08090b; --bar-ink: #eef2f6;
  --shadow: 0 1px 2px #000a, 0 6px 18px #0008;
  --paper:
    repeating-linear-gradient(0deg, #ffffff05 0 1px, transparent 1px 34px),
    radial-gradient(100% 45% at 50% 0%, #9fd0ea1f 0%, transparent 70%),
    radial-gradient(90% 70% at 100% 100%, #000 0%, transparent 70%),
    linear-gradient(#121519, #0a0b0e);
}
:root[data-house="nights-watch"] .topbar {
  background: linear-gradient(90deg, #22272e 0%, transparent 80%), linear-gradient(#15181d, var(--bar));
  border-bottom-color: #5d6874;
}
:root[data-house="nights-watch"] .tabs { background: linear-gradient(#111317, #050607); border-top-color: #5d6874; }
:root[data-house="nights-watch"] .tabs a { color: #7f8893; }
:root[data-house="nights-watch"] .tabs a.active { color: #dff2fb; text-shadow: 0 0 10px #9fd0ea80; }
:root[data-house="nights-watch"] .chip.on {
  background: linear-gradient(#e9eef2, #b9c4cf); color: #0d0f12; border-color: #f4f8fb;
  box-shadow: inset 0 0 0 1px #fff8, 0 0 10px #9fd0ea33;
}
:root[data-house="nights-watch"] .item,
:root[data-house="nights-watch"] .card {
  background: linear-gradient(#1c2026, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #2f353e;
}
:root[data-house="nights-watch"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239fd0ea' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* 拜拉席恩：黑底金鹿。煤黑面板、上緣一道王旗金黃，互動色用飽和的拜拉席恩黃（與蘭尼斯特的緋紅金錦區隔） */
:root[data-house="baratheon"] {
  --bg: #100f0c; --surface: #1b1914; --surface-2: #26231b; --text: #f1ead8; --muted: #a89f88;
  --line: #4a4230; --line-soft: #2c281e; --gold: #f2c832; --gold-soft: #8a7225;
  --accent: #f2c832; --accent-ink: #14120d; --info: #f2c832;
  --ok: #9cc98a; --warn: #f2a84a; --bad: #ef8a7e;
  --bar: #0b0a08; --bar-ink: #f6eed6;
  --shadow: 0 1px 2px #000a, 0 6px 18px #0008;
  --paper:
    radial-gradient(110% 40% at 50% 0%, #f2c8321a 0%, transparent 70%),
    repeating-linear-gradient(135deg, #ffffff03 0 2px, transparent 2px 9px),
    radial-gradient(90% 70% at 100% 100%, #000 0%, transparent 70%),
    linear-gradient(#15130f, #0b0a08);
}
:root[data-house="baratheon"] .topbar {
  background: linear-gradient(90deg, #3a3216 0%, transparent 75%), linear-gradient(#17150f, var(--bar));
  border-bottom: 2px solid #c9a227;
}
:root[data-house="baratheon"] .tabs { background: linear-gradient(#16140f, #070605); border-top-color: #c9a227; }
:root[data-house="baratheon"] .tabs a { color: #8f8670; }
:root[data-house="baratheon"] .tabs a.active { color: #ffe27a; text-shadow: 0 0 10px #f2c83266; }
:root[data-house="baratheon"] .chip.on {
  background: linear-gradient(#ffdf5e, #e0b324); color: #14120d; border-color: #fff0a8;
  box-shadow: inset 0 0 0 1px #fff6, 0 0 10px #f2c83333;
}
:root[data-house="baratheon"] .item,
:root[data-house="baratheon"] .card {
  background: linear-gradient(#211e17, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #4a3f1c;
}
:root[data-house="baratheon"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f2c832' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* 坦格利安：黑底血紅，龍鱗暗紋 */
:root[data-house="targaryen"] {
  --bg: #0e0a0a; --surface: #1a1213; --surface-2: #261a1b; --text: #f3e6e2; --muted: #ad9792;
  --line: #4d2a2a; --line-soft: #2c1a1a; --gold: #e0403a; --gold-soft: #7c2522;
  --accent: #e0403a; --accent-ink: #ffffff; --info: #f07a6e;
  --ok: #9cc98a; --warn: #f2a84a; --bad: #ff8a7a;
  --bar: #0a0707; --bar-ink: #f6e9e4;
  --shadow: 0 1px 2px #000a, 0 6px 18px #0008;
  --paper:
    radial-gradient(110% 40% at 50% 0%, #c0201a22 0%, transparent 70%),
    radial-gradient(circle at 0 0, #ffffff04 0 6px, transparent 7px) 0 0 / 14px 14px,
    radial-gradient(90% 70% at 100% 100%, #000 0%, transparent 70%),
    linear-gradient(#150d0d, #0a0707);
}
:root[data-house="targaryen"] .topbar {
  background: linear-gradient(90deg, #4a1010 0%, transparent 75%), linear-gradient(#160e0e, var(--bar));
  border-bottom: 2px solid #b3221c;
}
:root[data-house="targaryen"] .tabs { background: linear-gradient(#150d0d, #060404); border-top-color: #b3221c; }
:root[data-house="targaryen"] .tabs a { color: #94807b; }
:root[data-house="targaryen"] .tabs a.active { color: #ff6a5c; text-shadow: 0 0 10px #e0403a66; }
:root[data-house="targaryen"] .chip.on {
  background: linear-gradient(#e2463f, #a81c17); color: #fff; border-color: #ff9a8f;
  box-shadow: inset 0 0 0 1px #fff3, 0 0 10px #e0403a44;
}
:root[data-house="targaryen"] .item,
:root[data-house="targaryen"] .card {
  background: linear-gradient(#22171700, #1f1515), var(--surface);
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #5a1d1b;
}
:root[data-house="targaryen"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e0403a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* 葛雷喬伊：深海青黑底，海怪金 */
:root[data-house="greyjoy"] {
  --bg: #08100f; --surface: #101b1a; --surface-2: #172624; --text: #e6efec; --muted: #8fa39f;
  --line: #24403c; --line-soft: #162a27; --gold: #d8b44a; --gold-soft: #6f5c22;
  --accent: #d8b44a; --accent-ink: #0c1413; --info: #6fc2b4;
  --ok: #9cc98a; --warn: #f2a84a; --bad: #ef8a7e;
  --bar: #060c0b; --bar-ink: #e9f1ee;
  --shadow: 0 1px 2px #000a, 0 6px 18px #0008;
  --paper:
    radial-gradient(110% 40% at 50% 0%, #2f6f6622 0%, transparent 70%),
    repeating-linear-gradient(170deg, #ffffff03 0 3px, transparent 3px 14px),
    radial-gradient(90% 70% at 100% 100%, #000 0%, transparent 70%),
    linear-gradient(#0c1716, #060c0b);
}
:root[data-house="greyjoy"] .topbar {
  background: linear-gradient(90deg, #12403a 0%, transparent 75%), linear-gradient(#0c1615, var(--bar));
  border-bottom: 2px solid #b8963a;
}
:root[data-house="greyjoy"] .tabs { background: linear-gradient(#0c1615, #040807); border-top-color: #b8963a; }
:root[data-house="greyjoy"] .tabs a { color: #7f938f; }
:root[data-house="greyjoy"] .tabs a.active { color: #f0cf68; text-shadow: 0 0 10px #d8b44a55; }
:root[data-house="greyjoy"] .chip.on {
  background: linear-gradient(#e6c45c, #b48f2c); color: #0c1413; border-color: #f6e29a;
  box-shadow: inset 0 0 0 1px #fff5, 0 0 10px #d8b44a33;
}
:root[data-house="greyjoy"] .item,
:root[data-house="greyjoy"] .card {
  background: linear-gradient(#142321, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #2d5a53;
}
:root[data-house="greyjoy"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d8b44a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* 馬泰爾：沙漠暖橘底，太陽紅與金 */
:root[data-house="martell"] {
  --bg: #f3e6d2; --surface: #fbf3e6; --surface-2: #f0e0c6; --text: #3a2414; --muted: #8a6a4e;
  --line: #ddc3a0; --line-soft: #ecdcc2; --gold: #c2541c; --gold-soft: #e8b88a;
  --accent: #c2541c; --accent-ink: #fff8ee; --info: #b5461a;
  --ok: #4f8a3c; --warn: #c27a12; --bad: #b42e2e;
  --bar: #9c3f14; --bar-ink: #fff3e2;
  --shadow: 0 1px 2px #6b3a1422, 0 6px 18px #6b3a141a;
  --paper:
    radial-gradient(120% 50% at 50% 0%, #f7c56a33 0%, transparent 70%),
    repeating-linear-gradient(160deg, #a4622c08 0 2px, transparent 2px 12px),
    linear-gradient(#f6ead7, #ecd9bb);
}
:root[data-house="martell"] .topbar {
  background: linear-gradient(90deg, #c2541c 0%, #9c3f14 70%), var(--bar);
  border-bottom: 2px solid #e9b43e;
}
:root[data-house="martell"] .tabs { background: linear-gradient(#a5461a, #7c3010); border-top-color: #e9b43e; }
:root[data-house="martell"] .tabs a { color: #f3cfa8; }
:root[data-house="martell"] .tabs a.active { color: #ffe08a; text-shadow: 0 0 10px #ffcf5a66; }
:root[data-house="martell"] .chip.on {
  background: linear-gradient(#d9692a, #a8441a); color: #fff8ee; border-color: #f0a060;
  box-shadow: inset 0 0 0 1px #fff4, 0 0 10px #c2541c33;
}
:root[data-house="martell"] .item,
:root[data-house="martell"] .card {
  background: linear-gradient(#fffaf1, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #e3b98c;
}
:root[data-house="martell"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c2541c' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* 波頓：暗鐵灰黑底，剝皮人的血紅與粉紅 */
:root[data-house="bolton"] {
  --bg: #0f0c0d; --surface: #1b1517; --surface-2: #261d20; --text: #f0e4e6; --muted: #a8949a;
  --line: #4a2f36; --line-soft: #2c1d21; --gold: #d97a8a; --gold-soft: #7a3a46;
  --accent: #d0445c; --accent-ink: #ffffff; --info: #e88a9a;
  --ok: #9cc98a; --warn: #f2a84a; --bad: #ff8a7a;
  --bar: #0a0809; --bar-ink: #f4e8ea;
  --shadow: 0 1px 2px #000a, 0 6px 18px #0008;
  --paper:
    radial-gradient(110% 40% at 50% 0%, #a0283c22 0%, transparent 70%),
    radial-gradient(3px 3px at 30px 40px, #7a1a2a33 50%, transparent 51%) 0 0 / 120px 120px,
    radial-gradient(90% 70% at 100% 100%, #000 0%, transparent 70%),
    linear-gradient(#161113, #0a0809);
}
:root[data-house="bolton"] .topbar {
  background: linear-gradient(90deg, #4a1a24 0%, transparent 75%), linear-gradient(#161113, var(--bar));
  border-bottom: 2px solid #b0304a;
}
:root[data-house="bolton"] .tabs { background: linear-gradient(#161113, #060405); border-top-color: #b0304a; }
:root[data-house="bolton"] .tabs a { color: #96848a; }
:root[data-house="bolton"] .tabs a.active { color: #ff8fa2; text-shadow: 0 0 10px #d0445c66; }
:root[data-house="bolton"] .chip.on {
  background: linear-gradient(#d84d66, #9c2238); color: #fff; border-color: #f4a0b0;
  box-shadow: inset 0 0 0 1px #fff3, 0 0 10px #d0445c44;
}
:root[data-house="bolton"] .item,
:root[data-house="bolton"] .card {
  background: linear-gradient(#221a1d, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #5a2a34;
}
:root[data-house="bolton"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d0445c' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* 無旗兄弟會：林地墨綠底，火焰橘與金 */
:root[data-house="brotherhood"] {
  --bg: #0b110c; --surface: #141c15; --surface-2: #1c271d; --text: #e9f0e4; --muted: #9aab96;
  --line: #2f4430; --line-soft: #1b281c; --gold: #e8a23a; --gold-soft: #7a5620;
  --accent: #e8862a; --accent-ink: #160e04; --info: #f0b45a;
  --ok: #9cc98a; --warn: #f2a84a; --bad: #ef8a7e;
  --bar: #070b07; --bar-ink: #eef3ea;
  --shadow: 0 1px 2px #000a, 0 6px 18px #0008;
  --paper:
    radial-gradient(110% 40% at 50% 0%, #e8862a1c 0%, transparent 70%),
    repeating-linear-gradient(115deg, #ffffff03 0 2px, transparent 2px 11px),
    radial-gradient(90% 70% at 100% 100%, #000 0%, transparent 70%),
    linear-gradient(#0f1710, #070b07);
}
:root[data-house="brotherhood"] .topbar {
  background: linear-gradient(90deg, #22401f 0%, transparent 75%), linear-gradient(#0f1710, var(--bar));
  border-bottom: 2px solid #d8852c;
}
:root[data-house="brotherhood"] .tabs { background: linear-gradient(#0f1710, #040704); border-top-color: #d8852c; }
:root[data-house="brotherhood"] .tabs a { color: #8a9a86; }
:root[data-house="brotherhood"] .tabs a.active { color: #ffb35a; text-shadow: 0 0 10px #e8862a66; }
:root[data-house="brotherhood"] .chip.on {
  background: linear-gradient(#f09a3c, #c0641a); color: #160e04; border-color: #ffd29a;
  box-shadow: inset 0 0 0 1px #fff5, 0 0 10px #e8862a44;
}
:root[data-house="brotherhood"] .item,
:root[data-house="brotherhood"] .card {
  background: linear-gradient(#182219, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #33502f;
}
:root[data-house="brotherhood"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e8862a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}

/* 中立：皮革棕底，傭兵金幣色 */
:root[data-house="neutral"] {
  --bg: #120e0a; --surface: #1d1712; --surface-2: #282019; --text: #f1e8dc; --muted: #ab9a85;
  --line: #4a3a2a; --line-soft: #2c231a; --gold: #d8ae5a; --gold-soft: #77592a;
  --accent: #d8ae5a; --accent-ink: #160f08; --info: #e6c27a;
  --ok: #9cc98a; --warn: #f2a84a; --bad: #ef8a7e;
  --bar: #0c0906; --bar-ink: #f4ecdf;
  --shadow: 0 1px 2px #000a, 0 6px 18px #0008;
  --paper:
    radial-gradient(110% 40% at 50% 0%, #d8ae5a1a 0%, transparent 70%),
    repeating-linear-gradient(45deg, #ffffff03 0 2px, transparent 2px 10px),
    radial-gradient(90% 70% at 100% 100%, #000 0%, transparent 70%),
    linear-gradient(#18120d, #0c0906);
}
:root[data-house="neutral"] .topbar {
  background: linear-gradient(90deg, #4a3420 0%, transparent 75%), linear-gradient(#18120d, var(--bar));
  border-bottom: 2px solid #b08a44;
}
:root[data-house="neutral"] .tabs { background: linear-gradient(#18120d, #060403); border-top-color: #b08a44; }
:root[data-house="neutral"] .tabs a { color: #95856f; }
:root[data-house="neutral"] .tabs a.active { color: #f2cd7c; text-shadow: 0 0 10px #d8ae5a55; }
:root[data-house="neutral"] .chip.on {
  background: linear-gradient(#e6bf6c, #b08a3e); color: #160f08; border-color: #f6e0a6;
  box-shadow: inset 0 0 0 1px #fff5, 0 0 10px #d8ae5a33;
}
:root[data-house="neutral"] .item,
:root[data-house="neutral"] .card {
  background: linear-gradient(#231c15, var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 3px var(--surface), inset 0 0 0 4px #5a4026;
}
:root[data-house="neutral"] .search {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d8ae5a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}
.bonus-line { margin-top: 6px; }
.army-top { margin-top: 2px; }
.code-box { font: 13px/1.4 ui-monospace, Consolas, monospace; min-height: 90px; word-break: break-all; color: var(--text); }
.err-t { color: var(--bad); min-height: 1em; }
.shared-tag { font-size: 12.5px; color: var(--accent); margin-bottom: 4px; letter-spacing: .04em; }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.army-li { display: flex; align-items: center; gap: 8px; }
.army-li .army-item { flex: 1; min-width: 0; }

/* ---------- 輸出（列印卡牌） ---------- */
.print-tools .btn.wide { margin-top: 8px; }
.print-sheet { margin-top: 12px; background: #fff; color: #111; padding: 6mm; border-radius: 4px; overflow-x: auto; }
.pcards { display: flex; flex-wrap: wrap; gap: 1mm; align-items: flex-start; width: 198mm; }
.prow { display: flex; flex-wrap: wrap; gap: 1mm; align-items: flex-start; width: 198mm; margin-bottom: 2mm; break-inside: avoid; page-break-inside: avoid; }
.psec { margin-top: 3mm; }
.prow .ptitle { flex-basis: 100%; }
.psec.newpage { break-before: page; page-break-before: always; }
.ptitle { margin: 0 0 1.5mm; font: 700 10pt/1.3 var(--display); color: #555; letter-spacing: .1em; border-bottom: 0.3mm solid #bbb; width: 198mm; }
.pcard { display: block; outline: 0.2mm dashed #999; outline-offset: 0; break-inside: avoid; }
.pcard.landscape { width: 120mm; height: 70mm; }
.pcard.portrait { width: 63.5mm; height: 88.9mm; }
.plist { width: 198mm; margin-bottom: 4mm; font-size: 10pt; break-after: auto; }
.plist h2 { margin: 0 0 1mm; font: 700 14pt/1.3 var(--display); color: #111; }
.plist .pmeta { color: #555; font-size: 9pt; margin: 1mm 0; }
.plist table { border-collapse: collapse; width: 100%; }
.plist td { border-bottom: 0.2mm solid #ddd; padding: 0.8mm 1mm; }

@media print {
  @page { size: A4; margin: 6mm; }
  html, body { background: #fff !important; }
  .topbar, .tabs, .print-tools, .kw-sheet { display: none !important; }
  main, #view { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .print-sheet { margin: 0; padding: 0; border-radius: 0; overflow: visible; }
  body { padding: 0 !important; }
}
.usum { text-align: right; font-size: 13px; color: var(--muted); margin-top: 6px; }
.usum b { color: var(--gold); font-weight: 700; }
.plist td:nth-child(2), .plist td:nth-child(3) { text-align: right; width: 12mm; }
.plist tr.u td { border-top: 0.3mm solid #999; }
.plist tr.th td { color: #777; font-size: 8.5pt; border-bottom: 0.3mm solid #999; padding-top: 2mm; }
.plist tr.tot td { border-top: 0.4mm solid #333; font-size: 11pt; }
.pk-f { padding-top: 6px; }
.pk-f .chip { font-size: 13px; padding: 4px 11px; }
.pk-h { list-style: none; display: flex; justify-content: space-between; font: 700 12.5px/1 var(--display); color: var(--muted); letter-spacing: .08em; padding: 10px 2px 2px; border-bottom: 1px solid var(--line-soft); }
.pk-h span { font-weight: 400; }
.pk-h.cmd { color: var(--accent); }
.lock-note { color: var(--warn); margin: 14px 2px 0; }
.abadges { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px; }
.abadge { font-size: 11px; line-height: 1.5; padding: 0 6px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); }
.abadge.loyal { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); }
.abadge.aff { border-style: dashed; }
.abadge.bad { border-color: var(--bad); color: var(--bad); }
.plist .ptag { font-size: 8pt; color: #777; }
.meta .abadge { margin-right: 4px; cursor: pointer; }
.hero-attr { margin-top: 8px; }
.hero-attr .abadge { font-size: 12.5px; padding: 1px 8px; cursor: pointer; }

/* ================= 響應式：平板（≥768px）與電腦（≥1100px） ================= */
@media (min-width: 768px) {
  main { max-width: 1000px; padding: 18px 24px 28px; }
  .topbar h1 { font-size: 22px; }
  /* 清單類：兩欄 */
  #cardList, .list.armies, .list.games { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #cardList > .empty { grid-column: 1 / -1; }
  #cardList > li > .item, .list.armies > li > .item { height: 100%; box-sizing: border-box; }
  .list.armies > li { align-items: stretch; }
  /* 彈出面板：改成畫面中央的對話框 */
  .kw-sheet { align-items: center; padding: 24px; }
  .kw-panel { border-radius: 12px; border: 1px solid var(--gold); max-height: 80vh; }
  .pick-panel { max-width: 720px; }
  .pick-panel .list.pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-content: start; }
  .pick-panel .pk-h, .pick-panel .list.pick > .empty { grid-column: 1 / -1; }
  /* 卡牌詳細頁：左欄（名稱數值＋卡面）固定在畫面上；右欄（攻擊、能力、紀錄）與左欄等高，能力框往下填滿 */
  #view[data-page="card"] { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 18px; align-items: stretch; align-content: start; }
  #view[data-page="card"][data-shape="portrait"] { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  #view[data-page="card"] > .card-left { align-self: start; position: sticky; top: 70px; }
  #view[data-page="card"] > .card-right { display: flex; flex-direction: column; }
  #view[data-page="card"] .card-left > .card, #view[data-page="card"] .card-right > .card { margin-top: 0; margin-bottom: 12px; }
  #view[data-page="card"] .card-right > .abil { flex: 1 0 auto; }
  #view[data-page="card"] .card-right > .provenance { margin-top: 0; }
  #view[data-page="card"] .card-left .cardimg { max-height: calc(100vh - 400px); width: auto; height: auto; max-width: 100%; margin: 0 auto; display: block; }
  #view[data-page="card"][data-shape="portrait"] .card-left .cardimg { min-height: 260px; }
  /* 編成：戰鬥單位在左，指揮官、非戰鬥單位、戰術牌庫在右 */
  #view[data-page="army"] { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-auto-flow: row dense; column-gap: 16px; align-items: start; }
  #view[data-page="army"] > * { grid-column: 1 / -1; }
  #view[data-page="army"] > .a-units { grid-column: 1; grid-row: span 4; }
  #view[data-page="army"] > .a-cmd, #view[data-page="army"] > .a-ncu,
  #view[data-page="army"] > .a-enemy, #view[data-page="army"] > .a-tac { grid-column: 2; }
  #view[data-page="army"] > .card { margin-top: 12px; }
  /* 輸出頁：A4 預覽置中 */
  #view[data-page="print"] .print-sheet { width: fit-content; margin-left: auto; margin-right: auto; box-shadow: 0 4px 18px #0006; }
  /* 底部功能列：內容置中，不拉得太寬 */
  .tabs { justify-content: center; }
  .tabs a { flex: 0 1 180px; }
}
@media (min-width: 1100px) {
  main { max-width: 1440px; }
  #cardList, .list.armies { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .list.games { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #view[data-page="card"][data-shape="landscape"] { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
  .pick-panel { max-width: 960px; }
  .pick-panel .list.pick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media print {
  #view[data-page="print"] { display: block !important; }
  #view[data-page="print"] .print-sheet { box-shadow: none; }
}

/* 超大螢幕（2K / 4K 且系統縮放 100%）：整體等比放大，避免字與卡面太小、兩側過空 */
@media screen and (min-width: 2200px) { html { zoom: 1.25; } }
@media screen and (min-width: 2900px) { html { zoom: 1.5; } }
@media screen and (min-width: 3600px) { html { zoom: 1.75; } }

/* ================= 大螢幕兩側：陣營裝飾 =================
 * 內容區最寬 1440px；畫面更寬時，兩側放陣營色紋樣與圓形家徽浮水印，內容區像放在桌上的一本冊子。 */
.side { display: none; }
@media screen and (min-width: 1560px) {
  :root[data-view="game"] main {
    position: relative; z-index: 1; background: var(--bg);
    border-left: 1px solid var(--gold-soft); border-right: 1px solid var(--gold-soft);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--bg) 60%, transparent), 0 0 48px #000d;
    min-height: calc(100vh - 120px);
  }
  :root[data-view="game"] .side {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: fixed; top: 0; bottom: 0; z-index: 0; pointer-events: none; overflow: hidden;
    width: calc((100% - 1440px) / 2);
    background:
      radial-gradient(110% 60% at 50% 45%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 72%),
      repeating-linear-gradient(45deg, color-mix(in srgb, var(--gold) 9%, transparent) 0 1px, transparent 1px 22px),
      repeating-linear-gradient(-45deg, color-mix(in srgb, var(--gold) 9%, transparent) 0 1px, transparent 1px 22px),
      linear-gradient(color-mix(in srgb, var(--bar) 60%, var(--bg)), color-mix(in srgb, var(--bg) 85%, #000));
  }
  :root[data-view="game"] .side.l { left: 0; border-right: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
  :root[data-view="game"] .side.r { right: 0; border-left: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
  /* 上下的細飾線 */
  :root[data-view="game"] .side::before, :root[data-view="game"] .side::after {
    content: ""; width: 1px; flex: 1; margin: 90px 0 24px;
    background: linear-gradient(transparent, color-mix(in srgb, var(--gold) 45%, transparent), transparent);
  }
  :root[data-view="game"] .side::after { margin: 24px 0 90px; }
  :root[data-view="game"] .side-crest {
    flex: none; width: min(64%, 260px); aspect-ratio: 1; border-radius: 50%;
    background: var(--crest-url, none) center / cover no-repeat;
    opacity: .28; filter: saturate(.7) contrast(1.05);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 60%, transparent), 0 0 0 7px color-mix(in srgb, var(--gold) 14%, transparent), 0 0 60px #0008;
  }
}
@media print { .side { display: none !important; } }
