.seats .seat-body { min-width: 0; }
.seats .seat { max-width: 32%; }
.seats .seat-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.seats .backs { max-width: 100%; overflow: hidden; }
.seats .seat:has(.seat-kongs) {
  display: grid; grid-template-columns: auto minmax(0, 1fr); row-gap: 3px;
}
.seats:has(.seat-kongs) { align-items: flex-start; }
.kong-groups { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; }
.seat-kongs {
  --kong-width: clamp(12px, 1.25vw, 20px);
  max-width: 100%; padding: 1px 0; vertical-align: middle;
  border: 0; background: transparent; color: inherit;
}
.seat > .seat-kongs { grid-column: 1 / -1; color: #f2e7c8; }
.hand .seat-kongs { margin-inline-start: .7em; }
@media (min-width: 960px) and (min-height: 521px) {
  .table-hand-header {
    display: grid; grid-template-columns: minmax(0, 1fr) fit-content(46%) minmax(0, 1fr);
    align-items: center; column-gap: 12px;
  }
  .table-hand-header .hand-title-row, .table-hand-header .player-extras { display: contents; }
  .table-hand-header .hand-title { grid-area: 1 / 1; }
  .table-hand-header .hand-summary { grid-area: 1 / 2; text-align: center; }
  .table-hand-header .metadata {
    grid-area: 1 / 3; justify-content: flex-end; flex-wrap: wrap; row-gap: 3px;
  }
  .table-hand-header .metadata > span { white-space: nowrap; }
  .table-hand-header .seat-kongs {
    grid-area: 1 / 2 / span 2; justify-content: center;
    --kong-width: clamp(19px, 1.5vw, 26px); margin: 0;
  }
  .table-hand-header:has(.seat-kongs) .hand-summary { grid-area: 2 / 1; text-align: start; }
  .table-hand-header:has(.seat-kongs) .metadata { grid-row: 1 / span 2; }
}
.kong-group { display: inline-grid; justify-items: center; gap: 2px; line-height: 1; }
.kong-group small { font-size: clamp(10px, .8vw, 12px); font-weight: 600; }
.kong-faces { display: inline-flex; gap: 1px; }
.kong-tile {
  box-sizing: border-box; display: block; width: var(--kong-width); aspect-ratio: 3 / 4;
  border: 1px solid #d9cda7; border-radius: 2px; background: #fff9e6; box-shadow: 0 1px #9a8860;
}
.kong-back { background: linear-gradient(120deg, #5e977e, #2c6855); box-shadow: inset 0 0 0 1px #8fb49a, 0 1px #9a8860; }
.kong-detail { --kong-width: clamp(24px, 5vw, 37px); gap: 8px 14px; margin-block: 5px; }
.kong-detail small { font-size: 13px; }
@media (max-width: 400px) {
  .seat > .seat-kongs:has(.kong-group:nth-child(3)) {
    --kong-width: 9px;
    display: grid; grid-template-columns: repeat(2, max-content); gap: 3px;
  }
}
.turn-badge.waiting { border-color: #d9d4c5; color: #625f51; background: #eeece3; }
.turn-badge.waiting::before { background: #8b8979; }
#seat-wind { padding: 0; border: 0; }
.main:has(> #table-turn-status), .online-playing .online-main {
  padding-bottom: max(env(safe-area-inset-bottom), clamp(2px, .8dvh, 9px));
}
#table-turn-status {
  display: grid; flex: none; align-items: center; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  margin: 1px 0 clamp(3px, .6dvh, 7px); padding: 3px 5px;
  color: var(--ink); font-size: clamp(14px, 1.3vw, 19px); line-height: 1.25;
}
#table-status {
  grid-column: 1; justify-self: start; display: flex; align-items: baseline; gap: .6em;
  color: #565b49; font-size: clamp(12px, 1.05vw, 15px); white-space: nowrap; font-variant-numeric: tabular-nums;
}
#table-status span + span { padding-inline-start: .6em; border-inline-start: 1px solid #b8ad92; }
#table-status b { color: #294c3d; }
.turn-summary { grid-column: 2; display: flex; align-items: center; justify-content: center; gap: .7em; min-width: 0; }
#seat-status { display: flex; align-items: baseline; justify-content: center; gap: .4em; min-width: 0; }
#turn-player { min-width: 0; overflow-wrap: anywhere; color: #1c5142; font-weight: 750; }
#turn-player:empty { display: none; }
#turn-action { flex: none; }
#turn-clock {
  flex: none; padding: .15em .65em; border: 1px solid #b6c7b6; border-radius: 6px;
  color: #234a3c; background: #e5eddf; font-weight: 700; font-variant-numeric: tabular-nums;
}
#turn-clock.urgent { background: #f7dfd3; border-color: #ce9c86; color: #912d1d; }
@media (max-width: 700px) {
  #table-turn-status { grid-template-columns: max-content minmax(0, 1fr); gap: .5em; }
  .turn-summary { justify-self: end; gap: .5em; max-width: 100%; }
}
@media (max-width: 359px) {
  #table-status { flex-direction: column; gap: 0; }
  #table-status span + span { padding: 0; border: 0; }
}
@media (max-height: 520px) {
  #table-turn-status { margin: 0; padding-block: 1px; font-size: 14px; }
}

.table-mast-tools { justify-self: end; display: flex; align-items: center; gap: 6px; }
#room-reactions { position: relative; width: max-content; }
#reaction-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 4px 10px; border: 1px solid #b6a98b;
  border-radius: 7px; background: #fcf9ee; color: #284c40; font: 650 14px/1.2 var(--sans);
}
#reaction-toggle[aria-expanded="true"] { border-color: #688371; background: #e5ecdf; }
#reaction-toggle .icon { width: 21px; height: 21px; }
dialog > #room-reactions { z-index: 1; }
:is(#modal, #online-result-dialog) > #room-reactions { position: sticky; top: 0; float: right; margin: 0 32px 4px 6px; }
.solo-victory > #room-reactions { position: absolute; top: max(6px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
#reaction-flyout {
  --reaction-size: 128px;
  position: absolute; top: calc(100% + 5px); right: 0; z-index: 15; width: max-content;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  max-width: calc(100vw - 12px); padding: 0; border: 0; margin: 0; overflow: visible;
  background: transparent; color: #284c40; pointer-events: none;
}
#reaction-flyout[popover] { position: fixed; inset: auto; }
#reaction-home #reaction-flyout:not([popover]) { right: -46px; }
dialog:not(.solo-victory) #reaction-flyout:not([popover]) { position: static; max-width: 100%; }
dialog #room-reactions:has(#reaction-flyout:not([popover])) { max-width: 100%; float: none; }
#reaction-flyout:not([popover]) #reaction-picker { max-width: 100%; }
#reaction-picker {
  width: min(246px, calc(100vw - 12px)); max-height: 70vh; max-height: 70dvh;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: max-content; align-content: start;
  flex: none; padding: 4px; gap: 2px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid #b6a98b; border-radius: 12px;
  background: #fffcf3; box-shadow: 0 4px 15px #143a2f30; pointer-events: auto;
}
#reaction-picker button {
  display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 0; padding: 3px 1px;
  border: 0; border-radius: 8px; color: #304b3f; background: transparent; font: 650 12px/1.25 var(--sans);
}
#reaction-picker button:is(:hover, :focus-visible) { background: #e8eddf; }
#reaction-picker button:focus-visible { outline-offset: -2px; }
.reaction-sticker {
  display: block; width: 42px; height: 42px; flex: none;
  background-image: url("assets/reactions/birds.png"); background-repeat: no-repeat; background-size: 400% 400%;
}
#reaction-feed {
  display: flex; min-width: 0; align-items: flex-start; justify-content: flex-end; flex-wrap: wrap; gap: 6px;
  width: max-content; max-width: calc(100vw - 12px); pointer-events: none;
}
#reaction-feed:empty { display: none; }
.reaction-sender, .reaction-error {
  border: 1px solid #c1b493; border-radius: 12px; background: #fffaf0; color: #284c40;
  box-shadow: 0 2px 7px #18392b40; font: 650 14px/1.25 var(--sans);
}
.reaction-bubble { width: var(--reaction-size); display: grid; justify-items: center; align-content: start; }
.reaction-bubble .reaction-sticker { width: var(--reaction-size); height: var(--reaction-size); filter: drop-shadow(0 2px 2px #102c2340); }
.reaction-sender { display: flex; align-items: baseline; gap: 4px; padding: 2px 7px; min-width: 0; max-width: 100%; white-space: nowrap; }
.reaction-sender b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.reaction-sender small { flex: none; color: #616d5e; font: 500 11px/1.2 var(--sans); }
.reaction-error { padding: 8px 12px; }
@media (max-width: 540px) {
  .solo-mast { grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px; }
  .solo-title { justify-self: center; }
  .table-mast-tools { gap: 3px; }
  #reaction-toggle span { display: none; }
  #reaction-flyout { --reaction-size: 96px; }
}
@media (max-height: 520px) {
  #reaction-toggle { min-height: 32px; }
  #reaction-flyout { --reaction-size: 80px; }
}
@media (min-width: 560px) and (max-height: 580px) {
  #reaction-flyout[popover] { flex-direction: row-reverse; align-items: flex-start; }
}
