/* ============ 小鲸鱼棋牌 · 全局 ============ */
:root {
  --blue: #4a90d9;
  --blue-dark: #2c6cb0;
  --blue-deep: #1c5a9c;
  --blue-light: #eaf3fb;
  --text: #2c3e50;
  --muted: #7f8c9d;
  --red: #e24b4a;
  --line: #d6e8f7;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* hidden 属性必须能压过下面那些显式 display 的规则，否则弹窗/按钮藏不住 */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #eaf3fb 0%, #d6e8f7 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

/* ============ Kenney 九宫格按钮 ============ */
/* 用 Kenney UI Pack 的 button_rectangle*.png 做 border-image 切片：
   原图 192x64，16px 边距，故 slice 16 fill。 */
.kbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  min-height: 44px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: transparent;
  border: 0;
  border-image-slice: 16 fill;
  border-image-width: 16px;
  border-image-repeat: stretch;
  cursor: pointer;
  transition: filter 0.13s, transform 0.08s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}
.kbtn:hover { filter: brightness(1.08); }
.kbtn:active { transform: translateY(2px); filter: brightness(0.94); }
.kbtn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.5); }

.kbtn-blue { border-image-source: url("/assets/common/PNG/Blue/Default/button_rectangle_depth_gradient.png"); }
.kbtn-red { border-image-source: url("/assets/common/PNG/Red/Default/button_rectangle_depth_gradient.png"); }
.kbtn-grey {
  border-image-source: url("/assets/common/PNG/Grey/Default/button_rectangle_depth_gradient.png");
  color: #4a5468;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
.kbtn-lg { font-size: 17px; padding: 14px 26px; width: 100%; }

/* 小号图标按钮（返回用的箭头） */
.kbtn-icon { padding: 8px 14px; min-height: 38px; font-size: 14px; }

/* ============ 大厅 ============ */
.lobby {
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px;
  width: 380px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(44, 108, 176, 0.12);
}

.lobby-avatar { width: 96px; height: 96px; margin-bottom: 12px; }

h1 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }

/* 页头品牌名：用字标图代替标题文字（鲸鱼图形由上面的头像承担，不重复）。
   图已按墨迹裁紧为 226×53，这里用**固定高度**排版 —— 34px 高 → 约 145px 宽，
   和原来 22px 的文字标题宽度接近，页头比例不变；窄屏由 max-width 兜住。 */
.lobby-logo img { display: block; height: 34px; width: auto; max-width: 100%; margin: 0 auto; }

.sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

.seg {
  display: flex;
  flex-wrap: wrap;              /* 5 个棋种时允许换行，避免挤成一团 */
  gap: 4px;
  background: #f0f5fa;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}

.seg-btn {
  flex: 1 1 auto;
  min-width: 72px;              /* 保证每项可点，不被压成细条 */
  padding: 10px 8px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: 0.15s;
}
.seg-btn.active { background: #fff; color: var(--blue-dark); font-weight: 500; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }
.seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* 行内选择（人数 / 桌位人数 / 先后手）：按钮少且小，
   沿用棋种那种「白底 + 极淡阴影」的选中态几乎看不出来，
   所以这里给一套**高对比**的选中样式：实心蓝底 + 白字 + ✓ 前缀。 */
.seg-inline { background: transparent; padding: 0; gap: 8px; }
.seg-inline .seg-btn {
  min-width: 62px;
  padding: 9px 12px;
  background: #eef3f9;
  color: var(--muted);
  border: 1.5px solid transparent;
  font-weight: 500;
  border-radius: 10px;
}
.seg-inline .seg-btn:hover:not(.active):not(:disabled) { background: #e2ecf7; color: var(--blue-dark); }
.seg-inline .seg-btn.active {
  background: var(--blue-dark);
  color: #fff;
  font-weight: 700;
  border-color: var(--blue-deep);
  box-shadow: 0 2px 7px rgba(44, 108, 176, 0.3);
}
.seg-inline .seg-btn.active::before { content: '\2713\a0'; font-weight: 700; }
.seg-inline .seg-btn:disabled { opacity: 0.4; }


/* 选边行（国际象棋 / 中国象棋 · 对战 AI 时出现） */
.side-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.side-label { font-size: 13px; color: var(--muted); }
.seg-inline { flex: 1; margin-bottom: 0; min-width: 180px; }
.seg-inline .seg-btn { font-size: 13px; padding: 8px 6px; min-width: 0; }
.side-hint { font-size: 12px; color: var(--muted); width: 100%; }

.join-row { display: flex; gap: 10px; margin-bottom: 14px; }

.code-input {
  flex: 1;
  width: 100%;
  padding: 12px;
  font-family: inherit;
  font-size: 20px;
  letter-spacing: 4px;
  text-align: center;
  color: var(--text);
  border: 0;
  border-image-slice: 16 fill;
  border-image-width: 12px;
  border-image-repeat: stretch;
  border-image-source: url("/assets/common/PNG/Extra/Default/input_rectangle.png");
  background: transparent;
  outline: none;
}
.code-input:focus { border-image-source: url("/assets/common/PNG/Blue/Default/button_rectangle_border.png"); }

.btn-primary { width: 100%; margin-top: 4px; }

.err { color: var(--red); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* ============ 对局页 ============ */
.game { text-align: center; padding: 18px 16px 26px; width: 100%; max-width: 520px; }

.topbar { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 12px; }

.avatar {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: #fff;
  flex: none;
  box-shadow: 0 2px 10px rgba(44, 108, 176, 0.18);
}

/* 头像随局势动起来：得意时轻晃，慌神时发抖 */
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-3deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px) rotate(-2deg); }
  75% { transform: translateX(2px) rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .avatar { animation: none !important; }
  .piece.pop { animation: none; }
}

.topbar-text { text-align: left; min-width: 0; }

.status { font-size: 16px; font-weight: 600; }

.room-code { font-size: 12px; color: var(--muted); letter-spacing: 0.5px; }

.mood-chip {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--blue-light);
  color: var(--blue-dark);
  white-space: nowrap;
}
.mood-chip[data-level="winning"],
.mood-chip[data-level="leading"],
.mood-chip[data-level="ended_win"] { background: #fdecef; color: #c9364f; }
.mood-chip[data-level="behind"],
.mood-chip[data-level="losing"],
.mood-chip[data-level="ended_lose"] { background: #e9f6ec; color: #2f7d4f; }
.mood-chip[data-level="ended_draw"] { background: #eef0f4; color: #5b6472; }

/* 比分条 */
.scorebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0 auto 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-dark);
  background: #fff;
  border-radius: 999px;
  padding: 7px 18px;
  width: fit-content;
  box-shadow: 0 2px 10px rgba(44, 108, 176, 0.1);
}
.score-vs { color: var(--muted); font-size: 12px; letter-spacing: 1px; }

.board-wrap {
  position: relative;
  width: min(92vw, 440px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.board-bg { width: 100%; height: 100%; display: block; border-radius: 14px; }

/* 井字棋格子 */
.cell {
  position: absolute;
  width: 24%;
  height: 24%;
  cursor: pointer;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.cell:hover { background: rgba(44, 108, 176, 0.22); border-color: rgba(44, 108, 176, 0.55); }
.cell.disabled { cursor: not-allowed; }
.cell.disabled:hover { background: transparent; border-color: transparent; }

/* 黑白棋棋盘（CSS 绘制 8×8） */
.reversi-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  background: var(--blue);
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(44, 108, 176, 0.2);
}
.rcell {
  background: #eaf3fb;
  cursor: pointer;
  position: relative;
  border-radius: 2px;
  transition: background 0.12s;
}
.rcell:hover { background: #cfe6f9; }
.rcell.disabled { cursor: not-allowed; }
.rcell.disabled:hover { background: #eaf3fb; }
.rcell.legal::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: rgba(44, 108, 176, 0.3);
  pointer-events: none;
}
.rcell.legal:not(.disabled):hover::after { background: rgba(44, 108, 176, 0.55); }

/* ============================================================
   五子棋
   15×15，棋子落在**交叉点**上（与围棋同规矩，不是格子中心）。
   做法同中国象棋：SVG 画线 + 落子点按百分比定位到交叉点；
   线条与落子点共用同一套坐标（GOMOKU_MARGIN / GOMOKU_STEP），
   所以棋子必然压在线上。
   间距 = (100 - 5*2) / (15-1) = 6.4286%
   ============================================================ */
:root {
  --gmk-line: #6a4215;
  --gmk-bg: #e8b779;
}
.gomoku-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--gmk-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(120, 80, 30, 0.25);
}
.gmk-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.gmk-lines .gstar { fill: var(--gmk-line); }
.gmk-points { position: absolute; inset: 0; }
/* 落子点：方形热区（边长 = 交叉点间距）紧密平铺，点击无死角；
   用 translate(-50%,-50%) 让「点」的中心正好落在 left/top 指定的交叉点上。 */
.gpt {
  position: absolute;
  width: 6.4286%;
  height: 6.4286%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.12s;
}
.gpt:hover { background: rgba(255, 255, 255, 0.3); }
.gpt.disabled { cursor: not-allowed; }
.gpt.disabled:hover { background: transparent; }
/* 棋子：占间距的 84%，与相邻子留出缝隙；限定在 .gmk-points 内，
   避免影响井字棋/黑白棋共用的 .piece 尺寸（见手册「共用类名泄漏」坑）。 */
.gmk-points .piece { width: 84%; height: 84%; }
@media (prefers-reduced-motion: reduce) {
  .gpt { transition: none; }
}

/* 棋子（井字棋/黑白棋通用） */
.piece {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 88%;
  height: 88%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.piece.pop { animation: pop 0.18s ease; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } }

/* 翻面（黑白棋变色）：绕纵轴翻过来，而不是「消失再出现」 */
.piece.flip { animation: pieceFlip 0.26s ease-out; }
@keyframes pieceFlip {
  from { transform: translate(-50%, -50%) rotateY(92deg) scale(0.92); }
  to   { transform: translate(-50%, -50%) rotateY(0deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .piece.flip { animation: none; }
}

/* 气泡 */
.bubble {
  margin: 14px auto 0;
  max-width: 440px;
  background: #fff;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 15px;
  line-height: 1.45;
  text-align: left;
  box-shadow: 0 4px 14px rgba(44, 108, 176, 0.1);
  position: relative;
  min-height: 48px;
}
.bubble::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: #fff;
}
.bubble-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 3px;
  letter-spacing: 0.5px;
}
.bubble.say { animation: bubbleIn 0.22s ease; }
@keyframes bubbleIn { from { transform: translateY(6px); opacity: 0; } }

/* 操作区 */
.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.actions .kbtn { min-width: 112px; }

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 52, 80, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 26px 24px 20px;
  width: min(92vw, 340px);
  text-align: center;
  box-shadow: 0 14px 40px rgba(20, 50, 90, 0.3);
}
.modal-card h2 { font-size: 18px; margin-bottom: 10px; }
.modal-card p { font-size: 14px; color: var(--muted); line-height: 1.5; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .kbtn { flex: 1; }

/* ============ 移动端 ============ */
@media (max-width: 480px) {
  .lobby { width: 92vw; padding: 30px 22px; }
  .game { padding: 14px 12px 20px; }
  .kbtn { font-size: 14px; padding: 9px 16px; }
  .actions .kbtn { min-width: 96px; flex: 1; }
  .mood-chip { font-size: 11px; padding: 3px 8px; }
}

/* ============================================================
   国际象棋
   注意：grid-template-rows 必须显式写出。只写 columns 时隐式行会按
   grid-auto-rows:auto 以内容高度撑开 —— 有棋子的行高、空行塌陷，
   整块棋盘会被压扁（这是实际踩过的坑）。
   ============================================================ */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 4px solid var(--navy, #1e3a6e);
  box-shadow: 0 6px 20px rgba(20, 50, 90, 0.18);
}
.csq {
  aspect-ratio: 1;               /* 双保险：格子自身锁定 1:1 */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.csq.light { background: #e8f4fd; }
.csq.dark { background: #4a9fe0; }
.csq .piece {
  width: 88%;
  height: 88%;
  object-fit: contain;
  pointer-events: none;
}
.csq.pickable { cursor: pointer; }
.csq.pickable::after {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  pointer-events: none;
}
.csq.selected::after {
  border: 3px solid #f0b429;
  box-shadow: inset 0 0 0 3px rgba(240, 180, 41, 0.4);
}
.csq.target { cursor: pointer; }
.csq.target::before {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(47, 125, 79, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
.csq.target.maybe-capture::before {
  width: 78%; height: 78%;
  background: transparent;
  border: 3px dashed rgba(201, 54, 79, 0.75);
  box-shadow: none;
}

/* ============================================================
   中国象棋
   9 列 × 10 行，棋子落在**交叉点**上 —— 不能用等分格子放棋子，
   否则每枚都偏半格。做法：SVG 画线 + 百分比定位棋子到交叉点。
   ============================================================ */
:root {
  --xq-line: #6b4a2f;
  --xq-bg: #f3e2c7;
}
.xq-board {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 10;          /* 9 列 10 行，纵向略长 */
  background: var(--xq-bg) url('/assets/Chinesechess/board.webp') center/cover no-repeat;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(20, 50, 90, 0.18);
}
.xq-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.xq-points {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(10, 1fr);   /* 同样不能漏 */
}
.xq-pt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.xq-pt .xq-piece {
  position: absolute;
  width: 92%;
  max-width: 52px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.xq-pt .xq-piece .xq-token {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* 白底圆面：保证汉字在任何底托颜色上都有足够对比度
   （原先红方用近白色文字、而底托中心本身就是近白色 RGB(253,253,251)，
     白字压白底 → 完全看不见。改成统一的白底 + 黑字 + 浅色衬边。） */
.xq-pt .xq-piece .xq-face {
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  background: #fbfdff;
  box-shadow: inset 0 1px 3px rgba(20, 40, 80, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.9);
}
.xq-pt .xq-piece .xq-char {
  position: relative;
  font-family: KaiTi, STKaiti, 'Kaiti SC', 'Songti SC', serif;
  font-weight: 700;
  /* 字号统一收小一档：汉字在圆面里更透气，两侧视觉体量也更一致 */
  font-size: clamp(11px, 2.8vw, 19px);
  line-height: 1;
  color: #14181f;
  /* 浅色衬边，进一步拉开与底色的边界 */
  -webkit-text-stroke: 0.6px rgba(255, 255, 255, 0.95);
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  user-select: none;
}
/* 两侧靠底托颜色区分阵营：亮蓝 = 红方，深蓝 = 黑方 */
.xq-pt .xq-piece[data-side="red"] .xq-char { color: #b3261e; }
.xq-pt .xq-piece[data-side="black"] .xq-char { color: #14181f; }

/* 被吃掉的棋子：短暂保留一个残影做淡出
   层级要低于滑动中的棋子（SLIDE_Z=20），让「吃子方」压在残影之上 */
.piece.captured,
.xq-piece.captured {
  position: absolute;
  pointer-events: none;
  z-index: 6;
}
.xq-pt .xq-piece.captured { position: absolute; z-index: 6; }

/* 滑动中的棋子：必须盖过所有棋盘格。
   格子（.csq / .xq-pt）都是 position:relative 且 z-index:auto（不形成层叠上下文），
   所以子元素的 z-index 能作用到棋盘这一层，足以盖过按 DOM 顺序绘制的其它格子。 */
.csq, .xq-pt { z-index: auto; }

/* 棋类落子/吃子过渡 */
@keyframes pieceDrop {
  from { opacity: 0; transform: scale(0.82); }
  to { opacity: 1; transform: scale(1); }
}
/* ⚠️ 这里必须限定到「棋盘格子内」的棋子！
   原先写成 `.piece.pop`（不限格子），而它位于井字棋/黑白棋的
   `.piece.pop { animation: pop }` **之后** —— CSS 后者优先，
   于是井字棋与黑白棋的落子被覆盖成了**象棋的落下动画**（pieceDrop）。
   现在只在 .csq（国际象棋格）与 .xq-piece（中国象棋子）上生效。 */
.csq .piece.pop, .xq-piece.pop { animation: pieceDrop 0.22s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .piece.pop, .xq-piece.pop { animation: none; }
}
.xq-pt.pickable { cursor: pointer; }
.xq-pt.pickable .xq-piece::after {
  content: '';
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
}
.xq-pt.selected .xq-piece::after {
  border: 3px solid #f0b429;
}
.xq-pt.target { cursor: pointer; }
.xq-pt.target::before {
  content: '';
  position: absolute;
  width: 34%;
  height: 26%;
  border-radius: 50%;
  background: rgba(47, 125, 79, 0.5);
  pointer-events: none;
}

/* ============================================================
   21点牌桌
   ============================================================ */
.bj-table {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 14px;
  border-radius: 16px;
  background: linear-gradient(160deg, #1e3a6e, #2c5794);
  box-shadow: 0 8px 24px rgba(20, 50, 90, 0.28);
}
/* PVP 专属：轮到谁 / 本局状态（对战 AI 时隐藏） */
.bj-turn {
  text-align: center;
  font-size: 12.5px;
  color: #cfe4fb;
  letter-spacing: 0.3px;
  padding-bottom: 2px;
}
/* 一行的左右内边距固定，这样「高亮当前行」时不会让整块布局跳动 */
.bj-row { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px; margin: 0 -8px; border-radius: 10px; }
.bj-row.active { background: rgba(255, 255, 255, 0.11); }
.bj-row.active .bj-name { color: #fff; font-weight: 600; }
/* 状态徽章：正在打 / 已停手 / 爆牌 / 胜 / 负 / 平 */
.bj-badge {
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #d7e8fb;
  white-space: nowrap;
  line-height: 1.6;
}
.bj-badge:empty { display: none; }
.bj-badge.win { background: #2f9e6a; color: #fff; }
.bj-badge.lose { background: #c14a45; color: #fff; }
.bj-badge.push { background: #7b8ca4; color: #fff; }
.bj-badge.turn { background: var(--blue); color: #fff; }
/* 多人同桌会有「庄家 + 最多 4 人」共 5 行 —— 牌必须缩小，否则手机上要滚很久 */
.bj-table.multi .bj-hand { min-height: 64px; gap: 5px; }
.bj-table.multi .bj-card { width: 44px; border-radius: 5px; }
.bj-table.multi .bj-rank { font-size: 11px; }
.bj-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: #cfe4fb; letter-spacing: 0.5px;
}
.bj-label b { font-size: 15px; color: #fff; }
.bj-hand {
  display: flex;
  gap: 8px;
  min-height: 92px;
  flex-wrap: wrap;
  align-items: center;
}
.bj-card {
  position: relative;
  width: 62px;
  aspect-ratio: 1 / 1.4;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transform-origin: center bottom;
  /* 发牌动画：仅在「手牌真的变化」时触发（renderBlackjack 做了差异渲染），
     所以不会随轮询反复播放造成闪烁 */
  animation: cardDeal 0.32s cubic-bezier(0.2, 0.85, 0.3, 1) both;
  animation-delay: calc(var(--i) * 0.07s);
}
@keyframes cardDeal {
  from { opacity: 0; transform: translateY(-22px) rotate(-7deg) scale(0.88); }
  to { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}
/* 庄家暗牌翻开时的翻面过渡 */
.bj-card.back { background: #dce9f8; }
@keyframes cardFlip {
  from { transform: rotateY(88deg) scale(0.96); }
  to { transform: rotateY(0) scale(1); }
}
.bj-card.flip { animation: cardFlip 0.34s ease-out both; }
/* 点数变化时轻微脉冲，提示「点数更新了」 */
@keyframes totalPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); color: #ffe08a; }
  100% { transform: scale(1); }
}
.bj-label b.pulse { animation: totalPulse 0.42s ease-out; display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  .bj-card, .bj-card.flip, .bj-label b.pulse { animation: none; }
}
.bj-card.back img { width: 100%; height: 100%; object-fit: cover; }
.bj-card .bj-suit { width: 46%; height: 46%; object-fit: contain; }
.bj-card .bj-face { width: 100%; height: 100%; object-fit: cover; }
.bj-card .bj-rank {
  position: absolute;
  top: 3px; left: 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.bj-card .bj-rank.br { top: auto; left: auto; right: 4px; bottom: 3px; transform: rotate(180deg); }
.bj-card .bj-rank.red { color: #d8402f; }
.bj-card .bj-rank.black { color: #1e3a6e; }
.bj-sep { height: 1px; background: rgba(255, 255, 255, 0.16); margin: 2px 0; }

/* 要牌/停手 操作条 */
.bj-actions { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }
.bj-actions .kbtn { min-width: 110px; }

@media (max-width: 480px) {
  .bj-card { width: 52px; }
  .bj-hand { min-height: 78px; gap: 6px; }
  .bj-actions .kbtn { min-width: 92px; }
}

/* ============================================================
   斗地主 / 德州扑克 的牌面与桌面
   ============================================================ */
.pk-card {
  position: relative;
  width: 58px;
  aspect-ratio: 1 / 1.4;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(20, 40, 80, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.pk-card.back { background: #dce9f8; }
.pk-card.back img { width: 100%; height: 100%; object-fit: cover; }
.pk-card .pk-suit { width: 46%; height: 46%; object-fit: contain; }
.pk-card .pk-face { width: 100%; height: 100%; object-fit: cover; }
.pk-card .pk-rank {
  position: absolute; top: 3px; left: 4px;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.pk-card .pk-rank.br { top: auto; left: auto; right: 4px; bottom: 3px; transform: rotate(180deg); }
.pk-card .pk-rank.red { color: #d8402f; }
.pk-card .pk-rank.black { color: #1e3a6e; }
.pk-card.joker { background: #fff; }
.pk-card .pk-joker-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pk-card .pk-joker-label {
  font-family: KaiTi, STKaiti, serif;
  font-weight: 700; font-size: 13px;
  text-align: center; writing-mode: vertical-rl;
}
.pk-card .pk-joker-label.red { color: #d8402f; }
.pk-card .pk-joker-label.black { color: #1e3a6e; }

/* 斗地主桌面（参考常见棋牌手游的排布） */
.ddz-table { width: 100%; display: flex; flex-direction: column; gap: 10px; }

/* 上方两个对手 */
.ddz-opps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ddz-opp {
  background: #eef5fd; border-radius: 10px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: inset 0 0 0 1px rgba(30, 58, 110, 0.06);
  transition: box-shadow 0.15s, background 0.15s;
}
.ddz-opp.active { background: #e2f0ff; box-shadow: inset 0 0 0 2px var(--blue, #4a9fe0); }
.ddz-opp-head { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--navy, #1e3a6e); }
.ddz-opp-head b { font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ddz-opp-head i { font-style: normal; font-size: 12px; color: var(--muted); }
.ddz-opp-head i::after { content: ' 张'; font-size: 10px; }
/* 地主标记 */
.ddz-badge {
  font-size: 10px; font-weight: 700; color: #fff; background: #e0951b;
  border-radius: 4px; padding: 1px 5px; white-space: nowrap;
}
.ddz-badge[hidden] { display: none; }
/* 每家最近出的牌 */
.ddz-played { min-height: 42px; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.ddz-played .pk-card { width: 30px; border-radius: 4px; }
.ddz-played .pk-card .pk-rank { font-size: 9px; }
.ddz-played .pk-suit, .ddz-played .pk-face { opacity: 0.9; }
.ddz-thinking { font-size: 12px; color: var(--muted); }

/* 中间：底牌 + 出牌提示 */
.ddz-mid { display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 78px; justify-content: center; padding: 4px 0; }
.ddz-bottom { display: flex; align-items: center; gap: 4px; }
.ddz-bottom .lbl { font-size: 12px; color: var(--muted); margin-right: 4px; }
.ddz-bottom .pk-card { width: 38px; }
.ddz-turnbar { font-size: 12px; color: #2c5794; background: #eaf4ff;
  border-radius: 20px; padding: 3px 14px; }

/* 我的区域 */
.ddz-me { display: flex; flex-direction: column; gap: 4px;
  border-top: 1px dashed rgba(30, 58, 110, 0.14); padding-top: 8px; }
.ddz-me.active { border-top-color: var(--blue, #4a9fe0); }
.ddz-me-head { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--navy, #1e3a6e); }
.ddz-me-head i { font-style: normal; font-size: 12px; color: var(--muted); margin-left: auto; }
.ddz-me-head i::after { content: ' 张'; font-size: 10px; }
.ddz-me .ddz-played { justify-content: center; min-height: 40px; }

/* 手牌：扇面重叠，选中上浮 */
.ddz-hand { display: flex; justify-content: center; flex-wrap: wrap; gap: 0;
  padding: 14px 0 2px; }
.ddz-hand .pk-card { width: 52px; cursor: pointer; margin-left: -20px;
  transition: transform 0.12s ease, box-shadow 0.12s ease; }
.ddz-hand .pk-card:first-child { margin-left: 0; }
.ddz-hand .pk-card.sel { transform: translateY(-14px); box-shadow: 0 6px 14px rgba(20, 40, 80, 0.32); }
.ddz-hand .pk-card.sel::after {
  content: ''; position: absolute; inset: 0;
  border: 2px solid #f0b429; border-radius: 7px; pointer-events: none;
}

/* 德州扑克桌面（支持 2~6 人） */
.hm-table { width: 100%; display: flex; flex-direction: column; gap: 8px; }

/* 对手列表 */
.hm-opps { display: flex; flex-direction: column; gap: 6px; }
.hm-opp {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: background 0.15s, box-shadow 0.15s;
}
.hm-opp.active { background: rgba(255, 255, 255, 0.26); box-shadow: inset 0 0 0 2px #ffe08a; }
.hm-opp.folded { opacity: 0.45; }
.hm-opp-head { display: flex; align-items: center; gap: 6px; min-width: 92px; font-size: 13px; color: #fff; }
.hm-opp-head b { font-size: 13px; }
.hm-chips { font-style: normal; font-size: 12px; color: #d7e9ff; }
.hm-btn-mark {
  font-size: 9px; font-weight: 700; color: #1e3a6e; background: #ffe08a;
  border-radius: 50%; width: 15px; height: 15px; line-height: 15px; text-align: center;
}
.hm-btn-mark[hidden] { display: none; }
.hm-opp .hm-hand { display: flex; gap: 3px; }
.hm-opp .hm-hand .pk-card { width: 26px; }
.hm-state { margin-left: auto; font-size: 11px; color: #ffe08a; text-align: right; }

/* 中间：底池 + 公共牌 + 阶段 */
.hm-middle { display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14); }
.hm-pot { font-size: 13px; color: #ffe08a; font-weight: 600; }
.hm-pot b { font-size: 17px; }
.hm-board { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; min-height: 62px; align-items: center; }
.hm-board .pk-card { width: 40px; }
.hm-phase { font-size: 12px; color: #cfe4fb; }

/* 我的区域 */
.hm-me { display: flex; flex-direction: column; gap: 6px; }
.hm-me.active .hm-hand { box-shadow: 0 0 0 2px #ffe08a; border-radius: 8px; }
.hm-me-head { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #fff; }
.hm-me-head b { font-size: 14px; }
.hm-bet { margin-left: auto; font-size: 12px; color: #ffe08a; }
.hm-me .hm-hand { display: flex; gap: 6px; justify-content: center; padding: 2px; }
.hm-me .hm-hand .pk-card { width: 46px; }

/* 牌局操作条 */
.card-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.card-actions .kbtn { min-width: 92px; }

@media (max-width: 480px) {
  .pk-card { width: 46px; }
  .ddz-bottom .pk-card { width: 32px; }
  .ddz-played .pk-card { width: 26px; }
  .ddz-hand .pk-card { width: 44px; margin-left: -22px; }
  .ddz-hand { padding-top: 12px; }
  .ddz-opp-head b { font-size: 12px; }
  .hm-opp .hm-hand .pk-card { width: 22px; }
  .hm-board .pk-card { width: 32px; }
  .hm-me .hm-hand .pk-card { width: 38px; }
  .hm-opp-head { min-width: 74px; font-size: 12px; }
  .hm-state { font-size: 10px; }
  .card-actions .kbtn { min-width: 76px; font-size: 13px; padding: 8px 10px; }
}

/* 等待开局面板 */
.wait-box {
  width: 100%; padding: 28px 20px; border-radius: 16px;
  background: #eef5fd; text-align: center;
  box-shadow: inset 0 0 0 1px rgba(30, 58, 110, 0.08);
}
.wait-title { font-size: 16px; font-weight: 600; color: var(--navy, #1e3a6e); margin-bottom: 10px; }
.wait-count { font-size: 22px; color: var(--blue-dark, #2c5794); font-weight: 700; }
.wait-count b { font-size: 26px; }
.wait-hint { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.wait-hint b { color: var(--navy, #1e3a6e); }
