/* tileImage.png 精灵表 — 南方竖牌 / 倒地牌 */

.mj-atlas {
  --mj-tile-w: 73;
  --mj-tile-h: 107;
}

.mj-hand-row,
.ui-test-stage .zone-hand .zone-content {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0;
  width: auto;
  height: auto;
  padding: 0;
  box-sizing: border-box;
}

.mj-hand-tile {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  background: transparent;
}

.mj-hand-tile .mj-layer {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-color: transparent;
  pointer-events: none;
}

.mj-hand-tile .mj-layer--stand {
  z-index: 1;
}

.mj-hand-tile .mj-layer--face {
  z-index: 2;
}

/* 登记牌面：图集 Region 1:1 原尺寸，不随牌框拉伸 */
.mj-hand-tile .mj-layer--face-native {
  inset: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.mj-sprite {
  display: inline-block;
  background-repeat: no-repeat;
  vertical-align: bottom;
}

.mj-sprite--laydown {
  width: 54px;
  height: 78px;
}

.mj-sprite--laydown-ns {
  flex: 0 0 auto;
}

.mj-sprite--laydown-we {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: visible;
}

.mj-laydown-we-sprite {
  display: block;
  flex: 0 0 auto;
  transform: rotate(-90deg);
  transform-origin: center center;
  pointer-events: none;
}

/* 倒地牌 + 牌面（弃牌 / 吃碰杠） */
.mj-sprite--laydown-ns.mj-sprite--has-face,
.mj-sprite--laydown-we.mj-sprite--has-face {
  position: relative;
  overflow: hidden;
}

.mj-laydown-ns-body {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mj-laydown-face-box {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.mj-laydown-face {
  display: block;
  width: 76%;
  height: 88%;
  max-width: 76%;
  max-height: 88%;
  pointer-events: none;
}

.mj-laydown--bottom .mj-laydown-face-box,
.mj-laydown--top .mj-laydown-face-box {
  left: 11%;
  right: 11%;
  top: 9%;
  bottom: 21%;
  padding-bottom: 1%;
}

.mj-laydown--bottom .mj-laydown-face:not(.mj-laydown-face--ns-native),
.mj-laydown--top .mj-laydown-face:not(.mj-laydown-face--ns-native) {
  transform: scale(0.8);
  transform-origin: center center;
}

/* 北/南弃牌区 + 北/南吃碰杠：非 native 牌面 */
.discard-wing--north .mj-laydown--top .mj-laydown-face:not(.mj-laydown-face--ns-native),
.discard-wing--south .mj-laydown--bottom .mj-laydown-face:not(.mj-laydown-face--ns-native),
#meldNorthSlot .mj-laydown--top .mj-laydown-face:not(.mj-laydown-face--ns-native),
#meldSouthSlot .mj-laydown--bottom .mj-laydown-face:not(.mj-laydown-face--ns-native) {
  transform: scale(0.8) translateY(-7px);
}

/* 上/下 / 左右卧牌 native：与南方手牌一致，transform 由 JS 写入 */
.mj-laydown-face--ns-native,
.mj-laydown-face--we-native {
  pointer-events: none;
  z-index: 1;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  overflow: visible;
}

.mj-laydown-face--ns-native .mj-laydown-face__sprite {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  background-repeat: no-repeat;
  transform-origin: center center;
}

.mj-laydown-face--ns-native .mj-laydown-face__sprite,
.mj-laydown-face--ns-native {
  background-repeat: no-repeat;
}

.mj-laydown--left .mj-laydown-face-box,
.mj-laydown--right .mj-laydown-face-box {
  left: 11%;
  right: 11%;
  top: 0;
  bottom: 22%;
}

.mj-sprite--laydown-we.mj-sprite--has-face.mj-laydown--we-atlas-stand-tile,
.mj-sprite--laydown-we.mj-laydown--we-atlas-stand-tile .mj-laydown-face-box {
  overflow: visible;
}

.mj-laydown-face--we-atlas-stand {
  overflow: visible;
}

.mj-laydown--left .mj-laydown-face:not(.mj-laydown-face--ns-native):not(.mj-laydown-face--we-native) {
  width: 88%;
  height: 76%;
  max-width: 88%;
  max-height: 76%;
  transform: rotate(-90deg) translateY(-4%);
  transform-origin: center center;
}

/* 西弃牌 + 西吃碰杠 + 西明牌手牌：Canvas 裁切图 <img>，避免图集邻格出血 */
.discard-wing--west .mj-laydown--left .mj-laydown-face-box,
#meldWestSlot .mj-laydown--left .mj-laydown-face-box,
.opp-hand-mount--west .mj-laydown--left .mj-laydown-face-box,
.mj-west-open-hand .mj-laydown--left .mj-laydown-face-box {
  left: 4%;
  right: 14%;
  top: 4%;
  bottom: 14%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.discard-wing--west .mj-laydown--left .mj-laydown-face--crop,
#meldWestSlot .mj-laydown--left .mj-laydown-face--crop,
.opp-hand-mount--west .mj-laydown--left .mj-laydown-face--crop,
.mj-west-open-hand .mj-laydown--left .mj-laydown-face--crop {
  display: block;
  width: auto;
  height: auto;
  max-width: 90%;
  max-height: 86%;
  object-fit: contain;
  transform-origin: center center;
}

/* 西弃牌区 / 西明牌：屏幕坐标上移 10px（不用 translateY，避免左旋后变左右移） */
.discard-wing--west .mj-laydown--left .mj-laydown-face--crop,
.opp-hand-mount--west .mj-laydown--left .mj-laydown-face--crop,
.mj-west-open-hand .mj-laydown--left .mj-laydown-face--crop {
  margin-top: -10px;
}

#meldWestSlot .mj-laydown--left .mj-laydown-face--crop {
  margin-top: -10px;
}

/* 东弃牌 + 东吃碰杠 + 东明牌手牌：Canvas 裁切图 <img>，避免图集邻格出血 */
.discard-wing--east .mj-laydown--right .mj-laydown-face-box,
#meldEastSlot .mj-laydown--right .mj-laydown-face-box,
.opp-hand-mount--east .mj-laydown--right .mj-laydown-face-box,
.mj-east-open-hand .mj-laydown--right .mj-laydown-face-box {
  left: 14%;
  right: 4%;
  top: 4%;
  bottom: 14%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.discard-wing--east .mj-laydown--right .mj-laydown-face--crop,
#meldEastSlot .mj-laydown--right .mj-laydown-face--crop,
.opp-hand-mount--east .mj-laydown--right .mj-laydown-face--crop,
.mj-east-open-hand .mj-laydown--right .mj-laydown-face--crop {
  display: block;
  width: auto;
  height: auto;
  max-width: 90%;
  max-height: 86%;
  object-fit: contain;
  transform-origin: center center;
}

/* 东弃牌区 / 东明牌：屏幕坐标上移 10px */
.discard-wing--east .mj-laydown--right .mj-laydown-face--crop,
.opp-hand-mount--east .mj-laydown--right .mj-laydown-face--crop,
.mj-east-open-hand .mj-laydown--right .mj-laydown-face--crop {
  margin-top: -10px;
}

#meldEastSlot .mj-laydown--right .mj-laydown-face--crop {
  margin-top: -10px;
}

/* 桌面上单张牌（设计稿百分比定位） */
.mj-table-tile {
  position: absolute;
  overflow: hidden;
  z-index: 20;
  pointer-events: none;
}

.mj-table-tile--center {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.mj-west-hand-stack,
.mj-north-hand-stack,
.mj-east-hand-stack {
  position: relative;
  flex: 0 0 auto;
}

.mj-opp-tile--raw,
.mj-west-tile--raw,
.mj-north-tile {
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
}

.mj-opp-tile-sprite,
.mj-west-tile--raw .mj-west-tile-sprite {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mj-west-hand-row {
  position: relative;
  width: 22px;
  flex: 0 0 auto;
}

.mj-west-tile {
  position: absolute;
  overflow: hidden;
  background: transparent;
}

.mj-west-tile .mj-layer {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-color: transparent;
  pointer-events: none;
}

.mj-table-tiles-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  z-index: 25;
  pointer-events: none;
}

.mj-table-tiles-center .mj-table-tile {
  position: relative;
  flex: 0 0 auto;
}

.mj-table-tile .mj-layer {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-color: transparent;
}

/* 操作按钮（button.png · 队首@1.4×+呼吸 其余@1.1×） */
@keyframes mj-action-breathe-scale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes mj-action-breathe-glow {
  0%, 100% {
    filter:
      drop-shadow(0 0 4px var(--mj-action-glow-soft))
      brightness(1);
  }
  50% {
    filter:
      drop-shadow(0 1px 8px var(--mj-action-glow))
      drop-shadow(0 0 16px var(--mj-action-glow-soft))
      brightness(1.04);
  }
}

@keyframes mj-action-halo-pulse {
  0%, 100% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

.mj-action-btn {
  --mj-action-glow: rgba(46, 125, 50, 0.55);
  --mj-action-glow-soft: rgba(129, 199, 132, 0.32);
  flex: 0 0 auto;
  display: block;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
  transform-origin: center center;
  transition: transform 0.2s cubic-bezier(0.34, 1.15, 0.64, 1);
}

.mj-action-btn__sprite {
  display: block;
  background-repeat: no-repeat;
  pointer-events: none;
  transition: filter 0.2s ease;
}

.mj-action-btn:not(.mj-action-btn--primary) {
  margin-top: 30px;
}

.mj-action-btn--primary {
  position: relative;
  isolation: isolate;
  animation: mj-action-breathe-scale 1s ease-in-out infinite;
}

.mj-action-btn--primary::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(100% + 22px);
  height: calc(100% + 22px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.32);
  box-shadow:
    0 0 12px rgba(255, 255, 255, 0.28),
    0 0 28px rgba(255, 255, 255, 0.14);
  pointer-events: none;
  z-index: 0;
  animation: mj-action-halo-pulse 1s ease-in-out infinite;
}

.mj-action-btn--primary .mj-action-btn__sprite {
  position: relative;
  z-index: 1;
  animation: mj-action-breathe-glow 1s ease-in-out infinite;
}

.mj-action-btn--hu {
  --mj-action-glow: rgba(211, 47, 47, 0.62);
  --mj-action-glow-soft: rgba(255, 138, 128, 0.38);
}

.mj-action-btn--yao {
  --mj-action-glow: rgba(255, 160, 0, 0.58);
  --mj-action-glow-soft: rgba(255, 224, 130, 0.36);
}

@media (hover: hover) {
  .mj-action-btn:hover {
    animation: none;
    transform: scale(1.05);
  }

  .mj-action-btn--primary:hover::after {
    animation: none;
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.42);
    box-shadow:
      0 0 14px rgba(255, 255, 255, 0.36),
      0 0 32px rgba(255, 255, 255, 0.18);
  }

  .mj-action-btn:hover .mj-action-btn__sprite {
    animation: none;
    filter:
      drop-shadow(0 2px 8px var(--mj-action-glow))
      drop-shadow(0 0 18px var(--mj-action-glow-soft))
      brightness(1.06);
  }
}

.mj-action-btn:active {
  animation: none;
  transform: scale(0.98);
  transition-duration: 0.08s;
}

.mj-action-btn:active .mj-action-btn__sprite {
  animation: none;
  filter: brightness(0.96);
  transition-duration: 0.08s;
}

@media (prefers-reduced-motion: reduce) {
  .mj-action-btn--primary,
  .mj-action-btn--primary .mj-action-btn__sprite,
  .mj-action-btn--primary::after {
    animation: none;
  }
}
