@charset "UTF-8";
/* ============================================================
   魂牌局 UI v2 · 墨玉·金错
   视觉层单文件：引入方式见文件末 ZCODE 接入段
   状态全部由 class 表达，逻辑层不需改引擎
   ============================================================ */

/* ---------- 1. 设计令牌 ---------- */
:root {
  /* 桌面墨玉 */
  --felt-900: #0a1410;
  --felt-800: #0d1a14;
  --felt-700: #12241b;
  --felt-600: #1a3327;
  /* 鎏金 */
  --gold-400: #e8c66a;
  --gold-200: #f5e0a8;
  --gold-700: #8a6d20;
  --gold-grad: linear-gradient(180deg, #f5e0a8 0%, #e8c66a 46%, #a8871f 100%);
  /* 点睛 */
  --cinnabar: #c8402f;
  --cinnabar-lite: #e2685a;
  --celadon: #6fae9a;
  --warn: #d9a441;
  /* 纸与字 */
  --frost: #dfe6e2;
  --ivory: #f2ecdd;
  --ink: #16130e;
  --mute: #8fa79a;
  /* 字体 */
  --font-ui: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-card: "Songti SC", "Noto Serif SC", "SimSun", serif;
  /* 牌尺寸（标准扑克 1:1.42） */
  --card-xs: 30px;   --card-xs-h: 42px;
  --card-sm: 44px;   --card-sm-h: 62px;
  --card-md: 62px;   --card-md-h: 88px;
  --card-lg: clamp(74px, 9.2vw, 92px);
  --card-lg-h: calc(var(--card-lg) * 1.42);
  --card-r: 7px;
  /* 动效 */
  --e-out: cubic-bezier(.2, .8, .2, 1);
  --e-stamp: cubic-bezier(.3, 1.4, .4, 1);
  /* 素材（原型位于 ui_v2/，素材包在 ../assets/） */
  --a-back: url("../assets/cards/card_back.png");
  --a-felt: url("../assets/table/table_felt.jpg");
  --a-glow: url("../assets/table/lamp_glow.jpg");
  --a-silk: url("../assets/table/bg_silk.jpg");
  --a-bei: url("../assets/ui/chip_bei.jpg");
  --a-seal: url("../assets/ui/seal_cinnabar.jpg");
  --a-dealer: url("../assets/ui/dealer_disc.jpg");
}

/* ============================================================
   皮肤系统：牌背与牌面的全部外观都在这一组令牌里。
   用法：在任意容器上写 data-skin="jade|paper|blue|ink"，
   容器内所有扑克/麻将牌自动换装（变量继承），换肤只需改一个属性。
   运行时切换 = document.querySelector('.table-oval').dataset.skin = 'paper';
   ============================================================ */
[data-skin="jade"] {
  /* 墨玉·金错（默认） */
  --skin-back: url("../assets/cards/card_back.png");
  --skin-face: linear-gradient(180deg, #fffaf0 0%, #f2ecdd 14%, #e7ddc6 100%);
  --skin-face-edge: rgba(138, 109, 32, .55);
  --skin-face-inner: rgba(138, 109, 32, .42);
  --skin-ink: #16130e;
  --skin-red: #c8402f;
  --skin-grain: .10;
  /* 麻将牌骨面材质实拍图；其余皮肤不定义 → 自动回退到 CSS 骨面渐变 */
  --mj-base: url("../assets/cards/mj_base.jpg");
  --mj-edge: #8a6234;
}
[data-skin="paper"] {
  /* 宣纸·水墨 */
  --skin-back: url("../assets/cards/back_paper.jpg");
  --skin-face: url("../assets/cards/face_paper.jpg") center / 100% 100% no-repeat,
               linear-gradient(180deg, #fdf8ec, #ece0c4);
  --skin-face-edge: rgba(90, 66, 34, .48);
  --skin-face-inner: rgba(90, 66, 34, .30);
  --skin-ink: #241d14;
  --skin-red: #a8332a;
  --skin-grain: .18;
}
[data-skin="blue"] {
  /* 青花·白瓷 */
  --skin-back: url("../assets/cards/back_blue.jpg");
  --skin-face: url("../assets/cards/face_blue.jpg") center / 100% 100% no-repeat,
               linear-gradient(180deg, #f4f8f8, #e2ebec);
  --skin-face-edge: rgba(52, 86, 120, .42);
  --skin-face-inner: rgba(52, 86, 120, .26);
  --skin-ink: #1b2b3d;
  --skin-red: #b0392c;
  --skin-grain: .05;
}
[data-skin="ink"] {
  /* 水墨·单色 */
  --skin-back: url("../assets/cards/back_ink.jpg");
  --skin-face: linear-gradient(180deg, #f4f1e8 0%, #e6e2d6 100%);
  --skin-face-edge: rgba(40, 38, 32, .52);
  --skin-face-inner: rgba(40, 38, 32, .32);
  --skin-ink: #171512;
  --skin-red: #7a4b3a;
  --skin-grain: .20;
}
[data-skin="lacquer"] {
  /* 黑漆鎏金 */
  --skin-back: url("../assets/cards/back_lacquer.jpg");
  --skin-face: url("../assets/cards/face_paper.jpg") center / 100% 100% no-repeat,
               linear-gradient(180deg, #faf4e4, #e9dfc6);
  --skin-face-edge: rgba(28, 20, 10, .62);
  --skin-face-inner: rgba(176, 138, 52, .34);
  --skin-ink: #1a1206;
  --skin-red: #a02016;
  --skin-grain: .14;
  --mj-edge: #6d4a22;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--felt-900);
  color: var(--frost);
  font-family: var(--font-ui);
  font-size: 15px;
}

body { -webkit-font-smoothing: antialiased; }

/* ---------- 2. 场景层：桌布 + 顶灯 + 绢纹 ---------- */
.room {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 8%, rgba(232, 198, 106, .08), transparent 62%),
    var(--felt-900);
  isolation: isolate;
}
/* 顶灯光晕单独一层：原图是整幅暖橙实拍图，直接铺会把墨玉底冲成一片橙，
   必须限尺寸 + 降不透明度 + 径向渐隐，否则牌面完全淹没在暖光里。 */
.room::after {
  content: "";
  position: absolute;
  left: 50%; top: -8vh;
  transform: translateX(-50%);
  width: min(126vw, 900px); height: min(126vw, 900px);
  background: var(--a-glow) center / contain no-repeat;
  opacity: .30;
  -webkit-mask-image: radial-gradient(closest-side, #000 26%, rgba(0,0,0,.35) 58%, transparent 80%);
  mask-image: radial-gradient(closest-side, #000 26%, rgba(0,0,0,.35) 58%, transparent 80%);
  pointer-events: none;
  z-index: 0;
}
.room::before {                 /* 绢纹底噪 */
  content: "";
  position: absolute; inset: 0;
  background-image: var(--a-silk);
  background-size: 420px;
  opacity: .28;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 0;
}

/* 桌布整图自带椭圆木边 + 鎏金回纹内框 + 顶灯实拍，容器不再二次画椭圆桌，
   否则木边与 CSS 圆角叠成两层边（第一版就是这个毛病）。容器只负责定位座位。 */
.table-oval {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  width: min(94vw, 900px);
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  /* 放大裁边：原图 16:9 与容器同比例，不放大就会把顶部吊灯实体裁进画面（第二版遗留问题） */
  background: var(--a-felt) center 58% / 168% auto no-repeat, var(--felt-800);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .62), inset 0 0 0 1px rgba(232, 198, 106, .12);
}

/* ---------- 3. 扑克牌 ---------- */
.pcard {
  position: relative;
  width: var(--card-md); height: var(--card-md-h);
  border-radius: var(--card-r);
  flex: 0 0 auto;
  font-family: var(--font-card);
  container-type: inline-size;   /* 供下面的极小牌降级查询用 */
  background: var(--skin-face, linear-gradient(180deg, #fffaf0, #f2ecdd)) center / 100% 100% no-repeat,
              var(--felt-800);
  box-shadow:
    inset 0 0 0 1px var(--skin-face-edge, rgba(138, 109, 32, .55)),
    inset 0 1px 0 rgba(255, 255, 255, .8),
    0 2px 5px rgba(0, 0, 0, .45);
  color: var(--skin-ink, var(--ink));
  user-select: none;
  transition: transform .18s var(--e-out), box-shadow .18s var(--e-out), filter .18s;
}

/* 极小牌自动降级为字体符号。
   位图 mask 缩到 ~7px（座位小牌 17×24、极小牌 12×17）会被 mipmap 混成实心色块，
   花色彻底认不出；字体里的 ♠♥♣♦ 是矢量轮廓，任何尺寸都锐利。
   不需要改 DOM——符号由各 suit class 的 ::after 提供。
   不支持容器查询的浏览器自动沿用 mask 图（现状）。 */
@container (max-width: 36px) {
  .suit {
    -webkit-mask-image: none !important;
    mask-image: none !important;
    background: none !important;
    display: grid; place-items: center;
    font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", var(--font-card);
    line-height: .9;
    /* 字号按容器宽度自适应（cqw），并放开外部写死的 5-7px 尺寸——外部规则
       （.seat__hand .pcard__corner .suit 等）特异性更高，必须 !important 才压得住 */
    width: auto !important; height: auto !important;
    font-size: 46cqw !important;
  }
  .suit--spade::after   { content: "\2660"; }
  .suit--heart::after   { content: "\2665"; }
  .suit--club::after    { content: "\2663"; }
  .suit--diamond::after { content: "\2666"; }
  .suit--spade::after, .suit--club::after { color: var(--skin-ink, #16130e); }
  .suit--heart::after, .suit--diamond::after { color: var(--skin-red, #c8402f); }
  .suit--joker::after { content: "\265F"; color: var(--skin-red, #c8402f); }   /* ♟ 大王朱砂 */
  .suit--joker.suit--jokr-b::after { color: var(--skin-ink, #16130e); }        /* 小王墨色 */
}

/* 纸纹：覆盖在牌面上，用 multiply 让骨面/宣纸/瓷面都吃上绢纹颗粒 */
.pcard::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image: var(--a-silk);
  background-size: 190px;
  opacity: var(--skin-grain, .10);
  mix-blend-mode: multiply;
}

/* 牌面内金线框 */
.pcard::before {
  content: "";
  position: absolute; inset: 4px;
  border: 1px solid rgba(138, 109, 32, .42);
  border-radius: calc(var(--card-r) - 3px);
  pointer-events: none;
}

.pcard__corner {
  position: absolute;
  z-index: 2;                 /* 压在纸纹 ::after 之上 */
  display: flex; flex-direction: column; align-items: center;
  line-height: .96;
  font-size: calc(var(--card-md) * .30);
  font-weight: 600;
}
.pcard__corner--tl { top: 7%; left: 8%; }
.pcard__corner--br { bottom: 7%; right: 8%; transform: rotate(180deg); }
.pcard .suit { width: calc(var(--card-md) * .26); height: calc(var(--card-md) * .26); }

/* 中心大花色 */
.pcard__pip {
  position: absolute; inset: 0;
  z-index: 2;
  display: grid; place-items: center;
}
.pcard__pip .suit { width: 46%; height: 46%; }

/* 花色 mask：一源三染，颜色随皮肤走（青花皮黑花色偏蓝、宣纸皮红花色偏印泥） */
.suit {
  display: inline-block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: contain;
  mask-repeat: no-repeat; mask-position: center; mask-size: contain;
}
.suit--spade {
  background-color: var(--skin-ink, #16130e);
  -webkit-mask-image: var(--m-spade); mask-image: var(--m-spade);
}
.suit--heart, .suit--diamond {
  background-color: var(--skin-red, #c8402f);
}
.suit--heart  { -webkit-mask-image: var(--m-heart);  mask-image: var(--m-heart); }
.suit--diamond { -webkit-mask-image: var(--m-diamond); mask-image: var(--m-diamond); }
.suit--club {
  background-color: var(--skin-ink, #16130e);
  -webkit-mask-image: var(--m-club); mask-image: var(--m-club);
}

:root {
  --m-spade:   url("../assets/cards/suit_spade_mask.png");
  --m-heart:   url("../assets/cards/suit_heart_mask.png");
  --m-club:    url("../assets/cards/suit_club_mask.png");
  /* 方块改用标准菱形 PNG（PIL 直绘，见 postprocess.draw_diamond）。
   生图那版是「大菱形+小菱形」的装饰纹样，不像花色；SVG 当 mask-image 不可靠
   （外部 .svg 在 Chromium 上不渲染，内联 data-URI 又丢宽高比被拉胖）。 */
  --m-diamond: url("../assets/cards/suit_diamond_mask.png");
  --m-joker:   url("../assets/cards/joker_mask_mask.png");
  /* 大小王插画（不用 mask，直接铺图；细节多，单色 mask 会糊掉） */
  --joker-red:   url("../assets/cards/joker_red.png");
  --joker-black: url("../assets/cards/joker_black.png");
}

/* ---------- 大小王：不写字，中央画图 ----------
   契约：渲染层照旧输出 `suit--joker`（大王）/ `suit--joker suit--jokr-b`（小王），
   这里用 :has() 一把接管视觉，业务侧零改动：
     · 角标隐藏原「大王/小王」文字与小图 → 换成 ★（大王朱砂 / 小王墨）
     · 中央大图换成小丑插画（大王红金 / 小王黑白钢笔）
   浏览器不支持 :has() 时退化为「角标文字+中央纹章」，不算坏，只是没这次好看。 */
.pcard:has(.suit--joker) .pcard__corner b,
.pcard:has(.suit--joker) .pcard__corner .suit { display: none; }
.pcard:has(.suit--joker) .pcard__corner::after {
  content: "\2605";                 /* ★ */
  font-size: calc(var(--card-md) * .26);
  line-height: .9;
  color: var(--skin-red, #c8402f);
}
.pcard:has(.suit--jokr-b) .pcard__corner::after { color: var(--skin-ink, #16130e); }

/* 大小王中央插画：占满整个 pip 区。
   必须显式写 width/height:100% —— .pcard.is-mine .suit 会把元素锁成 24×24
   （那是给普通花色中心大花色用的），全身小丑塞进 24px 就糊成一团。 */
.pcard:has(.suit--joker) .pcard__pip .suit,
.pcard:has(.suit--jokr-b) .pcard__pip .suit {
  width: 100%; height: 100%;
  background-repeat: no-repeat;
  background-position: center;
  -webkit-mask-image: none; mask-image: none;
}
.pcard:has(.suit--joker) .pcard__pip .suit {
  background-image: var(--joker-red);
  background-size: auto 86%;
}
.pcard:has(.suit--jokr-b) .pcard__pip .suit {
  background-image: var(--joker-black);
  background-size: auto 86%;
}

/* H189 令11：麻将牌背换装——跟随 --skin-back（cover 裁切适配 1:1.31 比例），无定义时回退素骨面 */
.mcard.is-back {
  background: var(--skin-back, linear-gradient(180deg, #f7f1de 0%, #e8ddb8 100%)) center / cover no-repeat, var(--felt-700);
  box-shadow: 3px 3px 0 0 var(--mj-edge, #8a6234), 2px 3px 4px rgba(0, 0, 0, .42), inset 0 0 0 1px rgba(232, 198, 106, .3);
}
.mcard.is-back > * { display: none; }

/* 牌面状态 */
.pcard.is-back {
  /* 三层兜底：1 边缘金圈 2 中心金索 3 暗斜纹 —— 即使 card_back.png 不加载也能看见卡背轮廓 */
  background-image:
    radial-gradient(circle at 50% 50%, rgba(232, 198, 106, .35) 0%, transparent 62%),
    repeating-linear-gradient(45deg, rgba(232, 198, 106, .08) 0, rgba(232, 198, 106, .08) 5px, transparent 5px, transparent 11px),
    var(--skin-back, var(--a-back));
  background-color: var(--felt-700);
  background-size: 100% 100%, 100% 100%, 100% 100%;
  background-position: center, center, center;
  background-repeat: no-repeat;
  box-shadow:
    inset 0 0 0 2px rgba(232, 198, 106, .55),
    inset 0 0 0 4px var(--felt-900),
    0 2px 5px rgba(0, 0, 0, .5);
}
.pcard.is-back > * { display: none; }
/* H237b 兜底：SPAN is-back 在某些 viewport 无图时不显—— DIV 标签与最小高度双保险 */
span.pcard.is-back { display: inline-block; min-width: 32px; min-height: 44px; }

.pcard.is-mine {
  width: var(--card-lg); height: var(--card-lg-h);
  transform: translateY(-8px);
  box-shadow:
    inset 0 0 0 1px rgba(138, 109, 32, .55),
    inset 0 2px 0 rgba(255, 255, 255, .85),
    0 10px 22px rgba(0, 0, 0, .55),
    0 -6px 16px rgba(232, 198, 106, .16);
}
.pcard.is-mine .pcard__corner { font-size: calc(var(--card-lg) * .30); }
.pcard.is-mine .suit { width: calc(var(--card-lg) * .26); height: calc(var(--card-lg) * .26); }
.pcard.is-mine:hover { transform: translateY(-14px); }

.pcard.is-playable {
  box-shadow:
    inset 0 0 0 2px var(--gold-400),
    inset 0 1px 0 rgba(255, 255, 255, .85),
    0 8px 18px rgba(0, 0, 0, .5),
    0 0 16px rgba(232, 198, 106, .45);
  animation: breathe 2.2s var(--e-out) infinite;
}
.pcard.is-dim { filter: saturate(.4) brightness(.7); cursor: default; }
.pcard.is-hot { box-shadow: inset 0 0 0 2px var(--celadon), 0 6px 14px rgba(0, 0, 0, .5); }
.pcard.is-hot.is-danger { box-shadow: inset 0 0 0 2px var(--cinnabar), 0 6px 14px rgba(0, 0, 0, .5); }
.pcard.is-win {
  box-shadow: inset 0 0 0 2px var(--gold-400), 0 0 22px rgba(232, 198, 106, .6), 0 10px 20px rgba(0, 0, 0, .55);
  transform: translateY(-10px);
}
.pcard.is-discard {
  width: var(--card-xs); height: var(--card-xs-h);
  opacity: .85;
}
.pcard.is-discard .pcard__corner { font-size: 9px; }
.pcard.is-discard .pcard__corner .suit { width: 8px; height: 8px; }

/* ---------- 4. 麻将牌 ----------
   逼真要点：①牌有真实厚度（右下 3px 竹木层，用 0-spread box-shadow 叠出实体边，
   不额外加 DOM）；②骨面顶部受光、底部暖影；③刻字是「凹刻」——上缘受光下缘刻痕；
   ④牌面材质底图走皮肤变量，无图时回退到 CSS 骨面渐变。 */
.mcard {
  position: relative;
  /* 真实麻将牌 26×34mm ≈ 1:1.31，比扑克(1:1.42)更方更宽；旧版按扑克比例缩窄显得假 */
  width: calc(var(--card-md-h) / 1.31);
  height: var(--card-md-h);
  border-radius: 4px 4px 2px 2px;
  font-family: var(--font-card);
  color: var(--skin-ink, var(--ink));
  background: var(--mj-base, linear-gradient(180deg, #fffcf4 0%, #f4eeda 22%, #e0d4b6 100%))
              center / 100% 100% no-repeat, var(--felt-700);
  box-shadow:
    3px 3px 0 0 var(--mj-edge, #8a6234),          /* 竹木厚度层 */
    2px 3px 4px rgba(0, 0, 0, .42),
    0 8px 14px rgba(0, 0, 0, .40),
    inset 0 1px 0 rgba(255, 255, 255, .92),        /* 骨面顶部受光 */
    inset 0 -7px 11px -7px rgba(122, 96, 52, .38), /* 底部暖影 */
    inset 0 0 0 1px rgba(138, 109, 32, .34);
  display: grid; place-items: center;
  user-select: none;
}
/* 骨面顶光：牌面上缘一道斜向柔光，模拟骨质反射 */
.mcard::after {
  content: "";
  position: absolute; inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(158deg,
    rgba(255, 255, 255, .34) 0%,
    rgba(255, 255, 255, .10) 22%,
    transparent 46%);
}

.mcard__glyph {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  /* H196 修：竖排两行同大（五上萬下），仿真实麻将牌面——旧版单位字 .42em 小到认不出（用户令） */
  font-size: calc(var(--card-md-h) * .34);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  /* 凹刻：上缘受光 + 下缘刻痕 */
  text-shadow:
    0 1px 0 rgba(255, 255, 255, .9),
    0 -1px 1px rgba(64, 46, 22, .45),
    0 2px 3px rgba(90, 66, 34, .25);
}
.mcard__glyph small {
  display: block; font-size: 1em; color: var(--skin-red, #c8402f); font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 1px rgba(80, 30, 22, .35);
}
/* 红中整字红：单字占位更大 */
.mcard--red .mcard__glyph { font-size: calc(var(--card-md-h) * .55); color: var(--skin-red, #c8402f); }
/* H196 筒/条图案 SVG：占牌面主体，小牌随牌高缩放（svg 自身 viewBox 等比） */
.mcard__glyph .mj-art { width: 82%; height: 82%; display: block; }
.mcard__mark {
  position: absolute; inset: 0;
  z-index: 1;
  opacity: .13;          /* 底纹压字会显脏，0.20 太重 */
  background: var(--skin-ink, #16130e);
  -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: 62%;
  mask-repeat: no-repeat; mask-position: center; mask-size: 62%;
}
/* 红中/發财 一类整字红牌 */
.mcard--red .mcard__glyph { color: var(--skin-red, #c8402f); }

/* 尺寸变体：副露/牌墙/牌河用，字号随牌高走，避免各处硬编码宽度 */
.mcard--sm {
  width: calc(var(--card-sm-h) / 1.31); height: var(--card-sm-h);
  border-radius: 3px 3px 2px 2px;
  box-shadow:
    2px 2px 0 0 var(--mj-edge, #8a6234),
    1px 2px 3px rgba(0, 0, 0, .4),
    inset 0 1px 0 rgba(255, 255, 255, .9),
    inset 0 -5px 8px -6px rgba(122, 96, 52, .35);
}
.mcard--sm .mcard__glyph { font-size: calc(var(--card-sm-h) * .38); }
.mcard--xs {
  width: calc(var(--card-xs-h) / 1.31); height: var(--card-xs-h);
  border-radius: 2px;
  box-shadow:
    1px 1px 0 0 var(--mj-edge, #8a6234),
    0 2px 3px rgba(0, 0, 0, .38),
    inset 0 1px 0 rgba(255, 255, 255, .85);
}
.mcard--xs .mcard__glyph { font-size: calc(var(--card-xs-h) * .40); }
.mcard--wan .mcard__mark   { -webkit-mask-image: var(--m-mj-wan);   mask-image: var(--m-mj-wan); }
.mcard--tong .mcard__mark  { -webkit-mask-image: var(--m-mj-tong);  mask-image: var(--m-mj-tong); }
.mcard--tiao .mcard__mark  { -webkit-mask-image: var(--m-mj-tiao);  mask-image: var(--m-mj-tiao); }
.mcard--zi .mcard__mark    { -webkit-mask-image: var(--m-mj-honor); mask-image: var(--m-mj-honor); }
.mcard.is-hot { box-shadow: 3px 3px 0 0 var(--mj-edge, #8a6234), 0 0 14px rgba(111, 174, 154, .5), inset 0 0 0 2px var(--celadon), inset 0 1px 0 rgba(255,255,255,.92); }
.mcard.is-dim { filter: saturate(.45) brightness(.72); }
:root {
  --m-mj-wan:   url("../assets/cards/mj_wan_mask.png");
  --m-mj-tong:  url("../assets/cards/mj_tong_mask.png");
  --m-mj-tiao:  url("../assets/cards/mj_tiao_mask.png");
  --m-mj-honor: url("../assets/cards/mj_honor_mask.png");
}
.meld {
  display: flex; align-items: center; gap: 3px;
  padding: 3px 6px 3px 4px;
  border-radius: 6px;
  background: rgba(18, 36, 27, .72);
  box-shadow: inset 0 0 0 1px rgba(232, 198, 106, .3);
}
.meld__tag {
  font-size: 11px; color: var(--gold-400);
  border: 1px solid var(--gold-700); border-radius: 4px;
  padding: 1px 4px; margin-left: 2px;
}

/* ---------- 5. 座位 ---------- */
.seat {
  position: absolute;
  width: 128px;
  padding: 8px 8px 9px;
  border-radius: 12px;
  text-align: center;
  background: linear-gradient(180deg, rgba(13, 26, 20, .92), rgba(10, 20, 16, .88));
  box-shadow: inset 0 1px 0 rgba(232, 198, 106, .18), 0 6px 18px rgba(0, 0, 0, .5);
  z-index: 30;
}
.seat__av {
  width: 46px; height: 46px; border-radius: 50%;
  display: block; margin: 0 auto 5px;
  box-shadow: 0 0 0 1px rgba(232, 198, 106, .35);
}
.seat__name {
  font-size: 13px; font-weight: 600; color: var(--frost);
  letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seat__tpl { font-size: 10px; color: var(--mute); }
.seat__bei {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 4px;
  font-size: 12px; color: var(--gold-200);
  font-variant-numeric: tabular-nums;
}
.seat__bei::before {
  content: ""; width: 13px; height: 13px;
  background: var(--a-bei) center / contain no-repeat;
}
.seat__hand {
  display: flex; gap: 2px; justify-content: center;
  margin-top: 6px; min-height: 14px;
}
.seat__hand .pcard { width: 17px; height: 24px; border-radius: 3px; }
.seat__hand .pcard::before { inset: 2px; }

.seat.is-turn { box-shadow: inset 0 0 0 1px var(--gold-400), 0 6px 22px rgba(232, 198, 106, .22); }
.seat.is-turn .seat__av { box-shadow: 0 0 0 2px var(--gold-400); animation: pulse 2s infinite; }
.seat.is-rest { opacity: .6; filter: saturate(.35); }

.seat__badge {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: .16em;
  padding: 2px 8px; border-radius: 4px;
  background: var(--gold-grad); color: #241b06; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.seat__badge.rest { background: linear-gradient(180deg, #6b7b73, #46564f); color: #e6efe9; }
.seat__badge.refuse { background: linear-gradient(180deg, #d8564a, #a1302a); color: #ffe9e4; }
.seat__badge.lead { background: linear-gradient(180deg, #8fd0bb, #4e8d78); color: #06231b; }

/* 编制座位定位（容器已是 16:9 桌图，座位压在木边/桌沿位置 = 坐在桌边） */
[data-composition="3p"] .seat[data-seat="user"] { left: 50%; bottom: -6%; transform: translateX(-50%); }
[data-composition="3p"] .seat[data-seat="p1"]    { right: 3%; top: 6%; }
[data-composition="3p"] .seat[data-seat="p2"]    { left: 3%; top: 6%; }

[data-composition="4p2v2"] .seat[data-seat="user"] { left: 50%; bottom: -6%; transform: translateX(-50%); }
[data-composition="4p2v2"] .seat[data-seat="p1"]    { right: 3%; top: 2%; }
[data-composition="4p2v2"] .seat[data-seat="p2"]    { left: 50%; top: -9%; transform: translateX(-50%); }
[data-composition="4p2v2"] .seat[data-seat="p3"]    { left: 3%; top: 2%; }

[data-composition="mj4p"] .seat[data-seat="user"] { left: 50%; bottom: -6%; transform: translateX(-50%); }
[data-composition="mj4p"] .seat[data-seat="p1"]    { right: 3%; top: 38%; }
[data-composition="mj4p"] .seat[data-seat="p2"]    { right: 14%; top: 2%; }
[data-composition="mj4p"] .seat[data-seat="p3"]    { left: 14%; top: 2%; }

/* H250：金花 4 座菱形环坐（下/右/上/左） */
[data-composition="jh4p"] .seat[data-seat="user"] { left: 50%; bottom: -6%; transform: translateX(-50%); }
[data-composition="jh4p"] .seat[data-seat="p1"]    { right: 3%; top: 25%; }
[data-composition="jh4p"] .seat[data-seat="p2"]    { left: 50%; top: -6%; transform: translateX(-50%); }
[data-composition="jh4p"] .seat[data-seat="p3"]    { left: 3%; top: 25%; }

[data-composition="tx6p"] .seat[data-seat="user"] { left: 50%; bottom: -6%; transform: translateX(-50%); }
[data-composition="tx6p"] .seat[data-seat="p1"]    { right: 6%; bottom: 16%; }
[data-composition="tx6p"] .seat[data-seat="p2"]    { right: 2%; top: 10%; }
[data-composition="tx6p"] .seat[data-seat="p3"]    { left: 50%; top: -9%; transform: translateX(-50%); }
[data-composition="tx6p"] .seat[data-seat="p4"]    { left: 2%; top: 10%; }
[data-composition="tx6p"] .seat[data-seat="p5"]    { left: 6%; bottom: 16%; }

/* 2v2 队线 */
.team-line {
  position: absolute; left: 50%; top: 16%;
  width: 2px; height: 46%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, #3f6ea8 20%, #3f6ea8 80%, transparent);
  opacity: .5; border-radius: 2px; z-index: 5;
}

/* ---------- 6. 桌面子区 ---------- */
.pot {
  position: absolute; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 20;
}
.pot__bei {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 999px;
  background: rgba(10, 20, 16, .82);
  box-shadow: inset 0 0 0 1px var(--gold-700);
  color: var(--gold-200); font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pot__bei::before {
  content: ""; width: 22px; height: 22px;
  background: var(--a-bei) center / contain no-repeat;
}
.board-cards { display: flex; gap: 6px; }
.river {
  position: absolute; left: 50%; top: 52%;
  transform: translateX(-50%);
  display: flex; flex-wrap: wrap; gap: 5px;
  max-width: 62%;
  z-index: 40;   /* H201 修：压过座位面板(30)——掼蛋/斗地主出牌后牌面不再被自己座位挡住 */
}
.river .pcard {  /* H201 修：河牌放大 1.3 倍（container query 字号随宽自适配），出牌后桌面一眼可读 */
  width: calc(var(--card-md) * 1.3);
  height: calc(var(--card-md-h) * 1.3);
}

/* ---------- 7. 组件 ---------- */
.btn {
  appearance: none; cursor: pointer;
  min-height: 44px; min-width: 64px;
  padding: 9px 18px;
  font-family: var(--font-ui); font-size: 15px; font-weight: 600;
  border-radius: 9px;
  border: 1px solid var(--felt-600);
  background: rgba(18, 36, 27, .9);
  color: var(--frost);
  touch-action: manipulation;
  transition: transform .12s var(--e-out), box-shadow .18s, filter .18s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .38; cursor: default; transform: none; }
.btn-gold {
  border-color: var(--gold-700);
  background: linear-gradient(180deg, rgba(40, 33, 12, .95), rgba(22, 18, 8, .95));
  color: var(--gold-200);
  box-shadow: inset 0 1px 0 rgba(232, 198, 106, .25);
}
.btn-gold:not(:disabled):hover { box-shadow: 0 0 18px rgba(232, 198, 106, .35); }
.btn-cinnabar { border-color: #7d2a22; color: #ffd9d2; background: rgba(72, 24, 20, .9); }
.btn-ghost { background: transparent; }

.acts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.meter {
  height: 6px; border-radius: 3px; overflow: hidden;
  background: rgba(0, 0, 0, .45);
  box-shadow: inset 0 0 0 1px rgba(232, 198, 106, .16);
}
.meter i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--felt-600), var(--gold-400));
  border-radius: 3px;
}

.chat {
  max-height: 210px; overflow: auto;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(10, 20, 16, .78);
  box-shadow: inset 0 0 0 1px rgba(232, 198, 106, .14);
  font-size: 13px; line-height: 1.75;
}
.chat-line { display: flex; gap: 8px; }
.chat-line b { color: var(--gold-400); font-weight: 600; flex: 0 0 auto; }
.chat-line.said b { color: var(--cinnabar-lite); }
.chat-line em { color: var(--mute); font-style: normal; }

.result-veil {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(6, 12, 9, .72);
  backdrop-filter: blur(3px);
}
.result-card {
  width: min(88vw, 460px);
  padding: 26px 24px 22px;
  text-align: center;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(18, 36, 27, .97), rgba(10, 20, 16, .97));
  box-shadow: inset 0 0 0 1px var(--gold-700), 0 24px 60px rgba(0, 0, 0, .7);
}
.result-card__seal {
  width: 92px; height: 92px; margin: 0 auto 10px;
  background: var(--a-seal) center / contain no-repeat;
  animation: stamp .5s var(--e-stamp) both;
}
.result-card h3 { margin: 0 0 6px; font-family: var(--font-card); font-size: 26px; letter-spacing: .12em; color: var(--gold-200); }
.result-card .rows { margin: 14px 0 18px; font-size: 14px; }
.result-card .rows div { display: flex; justify-content: space-between; padding: 5px 2px; border-bottom: 1px dashed rgba(232, 198, 106, .18); }
.result-card .rows span:last-child { color: var(--gold-200); font-variant-numeric: tabular-nums; }

.bei-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 8px; border-radius: 999px;
  background: rgba(10, 20, 16, .8);
  box-shadow: inset 0 0 0 1px var(--gold-700);
  color: var(--gold-200); font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.bei-chip::before { content: ""; width: 18px; height: 18px; background: var(--a-bei) center / contain no-repeat; }

/* ---------- 8. 动效 ---------- */
@keyframes breathe { 0%, 100% { box-shadow: inset 0 0 0 2px var(--gold-400), 0 0 10px rgba(232, 198, 106, .3), 0 8px 18px rgba(0, 0, 0, .5); } 50% { box-shadow: inset 0 0 0 2px var(--gold-200), 0 0 20px rgba(232, 198, 106, .6), 0 8px 18px rgba(0, 0, 0, .5); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 2px var(--gold-400); } 50% { box-shadow: 0 0 0 5px rgba(232, 198, 106, .18); } }
@keyframes stamp { from { transform: scale(1.45) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes deal { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 翻牌动画：只动 opacity + blur，绝不动 transform。
   原版 flipin 用 `to{transform:none}`，会把 .is-mine 的 translateY(-8px)
   整段吞掉——手牌在翻牌 0.2s 里下沉 8px 再弹回，看着像抖动。
   改用 blur+opacity 表达「翻出来」，与任何 transform 状态零冲突。 */
@keyframes flipin2 {
  from { opacity: .22; filter: blur(1.4px); }
  to   { opacity: 1;   filter: none; }
}
.pcard.flip, .mcard.flip { animation: flipin2 .2s var(--e-out) !important; }
/* 选牌上浮时给一次翻牌反馈（h228 令牌被 h237 restore 清除后补回）；
   须在 is-playable 之前——「这张能出」的持续呼吸仍压过一次性选牌动画。 */
.pcard.sel { animation: flipin2 .2s var(--e-out) !important; }
/* 呼吸提示必须压过翻牌：同一元素两个 animation 会互相顶掉，
   而「这张能出」是持续性状态信息，优先级高于一次性翻牌。 */
.pcard.is-playable { animation: breathe 2.2s var(--e-out) infinite !important; }

.pcard.deal, .mcard.deal { animation: deal .26s var(--e-out) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 9. 自适应 ---------- */
@media (max-width: 560px) {
  :root { --card-lg: 66px; --card-md: 54px; --card-md-h: 76px; }
  .seat { width: 104px; padding: 6px; }
  .seat__av { width: 38px; height: 38px; }
  .table-oval { width: 98vw; }
}

/* ---------- 10. 手机适配（H190 甲批：≤768 视觉缩放，桌面 1280 零改动；
   布局骨架段在 index.html 内嵌 style，本段只管视觉令牌与组件 ---------- */
@supports (height: 100dvh) {
  .room { min-height: 100dvh; }   /* iOS 地址栏收展 100vh 会裁底 */
}
@media (max-width: 768px) {
  :root {
    --card-lg: 58px;
    --card-md: 46px; --card-md-h: 65px;
    --card-sm: 36px; --card-sm-h: 51px;
    --card-xs: 25px; --card-xs-h: 35px;
  }
  .table-oval { width: 100vw; margin: 0; border-radius: 0; box-shadow: none; }
  .room::after { opacity: .22; }            /* 顶灯光晕小屏减淡，免糊牌面 */
  .seat { width: 86px; padding: 5px 5px 6px; border-radius: 10px; }
  .seat__av { width: 32px; height: 32px; margin-bottom: 3px; }
  .seat__name { font-size: 11px; }
  .seat__tpl { font-size: 9px; }
  .seat__bei { font-size: 10px; gap: 3px; margin-top: 2px; }
  .seat__bei::before { width: 11px; height: 11px; }
  .seat__hand .pcard { width: 13px; height: 18px; }
  .seat__hand .pcard__corner { font-size: 7px; }
  .seat__hand .pcard__corner .suit { width: 6px; height: 6px; }
  .seat__hand .mcard { width: 16px; height: 21px; }
  .seat__badge { font-size: 9px; padding: 1px 6px; }
  .seat__emote { font-size: 20px; top: -12px; right: -8px; }
  .pot__bei { font-size: 14px; padding: 4px 10px; gap: 4px; }
  .pot__bei::before { width: 16px; height: 16px; }
  .meld { padding: 2px 4px; gap: 2px; }
  .meld__tag { font-size: 9px; }
  .river { max-width: 80%; }
  .chat { max-height: 120px; font-size: 12px; padding: 8px 10px; }
  .result-card { width: min(92vw, 420px); padding: 20px 14px 16px; }
  .result-card h3 { font-size: 21px; }
  .result-card__seal { width: 72px; height: 72px; }
  .btn { min-height: 46px; }                /* 触控目标 ≥44px 兜底 */
  /* 窄屏桌矮（375 宽桌高约 211px），百分比座位会互相压角：mj4p 右家下移错开 */
  [data-composition="mj4p"] .seat[data-seat="p2"],
  [data-composition="mj4p"] .seat[data-seat="p3"] { top: 0; }
  [data-composition="mj4p"] .seat[data-seat="p1"] { top: 50%; }
}
/* 手机横屏矮窗：座位再收一档；user 座位收进桌内（bottom -6% 在矮桌会把
   自己挤到桌面下缘之外，手牌区让位不够时整个座位看不见） */
@media (max-height: 480px) {
  .seat { width: 80px; }
  .seat__av { width: 26px; height: 26px; }
  .seat__name { font-size: 10px; }
  [data-composition] .seat[data-seat="user"] { bottom: 0; }
  /* 16:9 桌在矮视口放不下（375 高 < 桌高 456）：按视口高反推桌宽，整桌进首屏 */
  .table-oval { width: min(96vw, 148vh); }
}

/* ============================================================
   ZCODE 接入：
   1) index.html 第 7 行 <style> 之前插入
      <link rel="stylesheet" href="ui_v2/index.css">
   2) 删旧 <style> 中：body/#app 背景、button、.gcard-tpl、.pcard-tpl、
      .avatar、.bar、#board-cards 等视觉规则；布局与引擎段保留。
   3) 牌面内容由逻辑层按契约输出（见 docs/UI_V2_设计方案.md 第 10 节）：
      <div class="pcard is-mine" data-suit="S"><span class="pcard__corner
        pcard__corner--tl"><b>A</b><i class="suit suit--spade"></i></span>
        <span class="pcard__pip"><i class="suit suit--spade"></i></span>…</div>
   ============================================================ */