/* 牌桌、座位、扑克牌、筹码与动画 */
.table-area {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  padding: 6px 6px 0;
}
.table {
  position: relative;
  width: 100%;
  height: 100%;
  --anim: 1;
}

/* 椭圆（竖向跑道形）牌桌：木纹/深色边框 + 毡面渐变 */
.rail {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 10%;
  bottom: 15%;
  border-radius: 999px;
  padding: 11px;
  background:
    repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.03) 0 3px, rgba(0, 0, 0, 0.05) 3px 7px),
    linear-gradient(160deg, #5a3a22 0%, #3b2414 45%, #24150b 100%);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.6),
    inset 0 2px 2px rgba(255, 255, 255, 0.18),
    inset 0 -3px 6px rgba(0, 0, 0, 0.5);
}
.felt {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, #2fa564 0%, #1f7d48 45%, #145a33 80%, #0e4426 100%);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35), inset 0 0 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.felt-line {
  position: absolute;
  inset: 9%;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.09);
}
.felt-mark {
  position: absolute;
  left: 0;
  right: 0;
  top: 64%;
  text-align: center;
  font-size: 11px;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.13);
  font-weight: 700;
}

/* 扑克牌（CSS 绘制） */
.card {
  --cw: 44px;
  position: relative;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  border-radius: calc(var(--cw) * 0.12);
  background: linear-gradient(160deg, #ffffff 0%, #f3f3f1 70%, #e6e5e0 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  color: #15171a;
  flex: 0 0 auto;
  overflow: hidden;
}
.card.red { color: #d41f2c; }
.card .cr {
  position: absolute;
  left: 7%;
  top: 3%;
  font-weight: 800;
  font-size: calc(var(--cw) * 0.44);
  line-height: 1;
  letter-spacing: -1px;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.card .cs {
  position: absolute;
  left: 9%;
  top: 36%;
  font-size: calc(var(--cw) * 0.3);
  line-height: 1;
}
.card .cbig {
  position: absolute;
  right: 6%;
  bottom: 3%;
  font-size: calc(var(--cw) * 0.62);
  line-height: 1;
}
.card.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.18) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, #b3263a 0 3px, #8e1a2c 3px 6px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 0 0 2px #f4efe6, inset 0 0 0 3px rgba(0, 0, 0, 0.2);
}
.card.bcard { --cw: 46px; }
.card.big { --cw: 54px; }
.card.mid { --cw: 34px; }
.card.sm { --cw: 24px; }
.card.mini { --cw: 20px; }
.card.xs { --cw: 18px; box-shadow: none; }
.card.sm .cr, .card.mini .cr { display: none; }
.card.sm:not(.back) .cr { display: block; font-size: 11px; }
.card.sm:not(.back) .cbig { font-size: 13px; }
.card.sm:not(.back) .cs { display: none; }
.card.xs .cs, .card.xs .cbig { display: none; }
.card.xs .cr { font-size: 9px; left: 2px; top: 2px; }
.card.xs::after { content: ""; }

.card.flip { animation: flipIn calc(420ms * var(--anim)) ease-out both; transform-origin: 50% 50%; }
@keyframes flipIn {
  0% { transform: perspective(400px) rotateY(90deg) scale(0.9); filter: brightness(0.6); }
  100% { transform: perspective(400px) rotateY(0deg) scale(1); filter: none; }
}

/* 底池与公共牌 */
.pots {
  position: absolute;
  left: 50%;
  top: calc(47% - 40px);
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  z-index: 2;
  min-width: 90px;
}
.pot-line {
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pot-line.main { font-size: 13px; color: #ffe8a3; }
.pot-line small { color: var(--text2); font-weight: 400; margin-left: 3px; font-size: 10.5px; }
.pot-total { font-size: 11px; color: rgba(255, 255, 255, 0.6); }
.board {
  position: absolute;
  left: 50%;
  top: 47%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 4px;
  z-index: 2;
}
.board .slot {
  width: 46px;
  height: 64px;
  border-radius: 6px;
  border: 1.5px dashed rgba(255, 255, 255, 0.1);
}
.board .slot:has(.card) { border-color: transparent; }
.deck {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 30px;
  z-index: 1;
  opacity: 0.9;
}
.deck .card { position: absolute; left: 0; top: 0; }
.deck .card:nth-child(2) { left: 1.5px; top: -1.5px; }
.deck .card:nth-child(3) { left: 3px; top: -3px; }

/* 座位 */
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.3s;
}
.seat.out { opacity: 0.25; }
.who { display: flex; flex-direction: column; align-items: center; position: relative; }
.avatar-wrap { position: relative; width: 52px; height: 52px; }
.avatar {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.55), inset 0 -3px 6px rgba(0, 0, 0, 0.25), inset 0 2px 3px rgba(255, 255, 255, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.75);
}
.ring { position: absolute; inset: -2px; width: calc(100% + 4px); height: calc(100% + 4px); transform: rotate(-90deg); pointer-events: none; }
.ring circle { fill: none; stroke-width: 4; }
.ring-bg { stroke: transparent; }
.ring-fg { stroke: transparent; stroke-dasharray: 182.2; stroke-dashoffset: 0; stroke-linecap: round; }
.seat.acting .ring-bg { stroke: rgba(0, 0, 0, 0.45); }
.seat.acting .ring-fg { stroke: #fcd34d; animation: countdown 15s linear infinite; filter: drop-shadow(0 0 4px rgba(252, 211, 77, 0.9)); }
.seat.acting .avatar { box-shadow: 0 0 0 2px #fcd34d, 0 0 18px rgba(252, 211, 77, 0.7); }
@keyframes countdown {
  0% { stroke-dashoffset: 0; stroke: #fcd34d; }
  75% { stroke: #fb923c; }
  100% { stroke-dashoffset: 182.2; stroke: #ef4444; }
}
.plate {
  margin-top: -6px;
  min-width: 74px;
  max-width: 92px;
  padding: 3px 7px 3px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(22, 26, 32, 0.95), rgba(10, 12, 16, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  text-align: center;
  position: relative;
  z-index: 1;
}
.plate .nm { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate .stk { font-size: 13px; font-weight: 700; color: #ffe8a3; line-height: 1.15; }
.plate .stk-bb { font-size: 10px; color: var(--muted); line-height: 1.1; }
.seat.allin .plate .stk { color: #fca5a5; }
.seat.folded .who { opacity: 0.45; filter: grayscale(0.7); }
.seat.winner .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(245, 196, 81, 0.9); }

.dbtn {
  position: absolute;
  right: -6px;
  top: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #d9d9d9);
  color: #111;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  z-index: 2;
}
.blind-tag {
  position: absolute;
  left: -10px;
  bottom: 4px;
  font-size: 9.5px;
  padding: 1px 4px;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 底牌位置 */
.hole { display: flex; position: absolute; z-index: 2; pointer-events: none; }
.hole .card + .card { margin-left: -8px; }
.hole .card:first-child { transform: rotate(-7deg); }
.hole .card:last-child { transform: rotate(7deg); }
.hole .card.flip:first-child, .hole .card.flip:last-child { animation: flipIn calc(420ms * var(--anim)) ease-out both; }
.hole .card.mid + .card.mid { margin-left: -4px; }
.hole .card.mid { transform: none !important; }
.hole.dim { opacity: 0.4; filter: grayscale(0.6); }
.side-l .hole { left: 44px; top: 4px; }
.side-r .hole { right: 44px; top: 4px; }
.side-t .hole { left: 46px; top: 6px; }
.side-l .hole:has(.mid) { left: 40px; top: 12px; }
.side-r .hole:has(.mid) { right: 40px; top: 12px; }
.side-t .hole:has(.mid) { left: 44px; top: 10px; }

/* 自己（底部）：大号底牌 */
.seat.side-b { flex-direction: row; align-items: center; gap: 6px; }
.seat.side-b .hole { position: relative; order: 0; margin-right: 2px; }
.seat.side-b .who { order: 1; }
.seat.hero .hole .card + .card { margin-left: -14px; }
.seat.hero .hole .card:first-child { transform: rotate(-6deg) translateY(2px); }
.seat.hero .hole .card:last-child { transform: rotate(6deg) translateY(2px); }
.seat.hero .hole { min-width: 96px; min-height: 78px; align-items: center; justify-content: center; }
.seat.side-b:not(.hero) .hole { min-width: 0; }
.seat.side-b .bubble { top: -22px; }

/* 动作气泡、牌型、赢得 */
.bubble {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%) scale(0.6);
  opacity: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: #374151;
  color: #fff;
  transition: transform 0.18s, opacity 0.18s;
  z-index: 4;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }
.bubble.fold { background: #4b5563; color: #d1d5db; }
.bubble.check { background: #0f766e; }
.bubble.call { background: #1d4ed8; }
.bubble.raise { background: #c2410c; }
.bubble.allin { background: linear-gradient(135deg, #dc2626, #9f1239); }
.bubble.post { background: #334155; color: #cbd5e1; }
.hname {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #111;
  background: linear-gradient(180deg, #ffe08a, #f5b82e);
  padding: 1px 7px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  z-index: 4;
}
.hname.show { opacity: 1; }
.seat.side-b .hname { bottom: -14px; }
.win {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
}
.win.show { animation: winUp calc(1200ms * var(--anim)) ease-out forwards; }
@keyframes winUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  30% { opacity: 1; transform: translate(-50%, -14px) scale(1.15); }
  100% { opacity: 1; transform: translate(-50%, -22px) scale(1); }
}

/* 下注筹码 */
.bet {
  position: absolute;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  gap: 4px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 8px 2px 4px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.bet.show { display: flex; }
.chipstack { position: relative; width: 16px; height: 16px; display: inline-block; }
.chipstack i {
  position: absolute;
  left: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #f9d77e 0 30%, #c8932a 31% 45%, #f5c451 46% 62%, #fff 63% 70%, #d64545 71%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.chipstack i:nth-child(1) { top: 3px; }
.chipstack i:nth-child(2) { top: 0; }
.chipstack i:nth-child(3) { top: -3px; }

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 10; overflow: visible; }
.flyer { position: absolute; left: 0; top: 0; will-change: transform; }
.flyer .chipstack.fly { width: 18px; height: 18px; }

/* 回放中的缩小牌桌 */
.replay-table { height: min(54vh, 460px); flex: 0 0 auto; }
.replay-table .avatar-wrap { width: 42px; height: 42px; }
.replay-table .avatar { font-size: 19px; }
.replay-table .card.bcard { --cw: 34px; }
.replay-table .board .slot { width: 34px; height: 48px; }
.replay-table .card.mid { --cw: 26px; }
.replay-table .card.mid .cs { display: none; }
.replay-table .side-l .hole { left: 36px; top: 6px; }
.replay-table .side-r .hole { right: 36px; top: 6px; }
.replay-table .side-t .hole { left: 38px; top: 4px; }
.replay-table .plate { min-width: 64px; padding: 2px 5px; }
.replay-table .plate .stk { font-size: 12px; }
.replay-table .hname { font-size: 10px; bottom: -15px; }
.replay-table .pot-line { font-size: 11px; }

@media (max-width: 370px) {
  .card.bcard { --cw: 42px; }
  .board .slot { width: 42px; height: 59px; }
  .card.big { --cw: 50px; }
  .plate { min-width: 66px; }
}
@media (max-height: 640px) {
  .card.big { --cw: 46px; }
  .seat.hero .hole { min-height: 66px; }
}

/* 顶部座位：D 标记放在左上，避免压住底牌 */
.side-t .dbtn { right: auto; left: -8px; top: -2px; }
.side-r .blind-tag { left: auto; right: -10px; }

/* ———— 机器人座位（Deeplay 测试服）：青/品红霓虹边框 + BOT 徽标 + 连接状态 ———— */
.seat.bot .avatar {
  border-color: #22d3ee;
  box-shadow: 0 0 0 2px #d946ef, 0 0 12px rgba(34, 211, 238, 0.75), 0 0 20px rgba(217, 70, 239, 0.45);
}
.seat.bot .plate {
  min-width: 84px;
  max-width: 132px;
  border: 1.5px solid #22d3ee;
  box-shadow: 0 0 0 1px rgba(217, 70, 239, 0.7), 0 0 10px rgba(34, 211, 238, 0.55), 0 0 18px rgba(217, 70, 239, 0.35);
  animation: botGlow 2.4s ease-in-out infinite alternate;
}
@keyframes botGlow {
  from { box-shadow: 0 0 0 1px rgba(217, 70, 239, 0.7), 0 0 8px rgba(34, 211, 238, 0.45), 0 0 14px rgba(217, 70, 239, 0.25); }
  to { box-shadow: 0 0 0 1px rgba(217, 70, 239, 0.9), 0 0 12px rgba(34, 211, 238, 0.7), 0 0 22px rgba(217, 70, 239, 0.45); }
}
@media (prefers-reduced-motion: reduce) { .seat.bot .plate { animation: none; } }
.seat.bot .plate .nm { color: #a5f3fc; font-weight: 700; }
.seat.bot .plate .nm-sub {
  font-size: 9px;
  line-height: 1.15;
  color: #f0abfc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bot-badge {
  position: absolute;
  right: -14px;
  top: -6px;
  z-index: 3;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 6px;
  color: #06131a;
  background: linear-gradient(135deg, #22d3ee, #e879f9);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.8);
  pointer-events: none;
}
.bot-st {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: 1px;
  font-size: 9.5px;
  line-height: 1.2;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
}
.bot-st span { overflow: hidden; text-overflow: ellipsis; }
.bot-st i { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: #fbbf24; }
.seat.bot.st-connecting .bot-st i { animation: botBlink 1s steps(2) infinite; }
@keyframes botBlink { 50% { opacity: 0.25; } }
.seat.bot.st-ready .bot-st { color: #86efac; }
.seat.bot.st-ready .bot-st i { background: #22c55e; box-shadow: 0 0 5px #22c55e; }
.seat.bot.st-interrupted .bot-st { color: #fca5a5; font-weight: 700; }
.seat.bot.st-interrupted .bot-st i { background: #ef4444; box-shadow: 0 0 5px #ef4444; }
.seat.bot.st-interrupted .bot-badge { background: #ef4444; color: #fff; box-shadow: 0 0 8px rgba(239, 68, 68, 0.9); }
.seat.bot.st-interrupted .plate { border-color: #ef4444; animation: none; box-shadow: 0 0 10px rgba(239, 68, 68, 0.55); }
.replay-table .bot-st { display: none; }
.replay-table .seat.bot .plate { min-width: 70px; max-width: 92px; }
/* 机器人名牌更宽：顶部座位底牌按中心定位（与普通座位相对头像的位置一致），BOT 徽标放左上避开底牌 */
.seat.bot.side-t .hole { left: calc(50% + 9px); }
.seat.bot.side-t .hole:has(.mid) { left: calc(50% + 7px); }
.replay-table .seat.bot.side-t .hole { left: calc(50% + 6px); }
.seat.bot.side-t .bot-badge, .seat.bot.side-r .bot-badge { right: auto; left: -14px; }
