/* Blackjack — Game-specific styles */

/* ======= BALANCE BAR ======= */
.balance-bar {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 16px;
}

.balance-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.balance-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.balance-amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-heading);
}

/* ======= TABLE FELT ======= */
.table-felt {
  background: radial-gradient(ellipse at center, #1e6b35 0%, #155c2a 50%, #0f4a20 100%);
  border-radius: var(--radius-lg);
  border: 4px solid #3a2a1a;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4), 0 4px 20px rgba(0, 0, 0, 0.5);
  padding: 24px 16px;
  min-height: 340px;
  position: relative;
  margin-bottom: 16px;
}

.table-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 16px 0;
  position: relative;
}

/* ======= TABLE BET CHIPS ======= */
.table-bet-display {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  pointer-events: none;
  z-index: 5;
}

.table-bet-display:empty {
  display: none;
}

.table-chip {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  margin-top: -22px;
  position: relative;
  animation: chipDrop 0.3s ease-out forwards;
}

.table-chip:first-child {
  margin-top: 0;
}

.table-chip-10 {
  background: radial-gradient(circle at 30% 30%, #4da6ff, #2980b9);
}

.table-chip-25 {
  background: radial-gradient(circle at 30% 30%, #2ecc71, #1a9e52);
}

.table-chip-50 {
  background: radial-gradient(circle at 30% 30%, #e74c3c, #c0392b);
}

.table-chip-100 {
  background: radial-gradient(circle at 30% 30%, #2c3e50, #1a252f);
  border-color: rgba(255, 215, 0, 0.6);
  color: #f1c40f;
}

.bet-total-label {
  font-size: 13px;
  font-weight: 700;
  color: #f1c40f;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  margin-top: 4px;
  white-space: nowrap;
}

@keyframes chipDrop {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.6);
  }
  60% {
    opacity: 1;
    transform: translateY(2px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ======= HAND AREAS ======= */
.hand-area {
  min-height: 120px;
  padding: 8px 0;
}

.hand-label {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hand-total {
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}

.hand-total:empty {
  display: none;
}

.hand-total.bust {
  background: #c0392b;
}

.hand-total.blackjack {
  background: #f1c40f;
  color: #000;
}

/* ======= CARD ROW ======= */
.card-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 8px;
  min-height: 100px;
  flex-wrap: nowrap;
  perspective: 800px;
}

/* ======= PLAYING CARDS ======= */
.card {
  width: 72px;
  height: 100px;
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-style: preserve-3d;
  font-family: 'Georgia', serif;
}

.card.dealing {
  animation: dealCard 0.4s ease-out forwards;
}

@keyframes dealCard {
  0% {
    opacity: 0;
    transform: translateY(-60px) scale(0.5) rotateY(180deg);
  }
  60% {
    opacity: 1;
    transform: translateY(4px) scale(1.02) rotateY(20deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateY(0deg);
  }
}

/* Card face (front) */
.card-face {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #ffffff 0%, #f5f5f0 100%);
  border-radius: 8px;
  border: 1px solid #ccc;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 6px;
  position: relative;
  overflow: hidden;
}

.card-face::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 7px;
  border: 2px solid rgba(0, 0, 0, 0.06);
  pointer-events: none;
}

/* Card colors */
.card.red .card-face {
  color: #c0392b;
}

.card.black .card-face {
  color: #1a1a2e;
}

/* Corner values */
.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 0;
}

.card-corner-value {
  font-size: 15px;
  font-weight: 700;
}

.card-corner-suit {
  font-size: 11px;
  line-height: 1;
}

.card-corner.bottom {
  align-self: flex-end;
  transform: rotate(180deg);
}

/* Center suit */
.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  line-height: 1;
  opacity: 0.85;
}

/* Face card indicator */
.card-center.face-card {
  font-size: 26px;
  font-weight: 700;
  opacity: 0.7;
}

/* Card back */
.card-back {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(135deg, #1a3a6e 0%, #0f2247 100%);
  border: 1px solid #0a1530;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(255, 255, 255, 0.03) 4px,
    rgba(255, 255, 255, 0.03) 8px
  );
}

.card-back::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: radial-gradient(circle, rgba(77, 166, 255, 0.15) 0%, transparent 70%);
}

/* Card flip animation */
.card.flipping {
  animation: flipCard 0.5s ease-in-out forwards;
}

@keyframes flipCard {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

/* Active hand highlight */
.hand-area.active-hand {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
}

/* ======= CONTROLS ======= */
.controls-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}

/* Chip buttons */
.chip-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
}

.chip-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.5);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chip-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.chip-btn:active {
  transform: translateY(0);
}

.chip-10 {
  background: radial-gradient(circle at 30% 30%, #4da6ff, #2980b9);
}

.chip-25 {
  background: radial-gradient(circle at 30% 30%, #2ecc71, #1a9e52);
}

.chip-50 {
  background: radial-gradient(circle at 30% 30%, #e74c3c, #c0392b);
}

.chip-100 {
  background: radial-gradient(circle at 30% 30%, #2c3e50, #1a252f);
  border-color: rgba(255, 215, 0, 0.6);
  color: #f1c40f;
}

.chip-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Bet actions */
.bet-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Action buttons */
#action-controls .btn-primary {
  min-width: 80px;
}

#action-controls .btn-primary:disabled,
#action-controls .btn-secondary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* ======= RESULT OVERLAY ======= */
#result-overlay .result-content {
  max-width: 380px;
}

#result-title {
  font-size: 26px;
}

#result-message {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 8px;
}

.result-payout {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.result-payout.win {
  color: #2ecc71;
}

.result-payout.lose {
  color: #e74c3c;
}

.result-payout.push {
  color: var(--text-secondary);
}

/* ======= SPLIT HAND AREA ======= */
.split-area {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

/* ======= RESPONSIVE ======= */
@media (max-width: 768px) {
  .table-chip {
    width: 36px;
    height: 36px;
    font-size: 10px;
    margin-top: -18px;
  }

  .table-felt {
    padding: 16px 10px;
    min-height: 280px;
  }

  .card {
    width: 60px;
    height: 84px;
  }

  .card-corner-value {
    font-size: 13px;
  }

  .card-corner-suit {
    font-size: 9px;
  }

  .card-center {
    font-size: 26px;
  }

  .card-center.face-card {
    font-size: 22px;
  }

  .balance-amount {
    font-size: 24px;
  }

  .chip-btn {
    width: 48px;
    height: 48px;
    font-size: 13px;
  }

  .card-row {
    gap: 5px;
  }
}

@media (max-width: 480px) {
  .table-chip {
    width: 32px;
    height: 32px;
    font-size: 9px;
    margin-top: -16px;
    border-width: 2px;
  }

  .bet-total-label {
    font-size: 11px;
  }

  .table-felt {
    padding: 12px 6px;
    min-height: 240px;
    border-radius: var(--radius-md);
    border-width: 3px;
  }

  .card {
    width: 50px;
    height: 70px;
  }

  .card-corner-value {
    font-size: 11px;
  }

  .card-corner-suit {
    font-size: 8px;
  }

  .card-center {
    font-size: 22px;
  }

  .card-center.face-card {
    font-size: 18px;
  }

  .card-face {
    padding: 3px 4px;
  }

  .balance-bar {
    gap: 20px;
  }

  .balance-amount {
    font-size: 20px;
  }

  .chip-btn {
    width: 44px;
    height: 44px;
    font-size: 12px;
    border-width: 2px;
  }

  .chip-buttons {
    gap: 6px;
  }

  .hand-label {
    font-size: 13px;
  }

  .hand-total {
    font-size: 12px;
    padding: 2px 8px;
  }

  #action-controls .btn-primary {
    min-width: 60px;
    padding: 8px 14px;
    font-size: 14px;
  }

  .hand-area {
    min-height: 90px;
  }

  .card-row {
    gap: 3px;
    min-height: 74px;
  }
}

/* Many cards: overlap them */
.card-row.crowded .card {
  margin-left: -20px;
}

.card-row.crowded .card:first-child {
  margin-left: 0;
}
