.mahjong-screen {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mahjong-body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 60px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mahjong-stage {
  position: relative;
  flex: 1.1;
  min-height: 0;
}

.mahjong-stage__frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  padding: 12px;
  background:
    linear-gradient(145deg, #c79d63 0%, #8e6536 22%, #5f3d1d 48%, #a5753c 74%, #d7b27c 100%);
  box-shadow:
    inset 0 2px 1px rgba(255, 250, 227, 0.32),
    inset 0 -8px 14px rgba(56, 34, 12, 0.55),
    0 18px 34px rgba(0, 0, 0, 0.34);
}

.mahjong-stage__frame::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 22px;
  border: 1px solid rgba(255, 244, 214, 0.18);
  pointer-events: none;
}

.mahjong-stage__wood {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 24%),
    radial-gradient(circle at 18% 12%, rgba(255, 245, 214, 0.2), transparent 18%),
    radial-gradient(circle at 82% 10%, rgba(255, 245, 214, 0.12), transparent 18%);
  pointer-events: none;
  mix-blend-mode: screen;
}

.mahjong-stage__felt {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.16), transparent 24%),
    radial-gradient(circle at 50% 45%, #1f9e67 0%, #11784a 42%, #0c623d 70%, #083d27 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 244, 214, 0.08), inset 0 0 40px rgba(0, 0, 0, 0.34);
}

.mahjong-stage__grain,
.mahjong-stage__glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mahjong-stage__grain {
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.05) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.02) 0 2px, transparent 2px 5px);
  opacity: 0.55;
}

.mahjong-stage__glow {
  background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.16), transparent 42%);
}

.mahjong-stage__watermark {
  position: absolute;
  inset: auto 50% 46% auto;
  transform: translate(50%, 50%);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 6px;
  color: rgba(255, 245, 214, 0.08);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.26);
  user-select: none;
  pointer-events: none;
}

.mahjong-stage__indicator {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 82px;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(145deg, rgba(255, 236, 178, 0.2), rgba(92, 51, 10, 0.95)),
    linear-gradient(180deg, #2a1c14, #0b090a);
  border: 1px solid rgba(255, 239, 194, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -2px 4px rgba(0, 0, 0, 0.55),
    0 8px 18px rgba(0, 0, 0, 0.38);
  z-index: 4;
}

.mahjong-stage__indicator::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 238, 196, 0.28);
}

.mahjong-stage__indicator-num {
  position: relative;
  transform: rotate(-45deg);
  color: #fff0c8;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.mahjong-wall {
  position: absolute;
  z-index: 2;
  display: flex;
  gap: 2px;
}

.mahjong-wall--top,
.mahjong-wall--bottom {
  left: 12px;
  right: 12px;
  justify-content: center;
}

.mahjong-wall--top {
  top: 12px;
}

.mahjong-wall--bottom {
  bottom: 86px;
}

.mahjong-wall--left,
.mahjong-wall--right {
  flex-direction: column;
  top: 12px;
  bottom: 86px;
  justify-content: center;
}

.mahjong-wall--left {
  left: 10px;
}

.mahjong-wall--right {
  right: 10px;
}

.mahjong-wall__tile.mjtile {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    inset 0 -1px 2px rgba(56, 35, 18, 0.18),
    0 2px 5px rgba(0, 0, 0, 0.2);
}

.mahjong-wall__tile--left.mjtile--rotated,
.mahjong-wall__tile--right.mjtile--rotated {
  transform-origin: center center;
}

.mahjong-seat {
  position: absolute;
  z-index: 5;
}

.mahjong-seat--top {
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
}

.mahjong-seat--left {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.mahjong-seat--right {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.mahjong-seat--hero {
  left: 14px;
  bottom: 14px;
}

.mahjong-seat-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(9, 14, 12, 0.52);
  border: 1px solid rgba(255, 240, 205, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(4px);
}

.mahjong-seat-badge--hero-card {
  padding: 7px 9px;
}

.mahjong-seat-badge--active {
  border-color: rgba(244, 210, 122, 0.52);
  box-shadow:
    0 0 0 2px rgba(244, 210, 122, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mahjong-seat-badge__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 35% 30%, #ffecc5, #c89a3a 55%, #5c4018 100%);
  border: 1px solid rgba(255, 245, 214, 0.72);
  color: #2a1907;
  font-size: 12px;
  font-weight: 900;
  box-shadow:
    0 0 0 2px rgba(244, 210, 122, 0.1),
    0 4px 10px rgba(0, 0, 0, 0.24);
}

.mahjong-seat-badge--active .mahjong-seat-badge__avatar {
  box-shadow:
    0 0 0 2px rgba(255, 238, 192, 0.36),
    0 0 0 5px rgba(244, 210, 122, 0.24),
    0 4px 12px rgba(0, 0, 0, 0.28);
}

.mahjong-seat-badge__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mahjong-seat-badge__name {
  font-size: 12px;
  font-weight: 900;
  color: #f8edd1;
  line-height: 1.1;
}

.mahjong-seat-badge__coins {
  margin-top: 1px;
  font-size: 10px;
  color: rgba(244, 210, 122, 0.84);
}

.mahjong-seat__melds {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  position: absolute;
}

.mahjong-seat__melds--top {
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
}

.mahjong-seat__melds--side {
  top: 44px;
  left: 42px;
  max-width: 96px;
}

.mahjong-seat__melds--hero {
  left: 54px;
  top: 10px;
  max-width: 140px;
}

.mahjong-meld {
  display: flex;
  align-items: center;
  gap: 0;
}

.mahjong-meld__tile {
  margin-right: -4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
}

.mahjong-meld__tile--lift {
  transform: translateY(-2px) rotate(90deg);
}

.mahjong-discards {
  position: absolute;
  display: grid;
  gap: 3px;
  z-index: 3;
}

.mahjong-discards--top {
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  grid-template-columns: repeat(4, auto);
}

.mahjong-discards--left {
  top: 52%;
  left: 92px;
  transform: translateY(-50%);
  grid-template-columns: repeat(2, auto);
  max-width: 90px;
}

.mahjong-discards--right {
  top: 52%;
  right: 92px;
  transform: translateY(-50%);
  grid-template-columns: repeat(2, auto);
  max-width: 90px;
}

.mahjong-discards--hero {
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  grid-template-columns: repeat(4, auto);
}

.mahjong-discard.mjtile {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.68),
    0 1px 3px rgba(0, 0, 0, 0.18);
}

.mahjong-hero-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 2px 0;
}

.mahjong-hero-panel__info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
}

.mahjong-hero-panel__melds {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-content: flex-start;
  min-height: 44px;
  padding-top: 2px;
}

.mahjong-hand-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mahjong-hand-row__label {
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(244, 210, 122, 0.78);
  padding-left: 2px;
}

.mahjong-hand {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 3px;
  padding: 4px 2px 0;
  overflow-x: hidden;
}

.mahjong-hand__tile {
  flex: 0 0 auto;
}

.mahjong-hand__tile--drawn {
  margin-left: 10px;
}

.mahjong-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 2px);
}

.mahjong-actions__tools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.mahjong-actions__main {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.mahjong-tool-btn,
.mahjong-action-btn {
  border: 1px solid rgba(255, 240, 205, 0.16);
  border-radius: 16px;
  color: #2b1b05;
  font-weight: 900;
  background: linear-gradient(180deg, #fff0b8, #c99330);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    0 8px 16px rgba(0, 0, 0, 0.24);
}

.mahjong-tool-btn {
  padding: 9px 14px;
  font-size: 12px;
}

.mahjong-action-btn {
  padding: 12px 0;
  font-size: 13px;
}

@media (max-width: 380px) {
  .mahjong-body {
    padding-inline: 8px;
  }

  .mahjong-stage__watermark {
    font-size: 22px;
  }

  .mahjong-seat--hero {
    left: 10px;
  }

  .mahjong-discards--hero {
    bottom: 88px;
  }
}
