/* Gameplay layout — positioning/sizing only */

.game-hud {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 1.55fr) minmax(0, 1fr);
  gap: var(--gap-sm, 8px);
  align-items: center;
  padding:
    calc(10px + env(safe-area-inset-top))
    var(--pad-inline, 14px)
    4px;
}
.hud-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  min-height: 38px;
  padding: 4px clamp(9px, 2.8vw, 15px) 5px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(3, 7, 13, 0.5) 14%,
    rgba(3, 7, 13, 0.68) 50%,
    rgba(3, 7, 13, 0.5) 86%,
    transparent
  );
  box-shadow: inset 0 1px rgba(228, 193, 106, 0.08);
}
.game-hud .chip {
  justify-self: end;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.5vw, 7px);
  min-width: 0;
  max-width: min(38vw, 132px);
  padding: 4px clamp(8px, 2.5vw, 12px) 4px 5px;
  line-height: 1;
}
.game-hud .icon-btn {
  justify-self: start;
  padding: 0;
  line-height: 0;
}
.game-hud .icon-btn img,
.game-hud .chip img {
  display: block;
}
.game-hud .chip b {
  line-height: 1;
}
#hud-round {
  font-size: clamp(11px, 2.8vw, 12px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hud-status {
  font-size: clamp(12px, 3vw, 13px);
  color: rgba(247, 240, 223, 0.96);
  opacity: 1;
  min-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.table-stage {
  position: relative;
  z-index: 3;
  flex: 1 1 auto;
  min-height: 0;
  perspective: 900px;
  overflow: visible;
  margin-inline: clamp(4px, 1.5vw, 12px);
}
.table-stage::before {
  content: "";
  position: absolute;
  inset: 8% 7% 18%;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, rgba(255, 224, 151, 0.065), transparent 54%);
}
.table-felt {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 3%;
  bottom: -18%;
  border-radius: 48% / 34%;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 220, 140, 0.1), transparent 42%),
    radial-gradient(ellipse at 50% 78%, rgba(18, 70, 48, 0.45), transparent 55%);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.35),
    0 20px 40px rgba(0, 0, 0, 0.35);
  transform: rotateX(12deg);
  transform-origin: center 52%;
  pointer-events: none;
  z-index: 1;
}

/* Compact seat wrappers — absolute for placement, flex for children */
.seat {
  --seat-avatar: clamp(40px, 11vw, 50px);
  --seat-name: clamp(10px, 2.8vw, 12px);
  --seat-mini: clamp(20px, 5.5vw, 26px);
  position: absolute;
  z-index: 4;
  display: grid;
  grid-template-columns: var(--seat-avatar) minmax(42px, 58px);
  grid-template-rows: auto auto;
  grid-template-areas:
    "avatar info"
    "cards cards";
  align-items: center;
  justify-items: center;
  column-gap: 5px;
  row-gap: 2px;
  width: max-content;
  max-width: 116px;
  pointer-events: none;
}
.seat-avatar {
  grid-area: avatar;
  width: var(--seat-avatar);
  height: var(--seat-avatar);
  border-radius: 50%;
  border: 0;
  overflow: visible;
  position: relative;
  background: rgba(3, 8, 15, .7);
  flex: 0 0 auto;
}
.seat-avatar::after {
  content: "";
  position: absolute;
  inset: -18%;
  background: url("../assets/decorative/avatar_frame.webp") center / contain no-repeat;
  z-index: 2;
  pointer-events: none;
}
.seat-avatar img {
  position: absolute;
  inset: 10%;
  width: 80%;
  height: 80%;
  object-fit: contain;
  border-radius: 50%;
}
.seat-info {
  grid-area: info;
  min-width: 0;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(5, 8, 12, 0.62);
  overflow: hidden;
  text-align: center;
}
.seat-name,
.seat-meta {
  font-size: var(--seat-name);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.seat-meta {
  font-size: calc(var(--seat-name) - 1px);
  font-weight: 400;
  color: rgba(247, 240, 223, 0.7);
}
.seat-count {
  grid-area: cards;
  position: relative;
  justify-self: start;
  align-self: center;
  margin-left: calc(var(--seat-mini) + 5px);
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--gold);
  display: grid;
  place-items: center;
  font-size: 9px;
  z-index: 5;
}
.seat.is-turn .seat-avatar {
  box-shadow: 0 0 0 3px rgba(228, 193, 106, 0.85);
  filter: drop-shadow(0 0 5px rgba(228, 193, 106, 0.5));
  animation: activeSeatPulse 0.72s ease-out 1;
}
@keyframes activeSeatPulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.045); filter: drop-shadow(0 0 11px rgba(246, 226, 162, 0.82)); }
  100% { transform: scale(1); }
}
.seat.is-trick-winner .seat-avatar,
.you-chip.is-trick-winner {
  animation: winnerSeatGlow .9s ease-out 1;
}
@keyframes winnerSeatGlow {
  0%, 100% { filter: none; }
  40% { filter: drop-shadow(0 0 13px rgba(246, 226, 162, .9)); }
}
.seat.is-out { opacity: 0.42; filter: grayscale(0.6); }
.seat.is-leader .seat-avatar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  transform: translateX(-50%);
  z-index: 3;
  box-shadow: 0 0 8px rgba(228, 193, 106, 0.9);
}

/* Even 6-player ring — clear margin from table rim */
#seat-ai-1 { left: 5%; top: 56%; }
#seat-ai-2 { left: 6%; top: 17%; }
#seat-ai-3 { top: 5%; left: 50%; transform: translateX(-50%); }
#seat-ai-4 { right: 6%; top: 17%; }
#seat-ai-5 { right: 5%; top: 56%; }
#seat-ai-4,
#seat-ai-5 {
  grid-template-columns: minmax(42px, 58px) var(--seat-avatar);
  grid-template-areas:
    "info avatar"
    "cards cards";
}

.seat-cards {
  grid-area: cards;
  position: relative;
  justify-self: start;
  width: var(--seat-mini);
  height: calc(var(--seat-mini) * 1.35);
  margin-top: 0;
  pointer-events: none;
}
#seat-ai-1 .seat-cards,
#seat-ai-2 .seat-cards {
  justify-self: end;
}
#seat-ai-1 .seat-count,
#seat-ai-2 .seat-count {
  justify-self: end;
  margin-left: 0;
  transform: translate(4px, 3px);
}
#seat-ai-3 .seat-cards {
  justify-self: center;
}
#seat-ai-3 .seat-count {
  justify-self: center;
  margin-left: var(--seat-mini);
  transform: translate(1px, 3px);
}
#seat-ai-4 .seat-cards,
#seat-ai-5 .seat-cards {
  justify-self: start;
}
#seat-ai-4 .seat-count,
#seat-ai-5 .seat-count {
  justify-self: start;
  margin-left: 0;
  transform: translate(-5px, 3px);
}
#seat-ai-3 .seat-cards,
#seat-ai-4 .seat-cards,
#seat-ai-5 .seat-cards {
  left: auto;
  right: auto;
  transform: none;
}
.ai-card-back {
  position: absolute;
  width: var(--seat-mini);
  height: calc(var(--seat-mini) * 1.4);
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.4));
  left: 50%;
  top: 0;
  opacity: 0;
  transform: translateX(-50%);
}
.ai-card-back:last-child {
  opacity: 1;
  transform: translateX(-50%);
}

.pass-bubble {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translate(-50%, 6px);
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(8, 10, 18, 0.88);
  border: 1px solid rgba(228, 193, 106, 0.55);
  color: var(--gold-2);
  font-size: 10px;
  letter-spacing: 0.14em;
  opacity: 0;
  pointer-events: none;
  z-index: 12;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.pass-bubble.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.pot {
  position: absolute;
  left: 50%;
  top: 21%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  z-index: 4;
  pointer-events: none;
  opacity: 0.72;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pot img { width: 16px; height: 16px; margin: 0; object-fit: contain; }
.pot b { color: var(--gold-2); font-size: 10px; }
.table-ornament {
  position: absolute;
  width: min(42%, 176px);
  height: auto;
  aspect-ratio: 1;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  opacity: .13;
  z-index: 2;
  object-fit: contain;
  pointer-events: none;
}
.deck-holder {
  position: absolute;
  width: clamp(48px, 14vw, 66px);
  height: auto;
  aspect-ratio: 3 / 4;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  opacity: .42;
  z-index: 3;
  object-fit: contain;
  pointer-events: none;
}
#deal-deck {
  position: absolute;
  width: clamp(42px, 12vw, 54px);
  height: auto;
  aspect-ratio: 54 / 76;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  z-index: 6;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
#deal-deck.is-empty { opacity: 0; }
#deal-deck img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.45));
}
#deal-deck img:nth-child(2) { transform: translate3d(2px, -2px, 0) rotate(3deg); }
#deal-deck img:nth-child(3) { transform: translate3d(-2px, 2px, 0) rotate(-2deg); }

#card-fly-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}
.fly-card {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate3d(0,0,0);
  will-change: transform, opacity;
  filter: drop-shadow(0 12px 14px rgba(0,0,0,.5));
  z-index: 41;
}
.fly-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Center play zone — slightly above geometric center */
#play-area {
  position: absolute;
  left: 17%;
  right: 17%;
  top: 24%;
  height: 43%;
  z-index: 5;
  pointer-events: none;
}
.played-card {
  position: absolute;
  isolation: isolate;
  width: clamp(42px, 10.5vw, 50px);
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.45));
  transition: transform 0.2s cubic-bezier(.22,.8,.3,1), filter 0.2s ease, opacity 0.2s ease;
}
.played-card::before {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  z-index: -1;
}
.played-card.is-landing img { animation: cardSettle .34s cubic-bezier(.22,.8,.3,1); }
.played-card.is-catch-impact::before {
  background: radial-gradient(circle, rgba(246,226,162,.36), transparent 68%);
  animation: catchRipple .62s ease-out;
}
.played-card.is-pass-impact::before {
  background: radial-gradient(circle, rgba(113,132,151,.24), transparent 68%);
  animation: passRipple .5s ease-out;
}
.played-card.is-overtaken {
  opacity: .7;
  filter: brightness(.72) drop-shadow(0 7px 8px rgba(0,0,0,.42));
}
@keyframes cardSettle {
  0% { transform: translateY(-5px) scale(1.025); }
  55% { transform: translateY(1px) scale(.995); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes catchRipple {
  0% { opacity: 0; transform: scale(.55); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.55); }
}
@keyframes passRipple {
  0% { opacity: 0; transform: scale(.7); }
  40% { opacity: .7; }
  100% { opacity: 0; transform: scale(1.35); }
}
.played-card img {
  width: 100%;
  object-fit: contain;
}
.play-tag {
  position: absolute;
  left: 50%;
  bottom: -18px;
  display: block;
  transform: translate(-50%, 3px);
  text-align: center;
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--gold-2);
  background: rgba(5, 8, 12, 0.8);
  border: 1px solid rgba(228, 193, 106, 0.35);
  border-radius: 999px;
  padding: 3px 6px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.play-tag.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.played-card.is-revealing img {
  animation: cardReveal 0.35s cubic-bezier(.22,.8,.3,1);
}
@keyframes cardReveal {
  from { transform: rotateY(90deg) scale(0.92); opacity: 0.4; }
  to { transform: rotateY(0) scale(1); opacity: 1; }
}

/* Landing slots around center — match 6-seat ring */
.seat-from-0 { left: 50%; top: 82%; transform: translate(-50%, -50%); }
.seat-from-1 { left: 30%; top: 47%; transform: translate(-50%, -50%); }
.seat-from-2 { left: 36%; top: 25%; transform: translate(-50%, -50%); }
.seat-from-3 { left: 50%; top: 8%; transform: translate(-50%, -50%); }
.seat-from-4 { left: 64%; top: 25%; transform: translate(-50%, -50%); }
.seat-from-5 { left: 70%; top: 47%; transform: translate(-50%, -50%); }
.played-card.is-winning {
  filter: drop-shadow(0 0 16px rgba(246, 226, 162, 0.9));
  transform: translate(-50%, -50%) scale(1.08);
}

/* Human cohesive zone */
.player-zone {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1dvh, 12px);
  padding:
    0
    var(--pad-inline, 14px)
    calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent 0%, rgba(5, 6, 12, 0.55) 18%, rgba(5, 6, 12, 0.88) 100%);
}
.hand-wrap {
  position: relative;
  z-index: 6;
  height: clamp(136px, 19dvh, 170px);
  padding: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.you-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-size: clamp(11px, 2.8vw, 13px);
  color: var(--gold-2);
  margin-bottom: 2px;
  position: relative;
  z-index: 2;
}
.you-chip img {
  width: clamp(20px, 5vw, 26px);
  height: clamp(20px, 5vw, 26px);
  border-radius: 50%;
  border: 1px solid var(--gold);
  object-fit: contain;
}
#hand-row {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 4px;
}
.hand-card {
  --hand-w: clamp(62px, 18vw, 78px);
  --overlap: -0.3;
  position: relative;
  width: var(--hand-w);
  margin: 0 calc(var(--hand-w) * var(--overlap));
  padding: 0;
  border: 0;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  line-height: 0;
  transform: translateY(0) rotate(var(--rot, 0deg));
  transform-origin: bottom center;
  border-radius: 8%;
  /* box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18); */
  flex: 0 0 auto;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: grab;
}
.hand-card:focus,
.hand-card:focus-visible {
  outline: 0;
}
.hand-card img {
  width: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.hand-card.is-dragging {
  z-index: 100 !important;
  cursor: grabbing;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22);
  transition: none !important;
}
.hand-card.is-drag-neighbor {
  transition: transform 190ms cubic-bezier(.22,.8,.3,1) !important;
}
.hand-card.is-selected {
  transform: translateY(-12px) rotate(0deg) scale(1.04);
  z-index: 3;
}
.hand-card.is-selected::before {
  content: none;
}
.hand-card.hint-cut::after,
.hand-card.hint-lead::after,
.hand-card.hint-fold::after {
  content: none;
}

.action-bar {
  position: relative;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm, 8px);
  min-height: 48px;
}
.action-bar .btn {
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  padding-block: 6px;
  line-height: 1;
}
.action-bar .action-side {
  flex: 0 1 clamp(96px, 28vw, 120px);
  width: clamp(96px, 28vw, 120px);
  min-height: 46px;
  font-size: clamp(10px, 2.6vw, 12px);
  letter-spacing: 0.04em;
  padding-inline: clamp(9px, 2.6vw, 13px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.action-bar .action-center {
  flex: 1 1 auto;
  min-width: 0;
  max-width: min(46%, 180px);
  min-height: 46px;
  font-size: clamp(10px, 2.6vw, 12px);
  letter-spacing: 0.04em;
  padding-inline: clamp(12px, 3.2vw, 18px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.action-bar .btn img {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  object-fit: contain;
  object-position: center;
}
#btn-play-card:disabled {
  opacity: 1;
  cursor: default;
}
#btn-play-card.is-waiting {
  background: none;
  box-shadow: none;
  color: rgba(247, 240, 223, 0.72);
  text-shadow: none;
  font-weight: 600;
}
#btn-play-card.is-ready {
  color: #fff3ca;
}
#btn-force-fold:disabled {
  opacity: 0.42;
}
.btn-force.is-on {
  background: rgba(196, 73, 74, 0.2);
  border-color: rgba(196, 73, 74, 0.6);
  color: #ffd0d0;
}

.round-five .table-felt { box-shadow: inset 0 0 58px rgba(228, 193, 106, 0.2), inset 0 0 100px rgba(0,0,0,.24), 0 20px 40px rgba(0,0,0,.35); }
.round-five .table-stage::before {
  background: radial-gradient(ellipse at 50% 47%, rgba(246,226,162,.13), transparent 48%);
  animation: tensionTablePulse 2.8s ease-in-out infinite;
}
.round-six .table-felt {
  background:
    linear-gradient(rgba(2, 5, 10, 0.13), rgba(2, 5, 10, 0.2)),
    radial-gradient(ellipse at 50% 42%, rgba(255, 220, 140, 0.055), transparent 42%),
    radial-gradient(ellipse at 50% 78%, rgba(13, 53, 37, 0.4), transparent 55%);
  box-shadow:
    inset 0 0 76px rgba(0, 0, 0, 0.42),
    0 20px 40px rgba(0, 0, 0, 0.35);
}
.round-six .played-card.is-winning {
  filter: drop-shadow(0 0 7px rgba(246, 226, 162, 0.62));
  box-shadow: 0 0 0 1px rgba(255, 226, 145, 0.82);
  border-radius: 7%;
  transform: translate(-50%, -50%) scale(1);
  animation: finalWinnerCardPulse .68s ease-out 1;
}
.round-six .seat.is-trick-winner .seat-avatar,
.round-six .you-chip.is-trick-winner {
  animation: finalWinnerSeatPulse .78s ease-out 1;
}

@keyframes tensionTablePulse {
  0%, 100% { opacity: .55; }
  50% { opacity: .9; }
}
@keyframes finalWinnerCardPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  48% { transform: translate(-50%, -50%) scale(1.04); }
}
@keyframes finalWinnerSeatPulse {
  0%, 100% { filter: none; }
  45% { filter: drop-shadow(0 0 8px rgba(246, 226, 162, .68)); }
}

body.result-win .table-stage {
  animation: resultWinGlow 1.25s ease-out 1;
}
body.result-lose .table-stage {
  animation: resultLoseDim .8s ease-out 1;
}
@keyframes resultWinGlow {
  0%, 100% { filter: brightness(1); }
  42% { filter: brightness(1.13) drop-shadow(0 0 18px rgba(228,193,106,.3)); }
}
@keyframes resultLoseDim {
  0% { filter: brightness(1); }
  50% { filter: brightness(.82) saturate(.84); }
  100% { filter: brightness(.94); }
}

.you-chip.is-turn {
  box-shadow: 0 0 0 2px rgba(228,193,106,.72), 0 0 12px rgba(228,193,106,.3);
  animation: activeSeatPulse .72s ease-out 1;
}

@media (prefers-reduced-motion: reduce) {
  .seat.is-turn .seat-avatar,
  .seat.is-trick-winner .seat-avatar,
  .you-chip.is-turn,
  .you-chip.is-trick-winner,
  .played-card.is-landing img,
  .played-card.is-catch-impact::before,
  .played-card.is-pass-impact::before,
  .round-five .table-stage::before,
  .round-six .played-card.is-winning,
  .round-six .seat.is-trick-winner .seat-avatar,
  .round-six .you-chip.is-trick-winner,
  body.result-win .table-stage,
  body.result-lose .table-stage {
    animation: none;
  }
}
