/* 新牌桌 GUI — 参照微乐麻将练习场布局，无牌墩 */

.new-table-mode .table-frame,
.new-table-mode .table-3d,
.new-table-mode .table-rim,
.new-table-mode .table-felt,
.new-table-mode .felt-edge-glow,
.new-table-mode .table-watermark,
.new-table-mode .wall-ui-north,
.new-table-mode .wall-ui-south,
.new-table-mode .wall-ui-west,
.new-table-mode .wall-ui-east {
  display: none !important;
}

.new-table-mode .table-wrap {
  background: #0a2818;
}

.new-table-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #1a5c38;
  /* 相对路径：test/browser/newui/bg_green.jpeg；绝对路径：项目根 newui（需测试服映射） */
  background-image:
    url("bg_green.jpeg"),
    url("/newui/bg_green.jpeg");
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}

.new-table-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.12));
  pointer-events: none;
}

.new-table-mode .table-stage { z-index: 1; opacity: 0.98; }
.new-table-mode .table-ui-layer { z-index: 5; }

.game-hud-top {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: 0;
  height: 7.5%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.2% 0 1%;
  pointer-events: none;
}
.game-hud-top > * { pointer-events: auto; }

.hud-status-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(11px, 1.1vw, 14px);
  color: rgba(255, 255, 255, 0.92);
}
.hud-status-left .icon-btn {
  width: 34px; height: 34px;
  border: none; border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff; font-size: 16px; cursor: pointer;
}

.hud-top-right {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.hud-wechat-capsule {
  width: clamp(120px, 8vw, 150px);
  height: clamp(36px, 4.5vh, 48px);
  flex-shrink: 0;
}
.hud-promo {
  padding: 6px 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 152, 0, 0.85), rgba(255, 193, 7, 0.9));
  color: #3e2723;
  font-size: clamp(10px, 1vw, 13px);
  font-weight: bold;
  white-space: nowrap;
}

.deck-remain-badge {
  position: absolute;
  z-index: 12;
  left: 58%; top: 46%;
  transform: translate(-50%, -50%);
  min-width: 36px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(129, 199, 132, 0.5);
  color: #a5d6a7;
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
}

.new-table-mode .player-panel {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 8px;
  min-width: 72px;
}
.new-table-mode .pp-top { top: 8%; left: 50%; right: auto; bottom: auto; transform: translateX(-50%); }
.new-table-mode .pp-left { left: 1.2%; top: 38%; transform: translateY(-50%); }
.new-table-mode .pp-right { right: 1.2%; top: 36%; transform: translateY(-50%); }
.new-table-mode .pp-bottom { left: 1.2%; bottom: 22%; top: auto; }
.new-table-mode .avatar { position: relative; width: clamp(44px, 4.5vw, 56px); height: clamp(44px, 4.5vw, 56px); }

.dealer-tag {
  position: absolute;
  top: -4px; right: -4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #ff8f00;
  color: #3e2723;
  font-size: 10px;
  font-weight: bold;
}

.new-table-mode .south-hand-row {
  left: 8%;
  right: 12%;
  width: auto;
  transform: none;
  bottom: 2%;
  height: 15%;
  padding: 4px 6px 6px;
  box-sizing: border-box;
  justify-content: center;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #000;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 40;
}

.new-table-mode .south-hand-row .hand-zone.hz-bottom {
  width: 100%;
  height: 100%;
  justify-content: center;
  gap: 1px;
}

.new-table-mode .south-hand-row .hand-zone.hz-bottom .hand-tile {
  flex: 0 0 calc((100% - 13px) / 14);
  width: calc((100% - 13px) / 14) !important;
  min-width: 0 !important;
  max-width: none;
  height: auto;
  max-height: 100%;
  aspect-ratio: 73 / 109;
}

.new-table-mode .action-panel {
  right: 2%;
  bottom: 14%;
  left: auto;
  gap: 14px;
}

.hud-float-right {
  position: absolute;
  z-index: 18;
  right: 1%;
  top: 52%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hud-float-btn {
  width: 48px; height: 48px;
  border: none; border-radius: 50%;
  background: rgba(33, 150, 243, 0.85);
  color: #fff; font-size: 11px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.hud-float-btn.luck {
  background: rgba(255, 193, 7, 0.9);
  color: #5d4037;
  font-size: 10px;
  line-height: 1.1;
}

/* 上 / 左 / 右 对手手牌挂载区（占位框，后续填入素材） */
.opp-hand-mount {
  position: absolute;
  z-index: 28;
  box-sizing: border-box;
  pointer-events: none;
  overflow: visible;
  border: 2px dashed;
}

.opp-hand-mount__content {
  position: relative;
  width: 100%;
  height: 100%;
}

.opp-hand-mount--west {
  left: 294px;
  top: 205px;
  width: auto;
  height: auto;
  border-color: rgba(244, 67, 54, 0.92);
  background: rgba(244, 67, 54, 0.1);
  overflow: visible;
}

.opp-hand-mount--west .opp-hand-mount__content {
  width: auto;
  height: auto;
  overflow: visible;
}

.opp-hand-mount--north {
  top: 85px;
  left: 0;
  width: auto;
  height: auto;
  border-color: rgba(0, 0, 0, 0.88);
  background: rgba(0, 0, 0, 0.12);
  overflow: visible;
}

.opp-hand-mount--north .opp-hand-mount__content {
  width: auto;
  height: auto;
  overflow: visible;
}

.opp-hand-mount--east {
  /* 与西侧对称：吃碰杠右缘 + 与西侧相同的 9.6px 间隙 */
  left: calc(1508px + 56.4px + (360px - 294px - 56.4px));
  top: 205px;
  width: auto;
  height: auto;
  border-color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.08);
  overflow: visible;
}

.opp-hand-mount--east .opp-hand-mount__content {
  width: auto;
  height: auto;
  overflow: visible;
}

/* ══════════════════════════════════════════════
   弃牌区 / 吃碰杠占位（1920×1080，对齐参考图标注）
   红矩形=弃牌(外9中8内7)  红圈=罗盘  黑框=吃碰杠
   ══════════════════════════════════════════════ */

.discard-pool,
.table-zone {
  position: absolute;
  z-index: 26;
  box-sizing: border-box;
  pointer-events: none;
}

.discard-pool::before,
.table-zone::before,
.discard-wing::before,
.discard-disc::before {
  content: attr(data-label);
  position: absolute;
  font-size: 10px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

/* ── 弃牌大红矩形 ── */
.discard-pool {
  left: 430px;
  top: 218px;
  width: 1060px;
  height: 570px;
  border: 2px dashed rgba(244, 67, 54, 0.92);
  background: rgba(244, 67, 54, 0.06);
}

.discard-pool::before {
  top: 4px;
  left: 6px;
}

.discard-pool__inner {
  position: relative;
  width: 100%;
  height: 100%;
  --announce-north-bottom: calc(10px + 68.4px + 2 * (68.4px - 15px));
}

/* ── 中央圆盘（红圈） ── */
.discard-disc {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 176px;
  height: 176px;
  margin: -88px 0 0 -88px;
  border: 2px dashed rgba(244, 67, 54, 0.95);
  border-radius: 50%;
  background: rgba(244, 67, 54, 0.1);
  z-index: 2;
}

.discard-disc::before {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ── 四方弃牌阶梯格 ── */
.discard-wing {
  position: absolute;
  z-index: 1;
  display: flex;
  gap: 2px;
}

.discard-wing::before {
  top: 0;
  left: 0;
  font-size: 9px;
  opacity: 0.65;
}

.discard-wing--north {
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: 0;
  overflow: visible;
}

.discard-wing--south {
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: 0;
  overflow: visible;
}

/* 上/下弃牌行间距 -15px，由上往下叠盖 */
.discard-wing--north .discard-row,
.discard-wing--south .discard-row {
  position: relative;
  flex-shrink: 0;
}

.discard-wing--north .discard-row + .discard-row,
.discard-wing--south .discard-row + .discard-row {
  margin-top: -15px;
}

.discard-wing--north .discard-row:nth-child(1),
.discard-wing--south .discard-row:nth-child(1) {
  z-index: 1;
}

.discard-wing--north .discard-row:nth-child(2),
.discard-wing--south .discard-row:nth-child(2) {
  z-index: 2;
}

.discard-wing--north .discard-row:nth-child(3),
.discard-wing--south .discard-row:nth-child(3) {
  z-index: 3;
}

/* ── 上弃牌区下方 20px 公告（水蓝字 + 自左向右扫光，光效仅作用于字形） ── */
.game-announce-bar {
  position: absolute;
  left: 50%;
  top: calc(var(--announce-north-bottom) + 17px);
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  white-space: nowrap;
  padding: 0;
}

.game-announce-bar__text {
  display: inline-block;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: linear-gradient(
    90deg,
    #00ffff 0%,
    #00ffff 38%,
    #b8ffff 50%,
    #00ffff 62%,
    #00ffff 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter:
    drop-shadow(0 0 4px rgba(0, 255, 255, 0.55))
    drop-shadow(0 0 10px rgba(0, 230, 255, 0.38));
  animation: game-announce-text-glow 2.6s ease-in-out infinite;
}

@keyframes game-announce-text-glow {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

.discard-wing--west {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: row;
  align-items: center;
  gap: 2px;
}

.discard-wing--east {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: row;
  align-items: center;
  gap: 2px;
}

/* 横排格（上/下家）— Region 768,64 · 37×57 @ 1.2× */
.discard-row {
  --slot-w: 44.4px;
  --slot-h: 68.4px;
  --gap: 0px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--gap);
  height: var(--slot-h);
  border: 1px dashed rgba(244, 67, 54, 0.45);
  background-color: rgba(244, 67, 54, 0.04);
  background-image: repeating-linear-gradient(
    to right,
    rgba(244, 67, 54, 0.14) 0,
    rgba(244, 67, 54, 0.14) var(--slot-w),
    transparent var(--slot-w),
    transparent calc(var(--slot-w) + var(--gap))
  );
}

.discard-row--filled {
  background-image: none;
  background-color: transparent;
  border-color: rgba(244, 67, 54, 0.25);
}

.discard-row[data-n="9"] { width: calc(9 * var(--slot-w) + 8 * var(--gap)); }
.discard-row[data-n="8"] { width: calc(8 * var(--slot-w) + 7 * var(--gap)); }
.discard-row[data-n="7"] { width: calc(7 * var(--slot-w) + 6 * var(--gap)); }

/* 竖排格（左/右家）— Region 671,870 · 46×47 左旋90° @ 1.2× */
.discard-col {
  --slot-w: 56.4px;
  --slot-h: 55.2px;
  --gap: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  width: var(--slot-w);
  border: 1px dashed rgba(244, 67, 54, 0.45);
  background-color: rgba(244, 67, 54, 0.04);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(244, 67, 54, 0.14) 0,
    rgba(244, 67, 54, 0.14) var(--slot-h),
    transparent var(--slot-h),
    transparent calc(var(--slot-h) + var(--gap))
  );
}

.discard-col--filled {
  background-image: none;
  background-color: transparent;
  border-color: rgba(244, 67, 54, 0.25);
  position: relative;
  display: block;
  gap: 0;
}

.mj-laydown-we-col {
  position: relative;
  flex: 0 0 auto;
}

.discard-col[data-n="9"] { height: calc(9 * var(--slot-h) + 8 * var(--gap)); }
.discard-col[data-n="8"] { height: calc(8 * var(--slot-h) + 7 * var(--gap)); }
.discard-col[data-n="7"] { height: calc(7 * var(--slot-h) + 6 * var(--gap)); }

/* ── 吃碰杠黑框 ── */
.table-zone {
  overflow: visible;
  border: 2px dashed rgba(0, 0, 0, 0.88);
  background: rgba(0, 0, 0, 0.12);
}

.table-zone::before {
  top: 2px;
  left: 4px;
}

/* 北：紧贴上方手牌底边（85 + 56×1.2 + 2） */
.table-zone--meld-north {
  left: 620px;
  top: calc(85px + 56px * 1.2 + 2px);
  width: 680px;
  height: 68.4px;
}

.meld-mount__content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  box-sizing: border-box;
}

.meld-mount__content--vertical {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 4px 0;
}

/* 西：左列手牌与弃牌区之间竖条 — 牌宽 47×1.2 */
.table-zone--meld-west {
  left: 360px;
  top: 268px;
  width: 56.4px;
  height: 320px;
}

/* 东：右列手牌与弃牌区之间竖条 */
.table-zone--meld-east {
  left: 1508px;
  top: 268px;
  width: 56.4px;
  height: 320px;
}

/* 南：手牌正上方、与手牌左缘对齐（对齐黄框标记）— 宽 10 张手牌位 */
.table-zone--meld-south {
  --south-hand-tile-w: calc(73px * 1.4);
  --south-hand-gap: 1px;
  --south-meld-span: 10;
  left: calc((1920px - (var(--south-hand-tile-w) * 14 + var(--south-hand-gap) * 13)) / 2);
  right: auto;
  bottom: calc(40px + 107px * 1.4 + 8px);
  width: calc(var(--south-hand-tile-w) * var(--south-meld-span) + var(--south-hand-gap) * (var(--south-meld-span) - 1));
  height: calc(68px * 1.2);
}

.meld-mount__content--south {
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 4px;
}

/* 南：操作按钮区（橙框）— 手牌右半上方，左缘对齐第10张牌 */
.table-zone--action {
  --south-hand-tile-w: calc(73px * 1.4);
  --south-hand-tile-h: calc(107px * 1.4);
  --south-hand-gap: 1px;
  --south-hand-left: calc((1920px - (var(--south-hand-tile-w) * 14 + var(--south-hand-gap) * 13)) / 2);
  --action-start-tile: 9;
  --action-panel-left-offset: 50px;
  left: calc(var(--south-hand-left) + (var(--south-hand-tile-w) + var(--south-hand-gap)) * var(--action-start-tile) + var(--action-panel-left-offset));
  right: 18px;
  bottom: calc(40px + var(--south-hand-tile-h) + 8px);
  top: auto;
  height: 180px;
  width: auto;
  border-color: rgba(255, 152, 0, 0.92);
  background: rgba(255, 152, 0, 0.07);
  z-index: 31;
}

/* 南：操作按钮区 — 需接收点击 */
.table-zone--action {
  pointer-events: auto;
  z-index: 35;
}

.table-zone--action .action-mount__content {
  pointer-events: auto;
}

.table-zone--action:not(.has-actions) {
  pointer-events: none;
}

.action-mount__content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 20px;
  padding: 8px 10px;
  box-sizing: border-box;
  pointer-events: none;
}

.action-mount__content .mj-action-btn {
  pointer-events: auto;
}

/* ── 出牌区：南家手牌顶缘上方 10px 至画布顶部，左右贴边 ── */
.play-zone {
  --play-zone-hand-bottom: 40px;
  --play-zone-hand-tile-h: calc(107px * 1.4);
  --play-zone-gap-above-hand: 10px;
  position: absolute;
  z-index: 12;
  left: 0;
  top: 0;
  width: 1920px;
  height: calc(
    1080px
    - var(--play-zone-hand-bottom)
    - var(--play-zone-hand-tile-h)
    - var(--play-zone-gap-above-hand)
  );
  box-sizing: border-box;
  pointer-events: none;
  border: 2px dashed rgba(33, 150, 243, 0.88);
  background: rgba(33, 150, 243, 0.06);
}

.play-zone::before {
  content: attr(data-label);
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 10px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

.play-zone__inner {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
}

.play-zone .center-drop {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* 工坊：罗盘红圈与八边形图标同尺寸 */
.ui-test-stage .discard-disc {
  width: 110px;
  height: 110px;
  margin: -55px 0 0 -55px;
}

/* 工坊罗盘区与图标同尺寸，无需弱化 */

/* ══════════════════════════════════════════════
   对局页：1920×1080 画布缩放
   ══════════════════════════════════════════════ */

.game-stage-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-stage-viewport {
  position: relative;
  overflow: hidden;
}

.game-table-stage {
  position: relative;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  overflow: hidden;
}

.game-table-stage .new-table-bg {
  z-index: 0;
}

/* 对局页与工坊一致：不显示伪 HUD / 底部提示条 */
.new-table-mode .game-hud-top,
.new-table-mode .hud-float-right,
.game-table-stage .game-turn-bar {
  display: none !important;
}

.game-table-stage .opp-hand-mount,
.game-table-stage .discard-pool,
.game-table-stage .table-zone,
.game-table-stage .play-zone,
.game-table-stage .discard-wing::before,
.game-table-stage .discard-pool::before,
.game-table-stage .table-zone::before,
.game-table-stage .discard-disc::before {
  border: none !important;
  background: transparent !important;
}

.game-table-stage .opp-hand-mount::before,
.game-table-stage .discard-pool::before,
.game-table-stage .table-zone::before,
.game-table-stage .play-zone::before,
.game-table-stage .discard-wing::before,
.game-table-stage .discard-disc::before {
  content: none !important;
}

.game-table-stage .discard-row,
.game-table-stage .discard-col {
  border-color: transparent !important;
  background: transparent !important;
  background-image: none !important;
}

.game-table-stage .discard-disc {
  width: 110px;
  height: 110px;
  margin: -55px 0 0 -55px;
  border: none !important;
  background: transparent !important;
}

.game-table-stage .zone.zone-center {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  left: 50%;
  top: calc(218px + 570px / 2);
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  padding: 0;
  overflow: visible;
  border: none;
  background: transparent;
  border-radius: 8px;
  z-index: 30;
}

.game-table-stage .zone-hand {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 40;
  overflow: visible;
}

.game-table-stage .zone-hand .zone-content {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0;
}

.game-table-stage .player-badges-mount {
  position: absolute;
  inset: 0;
  z-index: 32;
  pointer-events: none;
}

.game-table-stage .player-badge {
  pointer-events: auto;
}

.game-turn-bar {
  position: absolute;
  left: 50%;
  top: calc(218px + 570px / 2 + 72px);
  transform: translateX(-50%);
  z-index: 34;
  max-width: 520px;
  padding: 4px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #e3f2fd;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.game-btn-roll {
  position: absolute;
  left: 50%;
  top: calc(218px + 570px / 2);
  transform: translate(-50%, -50%);
  z-index: 36;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 193, 7, 0.92);
  color: #5d4037;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  display: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.game-btn-roll.show {
  display: block;
}

.game-table-stage .settle-center {
  position: absolute;
  inset: 0;
  z-index: 100;
}

.game-table-stage .yao-reveal {
  position: absolute;
  left: 50%;
  top: calc(218px + 570px / 2);
  transform: translate(-50%, -50%);
  z-index: 38;
}

.game-btn-roll,
.game-table-stage .game-btn-roll {
  display: none !important;
}

.game-table-stage .zone-action.has-actions,
.game-table-stage .table-zone--action.has-actions {
  pointer-events: auto;
}

.game-table-stage .mj-hand-row .mj-hand-tile {
  cursor: grab;
  transition: transform 0.12s ease;
}

.game-table-stage .mj-hand-row .mj-hand-tile:hover {
  transform: translateY(-5px);
}

.game-table-stage .mj-hand-row .mj-hand-tile.src {
  opacity: 0.45;
}

.new-table-mode .table-stage,
.new-table-mode .table-ui-layer,
.new-table-mode .table-frame,
.new-table-mode .player-panel,
.new-table-mode .action-panel,
.new-table-mode .south-hand-row,
.new-table-mode .north-hand-row,
.new-table-mode .west-hand-col,
.new-table-mode .east-hand-col,
.new-table-mode .discard-zone,
.new-table-mode .meld-zone,
.new-table-mode .ban-held-zone,
.new-table-mode .compass-wrap {
  display: none !important;
}
