/* Both game transports load this last. Declared sets face the table, above the hand. */
.board .own-tiles {
  flex-wrap: wrap;
  row-gap: 16px;
}
.board .hand-topline .bonus-row .tile.tiny {
  --tile-w: 28px;
  --tile-h: calc(28px * 4/3);
}
.board .own-melds {
  order: -1;
  flex: 0 0 100%;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0 0 4px;
  overflow: visible;
}
@media (min-width: 801px) {
  .board:has(.own-melds) > .table-center {
    bottom: calc(var(--hand-space) + var(--action-room) + 54px);
  }
}
@media (max-width: 800px) and (orientation: portrait), (max-width: 559px) {
  .board .own-tiles {
    container-type: inline-size;
    padding-left: 0;
    padding-right: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 16px 1px;
    min-height: 64px;
    --rack-tile: min(48px, calc((100cqw - 4px) / var(--hand-count)));
  }
  .board .own-tiles > .tile {
    --tile-w: var(--rack-tile);
    --tile-h: calc(var(--rack-tile) * 4/3);
    width: var(--tile-w);
    height: var(--tile-h);
    flex-shrink: 0;
    min-height: 0;
  }
  .board .own-tiles > .tile.drawn {
    margin-left: 5px;
    transform: translateY(-5px);
  }
  .board .own-tiles > .tile.selected {
    transform: translateY(-9px);
  }
  .board .own-tiles > .tile.group-start {
    margin-left: 0;
  }
  .board .hand-zone {
    --own-public-tile: min(30px, calc((100vw - 70px) / var(--declared-count, 1)));
  }
  .board .own-melds {
    gap: 6px;
    margin: 0;
    --meld-tile: var(--own-public-tile);
  }
  .board .hand-topline .bonus-row .tile.tiny {
    --tile-w: var(--own-public-tile);
    --tile-h: calc(var(--own-public-tile) * 4/3);
  }
  .board .own-melds .tile {
    --tile-w: var(--meld-tile);
    --tile-h: calc(var(--meld-tile) * 4/3);
    width: var(--tile-w);
    height: var(--tile-h);
  }
  .board .own-melds .meld {
    gap: 0;
  }
  .board .own-melds .concealed-label {
    display: none;
  }
  .board .table-turn-bar .move-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }
  .board .table-turn-bar .move-actions > button {
    width: auto;
    flex: none;
    min-width: 65px;
    min-height: 40px;
    padding: 8px 12px;
  }
  .board .table-turn-bar .turn-status {
    text-align: center;
    min-height: 26px;
  }
  .board .table-turn-bar .turn-status p {
    display: none;
  }
  .board .hand-zone {
    padding: 3px 3px 0;
  }
  .board .player-dock {
    max-height: 48%;
  }
  .board .hand-topline {
    margin-bottom: 4px;
  }
  .board .hand-topline .you-label {
    max-width: 38%;
  }
  .board .hand-topline .tile-marker {
    --marker-height: 20px;
  }
}
.social-dialog button {
  background: #214d3e;
  border: 1px solid #dfc79644;
  border-radius: 7px;
  padding: 7px 11px;
}
.social-dialog .message-author,
.social-dialog .message-tools button {
  background: none;
  border: 0;
  padding: 0;
}
.social-dialog .primary,
.social-dialog .social-play {
  background: var(--gold);
  color: #143a2d;
}
.social-dialog .social-tabs [aria-pressed='true'] {
  background: var(--gold);
  color: #143a2d;
}
#account-tables {
  border-top: 1px solid #dfc79633;
  margin-top: 22px;
  padding-top: 18px;
}
#account-tables h2 {
  font-size: 20px;
}
#account-tables > button {
  display: block;
  width: 100%;
  text-align: left;
}

@media (min-width: 560px) and (max-width: 1100px) and (max-height: 600px) and (orientation: landscape),
  (min-width: 560px) and (max-width: 1400px) and (max-height: 900px) and (orientation: landscape) and (pointer: coarse) {
  .board .own-tiles {
    container-type: inline-size;
    row-gap: 12px;
    --rack-tile: min(44px, calc((100cqw - 30px) / var(--hand-count) - 3px));
  }
  .board .own-melds {
    padding-bottom: 0;
  }
  .online-app.playing #online-root {
    padding: 0;
  }
  .online-app.playing #game > .app-shell {
    width: 100%;
    min-width: 0;
  }
  .online-app.playing .workspace {
    height: calc(100dvh - 44px - env(safe-area-inset-top));
    max-height: calc(100dvh - 44px - env(safe-area-inset-top));
    padding: 0;
  }
  .board .own-melds .tile {
    --tile-w: 24px;
    --tile-h: 32px;
  }
  .board:has(.own-melds) .hand-topline .bonus-row .tile.tiny {
    --tile-w: 18px;
    --tile-h: 24px;
  }
  .board .own-tiles > .tile {
    --tile-w: var(--rack-tile);
    --tile-h: calc(var(--rack-tile) * 4/3);
  }
  .board:has(.own-melds) .landscape-felt {
    min-height: 158px;
  }
  .board:has(.own-melds) .landscape-seat-top {
    left: calc(var(--rail) + 5px);
    right: calc(var(--rail) + 5px);
    height: 48px;
  }
  .board:has(.own-melds) .landscape-seat-top .landscape-rack {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 7px;
  }
  .board:has(.own-melds) .landscape-seat-top .landscape-name {
    grid-column: 1;
  }
  .board:has(.own-melds) .landscape-seat-top .landscape-backs {
    grid-column: 1;
    width: 100%;
    height: 9px;
  }
  .board:has(.own-melds) .landscape-seat-top .landscape-declared,
  .board:has(.own-melds) .landscape-seat-top .landscape-winning {
    grid-area: 1/2/3/3;
    align-self: center;
  }
  .board:has(.own-melds) .landscape-centre {
    grid-template-rows: 48px minmax(27px, 1fr) minmax(44px, auto) minmax(27px, 1fr);
    column-gap: 4px;
  }
}

@media (max-width: 559px) and (max-height: 640px) {
  .board .own-tiles:has(.own-melds) {
    padding-top: 0;
  }
  .board:has(.own-melds) .player-dock {
    max-height: 58%;
  }
  .board:has(.own-melds) .portrait-table {
    min-height: 174px;
  }
}

/* Keep leaving within reach without opening the table menu. */
.mobile-header-actions .leave-game,
.mobile-header-actions [data-leave-game] {
  white-space: nowrap;
  padding-inline: 7px;
  font-size: 13px;
}
@media (max-width: 380px) {
  .topbar {
    gap: 4px;
    padding-inline: 1px;
  }
  .brand {
    min-width: 0;
  }
  .brand h1 {
    font-size: 14px;
  }
  .mobile-header-actions {
    gap: 3px;
    flex-shrink: 0;
  }
  .mobile-header-actions button {
    padding-inline: 6px;
    font-size: 13px;
  }
}

@media (min-width: 560px) and (max-height: 380px) and (orientation: landscape) {
  .board .player-dock {
    max-height: 74%;
  }
  .board .hand-topline {
    min-height: 24px;
    margin-bottom: 3px;
  }
  .board .hand-topline .bonus-row .tile.tiny {
    --tile-w: 16px;
    --tile-h: 21px;
  }
  .board .own-tiles {
    row-gap: 6px;
    padding-bottom: 3px;
  }
  .board .own-melds .tile {
    --tile-w: 18px;
    --tile-h: 24px;
  }
  .board .landscape-table .landscape-felt {
    min-height: 110px;
  }
  .board .landscape-table .landscape-centre {
    grid-template-rows: 33px minmax(9px, 1fr) minmax(40px, auto) minmax(9px, 1fr);
    row-gap: 2px;
  }
  .board .landscape-focus .mobile-latest,
  .board .landscape-focus .landscape-latest {
    min-height: 40px;
    padding-block: 1px;
  }
  .board .landscape-focus .tile {
    --tile-w: 26px;
    --tile-h: 35px;
    width: 26px;
    height: 35px;
  }
}

/* All opponent public tiles share a size; tapping still enlarges each group. */
.board .seat :is(.exposed-meld, .bonus-row) .tile.tiny {
  --tile-w: 24px;
  --tile-h: 32px;
}
.board .seat .melds {
  gap: 7px;
}
.board .seat .meld {
  gap: 1px;
}
.board :is(.mobile-melds, .mobile-bonuses) .tile.tiny {
  --tile-w: 24px;
  --tile-h: 32px;
}
.board :is(.landscape-meld, .landscape-bonus) .tile {
  --tile-w: 18px;
  --tile-h: 24px;
  width: 18px;
  height: 24px;
}
.board :is(.portrait-meld, .portrait-bonus) .portrait-piece {
  width: var(--portrait-public-w);
  height: var(--portrait-public-h);
}
.board :is(.portrait-meld, .portrait-bonus) .tile {
  --tile-w: var(--portrait-public-w);
  --tile-h: var(--portrait-public-h);
  width: var(--tile-w);
  height: var(--tile-h);
}
.board :is(.portrait-left, .portrait-right) :is(.portrait-meld, .portrait-bonus) .portrait-piece {
  width: var(--portrait-public-h);
  height: var(--portrait-public-w);
}

/* A brief gold tint belongs only to the winner's physical side of the table. */
.board.win-celebrating .seat.winner .opponent-rack,
.board.win-celebrating .portrait-seat.is-winner,
.board.win-celebrating .landscape-seat.is-winner .landscape-rack,
.board.win-celebrating .hand-zone.winner {
  background-color: rgb(200 165 79 / var(--win-alpha, 0));
  border-radius: 8px;
}
.win-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  pointer-events: none;
}
.board.hand-won .table-turn-bar [data-command='result'],
.board.hand-won :is(.portrait-focus, .landscape-focus) :is(.mobile-latest, .landscape-latest),
.board.hand-won .player-dock > .mobile-latest {
  display: none;
}
.board .seat.winner {
  z-index: 6;
}
.board .seat.winner .rack-line {
  background: none;
  box-shadow: none;
}
.board .portrait-seat.is-winner,
.board .landscape-seat.is-winner .landscape-rack {
  background: none;
  border-color: transparent;
}
.winning-piece {
  display: inline-grid;
  place-items: center;
  flex: none;
  line-height: 0;
}
.winning-concealed .winning-piece.winning-tile {
  margin: 0 0 0 3px;
}
.board .seat .winning-concealed {
  flex-wrap: nowrap;
  gap: 0;
  max-width: none;
}
.board .seat .winning-concealed .tile {
  --tile-w: 24px;
  --tile-h: 32px;
}
.board .own-tiles > .winning-concealed {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  max-width: 100%;
  gap: 0;
}
.board .own-tiles > .winning-concealed .tile {
  --tile-w: var(--rack-tile, 42px);
  --tile-h: calc(var(--tile-w) * 4/3);
  width: var(--tile-w);
  height: var(--tile-h);
  flex: none;
}

@media (max-width: 800px) and (orientation: portrait), (max-width: 559px) {
  .portrait-seat.is-winner:is(.portrait-left, .portrait-right) {
    display: flex;
    flex-direction: column;
  }
  .portrait-seat.is-winner:is(.portrait-left, .portrait-right) .portrait-rack {
    flex: 1;
    height: auto;
    min-height: 0;
  }
  .portrait-seat.is-winner .portrait-public {
    container-type: size;
    gap: 3px;
    padding: 0;
  }
  .portrait-seat.is-winner :is(.portrait-bonus, .portrait-meld) {
    min-height: 0;
    min-width: 0;
    gap: 0;
  }
  .portrait-seat.is-winner:is(.portrait-left, .portrait-right) .portrait-public {
    --public-w: min(
      var(--portrait-public-w),
      calc((100cqh - var(--winner-public-gaps) - 2px) / var(--winner-public-count))
    );
  }
  .portrait-seat.is-winner :is(.portrait-bonus, .portrait-meld) .tile {
    --tile-w: var(--public-w);
    --tile-h: calc(var(--public-w) * 4/3);
    width: var(--tile-w);
    height: var(--tile-h);
  }
  .portrait-seat.is-winner:is(.portrait-left, .portrait-right)
    :is(.portrait-bonus, .portrait-meld)
    .portrait-piece {
    width: calc(var(--public-w) * 4 / 3);
    height: var(--public-w);
  }
  .portrait-top.is-winner .portrait-public {
    container-type: inline-size;
    --public-w: min(
      var(--portrait-public-w),
      calc((100cqw - var(--winner-public-gaps) - 2px) / var(--winner-public-count))
    );
  }
  .portrait-top.is-winner :is(.portrait-bonus, .portrait-meld) .portrait-piece {
    width: var(--public-w);
    height: calc(var(--public-w) * 4 / 3);
  }
  /* The top row reveals along the same rack; side rows reveal vertically facing their owner. */
  .portrait-top:has(.portrait-winning) .portrait-rack {
    flex-direction: row;
    align-items: center;
    gap: 4px;
  }
  .portrait-top .portrait-winning {
    flex: 1;
    min-width: 0;
    container-type: inline-size;
  }
  .portrait-top:has(.portrait-winning) .portrait-public {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 45%;
    margin: 0;
  }
  .portrait-top .portrait-winning .winning-concealed {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    justify-content: center;
    width: 100%;
    transform: rotate(180deg);
    --reveal-w: min(var(--portrait-public-w), calc((100cqw - 3px) / var(--winning-count)));
  }
  .portrait-winning .winning-piece {
    width: var(--reveal-w);
    height: calc(var(--reveal-w) * 4 / 3);
  }
  .portrait-winning {
    overflow: visible;
  }
  .portrait-winning .tile {
    --tile-w: var(--reveal-w);
    --tile-h: calc(var(--reveal-w) * 4/3);
    width: var(--tile-w);
    height: var(--tile-h);
    flex: none;
  }
  .portrait-left:has(.portrait-winning) .portrait-rack {
    padding-left: var(--portrait-reveal-h);
  }
  .portrait-right:has(.portrait-winning) .portrait-rack {
    padding-right: var(--portrait-reveal-h);
  }
  :is(.portrait-left, .portrait-right) .portrait-winning {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--portrait-reveal-h);
    container-type: size;
  }
  .portrait-right .portrait-winning {
    left: auto;
    right: 0;
  }
  :is(.portrait-left, .portrait-right) .portrait-winning .winning-concealed {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0;
    width: 100%;
    height: 100%;
    --reveal-w: min(var(--portrait-reveal-w), calc((100cqh - 3px) / var(--winning-count)));
  }
  :is(.portrait-left, .portrait-right) .portrait-winning .winning-piece {
    width: calc(var(--reveal-w) * 4 / 3);
    height: var(--reveal-w);
  }
  :is(.portrait-left, .portrait-right) .portrait-winning .winning-tile {
    margin: 3px 0 0;
  }
  .portrait-left .portrait-winning .tile {
    transform: rotate(90deg);
  }
  .portrait-right .portrait-winning .tile {
    transform: rotate(-90deg);
  }
  .board .own-tiles > .winning-concealed {
    width: 100%;
    --rack-tile: min(48px, calc((100cqw - 4px) / var(--winning-count)));
  }
}

@media (min-width: 560px) and (max-width: 1100px) and (max-height: 600px) and (orientation: landscape),
  (min-width: 560px) and (max-width: 1400px) and (max-height: 900px) and (orientation: landscape) and (pointer: coarse) {
  .landscape-seat.is-winner .landscape-declared {
    container-type: inline-size;
    justify-content: center;
    gap: 3px;
    --public-w: min(
      18px,
      calc((100cqw - var(--winner-public-gaps) - 2px) / var(--winner-public-count))
    );
  }
  .board .landscape-seat.is-winner :is(.landscape-bonus, .landscape-meld) {
    gap: 0;
  }
  .board .landscape-seat.is-winner :is(.landscape-bonus, .landscape-meld) .tile {
    --tile-w: var(--public-w);
    --tile-h: calc(var(--public-w) * 4/3);
    width: var(--tile-w);
    height: var(--tile-h);
  }
  .landscape-winning {
    container-type: inline-size;
    overflow: visible;
    padding: 1px 0;
    min-width: 0;
    width: 100%;
  }
  .landscape-winning .winning-concealed {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    width: 100%;
    gap: 0;
    --reveal-w: min(18px, calc((100cqw - 3px) / var(--winning-count)));
  }
  .landscape-winning .winning-piece {
    width: var(--reveal-w);
    height: calc(var(--reveal-w) * 4 / 3);
  }
  .landscape-winning .tile {
    --tile-w: var(--reveal-w);
    --tile-h: calc(var(--reveal-w) * 4/3);
    width: var(--tile-w);
    height: var(--tile-h);
  }
  .landscape-seat.is-winner .landscape-rack {
    max-height: none;
    overflow: visible;
  }
  .landscape-seat.is-winner:is(.landscape-seat-left, .landscape-seat-right) .landscape-rack {
    width: calc(100cqh - 20px);
  }
  .board:has(.own-melds) .landscape-seat-top .landscape-winning,
  .board .landscape-seat-top .landscape-winning {
    grid-area: 2/1/3/2;
    align-self: center;
  }
  .board .own-tiles > .winning-concealed {
    --rack-tile: min(44px, calc((100cqw - 30px) / var(--winning-count) - 3px));
    width: 100%;
  }
}

/* Coaching is a separate launch signup, never an in-game coach mode. */
.coaching-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #dfc79666;
  border-radius: 7px;
  background: #214d3e;
  color: #f0dfb6;
  font: inherit;
  text-align: center;
  text-decoration: none;
}
.coaching-link span {
  font-size: 11px;
  font-weight: 400;
  color: #c6d3be;
}
.coaching-link:hover {
  background: #2b604d;
}
.coaching-link:focus-visible {
  outline: 3px solid #e8c66e;
  outline-offset: 3px;
}
.mobile-menu-grid .coaching-link {
  margin: 3px;
  min-width: 0;
}

/* Current balances stay one tap away in every table header. */
.topbar .score-button {
  border-color: #d8c28f88;
  color: #f1dbaa;
  font-weight: 650;
  white-space: nowrap;
}
@media (max-width: 380px) {
  .online-app .mobile-header-actions .ghost {
    padding-inline: 6px;
  }
}
