/* Dynamic concealed hands and clearer table tiles. Loaded after legacy styles. */
.concealed-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  height: auto;
  min-height: 30px;
  margin: auto;
  border-radius: 0;
  background: none;
  box-shadow: none;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.22));
}

.concealed-row.vertical {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  width: 30px;
  height: max-content;
  min-height: 0;
  margin: 0;
  background: none;
  box-shadow: none;
}

.concealed-tile-back {
  flex: none;
  width: 14px;
  height: 27px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 3px 3px 4px 4px;
  background: linear-gradient(145deg, #fbfdf9 0 15%, #d4e8de 16% 78%, #a5c9ba 79%);
  box-shadow: 0 2px 0 #397866;
}

.concealed-row.vertical .concealed-tile-back {
  width: 27px;
  height: 14px;
  border-radius: 4px 3px 3px 4px;
  box-shadow: 2px 0 0 #397866;
}

.concealed-row .drawn-tile {
  margin-left: 5px;
  outline: 1px solid rgba(245, 195, 77, 0.55);
}

.concealed-row.vertical .drawn-tile {
  margin-top: 5px;
  margin-left: 0;
}

.concealed-row.is-estimated {
  opacity: 0.72;
}

.tile-row {
  gap: 4px;
  min-height: 35px;
}

.tile-chip {
  width: 43px;
  height: 58px;
  border-radius: 6px 6px 8px 8px;
  box-shadow: 0 4px 0 #c8cec4, 0 6px 10px rgba(0, 0, 0, 0.22);
}

.tile-chip .mahjong-icon {
  font-size: 29px;
}

.tile-caption {
  font-size: 9px;
  font-weight: 900;
}

.river-row .tile-chip {
  width: 31px;
  height: 41px;
  box-shadow: 0 3px 0 #c8cec4, 0 4px 6px rgba(0, 0, 0, 0.18);
}

.river-row .mahjong-icon {
  font-size: 21px;
}

.my-hand-row {
  min-height: 69px;
}

.my-river {
  /* Reserve the bottom band for melds and the hand. The old 80px offset put
     the discard river in the same band as PON/KONG chips on narrow tables. */
  bottom: 150px;
  z-index: 12;
  max-height: 112px;
  overflow: auto;
  pointer-events: none;
  color: #c5dfd5;
  font-size: 11px;
  transition: bottom 180ms ease, opacity 180ms ease;
}

/* Claim/win controls live at table level so positioned rivers can never cover them. */
.table-action-panel {
  position: absolute;
  right: auto;
  /* Keep claim controls above the discard river and the player's meld row. */
  bottom: 255px;
  left: 50%;
  z-index: 50;
  width: min(680px, calc(100% - 48px));
  max-width: none;
  margin: 0;
  padding: 12px 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(251, 211, 104, 0.82);
  border-radius: 15px;
  background: rgba(3, 31, 26, 0.97);
  color: #fff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.42), 0 0 0 4px rgba(247, 197, 78, 0.12);
  backdrop-filter: blur(14px);
  isolation: isolate;
}

/* Setup and claim overlays must sit above every seat card/river on compact
   screens; otherwise the bottom player's card can cover their buttons. */
.table-center {
  position: absolute;
  z-index: 45;
}

.setup-panel {
  z-index: 60;
}

.seat-bottom {
  z-index: 24;
}

.seat-bottom .meld-list {
  position: relative;
  z-index: 35;
  margin-bottom: 6px;
  padding: 4px 8px;
  border: 1px solid rgba(247, 211, 104, 0.28);
  border-radius: 9px;
  background: rgba(3, 31, 26, 0.78);
}

.table-action-panel[hidden] {
  display: none;
}

.table-action-panel .action-message {
  margin-bottom: 9px;
  color: #fff4c5;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.table-action-panel .action-buttons {
  flex-wrap: wrap;
}

.table-action-panel .action-button {
  min-width: 96px;
  min-height: 42px;
  font-weight: 850;
}

.mahjong-table.has-pending-action .my-river {
  bottom: 150px;
  z-index: 12;
  opacity: 0.82;
}

.meld-list {
  min-height: 27px;
}

.meld-chip {
  gap: 5px;
  padding: 4px 7px;
  border-radius: 7px;
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.16);
}

.meld-chip .mahjong-icon {
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 760px) {
  .concealed-row {
    gap: 1px;
  }

  .concealed-tile-back {
    width: 11px;
    height: 23px;
  }

  .concealed-row.vertical {
    width: 23px;
    height: max-content;
  }

  .concealed-row.vertical .concealed-tile-back {
    width: 23px;
    height: 10px;
  }

  .concealed-row.vertical .drawn-tile {
    margin-top: 4px;
  }

  .seat-left .river-row,
  .seat-right .river-row {
    max-width: 118px;
  }

  .tile-chip {
    width: 38px;
    height: 52px;
  }

  .tile-chip .mahjong-icon {
    font-size: 26px;
  }

  .river-row .tile-chip {
    width: 29px;
    height: 39px;
  }

  .river-row .mahjong-icon {
    font-size: 20px;
  }

  .my-river {
    left: 74px;
    right: 74px;
    bottom: 125px;
  }

  .table-action-panel {
    bottom: 215px;
    width: calc(100% - 18px);
    padding: 10px;
  }

  .table-action-panel .action-button {
    flex: 1 1 82px;
    min-width: 72px;
    min-height: 46px;
  }

  .mahjong-table.has-pending-action .my-river {
    right: 7%;
    bottom: 125px;
    left: 7%;
    max-height: 72px;
  }
}

@media (max-width: 480px) {
  .table-action-panel {
    bottom: 205px;
    width: calc(100% - 12px);
  }

  .table-action-panel .action-message {
    margin-bottom: 7px;
    font-size: 12px;
  }

  .mahjong-table.has-pending-action .my-river {
    bottom: 125px;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .my-river,
  .mahjong-table.has-pending-action .my-river { bottom: 112px; max-height: 72px; }
  .table-action-panel { bottom: 188px; }
  .seat-bottom .meld-list { margin-bottom: 3px; padding-top: 2px; padding-bottom: 2px; }
}
