/* ── Card Fan Layout ─────────────────────────────────────── */
.card-fan {
  display: flex;
  align-items: flex-start;
  min-height: 126px;
}

/* Every card after the first overlaps left */
.card-fan .card:not(:first-child) {
  margin-left: -44px;
}

/* Each successive card cascades 16px lower — transform avoids layout shifts */
.card-fan .card:nth-child(2) { --card-y: 16px; }
.card-fan .card:nth-child(3) { --card-y: 32px; }
.card-fan .card:nth-child(4) { --card-y: 48px; }
.card-fan .card:nth-child(5) { --card-y: 64px; }
.card-fan .card:nth-child(6) { --card-y: 80px; }

/* ── Card Base ───────────────────────────────────────────── */
.card {
  --card-y: 0px;
  width: 90px;
  height: 126px;
  position: relative;
  border-radius: 9px;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  transform: translateY(var(--card-y));
}

.card-face,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 9px;
}

/* ── Card Face ───────────────────────────────────────────── */
.card-face {
  background: #ffffff;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 5px 6px;
}

.card-face.red { color: #d32f2f; }

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.bottom-right {
  transform: rotate(180deg);
  align-self: flex-end;
}

.card-rank {
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.card-corner .card-suit {
  font-size: 12px;
  line-height: 1;
}

.card-center-suit {
  font-size: 34px;
  text-align: center;
  line-height: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ── Card Back ───────────────────────────────────────────── */
.card-back {
  display: none;
  background: #2563eb;
  border-radius: 9px;
  overflow: hidden;
}

/* Outer border inset */
.card-back::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  z-index: 1;
}

/* Geometric diamond / angular shape (Stake-style logo) */
.card-back::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 3px;
  z-index: 2;
}

/* Face-down: show back, hide face */
.card.face-down .card-back { display: block; }
.card.face-down .card-face { display: none; }

/* ── Deal Animation ──────────────────────────────────────── */
@keyframes dealIn {
  0% {
    transform: translate(var(--deal-from-x, 0), var(--deal-from-y, -200px))
               rotateZ(-5deg)
               scale(0.6);
    opacity: 0;
  }
  60% { opacity: 1; }
  100% {
    transform: translateY(var(--card-y, 0px)) rotateZ(0deg) scale(1);
    opacity: 1;
  }
}

.card.dealt {
  animation: dealIn 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ── Flip Animation (hole card reveal) ───────────────────── */
@keyframes flipReveal {
  0%   { transform: translateY(var(--card-y, 0px)) scaleX(1); }
  45%  { transform: translateY(var(--card-y, 0px)) scaleX(0); }
  55%  { transform: translateY(var(--card-y, 0px)) scaleX(0); }
  100% { transform: translateY(var(--card-y, 0px)) scaleX(1); }
}

.card.flipping {
  animation: flipReveal 0.28s ease-in-out forwards;
}

/* ── Score Badges ────────────────────────────────────────── */
.score-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: #0d1820;
  color: #c2cfe0;
  border: 1px solid #1c2e40;
  min-width: 30px;
  text-align: center;
  white-space: nowrap;
}

.score-badge.bust {
  background: #450a0a;
  color: #fca5a5;
  border-color: #7f1d1d;
}

.score-badge.blackjack {
  background: #052e16;
  color: #4ade80;
  border-color: #14532d;
}
