/* =========================================
   GLOBAL RESET & SCROLLBAR REMOVAL 
   ========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Mandated rule: complete scrollbar removal */
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
}

::-webkit-scrollbar {
  display: none !important;
}

body {
  background-color: #000;
  color: #fff;
  font-family: 'Aclonica', sans-serif;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* =========================================
   THE CASINO TABLE & FELT
   ========================================= */
.casino-table {
  width: 100%;
  height: 100%;
  max-width: 1400px;
  background-color: #111;
  /* Leather bumper effect */
  padding: 1.5rem;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 1);
}

.table-felt {
  width: 100%;
  height: 100%;
  border-radius: 40px;
  /* Realistic Casino Green Felt */
  background: radial-gradient(circle at 50% 30%, #157B36 0%, #083b19 80%);
  border: 12px solid #2a1610;
  /* Dark wood/leather trim */
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8), 0 10px 30px rgba(0, 0, 0, 0.9);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* =========================================
   TABLE MARKINGS (Painted on the felt)
   ========================================= */
.table-markings {
  position: absolute;
  top: 35%;
  width: 100%;
  text-align: center;
  color: rgba(228, 200, 113, 0.6);
  /* Faded Gold Paint */
  pointer-events: none;
  /* Let clicks pass through */
}

.payout-text {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  letter-spacing: 4px;
  margin-bottom: 0.5rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.dealer-rules {
  font-size: clamp(0.8rem, 1.5vw, 1.2rem);
  letter-spacing: 2px;
  margin-bottom: 3rem;
  color: rgba(255, 255, 255, 0.5);
  /* Faded White Paint */
}

.insurance-line {
  width: 120%;
  height: 300px;
  border-top: 3px solid rgba(228, 200, 113, 0.4);
  border-radius: 50% 50% 0 0;
  position: absolute;
  left: -10%;
  text-align: center;
}

.insurance-line span {
  position: relative;
  top: -15px;
  background: #0d4a23;
  /* Match felt behind text */
  padding: 0 15px;
  font-size: clamp(0.8rem, 1.5vw, 1.2rem);
  letter-spacing: 3px;
}

/* =========================================
   GAME LAYOUT & CARDS
   ========================================= */
.top-nav {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 1.5rem;
  z-index: 10;
}

.bank-display {
  background: rgba(0, 0, 0, 0.6);
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  border: 1px solid rgba(228, 200, 113, 0.3);
  color: #e4c871;
  font-size: 1.2rem;
}

.table-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 5;
  width: 100%;
}

.dealer-section {
  margin-top: -2rem;
  min-height: 160px;
}

.player-section {
  margin-top: auto;
  margin-bottom: 0;
  min-height: 150px;
  position: relative;
  z-index: 30;
}

.card-rack {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 140px;
}

.card-rack img {
  width: clamp(70px, 9vw, 110px);
  margin-left: -35px;
  /* Realistic Overlap */
  border-radius: 6px;
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.6);
  transition: transform 0.3s;
}

.card-rack img:first-child {
  margin-left: 0;
}

.card-rack img:hover {
  transform: translateY(-10px);
  z-index: 10;
}

.score-badge {
  background: rgba(0, 0, 0, 0.7);
  padding: 0.3rem 1rem;
  border-radius: 20px;
  font-size: 1.1rem;
  color: #fff;
  margin: 10px 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* =========================================
   BETTING CIRCLE & CHIPS
   ========================================= */
.betting-circle {
  width: 90px;
  height: 90px;
  border: 3px solid rgba(228, 200, 113, 0.5);
  border-radius: 50%;
  margin: 1rem auto;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.1);
}

.play-on {
  color: #e4c871;
  font-size: 1.2rem;
  text-shadow: 1px 1px 2px #000;
  z-index: 10;
}

.betting-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 1rem;
  z-index: 10;
  flex-shrink: 0;
}

.chips-rack {
  background: rgba(0, 0, 0, 0.5);
  padding: 10px 20px;
  border-radius: 50px;
  margin-bottom: 1rem;
  border: 2px solid #222;
  box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.8);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.chip {
  width: 55px;
  cursor: pointer;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.6));
  transition: transform 0.2s;
}

.chip:hover {
  transform: scale(1.1) translateY(-5px);
}

/* =========================================
   CONTROLS & BUTTONS
   ========================================= */
.action-buttons, .game-controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1rem;
  z-index: 10;
}

.btn {
  font-family: 'Aclonica', sans-serif;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-transform: uppercase;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.btn-gold {
  background: linear-gradient(to bottom, #f3d779, #c39d38);
  color: #332400;
  border: 1px solid #ffd700;
}

.btn-gold:hover {
  background: linear-gradient(to bottom, #ffea99, #d4ae49);
}

.btn-dark {
  background: linear-gradient(to bottom, #444, #222);
  color: #fff;
  border: 1px solid #555;
}

.btn-dark:hover {
  background: linear-gradient(to bottom, #555, #333);
}

.btn-action {
  background: linear-gradient(to bottom, #2b5c8f, #15385e);
  color: #fff;
  border: 1px solid #4a8bd1;
}

.btn-action:hover {
  background: linear-gradient(to bottom, #3973b0, #1c4775);
}

/* =========================================
   NOTIFICATIONS & BANNERS
   ========================================= */
.score-output {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  border: 2px solid #e4c871;
  color: #e4c871;
  padding: 0.5rem 2rem;
  border-radius: 8px;
  font-size: 1.5rem;
  white-space: nowrap;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
  z-index: 20;
}

.toast-container {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1.1rem;
  border-left: 5px solid #e4c871;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-left-color: #ff3333;
}

.toast.warning {
  border-left-color: #ffaa00;
}

/* Rules Modal */
.table-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: #1a1a1a;
  border: 2px solid #e4c871;
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 100;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
}

.table-modal.rulesPop {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.table-modal h2 {
  color: #e4c871;
  margin-bottom: 1rem;
  border-bottom: 1px solid #333;
  padding-bottom: 0.5rem;
}

.table-modal ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.hide-toggle {
  display: none !important;
}

/* Mobile optimization */
@media (max-width: 600px) {
  .casino-table {
    padding: 0.5rem;
  }

  .table-felt {
    border-width: 6px;
  }

  .payout-text {
    letter-spacing: 2px;
  }

  .insurance-line {
    height: 200px;
  }

  .chip {
    width: 45px;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
}

/* =========================================
   SPLIT HANDS & INSURANCE UI
   ========================================= */
.player-hands-container:empty {
  min-height: 0;
  display: none;
}

.player-hands-container {
  display: flex;
  gap: 2rem;
  justify-content: center;
  align-items: flex-end;
  width: 100%;
  min-height: 140px;
  position: relative;
  z-index: 10;
}

.hand-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
  opacity: 0.5;
  /* Dim inactive hands */
  transform: scale(0.9);
}

.hand-wrapper.active-hand {
  opacity: 1;
  transform: scale(1);
}

.hand-wrapper.active-hand .score-badge {
  border-color: #00f0ff;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  color: #00f0ff;
}

.insurance-prompt {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 10, 15, 0.95);
  border: 2px solid #ffaa00;
  padding: 1.5rem 3rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 20px rgba(255, 170, 0, 0.2);
  z-index: 100;
  animation: popIn 0.3s ease-out;
}

.insurance-prompt p {
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  letter-spacing: 1px;
}

.insurance-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* =========================================
   PREMIUM BETTING BADGE (Glassmorphism + Neon)
   ========================================= */
.bet-area {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.5rem auto 2.5rem auto;
  position: relative;
  z-index: 20;
}

.active-bet-badge {
  background: rgba(10, 15, 20, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(0, 240, 255, 0.15);
  border-radius: 50px;
  padding: 0.6rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 200px;
}

.bet-label {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #a0aab5;
  margin-bottom: 0.3rem;
}

.active-bet-badge .play-on {
  color: #00f0ff;
  font-size: 1.8rem;
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
  font-weight: bold;
  margin: 0;
}

/* =========================================
   3D CARD DEALING ANIMATION
   ========================================= */
@keyframes dealCard3D {
  0% {
    opacity: 0;
    transform: translate(150px, -250px) rotate(-45deg) scale(0.6) perspective(600px) rotateY(45deg);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0) scale(1) perspective(600px) rotateY(0deg);
  }
}

.card-rack img {
  width: clamp(70px, 9vw, 110px);
  margin-left: -35px;
  border-radius: 6px;
  box-shadow: -6px 8px 15px rgba(0, 0, 0, 0.6), inset 0 0 2px rgba(255, 255, 255, 0.2);
  transition: transform 0.3s ease;
}

.card-rack img:first-child {
  margin-left: 0;
}

.card-rack img:hover {
  transform: translateY(-15px) scale(1.05);
  z-index: 20;
  box-shadow: -8px 12px 20px rgba(0, 0, 0, 0.8);
}

/* This class will now be applied dynamically by JS */
.deal-anim {
  animation: dealCard3D 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}