/* =========================================================
   牌桌专用 · CSS Grid 四家布局 + 拟真牌组件
   ========================================================= */

:root {
  --tile-md-w: 62px;
  --tile-md-h: 86px;
  --tile-sm-w: 34px;
  --tile-sm-h: 46px;
  --tile-xs-w: 32px;
  --tile-xs-h: 44px;
  --tile-lg-w: 68px;
  --tile-lg-h: 94px;
  --hand-gap: 3px;
  --opp-gap: 2px;
}

/* ---------- 牌组件（学 majiang-ex） ---------- */
.tile {
  --tw: var(--tile-md-w);
  --th: var(--tile-md-h);
  width: var(--tw);
  height: var(--th);
  padding: 0;
  border: 0;
  background: transparent;
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  perspective: 600px;
  transition: transform .16s cubic-bezier(.2,.8,.2,1), filter .16s;
}
.tile:disabled { cursor: default; opacity: 1; }
.tile--sm { --tw: var(--tile-sm-w); --th: var(--tile-sm-h); }
.tile--xs { --tw: var(--tile-xs-w); --th: var(--tile-xs-h); }
.tile--lg { --tw: var(--tile-lg-w); --th: var(--tile-lg-h); }
.tile--md { --tw: var(--tile-md-w); --th: var(--tile-md-h); }

.tile__inner {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: calc(var(--tw) * 0.12);
  transform-style: preserve-3d;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s;
  box-shadow:
    0 2px 0 rgba(0,0,0,.25),
    0 6px 12px rgba(0,0,0,.35);
}

.tile__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  background: #f4efe3;
  border: 1px solid rgba(0,0,0,.12);
}

.tile__img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

.tile__edge {
  position: absolute;
  left: 2px; right: 2px; bottom: -3px;
  height: 4px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(180deg, #cfc3a8, #a89878);
  z-index: -1;
  opacity: .9;
}

.tile.is-back .tile__face {
  background:
    repeating-linear-gradient(45deg, rgba(120,190,255,.14) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(-45deg, rgba(120,190,255,.1) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #1c5a96 0%, #0e3a66 55%, #0a2a4c 100%);
  border: 1px solid rgba(180, 220, 255, .35);
  box-shadow: inset 0 0 0 2px rgba(20, 50, 90, .55);
}
.tile.is-back .tile__img {
  /* PNG 牌背；失败时仍见 CSS 蓝底花纹 */
  opacity: 1;
}
.tile.is-back .tile__edge {
  background: linear-gradient(180deg, #2a6a9e, #143a60);
}

.tile.is-playable { cursor: pointer; }
.tile.is-playable:hover .tile__inner,
.tile.is-playable:focus-visible .tile__inner {
  transform: translateY(-10px) scale(1.04);
  box-shadow:
    0 14px 22px rgba(0,0,0,.4),
    0 0 0 2px rgba(0, 242, 254, .45),
    0 0 18px rgba(0, 242, 254, .25);
  filter: brightness(1.05);
}
.tile.is-selected .tile__inner {
  transform: translateY(-16px) scale(1.06);
  box-shadow:
    0 16px 28px rgba(0,0,0,.45),
    0 0 0 3px rgba(79, 172, 254, .95),
    0 0 0 7px rgba(79, 172, 254, .2),
    0 0 24px rgba(0, 242, 254, .35);
  filter: brightness(1.08) saturate(1.05);
}
.tile.is-dim {
  filter: grayscale(.2) brightness(.78);
  opacity: .72;
}
.tile.is-dim .tile__inner {
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.tile.is-drawn::after {
  content: "";
  position: absolute;
  top: 3px; right: 3px; z-index: 3;
  width: 8px; height: 8px; border-radius: 50%;
  background: #f0c56d;
  box-shadow: 0 0 8px #f0c56d;
  border: 1px solid rgba(0,0,0,.25);
}
.tile.is-pop { animation: tilePop .22s ease; }
@keyframes tilePop {
  from { transform: translateY(12px) scale(.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* 侧家：牌旋转 90° 横放（长边贴桌沿），外框先对调宽高再居中旋内层 */
.tile.rot-left,
.tile.rot-right {
  width: var(--th);
  height: var(--tw);
}
.tile.rot-left .tile__inner,
.tile.rot-right .tile__inner {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--tw);
  height: var(--th);
  margin: 0;
}
.tile.rot-left .tile__inner {
  transform: translate(-50%, -50%) rotate(-90deg);
}
.tile.rot-right .tile__inner {
  transform: translate(-50%, -50%) rotate(90deg);
}
.tile.rot-top .tile__inner { transform: rotate(180deg); }
/* 侧家可点态 / 最新出牌高亮：必须保住旋转，不能被其它 transform 盖掉 */
.tile.rot-left.is-playable:hover .tile__inner,
.tile.rot-left.is-playable:focus-visible .tile__inner,
.tile.rot-left.is-selected .tile__inner,
.tile.rot-left.is-latest-discard .tile__inner {
  transform: translate(-50%, -50%) rotate(-90deg) scale(1.06);
}
.tile.rot-right.is-playable:hover .tile__inner,
.tile.rot-right.is-playable:focus-visible .tile__inner,
.tile.rot-right.is-selected .tile__inner,
.tile.rot-right.is-latest-discard .tile__inner {
  transform: translate(-50%, -50%) rotate(90deg) scale(1.06);
}
.tile.rot-left.is-latest-discard:not(.is-selected):not(.is-playable) .tile__inner {
  transform: translate(-50%, -50%) rotate(-90deg);
}
.tile.rot-right.is-latest-discard:not(.is-selected):not(.is-playable) .tile__inner {
  transform: translate(-50%, -50%) rotate(90deg);
}

/* 最新出牌高亮（只在牌河里，不在桌心放大） */
.tile.is-latest-discard {
  z-index: 3;
  filter: drop-shadow(0 0 8px rgba(255, 220, 120, .85));
}
.tile.is-latest-discard .tile__inner {
  box-shadow:
    0 0 0 2px rgba(255, 220, 120, .95),
    0 4px 14px rgba(0,0,0,.4);
  animation: latestPulse 1.2s ease infinite;
}
@keyframes latestPulse {
  0%,100% { filter: brightness(1.05); }
  50% { filter: brightness(1.18); }
}

.hand-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: var(--opp-gap);
  flex-wrap: nowrap;
}
/* 左右：一列「横放」的牌背，沿桌边上下排开；轻叠压避免被桌面裁切 */
.hand-row.is-vertical {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-height: 100%;
  overflow: visible;
  flex-shrink: 0;
}
.board-cell.top .hand-row {
  gap: 2px;
  max-width: 100%;
  flex-wrap: nowrap;
}
.board-cell.top .hand-row .tile--sm {
  --tw: 30px;
  --th: 42px;
  width: 30px;
  height: 42px;
}
/* 旋转后外框 th×tw（横放）；高度约 22px + 叠压，14 张 ≈ 220px 可进中行 */
.board-cell.left .hand-row .tile--sm,
.board-cell.right .hand-row .tile--sm {
  --tw: 24px;
  --th: 34px;
  width: 34px;
  height: 24px;
  margin-block: -2px;
}
.board-cell.left .discard-grid .tile--xs,
.board-cell.right .discard-grid .tile--xs,
.board-cell.left .meld-row .tile--xs,
.board-cell.right .meld-row .tile--xs {
  --tw: 26px;
  --th: 36px;
  width: 36px;
  height: 26px;
}

/* 弃牌河：上下家横摊 6 列；左右家横放后往桌心铺 */
.discard-grid {
  display: grid;
  grid-template-columns: repeat(6, var(--tile-xs-w));
  gap: 3px;
  justify-content: center;
  max-width: calc(6 * var(--tile-xs-w) + 28px);
  padding: 6px;
  border-radius: 10px;
  background: rgba(0,0,0,.14);
  border: 1px solid rgba(255,255,255,.04);
}
/* 侧家：横放牌，2 列朝桌心（省宽防裁切） */
.discard-grid.is-side {
  grid-template-columns: repeat(2, 36px);
  grid-auto-flow: row;
  max-width: calc(2 * 36px + 14px);
  align-content: center;
  gap: 2px;
  padding: 4px;
  max-height: 100%;
  overflow: hidden;
}
.discard-grid:empty {
  display: none;
}
.meld-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
}
.board-cell.left .meld-row,
.board-cell.right .meld-row {
  flex-direction: column;
  gap: 4px;
}
.meld-group {
  display: flex;
  gap: 1px;
  padding: 3px 4px;
  border-radius: 8px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.08);
}
.board-cell.left .meld-group,
.board-cell.right .meld-group {
  flex-direction: column;
}

/* ---------- 牌桌舞台 ---------- */
#screen-table {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(79,172,254,.12), transparent 50%),
    linear-gradient(180deg, #05051a 0%, #0a0a24 40%, #050514 100%);
  overflow: hidden;
}

.game-stage {
  height: 100vh;
  height: 100dvh;
  display: grid;
  /* HUD / 日志压矮，中间 1fr 尽量给绿毡 */
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  max-width: min(1760px, 100vw);
  width: 100%;
  margin: 0 auto;
  padding: 2px 4px 0;
  gap: 2px;
  box-sizing: border-box;
}
.game-stage > .game-hud {
  padding: 4px 2px;
  gap: 6px;
}
.game-stage > .game-hud .pill {
  padding: 4px 10px;
  font-size: 11px;
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 4px;
  z-index: 5;
}
.game-hud .pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
}
.game-hud #room-code {
  color: var(--gold);
  letter-spacing: .16em;
  font-size: 13px;
}
.game-hud .hud-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 主桌：尽量铺满；中行加高保证左右竖列手牌进得去 */
.board {
  position: relative;
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(132px, 1.05fr) minmax(0, 2.5fr) minmax(132px, 1.05fr);
  grid-template-rows: minmax(92px, 0.9fr) minmax(220px, 1.75fr) minmax(48px, 0.55fr);
  grid-template-areas:
    "tl top tr"
    "left center right"
    "bl bottom br";
  background:
    radial-gradient(ellipse 70% 60% at 50% 48%, rgba(46, 140, 110, .55) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 45%, #1b7a58 0%, #0f523c 38%, #0a3a2c 70%, #062820 100%);
  border-radius: 20px;
  border: 6px solid #5c3a1e;
  box-shadow:
    inset 0 0 100px rgba(0,0,0,.4),
    inset 0 0 0 2px rgba(255, 220, 160, .12),
    0 0 0 2px #8b5a2b,
    0 0 0 3px #3a2410,
    0 14px 36px rgba(0,0,0,.55),
    0 0 80px rgba(40, 160, 120, .12);
  /* 圆角裁切：侧牌靠叠压+中行 min 高度保证完整可见 */
  overflow: hidden;
}
.board::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 50% 48%, rgba(255,255,255,.05), transparent 38%),
    /* 毡布纹理 */
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,.03) 3px, rgba(0,0,0,.03) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0,0,0,.02) 3px, rgba(0,0,0,.02) 4px);
  pointer-events: none;
}
/* 桌沿内侧高光 */
.board::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 22px;
  border: 1px solid rgba(255, 230, 180, .1);
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(0,0,0,.2);
}
.board-watermark {
  position: absolute;
  left: 50%; top: 48%;
  transform: translate(-50%, -50%);
  font-size: clamp(48px, 8vw, 80px);
  font-weight: 900;
  letter-spacing: .35em;
  color: rgba(255,255,255,.045);
  pointer-events: none;
  z-index: 0;
}

.board-cell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  min-width: 0;
  min-height: 0;
}
.board-cell.top { grid-area: top; justify-content: flex-start; padding-top: 6px; }
.board-cell.bottom { grid-area: bottom; justify-content: flex-end; padding-bottom: 4px; }
/* 左右：头像贴外沿，牌组朝桌心横排 */
.board-cell.left {
  grid-area: left;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px 4px 6px;
  gap: 4px;
}
.board-cell.right {
  grid-area: right;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 6px 4px 2px;
  gap: 4px;
}
.board-cell.center {
  grid-area: center;
  justify-content: center;
}
.board-cell.tl { grid-area: tl; }
.board-cell.tr { grid-area: tr; align-items: flex-end; }
.board-cell.bl { grid-area: bl; }
.board-cell.br { grid-area: br; }

/* 座位信息条 */
.seat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(16,22,42,.92), rgba(8,14,28,.88));
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(10px);
  margin-bottom: 6px;
  max-width: 100%;
  box-shadow: 0 8px 20px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
}
.seat-card .avatar.md,
.seat-card .avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 2px solid rgba(240,197,109,.45);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  flex: 0 0 auto;
  object-fit: cover;
  background: #1a2038;
}
.seat-card .meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.seat-card .sn {
  font-size: 13px; font-weight: 900;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 128px;
  color: #f4f7ff;
  letter-spacing: .02em;
}
.seat-card .sc {
  font-size: 12px;
  color: #ffd54f;
  font-weight: 900;
  text-shadow: 0 0 10px rgba(255,213,79,.25);
  font-variant-numeric: tabular-nums;
}
.seat-card .sc::before {
  content: '';
}
.board-cell.left .seat-card,
.board-cell.right .seat-card {
  flex-direction: column;
  text-align: center;
  padding: 8px 6px;
  min-width: 64px;
  margin-bottom: 0;
  flex: 0 0 auto;
}
.board-cell.left .seat-card .sn,
.board-cell.right .seat-card .sn { max-width: 70px; font-size: 11px; }
.board-cell.left .seat-card .avatar,
.board-cell.right .seat-card .avatar {
  width: 42px;
  height: 42px;
}

.sq-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.16);
  margin-top: 2px;
  letter-spacing: .04em;
}
.sq-tag.wan {
  color: #ff8a80;
  border-color: rgba(255,138,128,.5);
  background: rgba(255,80,80,.12);
  box-shadow: 0 0 12px rgba(255,100,100,.15);
}
.sq-tag.tong {
  color: #82b1ff;
  border-color: rgba(130,177,255,.5);
  background: rgba(80,140,255,.12);
  box-shadow: 0 0 12px rgba(100,160,255,.15);
}
.sq-tag.tiao {
  color: #69f0ae;
  border-color: rgba(105,240,174,.5);
  background: rgba(80,220,140,.12);
  box-shadow: 0 0 12px rgba(80,220,140,.15);
}

.hu-tag {
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(255,65,108,.4);
  animation: pulse 1.2s infinite;
}

.seat-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}
/* 左右：副露 → 手牌背 → 弃牌河（朝桌心） */
.board-cell.left .seat-stack,
.board-cell.right .seat-stack {
  flex: 1 1 auto;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
}
.board-cell.left .seat-stack { flex-direction: row; }
.board-cell.right .seat-stack { flex-direction: row-reverse; }
.board-cell.left .meld-row { order: 1; }
.board-cell.left .hand-row { order: 2; }
.board-cell.left .discard-grid.is-side { order: 3; }
.board-cell.right .meld-row { order: 1; }
.board-cell.right .hand-row { order: 2; }
.board-cell.right .discard-grid.is-side { order: 3; }

.board-cell.is-turn .seat-card {
  border-color: rgba(240,197,109,.85);
  box-shadow:
    0 0 0 2px rgba(240,197,109,.4),
    0 0 22px rgba(240,197,109,.35),
    0 10px 24px rgba(0,0,0,.35);
  background: linear-gradient(145deg, rgba(48,40,18,.95), rgba(20,16,8,.92));
}
.board-cell.is-turn .avatar {
  box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(240,197,109,.55);
  transform: scale(1.04);
}

/* 中央：四向牌墙围成方框；中间只放余牌数+回合灯，不放大出牌 */
.center-table {
  position: relative;
  width: min(480px, 94%);
  height: min(420px, 90%);
  min-height: 280px;
  margin: 0 auto;
}
.wall-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.wall-side {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.wall-side .wall-tiles {
  display: flex;
  gap: 0;
  align-content: center;
  justify-content: center;
}
.wall-stack-2 {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: center;
}
.wall-stack-2 .wall-row {
  display: flex;
  gap: 0;
  align-items: center;
}
.wall-stack-2 .wall-row + .wall-row {
  margin-top: -7px;
}
/* 左右牌墙：两层「横放」牌沿桌边排开 */
.wall-stack-2.is-side-wall {
  flex-direction: row;
  align-items: center;
}
.wall-stack-2.is-side-wall .wall-row {
  flex-direction: column;
}
.wall-stack-2.is-side-wall .wall-row + .wall-row {
  margin-top: 0;
  margin-left: -7px;
}
.wall-side .wall-num {
  font-size: 11px;
  font-weight: 900;
  color: #f0e6c8;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,220,160,.25);
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 28px;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.wall-top {
  top: 6px; left: 50%; transform: translateX(-50%);
  flex-direction: column;
}
.wall-top .wall-tiles { max-width: 280px; }
.wall-bottom {
  bottom: 6px; left: 50%; transform: translateX(-50%);
  flex-direction: column-reverse;
}
.wall-bottom .wall-tiles { max-width: 280px; }
.wall-left {
  left: 4px; top: 50%; transform: translateY(-50%);
  flex-direction: row;
}
.wall-left .wall-tiles { max-height: 240px; }
.wall-right {
  right: 4px; top: 50%; transform: translateY(-50%);
  flex-direction: row-reverse;
}
.wall-right .wall-tiles { max-height: 240px; }
/* 牌墙小牌背 */
.wall-tiles .tile {
  --tw: 20px;
  --th: 28px;
  width: 20px;
  height: 28px;
  margin: 0;
}
.wall-tiles .tile.rot-left,
.wall-tiles .tile.rot-right {
  width: 28px;
  height: 20px;
}
.wall-tiles .tile__inner {
  box-shadow: 0 1px 0 rgba(0,0,0,.35), 1px 1px 2px rgba(0,0,0,.25);
}

.center-core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2;
  min-width: 100px;
  pointer-events: none;
}
.wall-total-badge {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .06em;
  color: #fff8e0;
  background: linear-gradient(135deg, rgba(20,60,40,.9), rgba(0,0,0,.55));
  border: 1px solid rgba(240,197,109,.45);
  border-radius: 999px;
  padding: 7px 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
/* 中心不再放大出牌（牌只在各家牌河）；可有一行小字提示 */
.center-core .last-tile-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 160px;
}
.center-core .last-tile-wrap.is-compact:empty { display: none; }
.center-core .last-tile-wrap.is-compact .tile {
  display: none !important; /* 禁止中心放大牌 */
}
.last-discard-tip {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255,240,200,.95);
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,220,160,.2);
  border-radius: 999px;
  padding: 4px 12px;
  text-align: center;
  line-height: 1.35;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draw-fly {
  position: absolute;
  z-index: 5;
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .45s ease;
  pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,.45));
}
.draw-fly.is-anim {
  opacity: 1;
}
.turn-chip {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  padding: 7px 18px;
  border-radius: 999px;
  background: rgba(0,0,0,.5);
  border: 1px solid rgba(240,197,109,.4);
  box-shadow: 0 0 20px rgba(0, 200, 255, .15);
  white-space: nowrap;
}
/* 摸牌大按钮 */
.btn-draw {
  min-width: 130px !important;
  font-size: 20px !important;
  font-weight: 900 !important;
  padding: 14px 32px !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, #43e97b, #38f9d7) !important;
  color: #06281c !important;
  border: none !important;
  box-shadow: 0 8px 28px rgba(67, 233, 123, .4) !important;
  letter-spacing: .12em;
  animation: drawPulse 1.4s ease infinite;
}
@keyframes drawPulse {
  0%,100% { box-shadow: 0 8px 28px rgba(67, 233, 123, .35); }
  50% { box-shadow: 0 8px 36px rgba(67, 233, 123, .65), 0 0 0 6px rgba(67,233,123,.15); }
}

/* 日志：HUD 下横条，绝不叠在牌桌/座位上 */
.live-log {
  position: relative;
  z-index: 4;
  width: 100%;
  max-width: 100%;
  height: 34px;
  max-height: 34px;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 10px;
  background: rgba(0,0,0,.42);
  border: 1px solid rgba(255,255,255,.08);
  scrollbar-width: thin;
  white-space: nowrap;
  box-sizing: border-box;
  flex-shrink: 0;
}
.live-log div {
  flex: 0 0 auto;
  padding: 0 8px 0 0;
  border: 0;
  border-right: 1px solid rgba(255,255,255,.08);
  color: var(--muted);
  line-height: 1.25;
}
.live-log div:last-child { border-right: 0; }
.live-log .who { color: var(--gold); font-weight: 700; margin-right: 4px; }

/* ---------- 自己操作坞（尽量矮，把垂直空间让给绿毡） ---------- */
.self-dock {
  z-index: 20;
  padding: 0 4px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  max-height: 38vh;
}
.self-dock .action-bar {
  position: static;
  transform: none;
  left: auto;
  bottom: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 0;
  padding: 4px 0;
}
.self-dock .action-bar:empty { display: none; }
.self-dock .action-bar .btn {
  min-width: 80px;
  font-size: 17px;
  padding: 12px 22px;
  box-shadow: 0 8px 22px rgba(0,0,0,.4);
}
/* 出牌主按钮：大、醒目（学常见麻将 App） */
.self-dock .action-bar .btn-discard {
  min-width: 120px;
  font-size: 20px;
  font-weight: 900;
  padding: 14px 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f6d365, #fda085) !important;
  color: #1a120b !important;
  border: none !important;
  box-shadow: 0 8px 28px rgba(253, 160, 133, .45);
  letter-spacing: .12em;
}
.self-dock .action-bar .btn-discard:disabled {
  opacity: .35;
  filter: grayscale(.3);
  box-shadow: none;
}
.self-dock .action-bar .btn-cancel-sel {
  min-width: 72px;
  background: rgba(255,255,255,.08);
}

/* ---------- 定缺弹层（醒目） ---------- */
.que-modal {
  align-items: center;
  justify-content: center;
  padding: 3vh 12px;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(6px);
  z-index: 10050;
}
.que-card--wide {
  width: min(760px, 96vw);
  max-width: 96vw;
  border: 1px solid rgba(240,197,109,.45) !important;
  box-shadow:
    0 0 0 1px rgba(240,197,109,.2),
    0 24px 60px rgba(0,0,0,.55),
    0 0 40px rgba(240,197,109,.12) !important;
  animation: queCardIn .35s cubic-bezier(.2,1.2,.3,1);
}
@keyframes queCardIn {
  from { opacity: 0; transform: translateY(24px) scale(.94); }
  to { opacity: 1; transform: none; }
}
.que-badge {
  display: inline-flex;
  align-self: center;
  margin: 0 auto 8px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  color: #1a1200;
  background: linear-gradient(135deg, #ffe08a, #f0c56d);
  box-shadow: 0 4px 16px rgba(240,197,109,.4);
}
.que-title {
  text-align: center !important;
  font-size: 28px !important;
  font-weight: 900 !important;
  color: #ffe08a !important;
  margin: 0 0 6px !important;
  letter-spacing: .08em;
  text-shadow: 0 0 20px rgba(240,197,109,.35);
}
.que-desc {
  text-align: center;
  font-size: 13px !important;
  color: rgba(255,255,255,.78) !important;
  margin-bottom: 4px !important;
}
.que-hand-panel {
  background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.5));
  border: 1px solid rgba(240,197,109,.22);
  border-radius: 18px;
  padding: 14px 12px 16px;
  margin: 10px 0 14px;
  box-shadow: inset 0 0 24px rgba(0,0,0,.25);
}
.que-hand-label {
  font-size: 13px;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: .06em;
}
.que-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  min-height: 86px;
  align-items: flex-end;
}
.que-counts {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 800;
}
.que-counts span {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.1);
}
.que-counts .c-wan { color: #ff8a80; }
.que-counts .c-tong { color: #82b1ff; }
.que-counts .c-tiao { color: #69f0ae; }
.que-counts .is-best {
  outline: 2px solid var(--gold);
  box-shadow: 0 0 16px rgba(240,197,109,.4);
  background: rgba(240,197,109,.12);
}
.que-pick-label {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: rgba(255,255,255,.7);
  margin: 4px 0 12px;
}
.que-btns {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}
.btn.que {
  width: 118px;
  height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 22px !important;
  border: 2px solid rgba(255,255,255,.14) !important;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  cursor: pointer;
}
.btn.que:hover {
  transform: translateY(-4px) scale(1.03);
}
.btn.que.wan {
  background: linear-gradient(160deg, rgba(80,20,24,.95), rgba(40,10,14,.98)) !important;
  border-color: rgba(255,120,120,.45) !important;
}
.btn.que.tong {
  background: linear-gradient(160deg, rgba(16,40,90,.95), rgba(8,20,48,.98)) !important;
  border-color: rgba(120,170,255,.45) !important;
}
.btn.que.tiao {
  background: linear-gradient(160deg, rgba(12,60,40,.95), rgba(6,28,18,.98)) !important;
  border-color: rgba(100,240,170,.45) !important;
}
.btn.que .que-ico {
  font-size: 22px;
  font-weight: 900;
  opacity: .85;
  line-height: 1;
}
.btn.que .que-name { font-size: 34px; font-weight: 900; line-height: 1; }
.btn.que.wan .que-name { color: #ff8a80; }
.btn.que.tong .que-name { color: #82b1ff; }
.btn.que.tiao .que-name { color: #69f0ae; }
.btn.que .que-n {
  font-size: 14px;
  opacity: .95;
  font-weight: 800;
  color: rgba(255,255,255,.85);
  margin-top: 2px;
}
.btn.que.is-recommend {
  box-shadow: 0 0 0 3px var(--gold), 0 12px 32px rgba(0,0,0,.4), 0 0 28px rgba(240,197,109,.35);
  transform: translateY(-6px) scale(1.05);
  border-color: rgba(240,197,109,.8) !important;
}
.btn.que.is-recommend::after {
  content: '推荐';
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe08a, #f0c56d);
  color: #1a1200;
}
.btn.que { position: relative; }
.que-suggest {
  text-align: center;
  font-size: 14px;
  color: var(--gold);
  margin: 16px 0 4px;
  min-height: 1.2em;
  font-weight: 800;
}

.hand-tray {
  background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.45));
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px 14px 12px 12px;
  padding: 6px 10px 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 -8px 24px rgba(0,0,0,.2);
}
.hand-tray .meld-row { margin-bottom: 4px; }
.hand-tray .my-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--hand-gap);
  min-height: calc(var(--tile-md-h) + 10px);
  padding: 2px 0 0;
  flex-wrap: wrap;
}
/* 矮视口：自家手牌略缩，给桌面腾高 */
@media (max-height: 820px) {
  :root {
    --tile-md-w: 54px;
    --tile-md-h: 74px;
  }
  .self-dock { max-height: 34vh; }
  .board {
    grid-template-rows: minmax(80px, 0.85fr) minmax(200px, 1.9fr) minmax(44px, 0.5fr);
  }
}
@media (max-height: 700px) {
  :root {
    --tile-md-w: 48px;
    --tile-md-h: 66px;
    --tile-sm-w: 28px;
    --tile-sm-h: 38px;
  }
  .live-log { height: 28px; max-height: 28px; }
  .self-dock { max-height: 32vh; }
}
.hand-tray .my-hand .tile.is-playable {
  /* 手牌可点 */
}

.self-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 4px 0;
}
.self-bar .me-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px 6px 6px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(20,28,52,.75), rgba(8,12,24,.65));
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
}
#self-avatar {
  width: 48px !important;
  height: 48px !important;
  border-radius: 14px !important;
  border: 2px solid rgba(240,197,109,.55) !important;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
#self-name {
  font-size: 15px;
  font-weight: 900;
  color: #f4f7ff;
}
#self-chips {
  font-size: 13px;
  font-weight: 900;
  color: #ffd54f;
  text-shadow: 0 0 12px rgba(255,213,79,.3);
}
.self-bar .tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.round-delta {
  font-size: 12px;
  color: var(--chip);
  font-weight: 800;
}

/* 覆盖旧 table 固定定位 */
#screen-table .table-wrap { display: contents; }
#screen-table .side-log { display: none; }
#screen-table .table-toolbar { display: none; }
#screen-table .felt { display: none; }
#screen-table .action-bar:not(.self-dock .action-bar) {
  /* legacy */
}

@media (max-width: 860px) {
  :root {
    --tile-md-w: 48px;
    --tile-md-h: 66px;
    --tile-sm-w: 26px;
    --tile-sm-h: 36px;
    --tile-xs-w: 24px;
    --tile-xs-h: 34px;
    --tile-lg-w: 54px;
    --tile-lg-h: 74px;
  }
  .board {
    border-width: 5px;
    border-radius: 14px;
    grid-template-columns: minmax(100px, 0.95fr) minmax(0, 1.7fr) minmax(100px, 0.95fr);
    grid-template-rows: minmax(72px, 0.85fr) minmax(180px, 1.8fr) minmax(40px, 0.5fr);
  }
  .live-log { height: 28px; max-height: 28px; font-size: 10px; }
  .seat-card .sn { max-width: 64px; font-size: 11px; }
  .board-cell.left .seat-card,
  .board-cell.right .seat-card {
    min-width: 52px;
    padding: 6px 4px;
  }
  .board-cell.left .seat-card .avatar,
  .board-cell.right .seat-card .avatar {
    width: 36px;
    height: 36px;
  }
  .board-cell.top .hand-row .tile--sm {
    --tw: 22px; --th: 30px; width: 22px; height: 30px;
  }
  .board-cell.left .hand-row .tile--sm,
  .board-cell.right .hand-row .tile--sm {
    --tw: 20px; --th: 28px; width: 28px; height: 20px; margin-block: -3px;
  }
  .discard-grid.is-side {
    grid-template-columns: repeat(2, 28px);
    max-width: calc(2 * 28px + 10px);
  }
  .center-table { width: min(320px, 94%); height: min(280px, 86%); min-height: 180px; }
}

@media (max-width: 520px) {
  :root {
    --tile-md-w: 40px;
    --tile-md-h: 56px;
  }
  .game-stage { padding: 1px 2px 0; }
  .board {
    grid-template-columns: minmax(56px, 0.85fr) minmax(0, 1.6fr) minmax(56px, 0.85fr);
    border-width: 4px;
  }
}

/* 手机细项由 mobile.css 接管（后加载） */
