/* Momentum 灰盒 UI。美术素材通过 --asset-<name> 变量接入（见 src/ui/theme.js、assets/ui/README.md） */
:root {
  --bg: #12201d;
  --panel: #1b2f2a;
  --panel-2: #223a34;
  --line: #3b5a52;
  --text: #e8f0ec;
  --muted: #9bb3aa;
  --accent: #f0c04a;
  --danger: #e5645a;
  --ok: #5fcf8a;
  --cell-w: clamp(56px, 11.4vh, 124px);
  --bot-h: clamp(236px, 43vh, 520px);
  --card-h: max(104px, min(calc(var(--bot-h) - 112px), calc((70vw - 30px) / 3.6)));
  --card-w: calc(var(--card-h) * 0.714);
  --pm-h: clamp(70px, 22vh, 300px);
  --fs: clamp(11px, 1.55vh, 16px);
  --theme-cui: #2f9e6e; --theme-cui-ink: #fff;
  --theme-shuang: #5ab0e8; --theme-shuang-ink: #06293f;
  --theme-fu: #aeb8bf; --theme-fu-ink: #202a30;
  --theme-sha: #d9ad4f; --theme-sha-ink: #3a2a05;
  --pawn-red: #e0453a; --pawn-blue: #3b7de0; --pawn-green: #3fae4a; --pawn-yellow: #f2c230;
  /* 棋子渲染标准（docs/track-pawn-spec.md，数字由 refs/ 设计稿实测）：
     --pawn-disc-frac 必须与 scripts/prepare-pawns.js 的 DISC_FRAC 一致，影子宽度靠它算。 */
  --pawn-disc-frac: .519;   /* 底座宽 / 精灵画布宽；prepare-pawns.js 实际产出值，剪影收紧后应回到 .64 */
  --pawn-art-frac: .604;   /* 精灵画布里真正有画面的宽度占比；prepare-pawns.js 会打印该填多少 */
  --pawn-h: .92;           /* 棋子总高 / 格高（设计稿实测）——尺寸基准 */
  --pawn-art-h: .961;      /* 精灵画布里有画面的高度占比，取四只里最高的；prepare-pawns.js 会打印 */
  --pawn-foot: .69;        /* 脚底锚点 = 格高的几成 */
  --rail-h: .22;           /* 砖栏高 = 格高的几成 */
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--asset-table_bg, none) center/cover no-repeat, radial-gradient(ellipse at 50% 30%, #1d3a33, var(--bg) 70%);
  color: var(--text);
  font: var(--fs)/1.35 "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
#app {
  height: 100vh; padding: 6px; gap: 6px; display: grid;
  grid-template-columns: clamp(150px, 14vw, 250px) minmax(0, 1fr) clamp(270px, 25vw, 440px);
  grid-template-rows: auto auto auto minmax(0, 1fr) minmax(0, var(--bot-h));
  grid-template-areas: "top top top" "banner banner banner" "score score score" "pop market log" "hand hand right";
}
#top { grid-area: top; display: flex; align-items: center; gap: 14px; min-height: 30px; }
#logo { display: flex; align-items: center; gap: 8px; letter-spacing: .12em; }
.logo-img { display: none; width: 150px; height: 36px; background: var(--asset-logo_momentum, none) left center/contain no-repeat; }
.has-logo_momentum .logo-img { display: inline-block; }
.has-logo_momentum #logo strong { display: none; }
#turnInfo { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#deckInfo { color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#deckInfo b { color: var(--text); }
#banner { grid-area: banner; min-height: 1.9em; padding: 3px 10px; border-radius: 6px; background: #0e1816cc; border: 1px solid var(--line); display: flex; gap: 14px; align-items: center; white-space: nowrap; overflow: hidden; }
#banner .cur { font-weight: 700; color: var(--accent); }
#banner .last { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
#banner.busy .cur::after { content: " …"; }
#scorePanel { grid-area: score; }
#popPanel { grid-area: pop; overflow: auto; }
#market { grid-area: market; }
#logPanel { grid-area: log; display: flex; flex-direction: column; }
#handArea { grid-area: hand; display: block; }
#rightArea { grid-area: right; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
#publicMarket { flex: 0 0 auto; }
#actionPanel { flex: 1 1 auto; min-height: 0; overflow: auto; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 0; min-height: 0; }
.panel.large { background-image: var(--asset-panel_large, none); background-size: 100% 100%; }
.panel.small { background-image: var(--asset-panel_small, none); background-size: 100% 100%; }
.panel-title { font-weight: 700; margin-bottom: 4px; color: var(--accent); }
.panel-title small { font-weight: 400; color: var(--muted); }

/* ---------- Market ---------- */
#trackScroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; scroll-behavior: smooth; }
#trackWrap { position: relative; width: max-content; padding-top: 2px; }
#track { display: flex; align-items: flex-end; }
/* 上下两条细砖栏：格子的立体感来自它们和格子投在下栏上的影，不来自格子自己的厚度。
   位置由 app.js 的 layoutRails() 按格子实测矩形写入；素材缺失时整条不显示。 */
.rail { position: absolute; left: 0; display: none; background-size: auto 100%; background-repeat: repeat-x; pointer-events: none; z-index: 0; }
/* 格子底衬：垫在整排格子后面的深色槽。瓷砖圆角 + 边缘内收会让相邻两格之间露出木纹，
   有了它，缝读作暗槽而不是窟窿；也把上下砖栏和格子连成一体。位置由 layoutRails() 写入。 */
#tileBed { position: absolute; left: 0; display: none; pointer-events: none; z-index: 0; background: linear-gradient(#1b0f08, #2a1810 55%, #1a0e07); box-shadow: inset 0 2px 6px #000c, inset 0 -2px 6px #000a; }
.has-rail_top #tileBed, .has-rail_bottom #tileBed { display: block; }
#railTop { background-image: var(--asset-rail_top, none); }
#railBottom { background-image: var(--asset-rail_bottom, none); }
.has-rail_top #railTop, .has-rail_bottom #railBottom { display: block; }
/* 砖栏和 #track 同为 z-index 0，靠 DOM 顺序（砖栏在前）让格子压在砖栏上，和设计稿一致 */
/* 下栏顶端压一道内投影 = 格子落在砖上的影；画在栏上而不是每块格子上，格缝处才不会断 */
#railBottom { box-shadow: inset 0 6px 10px -4px rgba(0, 0, 0, .55); }
#railBottom { background-position-x: calc(var(--cell-w) * -0.37); }  /* 和上栏错开，避免砖缝对齐露馅 */
.start, .promo { flex: 0 0 auto; }
.start { width: var(--cell-w); text-align: center; color: var(--muted); font-size: .85em; }
.start .tile { background: repeating-linear-gradient(45deg, #2a3f39, #2a3f39 5px, #22352f 5px, #22352f 10px); color: var(--muted); }
.promo { position: relative; }
.promo .lab { height: 1.5em; font-size: .82em; line-height: 1.5em; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: clip; color: var(--muted); }
.promo .tiles { display: flex; }
.tile { width: var(--cell-w); height: clamp(34px, 9vh, 100px); display: flex; align-items: center; justify-content: center; font-weight: 700; border: 1px solid rgba(0,0,0,.35); border-left-width: 1px; position: relative; background-size: 100% 100%; }
.tile .num { position: absolute; left: 2px; top: 0; font-size: .7em; opacity: .75; font-weight: 400; }
.theme-E .tile, .tile.theme-E { background-color: var(--theme-cui); color: var(--theme-cui-ink); background-image: var(--asset-tile_cui, none); }
.theme-G .tile, .tile.theme-G { background-color: var(--theme-shuang); color: var(--theme-shuang-ink); background-image: var(--asset-tile_shuang, none); }
.theme-R .tile, .tile.theme-R { background-color: var(--theme-fu); color: var(--theme-fu-ink); background-image: var(--asset-tile_fu, none); }
.theme-T .tile, .tile.theme-T { background-color: var(--theme-sha); color: var(--theme-sha-ink); background-image: var(--asset-tile_sha, none); }
.promo.first-card .tile:first-child { border-left: 3px solid #fff8; }
.promo .badge { position: absolute; right: 2px; top: 0; font-size: .72em; background: #000a; color: #ffd9d4; border-radius: 4px; padding: 0 4px; }
.promo.behind .tile { filter: saturate(.55) brightness(.8); }
.promo.collectable { cursor: pointer; outline: 3px solid var(--accent); outline-offset: 1px; animation: pulse 1s infinite alternate; }
.promo.hl, .pm-card.hl { outline: 3px solid #fff; outline-offset: 1px; animation: pulse .6s infinite alternate; }
.promo.will-cover .tile.cov { outline: 2px dashed var(--danger); outline-offset: -3px; opacity: .55; }
.promo.ghost { opacity: .6; }
.promo.ghost .tile { border: 2px dashed #fff; }
.promo.pop-in { animation: popin .55s ease-out; }
@keyframes popin { from { transform: translateY(-26px) scale(1.25); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { from { outline-color: var(--accent); } to { outline-color: #fff; } }
.promo button.hit { all: unset; position: absolute; inset: 0; cursor: pointer; z-index: 2; }
.promo button.hit:focus-visible { outline: 3px solid #fff; }

#pawns { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.pawn { position: absolute; width: calc(var(--cell-w) * .46); height: calc(var(--cell-w) * .46); min-width: 16px; min-height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #000, 0 2px 4px #0008; display: flex; align-items: center; justify-content: center; font-size: .72em; font-weight: 800; color: #000; transition: left var(--pawn-t, .65s) linear, top .35s, transform .65s; background-size: contain; background-color: var(--c); z-index: 3; }
.pawn.pawn-red { background-image: var(--asset-pawn_red, none); }
.pawn.pawn-blue { background-image: var(--asset-pawn_blue, none); }
.pawn.pawn-green { background-image: var(--asset-pawn_green, none); }
.pawn.pawn-yellow { background-image: var(--asset-pawn_yellow, none); }
.pawn.cur { box-shadow: 0 0 0 2px var(--accent), 0 0 10px 3px var(--accent); }
.pawn.ghost { opacity: .75; border-style: dashed; background: transparent; color: #fff; text-shadow: 0 0 3px #000; }
/* 移动中的抬起效果在 m5.css（.pawn.moving 的 pawnStep 跳跃）。这里原来有一条
   transform: translateY(-10px) scale(1.25)，它会整条替换掉 .pawn 的脚底锚点
   translate(-50%,-100%)，棋子一走就掉出格子外还放大一圈，已删。 */

/* ---------- 中部面板 ---------- */
.pm-row { display: flex; gap: 6px; align-items: flex-start; }
.pm-card, .deck { width: calc(var(--pm-h) * .714); }
.pm-card { position: relative; background: none; border: 2px solid transparent; padding: 0; border-radius: 6px; cursor: default; }
.pm-card img, .deck .back { width: 100%; height: var(--pm-h); border-radius: 5px; display: block; object-fit: cover; }
.pm-card.selectable { cursor: pointer; border-color: #fff6; }
.pm-card.picked { border-color: var(--accent); transform: translateY(-4px); }
.pm-card .cap, .hcard .cap { display: block; font-size: .78em; text-align: center; padding: 1px 0; border-radius: 0 0 4px 4px; }
.deck { text-align: center; }
.deck .back { background: var(--asset-card_back, none) center/cover, repeating-linear-gradient(45deg, #3b5a52, #3b5a52 6px, #2b4741 6px, #2b4741 12px); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.4em; }
.deck.selectable { cursor: pointer; }
.deck.selectable .back { outline: 2px solid #fff6; }
.deck.picked .back { outline: 3px solid var(--accent); }
.deck button { all: unset; cursor: pointer; display: block; width: 100%; }
.deck button:focus-visible .back, .pm-card:focus-visible, .hcard:focus-visible { outline: 3px solid #fff; }
.empty-slot { width: calc(var(--pm-h) * .714); height: var(--pm-h); border: 2px dashed var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8em; }

.pop-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 2.3em; padding: 0 6px; border-radius: 10px; font-weight: 700; }
.chip.theme-E { background: var(--theme-cui); color: var(--theme-cui-ink); }
.chip.theme-G { background: var(--theme-shuang); color: var(--theme-shuang-ink); }
.chip.theme-R { background: var(--theme-fu); color: var(--theme-fu-ink); }
.chip.theme-T { background: var(--theme-sha); color: var(--theme-sha-ink); }
.ticon { display: inline-block; width: 1.1em; height: 1.1em; background-size: contain; background-repeat: no-repeat; vertical-align: -0.15em; margin-right: 2px; }
.theme-E .ticon { background-image: var(--asset-icon_cui, none); } .theme-G .ticon { background-image: var(--asset-icon_shuang, none); }
.theme-R .ticon { background-image: var(--asset-icon_fu, none); } .theme-T .ticon { background-image: var(--asset-icon_sha, none); }
.bar { flex: 1; height: 10px; background: #0e1816; border-radius: 5px; overflow: hidden; }
.bar > i { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left; transition: transform .4s; }
.pop-num { width: 1.6em; text-align: right; font-weight: 800; font-size: 1.15em; }
.hint { color: var(--muted); font-size: .8em; margin-top: 4px; }

.score-row { display: block; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; margin-bottom: 3px; cursor: pointer; }
.score-row.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.score-row .l1 { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.score-row .l1 .tot { margin-left: auto; font-size: 1.2em; color: var(--accent); }
.score-row .l2 b { font-weight: 600; }
.score-row .l2 { font-size: .78em; color: var(--muted); }
.score-row .l3 { font-size: .78em; color: #c9d8d1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; width: 1em; height: 1em; border-radius: 50%; border: 2px solid #fff; background-color: var(--c); background-size: contain; flex: 0 0 auto; }
.avatar { display: inline-block; padding: 1px; background-image: var(--asset-avatar_frame_1, none); background-size: 100% 100%; }
.dot.pawn-red { background-image: var(--asset-pawn_red, none); } .dot.pawn-blue { background-image: var(--asset-pawn_blue, none); }
.dot.pawn-green { background-image: var(--asset-pawn_green, none); } .dot.pawn-yellow { background-image: var(--asset-pawn_yellow, none); }

/* ---------- 日志 ---------- */
#log { flex: 1; overflow-y: auto; font-size: .82em; line-height: 1.35; }
#log div { padding: 2px 0; border-bottom: 1px solid #ffffff10; }
#log .sys { color: var(--accent); }
#log .pts { color: var(--ok); }

/* ---------- 手牌与行动 ---------- */
#handWrap { flex: 1 1 auto; min-width: 0; }
#hand { display: flex; gap: 6px; padding-top: 8px; min-height: calc(var(--card-h) + 22px); overflow-x: auto; }
.hcard { flex: 0 0 auto; width: var(--card-w); background: none; border: 2px solid transparent; border-radius: 6px; padding: 0; position: relative; cursor: pointer; transition: transform .15s; }
.hcard img { width: 100%; height: var(--card-h); display: block; border-radius: 5px; object-fit: cover; }
.hcard.sel { transform: translateY(-10px); border-color: var(--accent); }
.hcard.dis { cursor: default; opacity: .9; }
.cap.theme-E { background: var(--theme-cui); color: var(--theme-cui-ink); } .cap.theme-G { background: var(--theme-shuang); color: var(--theme-shuang-ink); }
.cap.theme-R { background: var(--theme-fu); color: var(--theme-fu-ink); } .cap.theme-T { background: var(--theme-sha); color: var(--theme-sha-ink); }
#actions { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 5px; }
.btn { min-height: 2.4em; padding: 2px 12px; border-radius: 6px; border: 1px solid var(--line); background-color: #2f5b4e; background-size: 100% 100%; cursor: pointer; font-weight: 700; }
.btn.primary { background-image: var(--asset-btn_primary_default, none); }
.btn.secondary { background-color: #2a3f39; background-image: var(--asset-btn_secondary_default, none); font-weight: 400; }
.btn.primary:hover:not(:disabled) { background-color: #3a7463; background-image: var(--asset-btn_primary_hover, none); }
.btn.secondary:hover:not(:disabled) { background-color: #36504a; background-image: var(--asset-btn_secondary_hover, none); }
.btn.primary:active:not(:disabled) { background-image: var(--asset-btn_primary_pressed, none); transform: translateY(1px); }
.btn.secondary:active:not(:disabled) { background-image: var(--asset-btn_secondary_pressed, none); transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; background-image: var(--asset-btn_primary_disabled, none); }
.btn.secondary:disabled { background-image: var(--asset-btn_secondary_disabled, none); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 1px; }
.btn.on { box-shadow: 0 0 0 2px var(--accent); }
.reasons { font-size: .78em; color: var(--muted); }
.reasons div b { color: #d8c27a; font-weight: 600; }
#preview { background: #0e1816; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: .86em; min-height: 3.2em; flex: 1; overflow: auto; }
#preview .good { color: var(--ok); } #preview .bad { color: var(--danger); }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 2em; }
.who-txt { font-weight: 700; }

/* ---------- 弹窗 ---------- */
#modal { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; z-index: 50; }
#modal[hidden] { display: none; }
.dialog { background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 14px 18px; max-width: min(900px, 94vw); max-height: 92vh; overflow: auto; }
.dialog h2 { margin: 0 0 8px; color: var(--accent); }
.dialog label { margin-right: 14px; }
.dialog .row { margin: 8px 0; }
.dialog table { border-collapse: collapse; width: 100%; }
.dialog th, .dialog td { border-bottom: 1px solid var(--line); padding: 4px 10px; text-align: center; }
.dialog tr.win td { background: #3a4a1f; font-weight: 700; }
.dialog .mini { display: flex; flex-wrap: wrap; gap: 4px; }
.dialog .mini img { height: clamp(70px, 14vh, 140px); border-radius: 4px; }
.dialog details { color: var(--muted); font-size: .9em; }
.dialog .pd-hand-count { display: inline-flex; align-items: center; vertical-align: middle; }
.dialog .pd-hand-count .ico-hand { width: 1.3em; height: 1.3em; }
.dialog .pd-pf-counts { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.dialog .pd-pf-counts > span { display: inline-flex; align-items: center; gap: 3px; }
.dialog .pd-pf-cards summary { display: inline-block; margin: 4px 0; padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; color: var(--text); }
.dialog input[type=text] { background: #0e1816; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; width: 8em; }
.dialog .btn { margin-right: 6px; }
.sr { position: absolute; left: -9999px; }
@media (prefers-reduced-motion: reduce) { .pawn, .promo.pop-in, .promo.collectable, .hl { animation: none !important; transition: none !important; } }
@media (max-height: 700px) {
  :root { --pm-h: 100px; }
  .score-row .l3 { display: none; }
  .score-row { margin-bottom: 2px; padding: 2px 6px; }
}

#places { position: absolute; left: 0; bottom: 0; width: 100%; height: 22px; pointer-events: none; }
#trackWrap.placing { padding-bottom: 26px; }
.place { position: absolute; bottom: 0; height: 22px; padding: 0; font-size: .72em; font-weight: 700; border: 2px solid #ffd35c; background: #3a3420; color: #ffd35c; border-radius: 4px; cursor: pointer; pointer-events: auto; }
.place.sel { background: #ffd35c; color: #1a1a1a; }
.place.off { border-color: #555; color: #777; background: #22302b; cursor: not-allowed; }
.placebar { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.place-opt.on { outline: 2px solid #ffd35c; }
.placewhy { color: var(--muted); font-size: .8em; }

.promo.ghost.draggable { cursor: grab; touch-action: none; opacity: .85; }
.promo.ghost.draggable .tile { border-color: #ffd35c; }
.promo.ghost.bad .tile { border-color: #ff6b5e; background: #5a2a26 !important; }

.coll-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; font-size: .75em; color: var(--muted); margin-top: 2px; }
.cthumb { display: inline-flex; align-items: center; gap: 2px; border: 2px solid var(--tc, #888); border-radius: 4px; padding: 0 3px 0 0; background: #0006; cursor: zoom-in; color: #fff; }
.cthumb img { height: 22px; width: 16px; object-fit: cover; border-radius: 2px; }
.cthumb.theme-E { --tc: #2fa36b; } .cthumb.theme-G { --tc: #4aa3df; } .cthumb.theme-T { --tc: #e0b040; } .cthumb.theme-R { --tc: var(--theme-fu); }
.cur.hl { background: #2a5a3a; color: #bff5d0; padding: 1px 8px; border-radius: 4px; border: 1px solid #5fd08a; }
#log .hl { background: #2a5a3a; color: #bff5d0; border-radius: 3px; padding: 1px 3px; }
.dialog .collf { margin-top: 6px; padding: 6px; background: #0004; border-radius: 4px; }

/* ======================= M4 皮肤层（素材存在时才生效，缺失回退灰盒） ======================= */
body { background: var(--asset-table_bg, none) center/cover no-repeat #1a120c; }
.has-table_bg body { background-color: #1a120c; }

/* 面板：CSS border-image 九宫格（切片/留白/缩放集中在 theme.js 的 SKIN.panel）。
   border-width = (slice − 透明留白) × scale；outset = 留白 × scale，使可见金框贴合盒边；中心 fill，四边拉伸、角饰不变形 */
:root { --ui-scale: 1; --k-large: calc(var(--k-large-base, .38) * var(--ui-scale)); --k-small: calc(var(--k-small-base, .5) * var(--ui-scale)); }
.has-panel_large .panel.large, .has-panel_small .panel.small { background: none; border-style: solid; border-color: transparent; }
.has-panel_large .panel.large {
  border-width: calc((var(--pl-st) - var(--pl-mt)) * var(--k-large) * 1px) calc((var(--pl-sr) - var(--pl-mr)) * var(--k-large) * 1px) calc((var(--pl-sb) - var(--pl-mb)) * var(--k-large) * 1px) calc((var(--pl-sl) - var(--pl-ml)) * var(--k-large) * 1px);
  border-image-source: var(--asset-panel_large);
  border-image-slice: var(--pl-st) var(--pl-sr) var(--pl-sb) var(--pl-sl) fill;
  border-image-width: calc(var(--pl-st) * var(--k-large) * 1px) calc(var(--pl-sr) * var(--k-large) * 1px) calc(var(--pl-sb) * var(--k-large) * 1px) calc(var(--pl-sl) * var(--k-large) * 1px);
  border-image-outset: calc(var(--pl-mt) * var(--k-large) * 1px) calc(var(--pl-mr) * var(--k-large) * 1px) calc(var(--pl-mb) * var(--k-large) * 1px) calc(var(--pl-ml) * var(--k-large) * 1px);
  border-image-repeat: stretch; padding: 0 2px;
}
.has-panel_small .panel.small {
  border-width: calc((var(--ps-st) - var(--ps-mt)) * var(--k-small) * 1px) calc((var(--ps-sr) - var(--ps-mr)) * var(--k-small) * 1px) calc((var(--ps-sb) - var(--ps-mb)) * var(--k-small) * 1px) calc((var(--ps-sl) - var(--ps-ml)) * var(--k-small) * 1px);
  border-image-source: var(--asset-panel_small);
  border-image-slice: var(--ps-st) var(--ps-sr) var(--ps-sb) var(--ps-sl) fill;
  border-image-width: calc(var(--ps-st) * var(--k-small) * 1px) calc(var(--ps-sr) * var(--k-small) * 1px) calc(var(--ps-sb) * var(--k-small) * 1px) calc(var(--ps-sl) * var(--k-small) * 1px);
  border-image-outset: calc(var(--ps-mt) * var(--k-small) * 1px) calc(var(--ps-mr) * var(--k-small) * 1px) calc(var(--ps-mb) * var(--k-small) * 1px) calc(var(--ps-ml) * var(--k-small) * 1px);
  border-image-repeat: stretch; padding: 0 2px;
}
.panel-title { text-shadow: 0 1px 2px #000; }
#logPanel { position: relative; }
#log { position: absolute; left: 14px; right: 10px; top: 36px; bottom: 12px; flex: none; }
#popPanel .hint { display: block; }
#scorePanel { display: flex; gap: 8px; align-items: stretch; }
#scorePanel .panel-title { display: none; }
#scorePanel .score-row { flex: 1 1 0; min-width: 0; margin: 0; }
#trackScroll { display: flex; align-items: center; min-height: 0; }
#trackScroll > #trackWrap { margin: 0 auto 0 0; }
#market { display: flex; flex-direction: column; }
#market #trackScroll { flex: 1; }

/* 顶部玩家栏：头像框 + 头像 */
.score-row { background: linear-gradient(#2a1c12cc, #1a110ccc); border-color: #8a6a2f; }
.score-row .l1 { gap: 8px; }
.avatar { position: relative; width: clamp(40px, 5.6vh, 60px); aspect-ratio: 1; flex: 0 0 auto; padding: 0; background: none; }
.avatar .portrait, .avatar .frame { position: absolute; display: block; }
.avatar .portrait { inset: 12%; border-radius: 50%; background: var(--c) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; overflow: hidden; }
.avatar .portrait::after { content: attr(data-ini); }
.avatar .frame { inset: 0; background: var(--frame, none) center/100% 100% no-repeat; border-radius: 50%; border: 0; }
.avatar { box-shadow: none; }
.av-red .portrait { background-image: var(--asset-avatar_red, none); } .av-blue .portrait { background-image: var(--asset-avatar_blue, none); }
.av-green .portrait { background-image: var(--asset-avatar_green, none); } .av-yellow .portrait { background-image: var(--asset-avatar_yellow, none); }
.has-avatar_red .av-red .portrait::after, .has-avatar_blue .av-blue .portrait::after, .has-avatar_green .av-green .portrait::after, .has-avatar_yellow .av-yellow .portrait::after { content: none; }
.avatar .portrait { box-shadow: 0 0 0 2px var(--c); }
.has-avatar_frame_1 .av-red .portrait, .has-avatar_frame_2 .av-blue .portrait, .has-avatar_frame_3 .av-green .portrait, .has-avatar_frame_4 .av-yellow .portrait { box-shadow: none; background-color: #1b1410; }
.score-row .l1 .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .l2 { white-space: normal; }

/* 棋子：竖立棋子图（96×128 比例），无素材时回退圆点 */
.has-pawn_red .pawn { border-radius: 0; border: 0; box-shadow: none; background-color: transparent; background-size: contain; background-position: center bottom; background-repeat: no-repeat; color: transparent; font-size: 0; filter: drop-shadow(0 2px 2px #000a); }
.has-pawn_red .pawn.cur { filter: drop-shadow(0 0 5px var(--accent)) drop-shadow(0 0 2px var(--accent)); }
/* 开发落点预览：要一眼看出是「预览」，不是又一枚棋子站在那儿。
   原来 grayscale(.4) + opacity .6 把它搅成一团暗色，脚下又没有任何标记，
   看着就是一个莫名其妙的阴影贴在后面的格子上。
   改成：保留本来的颜色、再透一点，脚下补一个本方颜色的落点环。 */
.has-pawn_red .pawn.ghost { opacity: .5; filter: drop-shadow(0 1px 2px #000a); border: 0; background-image: var(--asset-pawn_red, none); }
.dot { background-size: contain; }
.has-pawn_red .dot { width: .8em; height: 1.1em; border-radius: 0; border: 0; background-color: transparent; background-position: center bottom; background-repeat: no-repeat; vertical-align: -0.2em; }

/* Market 格子：tile_* 正方形，无缝拼接；主题以图标呈现，文字标签隐去（保留 title/aria） */
.tile { height: var(--cell-w); }
.has-tile_cui .theme-E .tile, .has-tile_shuang .theme-G .tile, .has-tile_fu .theme-R .tile, .has-tile_sha .theme-T .tile { border: 0; background-size: 100% 100%; background-repeat: no-repeat; }
.has-tile_cui .theme-E .tile .lbl, .has-tile_shuang .theme-G .tile .lbl, .has-tile_fu .theme-R .tile .lbl, .has-tile_sha .theme-T .tile .lbl { display: none; }
.tile .num { text-shadow: 0 0 2px #000, 0 0 3px #000; color: #fff; opacity: .9; z-index: 1; }
.promo.ghost .tile { box-shadow: inset 0 0 0 2px #fff; }
.has-tile_cui .promo.ghost .tile { border: 0; }
.promo .lab { color: #e9d9b0; text-shadow: 0 1px 2px #000; }
.promo .lab b::before, .promo.collectable .lab::after { content: ""; display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -0.3em; background-size: contain; background-repeat: no-repeat; }
.promo .lab b::before { background-image: var(--asset-marker_covered, none); }
.promo.collectable .lab::after { background-image: var(--asset-marker_collect, none); margin-left: 2px; }

/* 图标 */
.ico-deck, .ico-hand { display: inline-block; width: 1.7em; height: 1.7em; background-size: contain; background-repeat: no-repeat; background-position: center; vertical-align: middle; margin-right: 3px; }
.ico-deck { background-image: var(--asset-icon_deck, none); } .ico-hand { background-image: var(--asset-icon_hand, none); }
.chip .ticon { width: 1.5em; height: 1.5em; margin: -3px 3px -3px -5px; }
.pop-row .chip { min-width: 4.2em; }

/* 行动按钮：四态皮肤（480×160 = 3:1），文字叠在图标右侧 */
.btn-row.acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 6px; }
.btn.act { aspect-ratio: 3 / 1; min-height: 0; padding: 0 4% 0 36%; border: 0; border-radius: 10px; background-color: #2f5b4e; background-size: 100% 100%; background-repeat: no-repeat; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; letter-spacing: .02em; text-shadow: 0 1px 2px #000c; line-height: 1.1; }
.btn.act span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95em; }
.btn.act:disabled { opacity: 1; color: #b4b4b4; }
.btn.act.on { box-shadow: 0 0 0 2px var(--accent); }
.btn.act:active:not(:disabled) { transform: translateY(1px); }
.has-btn_promotion_default .btn-promotion { background-color: transparent; background-image: var(--asset-btn_promotion_default); }
.has-btn_promotion_hover .btn-promotion:hover:not(:disabled) { background-image: var(--asset-btn_promotion_hover); }
.has-btn_promotion_pressed .btn-promotion:active:not(:disabled) { background-image: var(--asset-btn_promotion_pressed); }
.has-btn_promotion_disabled .btn-promotion:disabled { background-image: var(--asset-btn_promotion_disabled); }
.has-btn_development_default .btn-development { background-color: transparent; background-image: var(--asset-btn_development_default); }
.has-btn_development_hover .btn-development:hover:not(:disabled) { background-image: var(--asset-btn_development_hover); }
.has-btn_development_pressed .btn-development:active:not(:disabled) { background-image: var(--asset-btn_development_pressed); }
.has-btn_development_disabled .btn-development:disabled { background-image: var(--asset-btn_development_disabled); }
.has-btn_draw_default .btn-draw { background-color: transparent; background-image: var(--asset-btn_draw_default); }
.has-btn_draw_hover .btn-draw:hover:not(:disabled) { background-image: var(--asset-btn_draw_hover); }
.has-btn_draw_pressed .btn-draw:active:not(:disabled) { background-image: var(--asset-btn_draw_pressed); }
.has-btn_draw_disabled .btn-draw:disabled { background-image: var(--asset-btn_draw_disabled); }
.has-btn_collection_default .btn-collection { background-color: transparent; background-image: var(--asset-btn_collection_default); }
.has-btn_collection_hover .btn-collection:hover:not(:disabled) { background-image: var(--asset-btn_collection_hover); }
.has-btn_collection_pressed .btn-collection:active:not(:disabled) { background-image: var(--asset-btn_collection_pressed); }
.has-btn_collection_disabled .btn-collection:disabled { background-image: var(--asset-btn_collection_disabled); }

/* Public Market / 牌库：4 列网格，牌宽随右栏自适应；牌背用 card_back */
.pm-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.pm-card, .deck, .empty-slot { width: auto; }
.pm-card img, .deck .back { height: auto; aspect-ratio: 5 / 7; }
.deck .back { background: var(--asset-card_back, none) center/100% 100% no-repeat, repeating-linear-gradient(45deg, #3b5a52, #3b5a52 6px, #2b4741 6px, #2b4741 12px); border: 0; color: #fff; text-shadow: 0 0 4px #000, 0 0 8px #000; }
.has-card_back .deck .back { background-color: transparent; }
.empty-slot { height: auto; aspect-ratio: 5 / 7; }

/* 卡牌伪 3D：perspective + 多层阴影 + 悬停抬起/倾斜（鼠标跟随由 app.js 写入 --rx/--ry） */
.hcard, .pm-card { transition: transform .18s ease-out, box-shadow .18s; will-change: transform; border-radius: 8px; box-shadow: 0 1px 1px #0006, 0 3px 4px #0005, 0 8px 12px #0005, 0 16px 24px -6px #000a; }
.hcard img, .pm-card img { border-radius: 6px; box-shadow: inset 0 0 0 1px #fff3; }
.hcard .cap, .pm-card .cap { transform: translateZ(1px); }
#hand { padding-bottom: 8px; padding-top: 16px; }
@media (prefers-reduced-motion: reduce) { .hcard, .pm-card { transition: none; } }

@media (max-height: 700px) {
  :root { --ui-scale: .72; }
  #app { gap: 4px; padding: 4px; }
  .panel-title { margin-bottom: 2px; }
  #popPanel .hint { display: none; }
  .logo-img { height: 28px; width: 120px; }
}

#actionPanel { overflow-y: auto; scrollbar-width: thin; }
#actionPanel .reasons { font-size: .72em; line-height: 1.3; }
.btn.act span { font-size: .82em; white-space: nowrap; }

/* ---- 评审修复 ---- */
.btn.act { container-type: inline-size; }
.btn.act { padding-left: 31%; }
.btn.act span { font-size: 10.5cqw; }
#actionPanel { overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
#actionPanel #actions { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
details.reasons { font-size: .72em; color: var(--muted); line-height: 1.3; }
details.reasons summary { cursor: pointer; }
.placebar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.placewhy { font-size: .72em; color: var(--danger); }
#preview { font-size: .8em; line-height: 1.3; min-height: 0; overflow: hidden; padding: 2px 6px; }
#actions.mode-edit .btn-row.acts { display: none; }
#log { padding-top: 2px; }
@media (max-height: 700px) {
  :root { --bot-h: clamp(236px, 49vh, 520px); }
  .pm-card .cap, .deck .cap { font-size: .7em !important; line-height: 1.1; }
  .avatar { width: 34px; }
  #scorePanel .score-row { padding: 1px 6px; }
  .btn-row.acts { gap: 3px 5px; }
  #publicMarket .panel-title, #handArea .panel-title { margin: 0 0 2px; }
  .pop-row { margin: 1px 0; }
}
@media (min-height: 800px) { #publicMarket .pm-row { max-width: 340px; margin: 0 auto; } }
.pm-card .cap { font-size: .66em !important; white-space: nowrap; letter-spacing: -.02em; padding: 1px 0; }

/* 小屏：计分行高度固定，收藏缩略图并入首行，避免行变高挤压 Popularity 面板 */
@media (max-height: 700px) {
  #scorePanel .score-row { position: relative; }
  .score-row .coll-row { position: absolute; right: 34px; top: 5px; max-width: 48%; display: flex; gap: 2px; overflow: hidden; font-size: 0; margin: 0; }
  .score-row .coll-row { flex-wrap: nowrap; }
  .score-row .coll-row .cthumb { font-size: 10px; flex: none; padding: 0 3px; }
  .score-row .coll-row .cthumb img { display: none; }
  #popPanel .pop-row { margin: 0; }
  #popPanel .pop-row .chip { padding-top: 0; padding-bottom: 0; }
}
