/* Hands & cards */
.hand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  min-height: 120px;
  margin: 10px 0;
  padding: 5px;
  width: 100%;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow: visible;
}

.card {
  width: 80px !important;
  height: 120px !important;
  min-width: 80px !important;
  min-height: 120px !important;
  max-width: 80px !important;
  max-height: 120px !important;
  flex-shrink: 0 !important;
  background: var(--card-bg);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px;
  color: var(--card-index);
  font-weight: bold;
  border: 1px solid var(--card-border);
  position: relative;
  overflow: hidden;
  transform-origin: center center;
  transition: transform 0.3s ease, box-shadow 0.2s ease;
}

.card.red { color: var(--card-index-red); }

.card::before,
.card::after {
  content: attr(data-value);
  position: absolute;
  font-size: 1.2rem;
}
.card::before { top: 5px; left: 5px; }
.card::after  { bottom: 5px; right: 5px; transform: rotate(180deg); }

.card .suit {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.card-back {
  background: var(--card-back-bg);
  color: white;
  border: var(--card-back-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.card-back .pattern {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 50%, var(--card-back-pattern-a) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, var(--card-back-pattern-b) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: 6px;
}

/* Player spot header - consistent sizing */
.player-spot h3 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Player info - fixed height to prevent layout shifts */
.player-info {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
  font-size: 0.95rem;
}

/* Transform-based scaling - scales entire card as one unit */

/* 5 cards: Scale to 85% using transform */
.hand:has(.card:nth-child(5)) {
  gap: 2px;
}

.hand:has(.card:nth-child(5)) .card {
  transform: scale(0.85);
}

/* 6 cards: Scale to 75% */
.hand:has(.card:nth-child(6)) {
  gap: 1px;
}

.hand:has(.card:nth-child(6)) .card {
  transform: scale(0.75);
}

/* 7 cards: Scale to 65% */
.hand:has(.card:nth-child(7)) {
  gap: 0px;
}

.hand:has(.card:nth-child(7)) .card {
  transform: scale(0.65);
}

/* 8+ cards: Scale to 55% */
.hand:has(.card:nth-child(8)) {
  gap: 0px;
}

.hand:has(.card:nth-child(8)) .card {
  transform: scale(0.55);
}

/* 10+ cards: Scale to 45% */
.hand:has(.card:nth-child(10)) .card {
  transform: scale(0.45);
}

/* Hover effect - slightly lift up with proper scale */
.hand .card:hover {
  transform: scale(1.05) translateY(-5px) !important;
  z-index: 10;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.hand:has(.card:nth-child(5)) .card:hover {
  transform: scale(0.90) translateY(-5px) !important;
}

.hand:has(.card:nth-child(6)) .card:hover {
  transform: scale(0.80) translateY(-5px) !important;
}

.hand:has(.card:nth-child(7)) .card:hover {
  transform: scale(0.70) translateY(-5px) !important;
}

.hand:has(.card:nth-child(8)) .card:hover {
  transform: scale(0.60) translateY(-5px) !important;
}

.hand:has(.card:nth-child(10)) .card:hover {
  transform: scale(0.50) translateY(-5px) !important;
}

/* Deal-in animation */
@keyframes deal {
  0% { transform: translateY(-100px) rotate(-5deg); opacity: 0; }
  100% { transform: translateY(0) rotate(0); opacity: 1; }
}
.card.dealing { animation: deal .5s ease-out forwards; }

/* Value badges & results */
.hand-value {
  font-weight: bold;
  font-size: 1.2rem;
  margin-top: 10px;
  color: #fff;
  text-align: center;
  background: rgba(0,0,0,0.5);
  padding: 5px;
  border-radius: 5px;
}

.player-status {
  font-weight: bold;
  margin-top: 5px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.5);
}

.player-result {
  font-weight: bold;
  font-size: 1.1rem;
  padding: 8px;
  border-radius: 5px;
  margin-top: 5px;
  animation: pulse 1s ease-in-out;
}
.win { background-color: var(--win); color: #fff; }
.blackjack { background-color: var(--blackjack); color: #000; }
.push { background-color: var(--push); color: #fff; }
.lose { background-color: var(--lose); color: #fff; }
.busted { background-color: #b00020; color: #fff; }

.dealer-result {
  font-weight: bold;
  font-size: 1.2rem;
  padding: 10px;
  border-radius: 5px;
  margin: 10px auto;
  max-width: 300px;
  background: rgba(0,0,0,0.7);
  color: gold;
  text-align: center;
}

#round-result { text-align: center; margin: 15px 0; }
#message { text-align: center; padding: 10px; font-weight: bold; background: rgba(0,0,0,0.5); border-radius: 5px; margin: 10px 0; }

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
