.card playing-card {
  display: inline-block;
  width: 4rem;
  aspect-ratio: 63 / 88;
  border-radius: 5px;
  overflow: hidden;
}

.cards {
  position: relative;
  /* top: 50%; */
  left: 50%;
  transform: translate(-50%);
  width: 100%;
  height: 90vh;
  perspective: 1000px;
  perspective-origin: 50% 40%;
  --hover-lift: 0.4rem;
  --hover-scale: 1.06;
  --spread: 0.8rem;
  --max-tilt: 10deg;
  --base-offset: -0.6rem;
  --stack-gap: 4.1rem;
}

.cards .card.deck {
  left: 28%;
  top: 50%;
  position: absolute;
  width: 4rem;
  aspect-ratio: 63 / 88;
  transform-origin: center center;
  transform:
    translateY(-50%)
    translateX(var(--deck-tx, 0rem))
    translateY(var(--deck-ty, 0rem))
    rotate(var(--deck-rotation, 0deg));
}

.cards .card.deck.is-face-down {
  transform:
    translateY(-50%)
    translateX(var(--deck-tx, 0rem))
    translateY(var(--deck-ty, 0rem))
    rotate(var(--deck-rotation, 0deg))
    rotateY(180deg);
}

.card {
  transform-style: preserve-3d;
  position: relative;
}


.card .face {
  position: absolute;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.card .face.front {
  /* transform: rotateY(180deg); */
}

.card .face.back {
  transform: rotateY(180deg);
}

/* .cards playing-card.deck:not(:first-child) { */
/*   /1* margin-left: -4.1rem; *1/ */
/* } */

.cards .card.discard {
  position: absolute;
  width: 4rem;
  aspect-ratio: 63 / 88;
  transform-origin: center center;
  transition: transform 0.2s ease;
  right: 27%;
  top: 44%;
  z-index: calc(100 + var(--card-index, 0));
}

.cards .card.discard.is-top {
  z-index: calc(200 + var(--card-index, 0));
  transform: rotate(10deg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.cards .card.discard.is-top::before {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: -6px;
  right: -36px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 5px;
  pointer-events: none;
}

.cards .card.discard.is-top::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -24px;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6l-1 14H6L5 6'/%3E%3Cpath d='M10 11v6M14 11v6'/%3E%3Cpath d='M9 6V4h6v2'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 1;
}

.cards .card.hand.current-user {
  position: absolute;
  left: calc(50% - 13.5rem + var(--hand-slot, 0) * 1.8rem);
  bottom: 8%;
  transform-origin: bottom center;
  transform: translateX(-50%);
  transition: transform .25s ease, left .15s ease;
  z-index: calc(100 + var(--hand-slot, 0));
}

.cards .card.hand.current-user.selected,
.cards .card.hand.current-user:hover {
  transform:
    translateX(-50%)
    translateY(calc(-1 * var(--hover-lift)))
    scale(var(--hover-scale));
}

.cards .card.hand.current-user.is-ghost playing-card {
  visibility: hidden;
}

.cards .card.hand.current-user.is-ghost {
  border: 2px dashed rgba(255, 255, 255, 0.45);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  z-index: 99 !important;
}

.cards .card.player-0,
.cards .card.player-1,
.cards .card.player-2,
.cards .card.player-3,
.cards .card.player-4 {
  display: none !important;
}

.cards .card.current-user {
  display: inline-block !important;
}

.cards .card.incoming playing-card {
  background: rgba(32, 255, 0, 0.2);
  z-index: calc(90 + var(--card-index))
}

.cards .card.outgoing playing-card {
  background: rgba(200, 0, 0, 0.4);
  z-index: calc(90 + var(--card-index))
}

.cards .card.discard.blocked {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.cards .card.incoming playing-card.back,
.cards .card.incoming playing-card img,
.cards .card.outgoing playing-card.back,
.cards .card.outgoing playing-card img {
  display: none;
}

.player.player--current .avatar {
  -webkit-box-shadow:0px 0px 8px 5px rgba(255,46,164,0.9);
  -moz-box-shadow: 0px 0px 8px 5px rgba(255,46,164,0.9);
  box-shadow: 0px 0px 8px 5px rgba(255,46,164,0.9);
}

/* Na boa: jogador a uma carta de bater */
.player.player--ready-to-win .avatar {
  -webkit-box-shadow: 0px 0px 10px 6px rgba(52, 211, 153, 0.9);
  -moz-box-shadow: 0px 0px 10px 6px rgba(52, 211, 153, 0.9);
  box-shadow: 0px 0px 10px 6px rgba(52, 211, 153, 0.9);
  animation: pulse-ready 1.5s ease-in-out infinite alternate;
}

@keyframes pulse-ready {
  0%   { box-shadow: 0px 0px 8px 4px rgba(52, 211, 153, 0.7); }
  100% { box-shadow: 0px 0px 14px 8px rgba(52, 211, 153, 1.0); }
}

/* Queimado: tentou furar a fila mas a carta não serviu */
.player.player--burned .avatar {
  filter: grayscale(70%) brightness(0.75);
  opacity: 0.8;
}

.player.player--burned::after {
  content: "🔥";
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  font-size: 1rem;
  pointer-events: none;
  z-index: 10;
}

.cards .card.joker {
  position: absolute;
  top: 23%;
  left: calc(50% + var(--joker-center-offset) + var(--joker-card-index) * var(--stack-gap));
  transition: transform 0.2s ease;
  z-index: calc(100 + var(--joker-card-index));
}

.cards .card.joker playing-card {
  width: 2.6rem;
}

.joker-label {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: bold;
  letter-spacing: 0.15em;
  pointer-events: none;
  z-index: 200;
}

/* Meld: carta que já foi agrupada em um meld — permanece na mão */
.cards .card.hand.current-user.meld {
  position: absolute;
  bottom: 8%;
}

.cards .card.hand.current-user.meld playing-card {
  outline: 1px solid rgba(251, 191, 36, 0.5);
  outline-offset: -1px;
}

/* Borda única que envolve todas as cartas de um meld */
.meld-group-border {
  position: absolute;
  border: 2px solid rgba(251, 191, 36, 0.85);
  border-radius: 10px;
  pointer-events: none;
  z-index: 200;
  background: rgba(251, 191, 36, 0.04);
  box-shadow:
    0 0 10px rgba(251, 191, 36, 0.35),
    inset 0 0 6px rgba(251, 191, 36, 0.07);
  transition: left 0.15s ease, top 0.15s ease, width 0.15s ease, height 0.15s ease;
}

.ready-set-go {
  position: fixed;
  font-size: 6rem;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  transform-origin: center center;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
}
