.play-table {
  --card-ratio: .64;
  --hand-width: min(11.2cqw, 10.6cqh);
  --hand-overlap: calc(var(--hand-width) * -.62);
  --pile-width: min(9.5cqw, 7.25cqh);
  --slot-width: min(10cqw, calc((19cqh - max(22px,3.6cqh) - max(16px,3cqh) - 13px) * var(--card-ratio)));
  width: min(100%, 820px);
  container-type: size;
  overflow: clip;
  height: 100dvh;
  min-height: 510px;
  margin: auto;
  display: grid;
  grid-template-rows: 4% 34% 4% 13.5% 19% minmax(0,1fr) 5%;
  padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom);
  gap: 0;
  background:
    radial-gradient(ellipse at 50% 18%,#c9a57452,transparent 56%),
    linear-gradient(#142f2d36 25%,#172f2abf 66%,#0b2621d9),
    url('/assets/table.webp') center/cover;
  color: #fff8e8;
}
.table-top,.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  background: #072926e8;
  font-size: 12px;
}
.table-top button,.table-footer button {
  min-height: 0;
  height: 100%;
  padding: 0 10px;
  background: transparent;
  color: #f5dfaa;
}
.table-footer { border-top: 2px solid #a38d56; }
.table-footer .reaction-open { min-width: 44px; font-size: 24px; border: none; }
.self-seat { flex: 1; display: flex; justify-content: center; align-items: center; gap: 8px; min-width: 0; }
.self-seat strong,.seat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.self-seat span,.seat-score { color: #f1d794; white-space: nowrap; }
.seat-rack { display: flex; justify-content: center; gap: 6px; min-height: 0; padding-top: 4px; width: 65%; justify-self: center; }
.table-seat {
  position: relative;
  flex: 1;
  max-width: 25cqw;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  justify-items: center;
  padding: 4px 4px 0;
  background: #143d39dc;
  border: 1px solid #a7c0a055;
  border-radius: 11px;
  font-size: 12px;
}
.turn-seat { box-shadow: inset 0 0 0 2px #f6d07a,0 0 16px #f6d07a33; }
.seat-portrait { position: relative; }
.seat-portrait span {
  display: grid;
  place-items: center;
  width: clamp(27px,6dvh,53px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #244f46;
  border: 2px solid #e3c784;
  color: #ffe7b2;
  font-weight: 900;
  font-size: 18px;
}
.seat-portrait b { position: absolute; bottom: 0; left: -8px; padding: 1px 4px; background: #15343a; border: 1px solid #e2c481; border-radius: 4px; }
.seat-alert { position: absolute; top: 8px; right: 0; background: #9f332a; color: white; font-size: 8px; font-weight: 900; padding: 2px; }
.seat-groups { display: flex; flex-direction: column; gap: 4px; width: 100%; min-height: 0; padding-block: 3px; }
.seat-groups > * { flex: 1 1 0; min-height: 0; }
.seat-empty { display: grid; place-items: center; border: 1px dashed #b4d5c275; border-radius: 5px; text-align: center; font-size: clamp(9px,2.4vw,13px); }
.seat-phase { font-size: 10px; letter-spacing: .06em; padding: 2px; }
.table-turn { justify-self: center; align-self: center; background: #07312ee8; border-radius: 14px; color: #f1d794; padding: 2px 10px; font-size: clamp(10px,1.8cqh,13px); font-weight: 750; }
.table-turn.own-turn { background: #f0d18b; color: #19332a; }
.table-turn.draft-error { background: #ffe0d4; color: #6e271d; text-align: center; }
.table-piles { display: flex; justify-content: center; align-items: center; gap: 5cqw; min-height: 0; z-index: 1; }
.table-pile { display: grid; justify-items: center; gap: 2px; min-width: var(--pile-width); padding: 2px; border-radius: 9px; }
.table-pile span { font-size: 9px; font-weight: 800; }
.table-pile button,.laid-cards {
  display: flex;
  padding: 0;
  background: transparent;
  min-height: 0;
  border-radius: 7px;
}
.table-pile button:disabled { opacity: 1; }
.table-pile button:not(:disabled) { outline: 2px solid #f3d897; outline-offset: 2px; }
.play-table .table-pile .card {
  width: var(--pile-width);
  height: auto;
  aspect-ratio: var(--card-ratio);
  min-height: 0;
  font-size: min(5.4cqw,4.8cqh);
}
.table-felt {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: minmax(0,1fr) minmax(22px,3.6cqh);
  gap: 0;
  min-height: 0;
  padding: 3px 6px;
  width: 60%;
  justify-self: center;
}
.table-felt::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -6% -31% -51%;
  border-radius: 50%;
  border: 3px solid #ba9254;
  background: radial-gradient(ellipse at 50% 13%,#dfbf80,#b58247 78%,#8f633b);
  box-shadow: 0 7px 0 #704824,0 13px 15px #051a18b3,inset 0 0 0 4px #ffd69955;
}
.table-felt::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: 10px;
  background: #163c35ed;
  box-shadow: 0 2px 4px #5137197a;
}
.table-felt .phase-trays { padding: 2px 2px 0; }
.phase-trays,.phase-actions { display: flex; justify-content: center; align-items: stretch; gap: 5px; min-width: 0; min-height: 0; }
.phase-tray { flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(16px,3cqh) minmax(0,1fr); border: 1px solid #b2d1bc74; border-radius: 8px; }
.phase-tray.tray-valid { border-color: #a3e4ad; box-shadow: inset 0 0 0 1px #a3e4ad; }
.tray-label { min-height: 0; padding: 0 2px; border-radius: 5px; background: transparent; color: #f5eedc; font-size: clamp(8px,2.4cqw,12px); white-space: nowrap; }
.tray-label span { color: #b5e5c4; }
.tray-stack {
  --visible-card: .56;
  --stack-card-width: min(var(--slot-width), calc(100% / (1 + (var(--slot-count, 1) - 1) * var(--visible-card))));
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  padding: 0 2px 2px;
}
.tray-slot { position: relative; container-type: inline-size; flex: 0 0 var(--stack-card-width); min-width: 0; aspect-ratio: var(--card-ratio); }
.tray-slot + .tray-slot { margin-inline-start: calc(var(--stack-card-width) * (var(--visible-card) - 1)); }
.tray-slot:has(.card) { z-index: 1; }
.tray-slot > button { position: absolute; inset: 0; }
.tray-slot > button:not(.card) { width: 100%; height: 100%; min-height: 0; padding: 0; background: transparent; }
.play-table .tray-slot .card { width: 100%; height: 100%; min-height: 0; font-size: 54cqw; border-radius: 5px; box-shadow: none; }
.play-table .tray-slot .card .corner { display: block; top: 2px; left: 2px; font-size: min(28cqw,12px); }
.tray-slot .card.selected { transform: none; outline: 1px solid #f7d789; outline-offset: -2px; }
.phase-actions { align-items: center; }
.phase-actions b { font-size: 10px; white-space: nowrap; }
.phase-actions { color: #fff8e8; }
.phase-actions button { min-height: 0; height: 86%; padding: 0 9px; font-size: clamp(9px,1.8cqh,12px); }
.table-cancel { background: #e5bb77; color: #35251a; }
.table-confirm { background: #a7e1b5; color: #153428; }
.laid-group { display: flex; justify-content: center; align-items: center; min-width: 0; width: 100%; max-width: 330px; }
.laid-cards { justify-content: center; flex: 1; min-width: 0; }
.laid-cards .fan-card { flex: 0 1 24px; min-width: 0; }
.laid-cards .fan-card + .fan-card { margin-left: -8px; }
.laid-cards .card { width: clamp(20px,4vw,30px); height: clamp(26px,5dvh,42px); min-height: 0; font-size: 14px; }
.meld-end {
  z-index: 1;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: clamp(13px, 3.5cqw, 34px);
  height: auto;
  min-height: 0;
  aspect-ratio: var(--card-ratio);
  padding: 0;
  border: 1px dashed #f1d389b3;
  border-radius: 5px;
  background: #f1d38920;
  color: #ffe3a1;
  font-size: clamp(10px, 2cqh, 16px);
}
.hit-preview span { pointer-events: none; }
.play-table:not(.card-dragging) .hit-muted,
.card-dragging .hit-preview:not(.hit-drag-match) { visibility: hidden; }
.play-table .hand { display: flex; justify-content: center; align-items: flex-end; gap: 0; overflow: visible; padding: 2px 0 min(2cqh,14px); min-height: 0; }
.play-table .hand .fan-card { flex: 0 0 var(--hand-width); transform: translateY(var(--lift,0px)) rotate(var(--angle,0deg)); transform-origin: center 88%; }
.play-table .hand .fan-card + .fan-card { margin-left: var(--hand-overlap); }
.play-table .hand .card { width: var(--hand-width); height: auto; aspect-ratio: var(--card-ratio); min-height: 0; padding: 0; font-size: min(6cqw, 5.5cqh); border-radius: 6px; }
.play-table .hand :is(.new-draw,.playable-card) { transform: translateY(calc(var(--lift,0px) - 11px)) rotate(var(--angle,0deg)); }
.new-draw-label {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 8px;
  background: #f1d389;
  color: #23392c;
  font-size: 9px;
  font-weight: 800;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  #draw-stock.draw-cue .card { animation: deck-nudge 2.6s ease-in-out infinite; }
  .play-table:not(.card-dragging) .hand .playable-card { animation: playable-rise 560ms ease-out both; }
}
@keyframes playable-rise {
  0% { transform: translateY(var(--lift,0px)) rotate(var(--angle,0deg)); }
  40%, 72% { transform: translateY(calc(var(--lift,0px) - 11px)) rotate(calc(var(--angle,0deg) + 3deg)); }
  56%, 84% { transform: translateY(calc(var(--lift,0px) - 11px)) rotate(calc(var(--angle,0deg) - 3deg)); }
}
@keyframes deck-nudge {
  0%, 24%, 100% { transform: rotate(0deg); }
  5%, 15% { transform: translateY(-3px) rotate(-5deg); }
  10%, 20% { transform: translateY(-2px) rotate(5deg); }
}
@media (orientation: landscape) and (min-width: 700px) {
  .play-table { width: 100%; }
}
.play-table .hand .corner { top: 4px; left: 4px; font-size: clamp(10px,2.5cqw,18px); }
.play-table .card.coral,.drag-card.card.coral { --face-accent: #a32636; --face-tint: #ffe3df; }
.play-table .card.gold,.drag-card.card.gold { --face-accent: #795300; --face-tint: #ffe59b; }
.play-table .card.teal,.drag-card.card.teal { --face-accent: #006460; --face-tint: #c5f2e6; }
.play-table .card.violet,.drag-card.card.violet { --face-accent: #57338d; --face-tint: #ebddff; }
.play-table .card:is(.coral,.gold,.teal,.violet),.drag-card.card:is(.coral,.gold,.teal,.violet) {
  color: var(--face-accent);
  background: linear-gradient(to bottom,var(--face-accent) 0 9%,var(--face-tint) 9% 90%,var(--face-accent) 90%);
}
.play-table .card:is(.coral,.gold,.teal,.violet) .corner {
  background: var(--face-tint);
  border-radius: 2px;
  padding-inline: 1px;
}
.table-felt .laid-group { flex: 1; }
.table-felt .laid-cards.tray-stack {
  --slot-width: min(11cqw, calc((19cqh - max(22px,3.6cqh) - 10px) * var(--card-ratio)));
  align-self: stretch;
}
.table-felt .laid-cards.tray-stack .fan-card {
  flex: 0 0 var(--stack-card-width);
  container-type: inline-size;
}
.table-felt .laid-cards.tray-stack .fan-card + .fan-card {
  margin-inline-start: calc(var(--stack-card-width) * (var(--visible-card) - 1));
}
.table-felt .laid-cards.tray-stack .card {
  width: 100%;
  height: auto;
  aspect-ratio: var(--card-ratio);
  font-size: 54cqw;
}
.table-felt .laid-cards.tray-stack .corner {
  display: block;
  top: 2px;
  left: 2px;
  font-size: min(28cqw,12px);
}
.seat-groups .laid-group { max-width: none; }
.seat-groups .laid-cards { container-type: size; align-self: stretch; }
.seat-groups .meld-end { width: clamp(12px, 2.5cqw, 24px); }
.seat-stack.tray-stack {
  --slot-width: calc(100cqh * var(--card-ratio));
  --visible-card: .48;
  width: 100%;
  padding: 0;
}
.seat-stack:has(.fan-card:nth-child(7)) { --visible-card: .38; }
.seat-stack.tray-stack .fan-card {
  flex: 0 0 var(--stack-card-width);
  container-type: inline-size;
}
.seat-stack.tray-stack .fan-card + .fan-card {
  margin-inline-start: calc(var(--stack-card-width) * (var(--visible-card) - 1));
}
.seat-stack .card {
  width: 100%;
  height: auto;
  aspect-ratio: var(--card-ratio);
  font-size: 54cqw;
  box-shadow: none;
}
.seat-stack .card .corner {
  display: block;
  top: 1px;
  left: 1px;
  font-size: min(24cqw,14px);
}
@media (max-width: 480px) {
  .seat-rack { width: 96%; }
  .table-seat { max-width: 31cqw; }
}
.play-table [data-card],.play-table .table-pile button { touch-action: none; user-select: none; -webkit-user-select: none; }
.drag-card.card { position: fixed; transform: translate(-50%,-65%) rotate(-5deg); z-index: 100; pointer-events: none; height: auto; aspect-ratio: .64; min-height: 0; }
.drag-source { opacity: .3; }
.drag-source.drag-inserting { opacity: 0; }
.drag-card.card.drag-snapped {
  transform: translate(-50%,-5px);
  clip-path: inset(0 var(--insertion-clip,0px) 0 0);
  transition: left 110ms ease-out, top 110ms ease-out, width 110ms ease-out;
}
.card-dragging :is(.hand .fan-card,.tray-slot) { transition: translate 125ms ease-out; }
.insertion-marker {
  position: fixed;
  transform: translateX(-50%);
  z-index: 99;
  border: 2px dashed #f7d789;
  border-radius: 7px;
  background: #f7d78935;
  pointer-events: none;
  transition: left 110ms ease-out, top 110ms ease-out;
}
.play-table .drop-hover { outline: 2px solid #f7d789; outline-offset: 1px; }
.self-portrait { display: grid; place-items: center; flex: 0 0 min(32px,4.3cqh); height: min(32px,4.3cqh); border-radius: 50%; background: #244f46; border: 2px solid #e3c784; color: #ffe7b2; }
.self-seat.turn-seat { border-radius: 20px; box-shadow: none; }
.self-seat.turn-seat .self-portrait { box-shadow: 0 0 12px #e3c784; }
.seat-skip-effect { position: absolute; z-index: 3; left: 50%; top: 28px; transform: translateX(-50%) rotate(-8deg); background: #b73c32; color: white; border: 2px solid #ffe7d6; border-radius: 5px; padding: 2px 6px; font-weight: 900; pointer-events: none; }
.results-podium { display: flex; align-items: flex-end; justify-content: center; gap: 5px; margin: 20px 0; text-align: center; }
.podium-seat { flex: 1; max-width: 130px; min-width: 0; display: grid; justify-items: center; gap: 4px; }
.podium-seat strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.podium-seat b { display: grid; place-items: center; width: 100%; height: 45px; background: #255c50; border: 1px solid #a7c0a0; border-radius: 7px 7px 0 0; color: #fff4d6; font-size: 24px; }
.podium-seat.winner b { height: 77px; background: #e9c378; color: #263c30; }
.podium-seat .avatar { margin: auto; }
@media (min-width: 540px) {
  .play-table { padding-inline: 14px; }
  .seat-rack,.phase-trays { gap: 10px; }
}
