/* ===== BLACKJACK GAME ===== */

#blackjackGame {
  background: radial-gradient(ellipse at 50% 40%, #0a4d2e 0%, #062a18 60%, #021008 100%);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Top bar */
.bj-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(0,0,0,0.4);
  z-index: 10;
  flex-shrink: 0;
}
.bj-top-info {
  display: flex;
  gap: 10px;
  align-items: center;
}
.bj-chip-display {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,215,0,0.15);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #ffd700;
}
.bj-phase-badge {
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.bj-close-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

/* ===== DEALER AREA — compact ===== */
.bj-dealer-area {
  text-align: center;
  padding: 6px 8px 4px;
  flex-shrink: 0;
}
.bj-dealer-label {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 3px;
  font-weight: 600;
}
.bj-dealer-cards {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: 52px;
}
.bj-dealer-total {
  display: inline-block;
  margin-top: 3px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 1px 10px;
  border-radius: 10px;
}
.bj-dealer-status {
  font-size: 12px;
  color: #ff5252;
  font-weight: 700;
  margin-top: 2px;
}

/* ===== OPPONENTS — compact horizontal strip ===== */
.bj-opponents {
  display: flex;
  gap: 6px;
  padding: 3px 8px;
  overflow-x: auto;
  flex-shrink: 0;
  justify-content: center;
}
.bj-opp-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 56px;
  padding: 4px 3px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}
.bj-opp-slot.bust {
  opacity: 0.4;
}
.bj-opp-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2px solid transparent;
  transition: border-color 0.3s;
}
.bj-opp-avatar.active-turn {
  border-color: #ffd700;
  box-shadow: 0 0 8px rgba(255,215,0,0.5);
}
.bj-opp-name {
  font-size: 10px;
  color: #ccc;
  font-weight: 600;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bj-opp-chips {
  font-size: 9px;
  color: #ffd700;
}
.bj-opp-bet {
  font-size: 9px;
  color: #ff9100;
  font-weight: 600;
}
.bj-opp-cards {
  display: flex;
  gap: 2px;
  margin-top: 1px;
}
.bj-opp-status {
  font-size: 9px;
  color: #00e676;
  font-weight: 700;
}

/* ===== MY AREA — dominant, fills remaining space ===== */
.bj-my-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  gap: 4px;
  min-height: 0;
  position: relative;
}

/* Fan-style card container */
.bj-my-cards {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 0;
  flex: 1;
  width: 100%;
  position: relative;
  padding: 8px 0;
}

.bj-my-total {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  flex-shrink: 0;
}
.bj-my-total.bj-21 {
  color: #ffd700;
  text-shadow: 0 0 16px rgba(255,215,0,0.6);
}
.bj-my-total.bj-bust {
  color: #ff5252;
}
.bj-my-status {
  font-size: 14px;
  font-weight: 700;
  color: #00e676;
  flex-shrink: 0;
}

/* ===== CARDS — base (dealer / opponents) ===== */
.bj-card {
  width: 40px;
  height: 58px;
  border-radius: 5px;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

/* ===== MY CARDS — huge, real card feel ===== */
.bj-card-big {
  /* Use viewport-relative sizing for real card feel */
  width: clamp(100px, 28vw, 160px);
  height: clamp(150px, 42vw, 240px);
  border-radius: 12px;
  box-shadow:
    0 4px 16px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.08),
    inset 0 1px 0 rgba(255,255,255,0.1);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Fan layout for my cards */
.bj-my-cards .bj-card-big {
  margin: 0 -12px;
  transform-origin: bottom center;
}

/* Fan rotation for each card position */
.bj-my-cards .bj-card-big:nth-child(1) { z-index: 1; }
.bj-my-cards .bj-card-big:nth-child(2) { z-index: 2; }
.bj-my-cards .bj-card-big:nth-child(3) { z-index: 3; }
.bj-my-cards .bj-card-big:nth-child(4) { z-index: 4; }
.bj-my-cards .bj-card-big:nth-child(5) { z-index: 5; }
.bj-my-cards .bj-card-big:nth-child(6) { z-index: 6; }

/* 2 cards — slight spread */
.bj-my-cards .bj-card-big:first-child:nth-last-child(2) {
  transform: rotate(-6deg) translateY(-4px);
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(2) ~ .bj-card-big {
  transform: rotate(6deg) translateY(-4px);
}

/* 3 cards — wider fan */
.bj-my-cards .bj-card-big:first-child:nth-last-child(3) {
  transform: rotate(-10deg) translateY(-2px);
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(3) + .bj-card-big {
  transform: rotate(0deg) translateY(-6px);
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(3) + .bj-card-big + .bj-card-big {
  transform: rotate(10deg) translateY(-2px);
}

/* 4 cards */
.bj-my-cards .bj-card-big:first-child:nth-last-child(4) {
  transform: rotate(-12deg) translateY(0px);
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(4) + .bj-card-big {
  transform: rotate(-4deg) translateY(-5px);
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(4) + .bj-card-big + .bj-card-big {
  transform: rotate(4deg) translateY(-5px);
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(4) + .bj-card-big + .bj-card-big + .bj-card-big {
  transform: rotate(12deg) translateY(0px);
}

/* 5+ cards — tighter overlap */
.bj-my-cards .bj-card-big:first-child:nth-last-child(n+5) {
  transform: rotate(-14deg) translateY(2px);
  margin: 0 -18px;
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(n+5) + .bj-card-big {
  transform: rotate(-7deg) translateY(-3px);
  margin: 0 -18px;
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(n+5) + .bj-card-big + .bj-card-big {
  transform: rotate(0deg) translateY(-6px);
  margin: 0 -18px;
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(n+5) + .bj-card-big + .bj-card-big + .bj-card-big {
  transform: rotate(7deg) translateY(-3px);
  margin: 0 -18px;
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(n+5) + .bj-card-big + .bj-card-big + .bj-card-big + .bj-card-big {
  transform: rotate(14deg) translateY(2px);
  margin: 0 -18px;
}
.bj-my-cards .bj-card-big:first-child:nth-last-child(n+5) + .bj-card-big + .bj-card-big + .bj-card-big + .bj-card-big ~ .bj-card-big {
  transform: rotate(18deg) translateY(6px);
  margin: 0 -18px;
}

/* Card back */
.bj-card-back {
  background: linear-gradient(135deg, #1a237e, #283593);
  border: 2px solid #3949ab;
}
.bj-card-back-pattern {
  position: absolute;
  inset: 4px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  background: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(255,255,255,0.05) 4px, rgba(255,255,255,0.05) 8px);
}
.bj-card-big.bj-card-back .bj-card-back-pattern {
  inset: 8px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.12);
  background:
    repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(255,255,255,0.04) 6px, rgba(255,255,255,0.04) 12px),
    radial-gradient(circle at center, rgba(255,255,255,0.06) 0%, transparent 70%);
}

/* Card face colors */
.bj-card.bj-red {
  background: #fff;
  border: 1px solid #ddd;
  color: #d32f2f;
}
.bj-card.bj-black {
  background: #fff;
  border: 1px solid #ddd;
  color: #212121;
}

/* Big card enhanced face */
.bj-card-big.bj-red {
  background: linear-gradient(160deg, #ffffff 0%, #fff5f5 100%);
  border: 1.5px solid #e0e0e0;
}
.bj-card-big.bj-black {
  background: linear-gradient(160deg, #ffffff 0%, #f5f5f5 100%);
  border: 1.5px solid #e0e0e0;
}

/* Card corners */
.bj-card-corner {
  position: absolute;
  top: 3px;
  left: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.bj-card-corner-br {
  top: auto;
  left: auto;
  bottom: 3px;
  right: 4px;
  transform: rotate(180deg);
}

/* Small card text */
.bj-card-rank {
  font-size: 11px;
  font-weight: 900;
}
.bj-card-suit-sm {
  font-size: 8px;
}
.bj-card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
}

/* Big card text — proportionally large */
.bj-card-big .bj-card-corner {
  top: 8px;
  left: 10px;
}
.bj-card-big .bj-card-corner-br {
  bottom: 8px;
  right: 10px;
}
.bj-card-big .bj-card-rank {
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 900;
  letter-spacing: -0.5px;
}
.bj-card-big .bj-card-suit-sm {
  font-size: clamp(14px, 4vw, 20px);
}
.bj-card-big .bj-card-center {
  font-size: clamp(44px, 12vw, 72px);
  opacity: 0.85;
}

/* New card deal animation */
@keyframes bjCardDeal {
  from {
    opacity: 0;
    transform: translateY(-40px) scale(0.7) rotate(0deg);
  }
  to {
    opacity: 1;
  }
}
.bj-my-cards .bj-card-big {
  animation: bjCardDeal 0.4s ease-out both;
}
.bj-my-cards .bj-card-big:nth-child(2) { animation-delay: 0.1s; }
.bj-my-cards .bj-card-big:nth-child(3) { animation-delay: 0.2s; }
.bj-my-cards .bj-card-big:nth-child(4) { animation-delay: 0.3s; }
.bj-my-cards .bj-card-big:nth-child(5) { animation-delay: 0.4s; }

/* ===== BOTTOM PANEL ===== */
.bj-bottom-panel {
  padding: 6px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
  flex-shrink: 0;
}

/* Betting area */
.bj-bet-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  padding: 10px;
}
.bj-bet-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  max-width: 320px;
}
.bj-bet-input {
  flex: 1;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  outline: none;
}
.bj-bet-input:focus {
  border-color: #ffd700;
}
.bj-bet-quick {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.bj-bet-quick-btn {
  background: rgba(255,215,0,0.15);
  border: 1px solid rgba(255,215,0,0.3);
  color: #ffd700;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.bj-bet-quick-btn:active {
  background: rgba(255,215,0,0.3);
}
.bj-bet-confirm {
  background: linear-gradient(135deg, #ffd700, #ffab00);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.bj-deal-btn {
  background: linear-gradient(135deg, #00e676, #00c853);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  margin: 0 auto;
  display: none;
}

/* Action area */
.bj-action-area {
  display: none;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.bj-action-btn {
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  min-width: 88px;
  transition: transform 0.1s, opacity 0.2s;
}
.bj-action-btn:active {
  transform: scale(0.95);
}
.bj-action-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}
.bj-btn-hit {
  background: linear-gradient(135deg, #00e5ff, #00b8d4);
  color: #000;
}
.bj-btn-stand {
  background: linear-gradient(135deg, #ff9100, #e65100);
  color: #fff;
}
.bj-btn-double {
  background: linear-gradient(135deg, #ffd700, #ffab00);
  color: #000;
}

/* ===== RESULT OVERLAY ===== */
.bj-result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
}
.bj-result-overlay.active {
  display: flex;
}
.bj-result-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 28px;
  color: #ffd700;
}
.bj-result-dealer {
  text-align: center;
}
.bj-result-dealer-label {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 6px;
}
.bj-result-dealer-cards {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.bj-result-dealer-total {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-top: 6px;
}
.bj-result-list {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bj-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  font-size: 14px;
}
.bj-result-row.bj-result-me {
  background: rgba(255,215,0,0.12);
  border: 1px solid rgba(255,215,0,0.3);
}
.bj-result-name {
  color: #fff;
  font-weight: 600;
}
.bj-result-total {
  color: #aaa;
  font-size: 12px;
}
.bj-result-label {
  font-weight: 700;
}
.bj-result-label.bj-win { color: #00e676; }
.bj-result-label.bj-lose { color: #ff5252; }
.bj-result-label.bj-push { color: #aaa; }
.bj-result-label.bj-blackjack { color: #ffd700; }
.bj-result-btns {
  display: flex;
  gap: 8px;
  max-width: 320px;
  width: 100%;
}

/* ===== MOBILE — 430px ===== */
@media screen and (max-width: 430px) {

  .bj-close-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  .bj-phase-badge {
    padding: 6px 12px;
    font-size: 11px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
  .bj-chip-display {
    font-size: clamp(12px, 3.5vw, 14px);
    padding: 3px 8px;
  }

  /* Dealer compact */
  .bj-dealer-area {
    padding: 4px 6px 2px;
  }
  .bj-dealer-label { font-size: 10px; }
  .bj-dealer-total { font-size: 12px; padding: 1px 8px; }
  .bj-dealer-cards {
    gap: 3px;
    min-height: 46px;
  }

  /* Dealer/opp small cards */
  .bj-card {
    width: 34px;
    height: 50px;
    border-radius: 4px;
  }
  .bj-card-rank { font-size: 10px; }
  .bj-card-suit-sm { font-size: 7px; }
  .bj-card-center { font-size: 15px; }

  /* My cards — HUGE on mobile */
  .bj-card-big {
    width: clamp(90px, 30vw, 140px);
    height: clamp(135px, 45vw, 210px);
    border-radius: 10px;
  }
  .bj-card-big .bj-card-rank {
    font-size: clamp(20px, 5.5vw, 28px);
  }
  .bj-card-big .bj-card-suit-sm {
    font-size: clamp(12px, 3.5vw, 18px);
  }
  .bj-card-big .bj-card-center {
    font-size: clamp(36px, 10vw, 60px);
  }
  .bj-card-big .bj-card-corner {
    top: 6px;
    left: 8px;
  }
  .bj-card-big .bj-card-corner-br {
    bottom: 6px;
    right: 8px;
  }

  .bj-my-total { font-size: clamp(22px, 6vw, 28px); }

  /* Opponents */
  .bj-opponents {
    padding: 2px 6px;
    gap: 4px;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .bj-opponents::-webkit-scrollbar { height: 0; display: none; }
  .bj-opp-slot {
    min-width: 50px;
    padding: 3px 2px;
  }
  .bj-opp-avatar { width: 24px; height: 24px; font-size: 12px; }
  .bj-opp-name { font-size: 9px; max-width: 50px; }
  .bj-opp-chips { font-size: 8px; }
  .bj-opp-bet { font-size: 8px; }
  .bj-opp-status { font-size: 8px; }

  /* Bottom panel */
  .bj-bottom-panel {
    padding: 4px 8px 10px;
    gap: 4px;
  }

  .bj-bet-area {
    padding: 8px;
    gap: 6px;
  }
  .bj-bet-row { max-width: 100%; gap: 6px; }
  .bj-bet-input {
    padding: 10px 8px;
    font-size: 16px;
    min-height: 44px;
    box-sizing: border-box;
  }
  .bj-bet-quick { gap: 4px; flex-wrap: wrap; }
  .bj-bet-quick-btn {
    padding: 10px 14px;
    font-size: 12px;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }
  .bj-bet-confirm {
    padding: 12px 20px;
    font-size: 15px;
    min-height: 44px;
    width: 100%;
    max-width: 280px;
  }
  .bj-deal-btn {
    padding: 12px 24px;
    font-size: 15px;
    min-height: 44px;
  }
  .bj-action-btn {
    padding: 14px 20px;
    font-size: 15px;
    min-width: 80px;
    min-height: 48px;
  }

  /* Result overlay */
  .bj-result-overlay { padding: 16px; gap: 12px; }
  .bj-result-title { font-size: clamp(22px, 6vw, 28px); }
  .bj-result-list { max-width: min(340px, calc(100vw - 32px)); }
  .bj-result-row { padding: 8px 10px; font-size: 13px; }
  .bj-result-total { font-size: 12px; }
  .bj-result-btns { max-width: min(320px, calc(100vw - 32px)); }
  .bj-result-btns > button { min-height: 44px; font-size: 14px; }
  .bj-result-dealer-cards { gap: 3px; }
}

/* ===== SMALL PHONE — 360px ===== */
@media screen and (max-width: 360px) {

  .bj-top-bar { padding: 4px 6px; }
  .bj-top-info { gap: 6px; }
  .bj-chip-display { font-size: 11px; padding: 2px 6px; }
  .bj-phase-badge { padding: 4px 8px; font-size: 10px; }

  /* Dealer/opp cards even smaller */
  .bj-card {
    width: 28px;
    height: 42px;
    border-radius: 3px;
  }
  .bj-card-rank { font-size: 9px; }
  .bj-card-suit-sm { font-size: 6px; }
  .bj-card-center { font-size: 13px; }
  .bj-card-corner { top: 2px; left: 2px; }
  .bj-card-corner-br { bottom: 2px; right: 2px; }

  /* My cards — still large! */
  .bj-card-big {
    width: clamp(80px, 28vw, 120px);
    height: clamp(120px, 42vw, 180px);
    border-radius: 8px;
  }
  .bj-card-big .bj-card-rank { font-size: clamp(18px, 5vw, 24px); }
  .bj-card-big .bj-card-suit-sm { font-size: clamp(11px, 3vw, 16px); }
  .bj-card-big .bj-card-center { font-size: clamp(32px, 9vw, 50px); }
  .bj-card-big .bj-card-corner { top: 5px; left: 6px; }
  .bj-card-big .bj-card-corner-br { bottom: 5px; right: 6px; }

  /* Opponents micro */
  .bj-opp-slot { min-width: 44px; padding: 2px 2px; }
  .bj-opp-avatar { width: 22px; height: 22px; font-size: 11px; }
  .bj-opp-name { font-size: 8px; max-width: 44px; }

  .bj-dealer-area { padding: 3px 4px 1px; }
  .bj-dealer-cards { gap: 2px; min-height: 44px; }
  .bj-dealer-total { font-size: 11px; }

  .bj-my-total { font-size: clamp(18px, 5vw, 22px); }

  .bj-bet-quick-btn {
    padding: 8px 10px;
    font-size: 11px;
    min-width: 40px;
    min-height: 40px;
  }
  .bj-action-btn {
    padding: 12px 16px;
    font-size: 14px;
    min-width: 72px;
    min-height: 44px;
  }

  .bj-result-overlay { padding: 12px; gap: 10px; }
  .bj-result-title { font-size: 20px; }
  .bj-result-row { padding: 6px 8px; font-size: 12px; }
  .bj-result-list { max-width: calc(100vw - 24px); }
  .bj-result-btns { max-width: calc(100vw - 24px); }
}
