/* Gameplay-only composition. All game behavior remains in the existing engine. */

#screen-table {
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 43%, rgba(16, 78, 58, 0.16), transparent 46%),
    linear-gradient(145deg, #080d16, #050810 72%);
}

#screen-table::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(224, 191, 119, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(224, 191, 119, 0.018) 1px, transparent 1px);
  background-size: 72px 72px;
}

#screen-table.active {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 44px minmax(0, 1fr) auto;
  gap: 6px;
  width: 100%;
  max-width: none;
  min-height: 100svh;
  margin: 0;
  padding: calc(6px + var(--safe-t)) 7px calc(6px + var(--safe-b));
}

/* Compact HUD */
.table-hud {
  position: relative;
  z-index: 14;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 175px 4px 8px;
  border: 1px solid rgba(221, 188, 113, 0.15);
  border-radius: 12px;
  background: rgba(9, 15, 26, 0.84);
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
}

.hud-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.hud-left > img {
  width: 32px;
  height: 32px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45));
}

.hud-left strong {
  display: block;
  color: #f0e9dd;
  font-family: Cinzel, serif;
  font-size: 12px;
  letter-spacing: 0.045em;
  line-height: 1;
}

.hud-left small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #8995a7;
  font-size: 8px;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-right {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
}

.stat {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid rgba(221, 188, 113, 0.17);
  border-radius: 999px;
  color: #dcc48d;
  background: rgba(255, 255, 255, 0.025);
  font-size: 8px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.hud-tools {
  position: absolute;
  z-index: 16;
  top: calc(13px + var(--safe-t));
  right: 13px;
  height: auto;
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.icon-btn {
  width: 27px;
  height: 27px;
  min-width: 27px;
  padding: 5px;
  border: 1px solid rgba(221, 188, 113, 0.17);
  border-radius: 50%;
  color: #d9c189;
  background: #111a29;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.icon-btn:hover {
  border-color: rgba(230, 202, 139, 0.45);
  background: #192437;
  transform: translateY(-1px);
}

.icon-btn:active { transform: translateY(1px); }
.icon-btn.off { opacity: 0.42; }
.icon-btn img { width: 100%; height: 100%; object-fit: contain; }

.log-toggle {
  width: 34px;
  min-width: 34px;
  border-radius: 8px;
  padding: 0;
  font-family: Cinzel, serif;
  font-size: 7px;
  letter-spacing: 0.06em;
}

/* Board sizing follows available width AND height using container units. */
.table-root {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center;
  overflow: visible;
  container-type: size;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 53%, rgba(12, 74, 54, 0.13), transparent 56%);
  pointer-events: none;
}

.felt-wrap {
  position: relative;
  width: min(96%, 1380px);
  width: min(96cqw, calc(98cqh * 1.72), 1380px);
  height: auto;
  aspect-ratio: 1.72 / 1;
  max-height: none;
  pointer-events: none;
  filter: drop-shadow(0 24px 28px rgba(0, 0, 0, 0.42));
}

.felt-wrap::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 5%;
  right: 5%;
  bottom: 1%;
  height: 18%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  filter: blur(18px);
}

.felt-art {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  filter: saturate(0.92) contrast(1.04) brightness(0.93);
  pointer-events: none;
}

.felt-core {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 49%;
  width: min(58%, 650px);
  display: grid;
  justify-items: center;
  gap: clamp(5px, 0.7cqh, 9px);
  transform: translate(-50%, -50%);
}

.pot-display {
  min-height: 31px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 1px solid rgba(225, 194, 124, 0.25);
  border-radius: 999px;
  background: rgba(3, 20, 15, 0.72);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(6px);
}

.pot-display img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.pot-display > div { display: grid; line-height: 1; }
.pot-display small {
  color: #8f9f9a;
  font-size: 6px;
  letter-spacing: 0.14em;
}
.pot-display strong {
  margin-top: 3px;
  color: #ecd18f;
  font-size: clamp(10px, 1.1cqw, 14px);
}

.board-row {
  min-height: clamp(52px, 7.5cqw, 82px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 0.65cqw, 10px);
}

.board-row .playing-card {
  width: clamp(44px, 5.2cqw, 69px);
  flex: none;
}

.street-pill {
  min-width: 58px;
  padding: 3px 9px;
  border: 1px solid rgba(222, 190, 118, 0.15);
  border-radius: 999px;
  color: #ccb06f;
  background: rgba(3, 20, 15, 0.57);
  font-family: Cinzel, serif;
  font-size: 7px;
  letter-spacing: 0.16em;
  text-align: center;
}

.playing-card {
  perspective: 600px;
  animation: dealIn 0.34s ease both;
}

.playing-card.ghost {
  border: 1px solid rgba(224, 192, 120, 0.17);
  border-radius: 6px;
  background: rgba(2, 31, 22, 0.25);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.12);
}

.card-face {
  border-radius: 6px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.34);
}

/* Six fixed, non-overlapping seat zones. */
.seat {
  position: absolute;
  z-index: 5;
  width: clamp(112px, 11cqw, 152px);
  display: grid;
  justify-items: center;
  gap: 2px;
  transition: opacity 0.22s ease, filter 0.22s ease;
}

.seat-0 {
  left: 50%;
  bottom: 0;
  width: clamp(128px, 13cqw, 174px);
  transform: translateX(-50%);
}
.seat-1 { left: 0; bottom: 15%; }
.seat-2 { left: 2%; top: 11%; }
.seat-3 { left: 50%; top: 0; transform: translateX(-50%); }
.seat-4 { right: 2%; top: 11%; }
.seat-5 { right: 0; bottom: 15%; }

.seat-2 .seat-body,
.seat-3 .seat-body,
.seat-4 .seat-body { order: 1; }
.seat-2 .seat-cards,
.seat-3 .seat-cards,
.seat-4 .seat-cards { order: 2; }
.seat-2 .street-bet,
.seat-3 .street-bet,
.seat-4 .street-bet { order: 3; }

.seat-cards,
.seat.hero .seat-cards {
  min-height: 31px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}

.seat .playing-card.sm {
  width: clamp(24px, 2.35cqw, 33px);
}

.seat.hero .seat-cards { min-height: 50px; }
.seat.hero .playing-card {
  width: clamp(40px, 4.1cqw, 54px);
}

.seat-body {
  min-width: 108px;
  max-width: 100%;
  min-height: 41px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  border: 1px solid rgba(218, 184, 107, 0.18);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(18, 27, 42, 0.97), rgba(8, 13, 22, 0.96));
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.35), inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(7px);
}

.seat.hero .seat-body {
  min-width: 124px;
  border-color: rgba(226, 192, 112, 0.42);
  background: linear-gradient(145deg, rgba(35, 32, 29, 0.98), rgba(9, 15, 25, 0.98));
}

.avatar-wrap {
  position: relative;
  width: 35px;
  height: 35px;
  flex: none;
  overflow: hidden;
  border: 1px solid rgba(222, 190, 114, 0.2);
  border-radius: 8px;
  background: #111a29;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  object-fit: cover;
  object-position: center 14%;
}

.seat-meta { min-width: 0; }
.name-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pname {
  max-width: 78px;
  display: block;
  overflow: hidden;
  color: #edf0f4;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-row {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
  color: #dec78e;
  font-size: 8px;
}

.stack-row img { width: 10px; height: 10px; }

.blind-tag,
.status-tag {
  border-radius: 999px;
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.blind-tag {
  padding: 1px 4px;
  color: #211807;
  background: #d8b45f;
}

.status-tag {
  width: max-content;
  margin-top: 2px;
  padding: 2px 5px;
  color: #d4dbe7;
  background: #26334a;
}

.seat.acting .status-tag {
  color: #251b09;
  background: #dfbd6b;
}

.pulse-ring {
  position: absolute;
  inset: -1px;
  border: 1px solid #e7c975;
  border-radius: 8px;
  animation: turnRing 1.1s ease-in-out infinite alternate;
}

.seat.acting .avatar-wrap {
  border-color: #e7c975;
  box-shadow: 0 0 11px rgba(231, 201, 117, 0.35);
}

.seat.folded {
  opacity: 0.36;
  filter: grayscale(0.66);
}
.seat.busted { opacity: 0.2; }
.seat.winner .seat-body {
  border-color: #f0d58c;
  box-shadow: 0 0 20px rgba(228, 195, 122, 0.3);
}

.dealer-chip {
  position: absolute;
  z-index: 3;
  top: 39px;
  left: 3px;
  width: 20px;
  filter: drop-shadow(0 2px 3px #000);
}

.street-bet {
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid rgba(220, 186, 109, 0.14);
  border-radius: 999px;
  color: #dfc78c;
  background: rgba(4, 17, 14, 0.76);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.22);
  font-size: 7px;
  animation: betBadgeIn 0.24s ease both;
}

.street-bet img {
  width: 11px;
  height: 11px;
  object-fit: contain;
}

/* Compact desktop log; drawer everywhere below 1400px. */
.log-wrap {
  display: block;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(221, 188, 113, 0.16);
  border-radius: 13px;
  background: rgba(9, 15, 26, 0.94);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(14px);
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(221, 188, 113, 0.14);
}

.log-wrap h3 {
  margin: 0;
  color: #e5d2a7;
  font-size: 10px;
  letter-spacing: 0.1em;
}

#closeHandLog {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(221, 188, 113, 0.17);
  border-radius: 50%;
  color: #d9c48f;
  background: #151e2d;
  font-size: 16px;
  line-height: 1;
}

.log-wrap ul {
  display: grid;
  gap: 0;
  margin: 5px 0 0;
  padding: 0;
}

.log-wrap li {
  position: relative;
  padding: 6px 3px 6px 11px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035) !important;
  color: #8895a7;
  font-size: 8px;
  line-height: 1.35;
}

.log-wrap li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 10px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #9b7e43;
}

.log-wrap li:first-child { color: #e1e6ee; }
.log-wrap li:first-child::before { background: #e1bf70; }

@media (max-width: 1399px) {
  .log-wrap {
    position: fixed;
    z-index: 24;
    top: calc(56px + var(--safe-t));
    right: 8px;
    bottom: calc(88px + var(--safe-b));
    width: min(250px, calc(100vw - 24px));
    transform: translateX(calc(100% + 18px));
    visibility: hidden;
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s;
    pointer-events: none;
  }

  .log-wrap.open {
    transform: translateX(0);
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 1400px) {
  #screen-table.active {
    grid-template-columns: minmax(0, 1fr) 190px;
  }
  .table-hud,
  .action-bar { grid-column: 1 / -1; }
  .table-root { grid-column: 1; }
  .log-wrap {
    position: static;
    grid-column: 2;
    grid-row: 2;
    max-height: none;
  }
  .log-toggle,
  #closeHandLog { display: none; }
  .table-hud { padding-right: 143px; }
}

/* Compact, game-like action deck. */
.action-bar {
  position: relative;
  z-index: 12;
  width: 100%;
  padding: 5px 6px;
  border: 1px solid rgba(221, 188, 113, 0.16);
  border-radius: 13px;
  background: rgba(8, 14, 24, 0.95);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.action-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.act {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  overflow: hidden;
  padding: 5px 9px;
  border: 1px solid rgba(221, 188, 113, 0.16);
  border-radius: 9px;
  color: #edf0f4;
  background: #151e2e;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.03);
  transition: transform 0.12s ease, filter 0.12s ease, border-color 0.12s ease;
}

.act:hover:not(:disabled) {
  border-color: rgba(232, 204, 142, 0.4);
  filter: brightness(1.07);
  transform: translateY(-1px);
}
.act:active:not(:disabled) { transform: translateY(1px); }

.act img {
  width: 21px;
  height: 21px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}

.act-copy {
  min-width: 0;
  display: grid;
  line-height: 1;
  text-align: left;
}

.act-copy small {
  overflow: hidden;
  color: #8996a8;
  font-size: 5px;
  letter-spacing: 0.11em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.act-copy strong {
  margin-top: 3px;
  font-family: Cinzel, serif;
  font-size: clamp(9px, 1vw, 12px);
  letter-spacing: 0.03em;
}

.act.danger {
  border-color: rgba(153, 62, 74, 0.32);
  background: linear-gradient(145deg, #341923, #211218);
}
.act.danger .act-copy strong { color: #e7c5ca; }
.act.ghost { background: linear-gradient(145deg, #172337, #101827); }
.act.gold {
  border-color: rgba(232, 201, 128, 0.5);
  color: #211806;
  background: linear-gradient(145deg, #d8b969, #b5893d);
}
.act.gold .act-copy small { color: rgba(43, 30, 8, 0.62); }
.act.gold .act-copy strong { color: #211806; }
.act.fire {
  border-color: rgba(166, 81, 50, 0.36);
  background: linear-gradient(145deg, #472219, #281512);
}
.act.fire .act-copy strong { color: #edc0a1; }
.act:disabled {
  opacity: 0.3;
  filter: grayscale(0.5);
  cursor: not-allowed;
  box-shadow: none;
}

.bet-control {
  min-width: 0;
  min-height: 27px;
  display: grid;
  grid-template-columns: auto minmax(90px, 280px) auto 52px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 2px 5px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.018);
}

.bet-label {
  color: #7f8b9d;
  font-size: 6px;
  letter-spacing: 0.15em;
}

.bet-control > strong {
  min-width: 46px;
  color: #ebcc84;
  font-family: Cinzel, serif;
  font-size: 11px;
  text-align: right;
}

.bet-control input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.bet-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, #806536, #273247);
}

.bet-control input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  appearance: none;
  border: 2px solid #efd18a;
  border-radius: 50%;
  background: #ad8238;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.bet-control input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: #283449;
}

.bet-control input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #efd18a;
  border-radius: 50%;
  background: #ad8238;
}

.raise-presets {
  display: flex;
  gap: 3px;
}

.raise-presets button {
  min-width: 41px;
  min-height: 22px;
  padding: 2px 5px;
  border: 1px solid rgba(221, 188, 113, 0.17);
  border-radius: 6px;
  color: #d5bf8a;
  background: #121b29;
  font-size: 7px;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.raise-presets button:hover {
  border-color: rgba(224, 193, 123, 0.42);
  background: #1a2537;
  transform: translateY(-1px);
}

.wait-line {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 5px;
}
.wait-line > span:last-child { display: grid; text-align: left; }
.wait-line small { color: #7f8b9d; font-size: 6px; letter-spacing: 0.14em; }
.wait-line strong { margin-top: 3px; color: #d9e0e9; font-size: 10px; font-weight: 500; }
.dot {
  width: 7px;
  height: 7px;
  margin: 0;
  background: #d9b968;
  box-shadow: 0 0 9px rgba(217, 185, 104, 0.42);
}

/* Portrait is a dedicated seat map, not a shrunken desktop board. */
@media (max-width: 767px) and (orientation: portrait) {
  #screen-table.active {
    grid-template-rows: 40px minmax(0, 1fr) auto;
    gap: 4px;
    padding: calc(4px + var(--safe-t)) 4px calc(4px + var(--safe-b));
  }

  .table-hud {
    padding: 3px 151px 3px 6px;
    border-radius: 10px;
  }
  .hud-left > img { width: 28px; height: 28px; }
  .hud-left strong { font-size: 9px; }
  .hud-left small { font-size: 6px; }
  .hud-right { display: none; }
  .hud-tools {
    top: calc(10px + var(--safe-t));
    right: 8px;
    gap: 3px;
  }
  .icon-btn { width: 25px; height: 25px; min-width: 25px; padding: 4px; }
  .log-toggle { width: 32px; min-width: 32px; padding: 0; }

  .table-root { border-radius: 14px; }
  .felt-wrap {
    width: min(98cqw, 430px);
    height: min(98cqh, 130cqw);
    aspect-ratio: auto;
    filter: drop-shadow(0 17px 22px rgba(0, 0, 0, 0.4));
  }
  .felt-wrap::before {
    left: 4%;
    right: 4%;
    bottom: 24%;
    height: 12%;
  }
  .felt-art {
    inset: 28% 0 auto;
    height: 48%;
    object-fit: fill;
  }
  .felt-core {
    top: 52%;
    width: 67%;
    gap: 4px;
  }
  .pot-display {
    min-height: 26px;
    padding: 3px 7px 3px 3px;
  }
  .pot-display img { width: 20px; height: 20px; }
  .pot-display strong { font-size: 9px; }
  .board-row {
    min-height: 48px;
    gap: 3px;
  }
  .board-row .playing-card { width: clamp(35px, 10vw, 43px); }
  .street-pill { padding: 2px 7px; font-size: 6px; }

  .seat {
    width: 108px;
    gap: 1px;
  }
  .seat-0 {
    bottom: 0;
    width: 128px;
  }
  .seat-1 { left: 0; bottom: 21%; }
  .seat-2 { left: 0; top: 18%; }
  .seat-3 { top: 0; }
  .seat-4 { right: 0; top: 18%; }
  .seat-5 { right: 0; bottom: 21%; }

  .seat-body {
    min-width: 96px;
    min-height: 36px;
    gap: 4px;
    padding: 2px 6px 2px 2px;
    border-radius: 9px;
  }
  .seat.hero .seat-body { min-width: 112px; }
  .avatar-wrap { width: 31px; height: 31px; border-radius: 7px; }
  .avatar { border-radius: 6px; }
  .pulse-ring { border-radius: 7px; }
  .pname { max-width: 61px; font-size: 8px; }
  .stack-row { font-size: 7px; }
  .stack-row img { width: 8px; height: 8px; }
  .blind-tag,
  .status-tag { font-size: 5px; }
  .seat-cards { min-height: 27px; gap: 2px; }
  .seat .playing-card.sm { width: 22px; }
  .seat.hero .seat-cards { min-height: 45px; }
  .seat.hero .playing-card { width: 37px; }
  .dealer-chip { top: 32px; width: 17px; }
  .street-bet { min-height: 16px; padding: 1px 5px; font-size: 6px; }
  .street-bet img { width: 9px; height: 9px; }

  .log-wrap {
    top: calc(49px + var(--safe-t));
    bottom: calc(112px + var(--safe-b));
  }

  .action-bar {
    padding: 5px;
    border-radius: 12px;
  }
  .action-inner { gap: 4px; }
  .action-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }
  .act {
    min-height: 42px;
    gap: 6px;
    padding: 4px 7px;
    border-radius: 8px;
  }
  .act img { width: 19px; height: 19px; }
  .act-copy strong { font-size: 9px; }
  .bet-control {
    grid-template-columns: auto minmax(70px, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 3px 5px;
    padding: 3px 4px;
  }
  .bet-label { grid-column: 1; grid-row: 1; }
  .bet-control input { grid-column: 2; grid-row: 1; }
  .bet-control > strong { grid-column: 3; grid-row: 1; font-size: 9px; }
  .raise-presets {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }
  .raise-presets button { min-width: 55px; min-height: 21px; }
  .wait-line { min-height: 42px; }
}

@media (max-width: 380px) and (orientation: portrait) {
  .table-hud { padding-right: 143px; }
  .hud-left small { display: none; }
  .seat { width: 103px; }
  .seat-0 { width: 122px; }
  .pname { max-width: 56px; }
  .board-row .playing-card { width: 34px; }
}

/* Short landscape gets the largest possible board and a single compact action strip. */
@media (min-width: 768px) and (max-height: 650px) {
  #screen-table.active {
    grid-template-rows: 40px minmax(0, 1fr) auto;
    gap: 4px;
    padding: calc(4px + var(--safe-t)) 5px calc(4px + var(--safe-b));
  }
  .table-hud { padding-top: 3px; padding-bottom: 3px; }
  .hud-tools { top: calc(10px + var(--safe-t)); }
  .felt-wrap {
    width: min(97cqw, calc(100cqh * 1.78), 1260px);
    aspect-ratio: 1.78 / 1;
  }
  .felt-core { top: 48%; }
  .seat { width: clamp(108px, 12cqw, 138px); }
  .seat-0 { width: clamp(126px, 14cqw, 158px); }
  .seat-body { min-height: 37px; }
  .avatar-wrap { width: 31px; height: 31px; }
  .seat-cards { min-height: 27px; }
  .seat.hero .seat-cards { min-height: 43px; }
  .seat.hero .playing-card { width: clamp(37px, 4cqw, 47px); }
  .board-row { min-height: 51px; }
  .board-row .playing-card { width: clamp(39px, 5cqw, 56px); }
  .dealer-chip { top: 34px; }
  .action-bar { padding: 4px 5px; }
  .act { min-height: 38px; }
  .bet-control { min-height: 24px; }
  .raise-presets button { min-height: 20px; }
  .log-wrap { bottom: calc(78px + var(--safe-b)); }
}

@keyframes turnRing {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

@keyframes betBadgeIn {
  from { opacity: 0; transform: translateY(4px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-ring,
  .street-bet,
  .playing-card { animation: none; }
}

/* Persistent card and chip motion layer. Existing nodes never replay these. */
.deck-anchor {
  position: absolute;
  z-index: 4;
  left: 52%;
  top: 16%;
  width: clamp(22px, 2.5cqw, 32px);
  aspect-ratio: 3 / 4.2;
  border: 1px solid rgba(231, 201, 133, 0.45);
  border-radius: 5px;
  background: url("../assets/img/card-back.webp") center / cover no-repeat;
  box-shadow:
    3px 2px 0 -1px #101827,
    5px 4px 0 -1px #8d6c31,
    0 6px 12px rgba(0, 0, 0, 0.4);
  transform: translateX(-50%) rotate(2deg);
  pointer-events: none;
}

.deck-anchor span {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.board-slot,
.hole-slot {
  display: grid;
  place-items: center;
  flex: none;
}

.board-slot {
  width: clamp(44px, 5.2cqw, 69px);
  min-height: clamp(52px, 7.5cqw, 82px);
}

.board-slot > .playing-card { width: 100%; }

.felt-wrap .playing-card { animation: none; }

.felt-wrap .playing-card.card-dealing {
  z-index: 18;
  animation: cardTravel 340ms cubic-bezier(.22, .8, .3, 1) var(--deal-delay, 0ms) both;
  will-change: transform, opacity;
}

.card-3d { transition: transform 400ms cubic-bezier(.22, .8, .3, 1); }
.playing-card.is-revealing .card-3d { transition-duration: 400ms; }

.dealer-marker {
  position: absolute;
  z-index: 8;
  width: clamp(18px, 2cqw, 25px);
  height: auto;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55));
  transform: translate(-50%, -50%);
  transition:
    left 340ms cubic-bezier(.22, .8, .3, 1),
    top 340ms cubic-bezier(.22, .8, .3, 1);
  pointer-events: none;
}

.chip-flight-layer {
  position: absolute;
  z-index: 20;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.chip-flight {
  position: absolute;
  width: 22px;
  height: 22px;
  animation: chipToPot 460ms cubic-bezier(.22, .8, .3, 1) var(--chip-delay, 0ms) both;
  will-change: transform, opacity;
}

.chip-flight.winner-flight {
  animation-name: potToWinner;
  animation-duration: 680ms;
}

.chip-flight img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.45));
}

.action-bar.animating {
  pointer-events: none;
}

.action-bar.animating .act,
.action-bar.animating .bet-control {
  opacity: 0.55;
}

@keyframes cardTravel {
  0% {
    opacity: 0;
    transform: translate(var(--deal-x), var(--deal-y)) rotate(-5deg) scale(0.9);
  }
  82% {
    opacity: 1;
    transform: translate(0, 0) rotate(0.7deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0) scale(1);
  }
}

@keyframes chipToPot {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.8);
  }
  18% { opacity: 1; }
  100% {
    opacity: 1;
    transform: translate(var(--chip-x), var(--chip-y)) scale(0.74);
  }
}

@keyframes potToWinner {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.78);
  }
  72% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(var(--chip-x), var(--chip-y)) scale(1);
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .deck-anchor {
    top: 31%;
    width: 23px;
  }
  .board-slot {
    width: clamp(35px, 10vw, 43px);
    min-height: 48px;
  }
  .dealer-marker { width: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .felt-wrap .playing-card.card-dealing,
  .chip-flight {
    animation-duration: 1ms;
    animation-delay: 0ms;
  }
  .card-3d,
  .dealer-marker { transition-duration: 1ms; }
}

/* Preserve complete card artwork, corner marks, and external shadows. */
.board-row {
  min-height: 0;
  padding: clamp(5px, 0.65cqw, 9px) 2px;
  overflow: visible;
}

.board-slot {
  min-height: 0;
  aspect-ratio: 2.5 / 3.5;
  overflow: visible;
}

.board-slot > .playing-card {
  width: 100%;
  height: 100%;
}

.seat-cards,
.board-slot,
.hole-slot,
.playing-card,
.card-3d,
.card-face {
  overflow: visible;
}

.card-front,
.card-back {
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

@media (max-width: 767px) and (orientation: portrait) {
  .board-row {
    min-height: 0;
    gap: 4px;
    padding-block: 5px;
  }

  .board-slot {
    min-height: 0;
    aspect-ratio: 2.5 / 3.5;
  }
}

/* Final commercial polish: quiet HUD, compact actions, atmospheric stage. */
#screen-table {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(173, 121, 52, 0.075), transparent 38%),
    radial-gradient(ellipse at 50% 55%, rgba(11, 67, 51, 0.13), transparent 52%),
    linear-gradient(145deg, #07111c 0%, #030710 48%, #020409 100%);
}

#screen-table::before {
  opacity: 1;
  background:
    radial-gradient(circle at 13% 24%, rgba(211, 165, 85, 0.055) 0 2px, transparent 4px),
    radial-gradient(circle at 83% 19%, rgba(223, 179, 98, 0.045) 0 3px, transparent 6px),
    radial-gradient(circle at 91% 65%, rgba(209, 152, 72, 0.035) 0 2px, transparent 5px),
    radial-gradient(circle at 8% 71%, rgba(207, 159, 78, 0.035) 0 3px, transparent 7px),
    linear-gradient(rgba(219, 185, 110, 0.013) 1px, transparent 1px),
    linear-gradient(90deg, rgba(219, 185, 110, 0.01) 1px, transparent 1px);
  background-size: auto, auto, auto, auto, 88px 88px, 88px 88px;
}

#screen-table::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 58%, transparent 35%, rgba(0, 2, 7, 0.34) 77%, rgba(0, 1, 4, 0.68) 100%),
    linear-gradient(180deg, rgba(194, 137, 59, 0.025), transparent 28%);
}

.table-root::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: 5%;
  width: min(82%, 1260px);
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(180, 126, 52, 0.07), rgba(0, 0, 0, 0.28) 55%, transparent 73%);
  filter: blur(20px);
  transform: translateX(-50%);
  pointer-events: none;
}

.felt-wrap {
  filter:
    drop-shadow(0 27px 31px rgba(0, 0, 0, 0.5))
    drop-shadow(0 3px 18px rgba(180, 128, 55, 0.055));
}

.table-hud {
  width: min(100%, 1480px);
  margin-inline: auto;
  border-color: rgba(219, 188, 119, 0.12);
  background: linear-gradient(180deg, rgba(12, 20, 33, 0.89), rgba(7, 13, 23, 0.86));
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.025);
}

.stat {
  height: 27px;
  min-height: 27px;
  padding-inline: 9px;
  border-color: rgba(219, 188, 119, 0.14);
  color: #d9c28e;
  background: rgba(255, 255, 255, 0.022);
  font-size: 8px;
}

.hud-tools {
  right: max(13px, calc((100% - 1480px) / 2 + 13px));
  gap: 5px;
}

.icon-btn {
  width: 27px;
  height: 27px;
  min-width: 27px;
  border-color: rgba(219, 188, 119, 0.14);
  background: linear-gradient(180deg, #151f30, #0d1522);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.22), inset 0 1px rgba(255, 255, 255, 0.025);
}

.log-toggle {
  width: 36px;
  min-width: 36px;
  height: 27px;
  border-radius: 8px;
  letter-spacing: 0.08em;
}

.action-bar {
  width: min(86%, 760px);
  height: 82px;
  min-height: 82px;
  margin-inline: auto;
  padding: 5px;
  border-color: rgba(220, 188, 117, 0.15);
  background: linear-gradient(180deg, rgba(12, 20, 32, 0.96), rgba(7, 12, 21, 0.97));
  box-shadow:
    0 -8px 24px rgba(0, 0, 0, 0.18),
    0 13px 28px rgba(0, 0, 0, 0.27),
    inset 0 1px rgba(255, 255, 255, 0.025);
}

.action-bar.locked {
  display: grid;
  align-items: center;
}

.action-inner {
  gap: 5px;
}

.action-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 0.8vw, 10px);
}

.act {
  min-height: 40px;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9px;
  box-shadow:
    0 5px 12px rgba(0, 0, 0, 0.24),
    inset 0 1px rgba(255, 255, 255, 0.055),
    inset 0 -1px rgba(0, 0, 0, 0.12);
}

.act img {
  width: 18px;
  height: 18px;
}

.act-copy {
  justify-items: start;
}

.act-copy strong {
  margin: 0;
  font-size: clamp(9px, 0.8vw, 11px);
  line-height: 1;
}

.act-copy small {
  margin-top: 3px;
  color: #7f8b9d;
  font-size: 5.5px;
  line-height: 1;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.act.danger {
  border-color: rgba(151, 65, 78, 0.3);
  background: linear-gradient(155deg, #351a24, #211219 74%);
}

.act.ghost {
  border-color: rgba(114, 137, 169, 0.2);
  background: linear-gradient(155deg, #19263a, #101825 74%);
}

.act.gold {
  border-color: rgba(236, 207, 139, 0.56);
  background: linear-gradient(155deg, #dec17a, #bd9249 72%);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.25),
    inset 0 1px rgba(255, 255, 255, 0.28),
    inset 0 -1px rgba(75, 48, 12, 0.2);
}

.act.gold .act-copy small { color: rgba(46, 31, 8, 0.58); }

.act.fire {
  border-color: rgba(160, 78, 54, 0.32);
  background: linear-gradient(155deg, #48231c, #281512 76%);
}

.act:hover:not(:disabled) {
  border-color: rgba(234, 206, 144, 0.44);
  filter: brightness(1.055);
  transform: translateY(-1px);
}

.act:active:not(:disabled) {
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.24);
  transform: translateY(1px);
}

.act:disabled {
  opacity: 0.28;
  filter: saturate(0.45);
}

.bet-control {
  width: min(100%, 560px);
  margin-inline: auto;
}

.action-bar:not(.locked):not(.animating) {
  border-color: rgba(222, 190, 117, 0.25);
  box-shadow:
    0 -8px 24px rgba(0, 0, 0, 0.18),
    0 13px 28px rgba(0, 0, 0, 0.27),
    0 0 20px rgba(213, 174, 93, 0.045),
    inset 0 1px rgba(255, 255, 255, 0.03);
}

.seat.hero.acting .seat-body {
  border-color: rgba(233, 203, 132, 0.56);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.36), 0 0 13px rgba(223, 187, 103, 0.11);
}

@media (max-width: 767px) and (orientation: portrait) {
  .table-hud {
    width: 100%;
  }

  .hud-tools {
    right: 8px;
    gap: 3px;
  }

  .action-bar {
    width: 100%;
    padding: 5px;
  }

  .action-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }

  .act {
    min-height: 42px;
    gap: 3px;
    padding-inline: 4px;
  }

  .act img { width: 14px; height: 14px; }
  .act-copy strong { font-size: 9px; }
  .act-copy small { font-size: 4.5px; }
  .bet-control { width: 100%; }
}

@media (min-width: 1600px) {
  .action-bar {
    width: min(78%, 760px);
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .action-bar {
    height: 112px;
    min-height: 112px;
  }
}

@media (min-width: 768px) and (max-height: 650px) {
  .action-bar {
    height: 78px;
    min-height: 78px;
  }
}

/*
 * Mobile landscape is a dedicated composition. It is intentionally driven by
 * both height and width so a short phone never inherits scaled desktop seats.
 */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1023px) {
  #screen-table.active {
    width: 100dvw;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 34px minmax(0, 1fr) 76px;
    gap: 3px;
    overflow: hidden;
    padding:
      max(3px, var(--safe-t))
      max(4px, var(--safe-r, 0px))
      max(3px, var(--safe-b))
      max(4px, var(--safe-l, 0px));
  }

  #screen-table::before,
  #screen-table::after {
    opacity: 0.1;
  }

  .table-hud {
    width: 100%;
    min-height: 0;
    padding: 2px 148px 2px 5px;
    gap: 5px;
    border-radius: 9px;
  }

  .hud-left { gap: 4px; }
  .hud-left > img {
    width: 24px;
    height: 24px;
  }
  .hud-left strong { font-size: 9px; }
  .hud-left small {
    max-width: 170px;
    margin-top: 2px;
    font-size: 6px;
  }
  .hud-right { gap: 3px; }
  .stat {
    height: 22px;
    min-height: 22px;
    padding: 2px 6px;
    font-size: 7px;
  }
  .hud-right .stat:last-child { display: none; }

  .hud-tools {
    top: max(6px, var(--safe-t));
    right: max(6px, var(--safe-r, 0px));
    gap: 2px;
  }
  .icon-btn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 5px;
  }
  .log-toggle {
    width: 31px;
    min-width: 31px;
    height: 26px;
    padding: 0;
    font-size: 6px;
  }

  .table-root {
    width: 100%;
    min-width: 0;
    min-height: 0;
    border-radius: 12px;
    overflow: visible;
  }
  .table-root::before { display: none; }

  .felt-wrap {
    width: min(98cqw, calc(100cqh * 2.05), 920px);
    height: auto;
    max-height: 100cqh;
    aspect-ratio: 2.05 / 1;
    filter: drop-shadow(0 10px 13px rgba(0, 0, 0, 0.42));
  }
  .felt-wrap::before {
    height: 11%;
    filter: blur(9px);
  }

  .felt-core {
    top: 46%;
    width: 70%;
    gap: 2px;
  }
  .pot-display {
    min-height: 20px;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 7px;
  }
  .pot-display img {
    width: 14px;
    height: 14px;
  }
  .pot-display small { font-size: 5px; }
  .pot-display strong { font-size: 9px; }
  .board-row {
    width: max-content;
    min-height: 48px;
    gap: 3px;
    padding: 2px;
  }
  .board-slot {
    width: clamp(28px, 4.8dvw, 42px);
    flex: 0 0 auto;
  }
  .board-row .playing-card {
    width: 100%;
  }
  .street-pill {
    min-width: 48px;
    padding: 2px 6px;
    font-size: 5px;
  }

  .seat,
  .seat-0 {
    width: clamp(76px, 10dvw, 98px);
  }
  .seat-0 { bottom: 0; }
  .seat-1 {
    left: 0;
    top: auto;
    bottom: 8%;
  }
  .seat-2 {
    left: 0;
    top: 8%;
    bottom: auto;
  }
  .seat-3 {
    left: 50%;
    top: 0;
    transform: translateX(-50%);
  }
  .seat-4 {
    left: auto;
    right: 0;
    top: 8%;
  }
  .seat-5 {
    left: auto;
    right: 0;
    top: auto;
    bottom: 8%;
  }

  .seat-body,
  .seat.hero .seat-body {
    position: relative;
    width: clamp(74px, 9.6dvw, 94px);
    min-width: 0;
    min-height: 28px;
    gap: 3px;
    padding: 2px 5px 2px 2px;
    border-radius: 7px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(4px);
  }
  .seat.hero .seat-body {
    width: clamp(80px, 10.5dvw, 104px);
  }
  .avatar-wrap {
    width: clamp(22px, 2.8dvw, 28px);
    height: clamp(22px, 2.8dvw, 28px);
    border-radius: 6px;
  }
  .avatar { border-radius: 5px; }
  .pulse-ring { border-radius: 6px; }
  .name-row { gap: 2px; }
  .pname {
    max-width: clamp(38px, 5dvw, 52px);
    font-size: 7px;
  }
  .stack-row {
    margin-top: 1px;
    gap: 2px;
    font-size: 6.5px;
  }
  .stack-row img {
    width: 7px;
    height: 7px;
  }
  .blind-tag {
    padding: 1px 3px;
    font-size: 5px;
  }
  .status-tag {
    position: absolute;
    right: 2px;
    bottom: -5px;
    z-index: 8;
    max-width: 48px;
    margin: 0;
    overflow: hidden;
    padding: 1px 3px;
    font-size: 5px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .seat-cards,
  .seat.hero .seat-cards {
    min-height: 27px;
    gap: 2px;
  }
  .seat .playing-card.sm {
    width: clamp(20px, 2.4dvw, 24px);
  }
  .seat.hero .seat-cards { min-height: 42px; }
  .seat.hero .playing-card {
    width: clamp(28px, 4.6dvw, 40px);
  }

  .street-bet {
    position: absolute;
    z-index: 9;
    right: -2px;
    min-height: 13px;
    padding: 1px 4px;
    font-size: 5px;
  }
  .seat-0 .street-bet,
  .seat-1 .street-bet,
  .seat-5 .street-bet { top: -4px; }
  .seat-2 .street-bet,
  .seat-3 .street-bet,
  .seat-4 .street-bet { bottom: -4px; }
  .street-bet img {
    width: 7px;
    height: 7px;
  }

  .dealer-marker { width: 17px; }
  .deck-anchor {
    width: 24px;
    height: 34px;
  }

  .felt-wrap.players-4 .seat-0 {
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
  }
  .felt-wrap.players-4 .seat-1 {
    left: 0;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }
  .felt-wrap.players-4 .seat-2 {
    left: 50%;
    top: 0;
    transform: translateX(-50%);
  }
  .felt-wrap.players-4 .seat-3 {
    left: auto;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
  }

  .felt-wrap.players-8 .seat {
    width: clamp(68px, 9dvw, 88px);
  }
  .felt-wrap.players-8 .seat-0 {
    left: 50%;
    bottom: 0;
  }
  .felt-wrap.players-8 .seat-1 {
    left: 0;
    top: auto;
    bottom: 7%;
  }
  .felt-wrap.players-8 .seat-2 {
    left: 0;
    top: 34%;
    bottom: auto;
  }
  .felt-wrap.players-8 .seat-3 {
    left: 13%;
    top: 0;
    transform: none;
  }
  .felt-wrap.players-8 .seat-4 {
    left: 50%;
    right: auto;
    top: 0;
    transform: translateX(-50%);
  }
  .felt-wrap.players-8 .seat-5 {
    left: auto;
    right: 13%;
    top: 0;
  }
  .felt-wrap.players-8 .seat-6 {
    left: auto;
    right: 0;
    top: 34%;
  }
  .felt-wrap.players-8 .seat-7 {
    left: auto;
    right: 0;
    top: auto;
    bottom: 7%;
  }

  .action-bar {
    width: 100%;
    height: 76px;
    min-height: 76px;
    padding: 3px 4px;
    border-radius: 9px;
  }
  .action-inner { gap: 2px; }
  .action-grid { gap: 3px; }
  .act {
    min-height: 42px;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 7px;
  }
  .act img {
    width: 17px;
    height: 17px;
  }
  .act-copy strong {
    margin-top: 1px;
    font-size: 8px;
  }
  .act-copy small {
    margin-top: 2px;
    font-size: 4.5px;
  }
  .bet-control {
    width: min(100%, 620px);
    min-height: 24px;
    grid-template-columns: minmax(70px, 1fr) auto 38px;
    gap: 4px;
    padding: 1px 3px;
  }
  .bet-label { display: none; }
  .bet-control input[type="range"] { height: 16px; }
  .bet-control > strong {
    min-width: 34px;
    font-size: 8px;
  }
  .raise-presets { gap: 2px; }
  .raise-presets button {
    min-width: 32px;
    min-height: 20px;
    padding: 1px 3px;
    font-size: 6px;
  }
  .wait-line {
    min-height: 0;
    height: 100%;
    padding: 2px;
  }
  .wait-line small { font-size: 5px; }
  .wait-line strong { font-size: 8px; }

  .log-wrap {
    top: calc(38px + var(--safe-t));
    right: max(4px, var(--safe-r, 0px));
    bottom: calc(79px + var(--safe-b));
    width: min(78dvw, 280px);
  }
}

@media (orientation: landscape) and (max-height: 400px) and (max-width: 1023px) {
  #screen-table.active {
    grid-template-rows: 32px minmax(0, 1fr) 66px;
    gap: 2px;
    padding:
      max(2px, var(--safe-t))
      max(3px, var(--safe-r, 0px))
      max(2px, var(--safe-b))
      max(3px, var(--safe-l, 0px));
  }

  .table-hud {
    padding-right: 124px;
  }
  .hud-left > img {
    width: 22px;
    height: 22px;
  }
  .hud-left strong { font-size: 8px; }
  .hud-left small {
    max-width: 145px;
    font-size: 5.5px;
  }
  .stat {
    height: 20px;
    min-height: 20px;
    padding-inline: 5px;
    font-size: 6px;
  }
  .hud-tools {
    top: max(4px, var(--safe-t));
    right: max(4px, var(--safe-r, 0px));
  }
  .icon-btn {
    width: 27px;
    height: 27px;
    min-width: 27px;
  }
  .log-toggle {
    width: 29px;
    min-width: 29px;
    height: 27px;
  }
  #hudHow { display: none; }

  .felt-wrap {
    width: min(99cqw, calc(100cqh * 2.05));
  }
  .felt-core {
    top: 45%;
    width: 72%;
  }
  .pot-display { min-height: 18px; }
  .board-row {
    min-height: 42px;
    gap: 2px;
  }
  .board-slot {
    width: clamp(30px, 5dvw, 36px);
  }
  .street-pill { display: none; }

  .seat,
  .seat-0 {
    width: clamp(72px, 13.5dvw, 86px);
    gap: 0;
  }
  .seat-body,
  .seat.hero .seat-body {
    width: clamp(70px, 13dvw, 84px);
    min-height: 24px;
  }
  .seat.hero .seat-body {
    width: clamp(76px, 14dvw, 90px);
  }
  .avatar-wrap {
    width: 22px;
    height: 22px;
  }
  .pname {
    max-width: 40px;
    font-size: 7px;
  }
  .stack-row { font-size: 6.25px; }
  .seat-cards { min-height: 25px; }
  .seat .playing-card.sm { width: clamp(20px, 3.5dvw, 22px); }
  .seat.hero .seat-cards { min-height: 40px; }
  .seat.hero .playing-card { width: clamp(28px, 5.5dvw, 34px); }

  .felt-wrap.players-8 .seat {
    width: clamp(64px, 12dvw, 76px);
  }

  .action-bar {
    height: 66px;
    min-height: 66px;
    padding: 3px;
  }
  .act {
    min-height: 38px;
    gap: 3px;
    padding: 2px 4px;
  }
  .act img {
    width: 14px;
    height: 14px;
  }
  .act-copy strong { font-size: 8.5px; }
  .act-copy small { font-size: 5px; }
  .act[data-act="fold"] .act-copy small,
  .act[data-act="raise"] .act-copy small,
  .act[data-act="bet"] .act-copy small,
  .act[data-act="check"] .act-copy small {
    display: none;
  }
  .bet-control {
    min-height: 18px;
    grid-template-columns: minmax(64px, 1fr) auto 34px;
    gap: 3px;
    padding: 0 2px;
  }
  .bet-control input[type="range"] { height: 14px; }
  .bet-control > strong {
    min-width: 30px;
    font-size: 7px;
  }
  .raise-presets button {
    min-width: 29px;
    min-height: 18px;
    font-size: 5.5px;
  }
  .log-wrap {
    top: calc(35px + var(--safe-t));
    bottom: calc(69px + var(--safe-b));
  }
}

@media (orientation: landscape) and (max-height: 330px) and (max-width: 600px) {
  .hud-left > img { display: none; }
  .hud-left small { max-width: 130px; }
  .table-hud { padding-left: 6px; }
  .seat-1,
  .seat-5 { bottom: 4%; }
  .seat-2,
  .seat-4 { top: 4%; }
  .status-tag { max-width: 42px; }
}

/* Keep both private cards visually separate without changing their size. */
.seat-cards {
  column-gap: clamp(5px, 0.5cqw, 7px);
  padding-inline: 4px;
}

@media (max-width: 767px) and (orientation: portrait) {
  .seat-cards,
  .seat.hero .seat-cards {
    column-gap: 5px;
    padding-inline: 3px;
  }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1023px) {
  .seat-cards,
  .seat.hero .seat-cards {
    column-gap: 3px;
    padding-inline: 2px;
  }
}

/* The top-center is reserved for the house dealer and deck, never a player. */
.dealer-station {
  position: absolute;
  z-index: 6;
  top: -4.5%;
  left: 50%;
  width: clamp(150px, 15cqw, 194px);
  height: clamp(82px, 9.5cqw, 108px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  color: #ead39b;
  transform: translateX(-50%);
  pointer-events: none;
}

.dealer-station > .dealer-host {
  width: clamp(74px, 8.2cqw, 96px);
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.45));
}

.dealer-station > span {
  position: absolute;
  top: 34%;
  left: calc(50% + 33px);
  min-width: 73px;
  display: grid;
  padding: 5px 7px;
  border: 1px solid rgba(225, 192, 117, 0.28);
  border-radius: 8px;
  line-height: 1;
  text-align: left;
  background: linear-gradient(155deg, rgba(19, 29, 44, 0.97), rgba(8, 14, 24, 0.97));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.32), inset 0 1px rgba(255, 255, 255, 0.05);
}

.dealer-station strong {
  font-family: Cinzel, serif;
  font-size: 9px;
  letter-spacing: 0.09em;
}

.dealer-station small {
  margin-top: 3px;
  color: #8793a4;
  font-size: 5px;
  letter-spacing: 0.08em;
}

.deck-anchor {
  left: 50%;
  top: 15%;
  z-index: 10;
}

.felt-wrap.players-4 .seat-0,
.felt-wrap.players-5 .seat-0,
.felt-wrap.players-6 .seat-0,
.felt-wrap.players-8 .seat-0 {
  left: 50%;
  right: auto;
  top: auto;
  bottom: 0;
  transform: translateX(-50%);
}

.felt-wrap.players-4 .seat-1 {
  left: 0;
  right: auto;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

.felt-wrap.players-4 .seat-2 {
  left: auto;
  right: 0;
  top: 10%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-4 .seat-3 {
  left: auto;
  right: 0;
  top: auto;
  bottom: 10%;
  transform: none;
}

.felt-wrap.players-5 .seat-1 {
  left: 0;
  right: auto;
  top: auto;
  bottom: 14%;
  transform: none;
}

.felt-wrap.players-5 .seat-2 {
  left: 0;
  right: auto;
  top: 10%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-5 .seat-3 {
  left: auto;
  right: 0;
  top: auto;
  bottom: 14%;
  transform: none;
}

.felt-wrap.players-5 .seat-4 {
  left: auto;
  right: 0;
  top: 10%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-6 .seat-1 {
  left: 0;
  right: auto;
  top: auto;
  bottom: 14%;
  transform: none;
}

.felt-wrap.players-6 .seat-2 {
  left: 0;
  right: auto;
  top: 10%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-6 .seat-3 {
  left: auto;
  right: 0;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

.felt-wrap.players-6 .seat-4 {
  left: auto;
  right: 0;
  top: 5%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-6 .seat-5 {
  left: auto;
  right: 0;
  top: auto;
  bottom: 14%;
  transform: none;
}

.felt-wrap.players-8 .seat-1 {
  left: 0;
  right: auto;
  top: auto;
  bottom: 0;
  transform: none;
}

.felt-wrap.players-8 .seat-2 {
  left: 0;
  right: auto;
  top: 53%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-8 .seat-3 {
  left: 0;
  right: auto;
  top: 27%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-8 .seat-4 {
  left: auto;
  right: 0;
  top: 0;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-8 .seat-5 {
  left: auto;
  right: 0;
  top: 38%;
  bottom: auto;
  transform: none;
}

.felt-wrap.players-8 .seat-6 {
  left: auto;
  right: 0;
  top: auto;
  bottom: 0;
  transform: none;
}

.felt-wrap.players-8 .seat-7 {
  left: 0;
  right: auto;
  top: 0;
  bottom: auto;
  transform: none;
}

@media (max-width: 767px) and (orientation: portrait) {
  .dealer-station {
    top: -1%;
    width: 104px;
    height: 60px;
  }

  .dealer-station > .dealer-host { width: 48px; height: 60px; }
  .dealer-station > span {
    top: 28%;
    left: calc(50% + 17px);
    min-width: 50px;
    padding: 3px 4px;
  }
  .dealer-station strong { font-size: 6px; }
  .dealer-station small { display: none; }
  .deck-anchor { top: 25%; }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1023px) {
  .dealer-station {
    top: -2%;
    width: 90px;
    height: 50px;
  }

  .dealer-station > .dealer-host { width: 42px; height: 50px; }
  .dealer-station > span {
    top: 27%;
    left: calc(50% + 14px);
    min-width: 43px;
    padding: 2px 4px;
    border-radius: 6px;
  }
  .dealer-station strong { font-size: 6px; }
  .dealer-station small { display: none; }
  .deck-anchor { left: 50%; top: 18%; }

  .felt-wrap.players-6 .seat-3 {
    right: 20%;
  }
}

.rotate-gate {
  display: none;
}

@media (orientation: portrait) and (max-width: 1023px) {
  #screen-table.active .rotate-gate {
    position: absolute;
    z-index: 200;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding:
      max(18px, var(--safe-t))
      max(18px, var(--safe-r))
      max(18px, var(--safe-b))
      max(18px, var(--safe-l));
    background:
      radial-gradient(circle at 50% 44%, rgba(119, 87, 42, 0.2), transparent 42%),
      rgba(4, 9, 16, 0.97);
    backdrop-filter: blur(12px);
    pointer-events: auto;
  }

  .rotate-card {
    width: min(78dvw, 280px);
    display: grid;
    justify-items: center;
    padding: 18px 16px;
    border: 1px solid rgba(225, 193, 119, 0.3);
    border-radius: 14px;
    color: #f2ead8;
    text-align: center;
    background: linear-gradient(155deg, rgba(21, 31, 47, 0.98), rgba(8, 14, 24, 0.99));
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.46), inset 0 1px rgba(255, 255, 255, 0.06);
  }

  .rotate-phone {
    width: 42px;
    height: 42px;
    margin-bottom: 10px;
    object-fit: contain;
    filter: drop-shadow(0 0 9px rgba(215, 182, 99, 0.15));
    animation: rotateHint 1.8s ease-in-out infinite;
  }

  .rotate-card small {
    color: #cda954;
    font-size: 8px;
    letter-spacing: 0.16em;
  }

  .rotate-card h2 {
    margin: 6px 0 7px;
    font-family: Cinzel, serif;
    font-size: clamp(17px, 5.6dvw, 22px);
    line-height: 1.1;
  }

  .rotate-card p {
    max-width: 230px;
    margin: 0;
    color: #9aa5b5;
    font-size: 10px;
    line-height: 1.45;
  }

  .rotate-card button {
    min-width: 150px;
    min-height: 38px;
    margin-top: 14px;
    padding: 7px 14px;
    border: 1px solid #e5c978;
    border-radius: 10px;
    color: #241a08;
    font-family: Cinzel, serif;
    font-size: 10px;
    font-weight: 700;
    background: linear-gradient(145deg, #e0c276, #b98a3f);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.3);
    touch-action: manipulation;
  }
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  45%, 65% { transform: rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-phone { animation: none; }
}
