:root {
  --bg-color: #040605;
  --accent-green: rgba(18, 53, 36, 0.9);
  --accent-gold: #d4af37;
  --accent-gold-dim: rgba(212, 175, 55, 0.3);
  --text-color: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --card-bg: #f9f9f9;
  --tier-color: #a9a9a9;
  --transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Tier Specific Overrides */
body[data-tier="platinum"] {
  --bg-color: #0a0a0c;
  --accent-green: rgba(40, 45, 60, 0.9);
  --tier-color: #e5e4e2;
  --glass-border: rgba(229, 228, 226, 0.3);
}

body[data-tier="obsidian"] {
  --bg-color: #000000;
  --accent-green: rgba(0, 0, 0, 0.9);
  --tier-color: #00ffcc; /* neon accent for contrast */
  --card-bg: #1a1a1a;
  --glass-border: rgba(0, 255, 204, 0.2);
}
body[data-tier="obsidian"] .card {
  color: #fff;
  box-shadow: 0 12px 24px rgba(0,0,0,0.8), inset 0 0 0 1px rgba(0,255,204,0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: radial-gradient(circle at 50% 35%, var(--accent-green) 0%, transparent 75%);
  touch-action: none; /* Prevent pinch-to-zoom on iOS */
  overscroll-behavior: none; /* Prevent pull-to-refresh */
}

#app {
  width: 100%;
  max-width: 500px;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  padding: 10px 24px;
  font-size: 1.05rem;
  font-weight: 300;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.85);
  z-index: 10;
}

/* Privilege Header (Phase 2) */
.privilege-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 24px 0 24px;
  z-index: 10;
}

.tier-section {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.tier-icon {
  font-size: 1.8rem;
  color: var(--tier-color);
  text-shadow: 0 0 10px var(--tier-color);
}

.tier-details {
  display: flex;
  flex-direction: column;
}

.tier-name {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--tier-color);
  margin-bottom: 4px;
}

.ep-progress {
  width: 80px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.ep-fill {
  height: 100%;
  width: 0%;
  background: var(--tier-color);
  box-shadow: 0 0 5px var(--tier-color);
  transition: width 1s ease-out;
}

.rank-section {
  font-size: 0.9rem;
  font-weight: 300;
  color: #fff;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  backdrop-filter: blur(5px);
}

}

.drawer-header {
  display: flex;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--glass-border);
}

.drawer-header h2 {
  font-weight: 300;
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.drawer-content {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.rank-item.ghost-v2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.rank-item.ghost-v2:active {
  transform: scale(0.98);
  background: rgba(255,255,255,0.05);
}
.rank-item.is-player {
  background: rgba(212, 175, 55, 0.1);
  border-color: rgba(212, 175, 55, 0.3);
}
.rank-item.is-rival {
  background: rgba(255, 77, 77, 0.05);
  border-color: rgba(255, 77, 77, 0.2);
}
.ghost-avatar {
  font-size: 1.8rem;
  margin-right: 15px;
  background: rgba(0,0,0,0.5);
  width: 45px; height: 45px;
  display: flex; justify-content: center; align-items: center;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.ghost-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.rank-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: #fff;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ghost-status {
  font-size: 0.75rem;
  color: #888;
}
.status-dot { font-size: 0.5rem; animation: pulseTitle 2s infinite alternate;}
.ghost-wealth {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.rank-score {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent-gold);
}
.ghost-tier {
  font-size: 0.7rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.rival-badge {
  font-size: 0.6rem;
  background: #ff4d4d;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.buy-rank-btn {
  margin-top: auto;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}
.buy-rank-btn .btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-gold), #fff);
  color: #000;
  border: none;
}

#balance, #current-bet {
  color: var(--accent-gold);
  font-weight: 400;
}

.table {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 20px 10px 20px;
  position: relative;
  perspective: 1000px;
  transition: transform 0.5s ease;
}
.table.shift-left {
  transform: translateX(-15px);
}

.center-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.2rem;
  font-weight: 200;
  letter-spacing: 14px;
  opacity: 0.15;
  text-transform: uppercase;
  text-align: center;
  color: var(--accent-gold);
  pointer-events: none;
}

.cards {
  display: flex;
  justify-content: center;
  min-height: 120px;
}

.card {
  width: 76px;
  height: 114px;
  background: var(--card-bg);
  box-shadow: 0 12px 24px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(255,255,255,1);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  font-weight: 400;
  color: #111;
  margin-left: -45px;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  opacity: 0;
  transform: translate(150px, -300px) rotate(25deg) scale(0.8);
  animation: dealCard 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

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

.card.red {
  color: #d12e2e;
}

.card.hidden-card {
  background: repeating-linear-gradient(
    45deg,
    #0b1c13,
    #0b1c13 6px,
    #0f281b 6px,
    #0f281b 12px
  );
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.05), 0 10px 20px rgba(0,0,0,0.5);
  color: transparent;
}

@keyframes dealCard {
  to {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

.card.sweep-away {
  transform: translate(300px, -400px) rotate(45deg) scale(0.5) !important;
  opacity: 0 !important;
  transition: transform 0.6s cubic-bezier(0.5, 0, 0.2, 1), opacity 0.5s ease-in !important;
}

.score-display {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 1px;
  opacity: 0.7;
  margin: 15px 0;
  min-height: 1.2rem;
  text-transform: uppercase;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
}

.controls {
  padding: 10px 20px;
  padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 15px);
  z-index: 10;
  background: linear-gradient(to top, rgba(5,5,5,1) 20%, rgba(5,5,5,0.8) 70%, rgba(5,5,5,0) 100%);
}

.betting-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  transition: var(--transition);
}

.play-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 350px;
  margin: 0 auto;
  transition: var(--transition);
}

.hidden {
  display: none !important;
}

.btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  padding: 16px 10px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 300;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.2s, background-color 0.2s;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn.chip {
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at top left, rgba(60, 60, 65, 0.8), rgba(20, 20, 25, 0.9));
  box-shadow: 0 8px 20px rgba(0,0,0,0.6), inset 0 2px 2px rgba(255,255,255,0.1);
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.btn.chip::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  pointer-events: none;
}

.btn.chip:active {
  background: radial-gradient(circle at top left, rgba(80, 80, 85, 0.8), rgba(30, 30, 35, 0.9));
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.6), inset 0 3px 5px rgba(0,0,0,0.4);
}

.btn.action-btn {
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-radius: 12px;
  padding: 12px 8px;
  font-size: 1rem;
  box-shadow: 0 10px 20px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.1);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.btn.action-btn:active {
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.7), inset 0 2px 4px rgba(0,0,0,0.4);
}

/* Hit Button: Deep Sapphire */
#btn-hit {
  background: linear-gradient(135deg, #0e5a8a, #042036);
  border: 1px solid rgba(14, 153, 255, 0.3);
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* Stand Button: Ruby Red */
#btn-stand {
  background: linear-gradient(135deg, #8a1324, #36040b);
  border: 1px solid rgba(255, 30, 60, 0.3);
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* Double Button: Rich Gold */
#btn-double {
  background: linear-gradient(135deg, #d4af37, #8c6a0b);
  border: 1px solid rgba(255, 223, 0, 0.4);
  color: #111;
  text-shadow: 0 1px 1px rgba(255,255,255,0.3);
}

/* Surrender Button: Subtle Dark Glass */
#btn-surrender {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.5);
  box-shadow: none;
}

.btn.outline {
  /* Removed to let #btn-double and #btn-surrender keep their custom gradients */
}

.btn.outline:active {
  /* Removed to not override the base :active */
}

.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  animation: fadeIn 0.4s forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.modal-content {
  background: rgba(12, 16, 14, 0.85);
  padding: 40px 30px;
  border-radius: 24px;
  border: 1px solid var(--accent-gold-dim);
  box-shadow: 0 24px 48px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.05);
  text-align: center;
  width: 85%;
  transform: scale(0.95);
  animation: scaleUp 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes scaleUp {
  to { transform: scale(1); }
}

.modal-content h2 {
  font-weight: 300;
  margin-bottom: 12px;
  color: var(--accent-gold);
  letter-spacing: 1px;
}

.modal-content p {
  opacity: 0.8;
  font-size: 0.95rem;
  margin-bottom: 30px;
  line-height: 1.5;
  color: #f0f0f0;
}

.modal-content .text-btn {
  background: transparent;
  border: none;
  display: block;
  width: 100%;
  margin-top: 20px;
  opacity: 0.5;
  font-weight: 300;
  font-size: 0.9rem;
  color: #fff;
  transition: opacity 0.2s;
}

.modal-content .text-btn:active {
  opacity: 1;
}

/* VICTORY & DEFEAT OVERLAYS */
.victory-overlay, .defeat-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.victory-overlay {
  background: radial-gradient(circle at center, rgba(212, 175, 55, 0.15) 0%, rgba(0,0,0,0.85) 100%);
  animation: victoryIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.defeat-overlay {
  background: radial-gradient(circle at center, rgba(150, 0, 0, 0.08) 0%, rgba(10,10,10,0.9) 100%);
  backdrop-filter: blur(8px) grayscale(60%);
  -webkit-backdrop-filter: blur(8px) grayscale(60%);
  animation: defeatIn 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.victory-overlay.hidden, .defeat-overlay.hidden { 
  display: none !important; 
  animation: none; 
}

@keyframes victoryIn {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); filter: brightness(0.5); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: brightness(1.2); }
}

@keyframes defeatIn {
  0% { opacity: 0; transform: scale(1.1); filter: contrast(1); }
  50% { opacity: 1; transform: scale(0.98); filter: contrast(1.5); }
  100% { opacity: 1; transform: scale(1); filter: contrast(1.2); }
}

.victory-title {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--accent-gold);
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.8), 0 10px 20px rgba(0,0,0,0.9);
  letter-spacing: 2px;
  margin-bottom: 10px;
  text-transform: uppercase;
  text-align: center;
  width: 100%;
  padding: 0 10px;
  box-sizing: border-box;
  animation: pulseTitle 1.5s infinite alternate;
}

@media (max-width: 400px) {
  .victory-title {
    font-size: 2.5rem;
    letter-spacing: 1px;
  }
}

@keyframes pulseTitle {
  to { transform: scale(1.05); text-shadow: 0 0 40px rgba(212, 175, 55, 1), 0 5px 15px rgba(0,0,0,0.8); }
}

.defeat-title {
  color: #e74c3c;
  text-shadow: 0 0 30px rgba(231, 76, 60, 0.4), 0 5px 15px rgba(0,0,0,0.9);
  letter-spacing: 8px;
  text-align: center;
  font-weight: 300;
  margin-bottom: 15px;
  animation: pulseDefeat 2s infinite alternate;
}

@keyframes pulseDefeat {
  to { transform: scale(1.02); text-shadow: 0 0 40px rgba(231, 76, 60, 0.6); }
}

.victory-amount {
  font-size: 2.5rem;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 2px 10px rgba(255,255,255,0.3);
}

.defeat-amount {
  color: #ff8888;
  opacity: 0.8;
  font-size: 2rem;
}

/* CARD HIGHLIGHTS */
.win-glow {
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.5) !important;
  transform: scale(1.08) translateY(-10px) !important;
  border-color: rgba(255, 255, 255, 0.8) !important;
  z-index: 10;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.win-glow-dealer {
  box-shadow: 0 0 40px rgba(255, 50, 50, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.3) !important;
  transform: scale(1.08) translateY(10px) !important;
  border-color: rgba(255, 100, 100, 0.8) !important;
  z-index: 10;
  transition: all 0.5s ease-out;
}

.lose-dim {
  filter: brightness(0.4) grayscale(0.8);
  transform: scale(0.95) !important;
  transition: all 0.5s ease-in-out;
}

.lose-dim-player {
  filter: brightness(0.3) grayscale(1) sepia(0.5) hue-rotate(-50deg);
  transform: scale(0.92) translateY(20px) rotate(-3deg) !important;
  opacity: 0.6;
  transition: all 0.6s cubic-bezier(0.55, 0.085, 0.68, 0.53);
}

/* Screen Shake */
.shake-light { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; }
.shake-heavy { animation: shakeHeavy 0.5s cubic-bezier(.36,.07,.19,.97) both; }

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

@keyframes shakeHeavy {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(6px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-10px, 0, 0); }
  40%, 60% { transform: translate3d(10px, 0, 0); }
}

.flash-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; opacity: 0; z-index: 200;
}
.flash-win { animation: flashWin 0.8s ease-out; }
.flash-lose { animation: flashLose 0.8s ease-out; }

@keyframes flashWin {
  0% { opacity: 0.8; background: rgba(212, 175, 55, 0.4); }
  100% { opacity: 0; background: transparent; }
}
@keyframes flashLose {
  0% { opacity: 0.9; background: rgba(255, 0, 0, 0.5); }
  100% { opacity: 0; background: transparent; }
}

#particles-container {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 80; overflow: hidden;
}
.particle {
  position: absolute;
  width: 8px; height: 15px;
  background: var(--accent-gold);
  border-radius: 4px;
  box-shadow: 0 0 10px var(--accent-gold);
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* === CASINO CHIP & TABLE STYLES === */


.physical-chip {
  width: 48px; 
  height: 48px;
  border-radius: 50%;
  position: absolute;
  background: repeating-conic-gradient(
    #ffffff 0deg 15deg,
    var(--chip-color) 15deg 45deg
  );
  box-shadow: 0 6px 10px rgba(0,0,0,0.5), inset 0 0 4px rgba(0,0,0,0.6);
  display: flex; 
  justify-content: center; 
  align-items: center;
  z-index: 20;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), left 0.4s cubic-bezier(0.25, 1, 0.5, 1), top 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  border: 1px solid rgba(0,0,0,0.3);
}

.physical-chip.chip-flying {
  z-index: 100;
  box-shadow: 0 15px 25px rgba(0,0,0,0.6);
}

.chip-inner {
  width: 34px; 
  height: 34px;
  border-radius: 50%;
  background: var(--chip-color);
  border: 2px dashed rgba(255, 255, 255, 0.8);
  display: flex; 
  justify-content: center; 
  align-items: center;
  color: #fff; 
  font-weight: 700; 
  font-size: 13px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
}

.chip-10 { --chip-color: #3498db; }
.chip-50 { --chip-color: #e74c3c; }
.chip-100 { --chip-color: #2ecc71; }
.chip-500 { --chip-color: #9b59b6; }

/* SPECIFIC BUTTON STYLES FOR COGNITIVE EASE */

/* DEAL BUTTON - The Gateway (Solid Gold) */
#btn-deal {
  background: linear-gradient(145deg, #e6c27a 0%, #d4af37 50%, #aa8c2c 100%);
  color: #111;
  border: 1px solid rgba(255, 245, 200, 0.6);
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.3), inset 0 2px 2px rgba(255, 255, 255, 0.4);
  text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
#btn-deal:active {
  box-shadow: 0 4px 10px rgba(212, 175, 55, 0.2), inset 0 3px 5px rgba(0, 0, 0, 0.3);
}

/* HIT BUTTON - Action/Continue (Sapphire Glass) */
#btn-hit {
  background: linear-gradient(145deg, rgba(30, 100, 220, 0.8) 0%, rgba(15, 60, 160, 0.9) 100%);
  color: #ffffff;
  border: 1px solid rgba(100, 150, 255, 0.4);
  box-shadow: 0 8px 25px rgba(15, 60, 160, 0.3), inset 0 2px 2px rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
#btn-hit:active {
  box-shadow: 0 4px 10px rgba(15, 60, 160, 0.2), inset 0 3px 5px rgba(0, 0, 0, 0.4);
}

/* STAND BUTTON - Stop/Hold (Ruby Glass) */
#btn-stand {
  background: linear-gradient(145deg, rgba(200, 40, 60, 0.8) 0%, rgba(130, 15, 30, 0.9) 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 100, 120, 0.4);
  box-shadow: 0 8px 25px rgba(130, 15, 30, 0.3), inset 0 2px 2px rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
#btn-stand:active {
  box-shadow: 0 4px 10px rgba(130, 15, 30, 0.2), inset 0 3px 5px rgba(0, 0, 0, 0.4);
}

/* DOUBLE DOWN BUTTON - High Risk/Reward (Obsidian Gold Outline) */
#btn-double {
  background: radial-gradient(circle at top left, rgba(40, 40, 45, 0.9), rgba(15, 15, 18, 1));
  color: #d4af37;
  border: 1px solid #d4af37;
  box-shadow: 0 8px 20px rgba(0,0,0,0.6), inset 0 2px 2px rgba(212, 175, 55, 0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
#btn-double:active {
  background: radial-gradient(circle at top left, rgba(50, 50, 55, 0.9), rgba(20, 20, 25, 1));
  box-shadow: 0 4px 10px rgba(0,0,0,0.6), inset 0 3px 5px rgba(0,0,0,0.6);
}
/* SURRENDER BUTTON - Escape (Slate/Grey Outline) */
#btn-surrender {
  background: radial-gradient(circle at top left, rgba(60, 60, 65, 0.8), rgba(20, 20, 25, 0.9));
  color: #a0a0a0;
  border: 1px solid #707070;
  box-shadow: 0 5px 15px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.1);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
#btn-surrender:active {
  background: radial-gradient(circle at top left, rgba(40, 40, 45, 0.8), rgba(10, 10, 15, 0.9));
  box-shadow: 0 3px 10px rgba(0,0,0,0.6), inset 0 3px 5px rgba(0,0,0,0.6);
}

/* ROOM INDICATOR */
.room-indicator {
  text-align: center;
  padding: 8px 0;
  font-size: 0.85rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.room-icon {
  color: var(--accent-gold);
  margin-right: 5px;
}
/* BETTING CHIPS AS CIRCLES */
.betting-controls {
  display: flex;
  gap: 25px;
  justify-content: center;
  align-items: center;
  transition: var(--transition);
  padding: 10px 0;
}

.betting-controls .btn.chip {
  flex: 0 0 auto;
  width: 75px;
  height: 75px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(0,0,0,0.8), inset 0 2px 4px rgba(255,255,255,0.4), inset 0 -4px 6px rgba(0,0,0,0.6);
  border: 1px solid rgba(0,0,0,0.8);
  position: relative;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.2s;
}

.betting-controls .btn.chip::before {
  content: '';
  position: absolute;
  top: 6px; left: 6px; right: 6px; bottom: 6px;
  border: 3px dashed rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  pointer-events: none;
}

.betting-controls .btn.chip::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(
    rgba(255,255,255,0.15) 0deg 15deg,
    transparent 15deg 45deg
  );
  pointer-events: none;
}

.betting-controls .btn.chip:active {
  transform: scale(0.9) translateY(4px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.8), inset 0 4px 8px rgba(0,0,0,0.8);
}

/* Specific chip colors based on value */
.betting-controls .btn.chip:nth-child(1) { /* $50 */
  background: radial-gradient(circle at top left, #ff4b2b, #8e0000);
  color: #fff;
}
.betting-controls .btn.chip:nth-child(2) { /* $100 */
  background: radial-gradient(circle at top left, #00b09b, #005f3b);
  color: #fff;
}
.betting-controls .btn.chip:nth-child(3) { /* $500 */
  background: radial-gradient(circle at top left, #4a00e0, #140033);
  color: #fff;
}


/* The DEAL button is separate and should remain rectangular but centered */
.deal-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 15px;
}

.deal-container .btn-deal {
  width: 80%;
  max-width: 300px;
}

/* TABLE BETTING AREA (Invisible container for chips) */
.dealer-area {
  transform: translateY(-20px);
}

.player-area {
  transform: translateY(0px);
}

.table-bet-area {
  position: absolute;
  top: 50%; 
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* Ensure chips stack nicely inside */
.table-bet-area .physical-chip {
  position: absolute;
  margin-top: -10px; 
}

/* Advanced Play Controls */
.pulse-btn {
  animation: breathe 2s infinite ease-in-out;
}
@keyframes breathe {
  0% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.2); }
  50% { box-shadow: 0 0 20px rgba(255, 255, 255, 0.6); }
  100% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.2); }
}

.pulse-btn-subtle {
  animation: breatheSubtle 3s infinite ease-in-out;
}
@keyframes breatheSubtle {
  0% { box-shadow: inset 0 0 2px rgba(212, 175, 55, 0.2); }
  50% { box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.4); border-color: rgba(212,175,55,0.6); }
  100% { box-shadow: inset 0 0 2px rgba(212, 175, 55, 0.2); }
}

.muted-btn {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.05) !important;
  color: #eee !important;
  border-color: rgba(255,255,255,0.15) !important;
  font-weight: 300 !important;
  box-shadow: none !important;
}

/* Bailout & Insurance */
.bailout-contract {
  background: #f4f1ea !important;
  color: #222 !important;
  border-radius: 4px !important;
  font-family: 'Times New Roman', serif !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  background-image: url('data:image/svg+xml;utf8,<svg opacity="0.05" xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23n)"/></svg>');
}
.bailout-contract h2 { color: #111 !important; font-weight: bold; border-bottom: 2px solid #111; padding-bottom: 10px;}
.contract-text { color: #333 !important; text-align: justify; font-size: 0.85rem !important; margin-bottom: 40px !important;}

.long-press-btn {
  background: #111 !important;
  color: #fff !important;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s;
}
.long-press-fill {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%;
  background: rgba(212, 175, 55, 0.5);
  transition: width 0.1s linear;
}

.insurance-bg { background: rgba(80, 10, 10, 0.85) !important; }
.insurance-bg .modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.alert-text { color: #ff4d4d !important; text-shadow: 0 0 10px rgba(255,0,0,0.5); margin-bottom: 15px;}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 15px;
}
.timer-bar { width: 100%; height: 4px; background: rgba(0,0,0,0.5); margin-top: 20px; border-radius: 2px; overflow: hidden; }
.timer-fill { width: 100%; height: 100%; background: #ff4d4d; }

/* Abyss Vault */
.abyss-vault {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: transform 0.2s;
}
.abyss-vault:active { transform: scale(0.9); }
.vault-ring { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 3.5; }
.ring-fill { fill: none; stroke: var(--accent-gold); stroke-width: 3.5; stroke-linecap: round; transition: stroke-dasharray 0.5s ease-out; }
.vault-amount {
  position: absolute; font-size: 0.65rem; font-weight: bold; color: var(--accent-gold); text-shadow: 0 0 5px rgba(212,175,55,0.5);
}
.vault-ready {
  animation: vaultPulse 1s infinite alternate;
  box-shadow: 0 0 20px rgba(212,175,55,0.8), inset 0 0 10px rgba(212,175,55,0.5);
  border-radius: 50%;
}
@keyframes vaultPulse {
  0% { transform: scale(1); filter: brightness(1); box-shadow: 0 0 15px rgba(212,175,55,0.6); }
  100% { transform: scale(1.15); filter: brightness(1.5); box-shadow: 0 0 30px rgba(212,175,55,1), 0 0 40px rgba(255,255,255,0.4); }
}

/* Tooltip base */
.tooltip-container {
  position: relative;
  cursor: pointer;
}
.tooltip-container::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(10, 10, 10, 0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  z-index: 1000;
  pointer-events: none;
}
.tooltip-container:active::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.phantom-toast {
  position: absolute;
  top: 100px; right: 20px; left: auto;
  transform: translateX(120%);
  background: rgba(10, 15, 20, 0.9);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 0.85rem;
  color: #ddd;
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.phantom-toast.show {
  transform: translateX(0);
  opacity: 1;
}
.phantom-highlight {
  color: var(--accent-gold);
  font-weight: 500;
}
.intro-overlay {
  position: fixed; top:0; left:0; width:100vw; height:100vh;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}
.intro-overlay.fade-out {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.intro-content {
  text-align: center;
  animation: introPop 2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.intro-icon {
  font-size: 4rem;
  color: var(--tier-color);
  margin-bottom: 10px;
  text-shadow: 0 0 20px var(--tier-color);
}
.intro-name {
  font-size: 1.2rem;
  letter-spacing: 4px;
  color: #fff;
  font-weight: 300;
  text-transform: uppercase;
}
@keyframes introPop {
  0% { opacity: 0; transform: scale(0.8) translateY(20px); filter: blur(10px); }
  30% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0px); }
  70% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0px); }
  100% { opacity: 0; transform: scale(1.1) translateY(-10px); filter: blur(5px); }
}

/* Mystery Drop Envelope */
.envelope-container {
  width: 280px; height: 180px;
  position: relative;
  cursor: pointer;
  perspective: 1000px;
}
.envelope {
  width: 100%; height: 100%;
  background: #111;
  border: 1px solid #333;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  position: relative;
  transition: transform 0.5s;
}
.envelope:active { transform: scale(0.95); }
.envelope-flap {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0;
  border-left: 140px solid transparent;
  border-right: 140px solid transparent;
  border-top: 100px solid #1a1a1a;
  transform-origin: top;
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 4;
}
.envelope.open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}
.envelope-seal {
  position: absolute; top: 90px; left: 50%;
  transform: translate(-50%, -50%);
  width: 50px; height: 50px;
  background: #8b0000;
  border-radius: 50%;
  display: flex; justify-content: center; align-items: center;
  color: #fff; font-family: serif; font-style: italic;
  font-size: 0.8rem; box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  z-index: 5;
  transition: opacity 0.3s;
}
.envelope.open .envelope-seal { opacity: 0; }
.envelope-letter {
  position: absolute; top: 10px; left: 10px; right: 10px; bottom: 10px;
  background: #f4f1ea;
  border: 1px solid #ddd;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  z-index: 2;
  transform: translateY(0);
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1) 0.3s;
  color: #111;
}
.envelope.open .envelope-letter {
  transform: translateY(-80px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 5;
}
.envelope-letter h3 { color: var(--accent-gold); font-size: 2rem; margin-bottom: 5px; }
.envelope-letter p { font-size: 0.8rem; font-family: serif; font-style: italic; opacity: 0.8;}

/* Overlap CSS Variables setup */
.split-hands-container {
  display: flex;
  gap: 40px;
  justify-content: center;
  transition: all 0.4s ease;
}
.hand-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
  opacity: 0.5;
  transform: scale(0.85);
}
.hand-wrapper.active-hand {
  opacity: 1;
  transform: scale(1);
  z-index: 10;
}
.hand-wrapper.active-hand .score-display {
  color: var(--accent-gold);
  font-weight: bold;
}

/* Streak Meter */
.streak-meter {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.4;
  transition: all 0.3s ease;
}
.streak-meter.active {
  opacity: 1;
  color: #ff9d00;
  text-shadow: 0 0 10px rgba(255, 157, 0, 0.5);
}
.streak-meter.active .streak-icon {
  display: inline-block;
  animation: fireFlicker 0.6s infinite alternate ease-in-out;
}
.streak-meter.active .streak-count {
  animation: firePulseText 1.2s infinite alternate ease-in-out;
}
@keyframes fireFlicker {
  0% { filter: drop-shadow(0 0 2px rgba(255,157,0,0.8)) drop-shadow(0 0 5px rgba(255,69,0,0.5)); transform: scale(1) rotate(-3deg); }
  50% { filter: drop-shadow(0 0 8px rgba(255,157,0,1)) drop-shadow(0 0 15px rgba(255,69,0,0.8)); transform: scale(1.15) rotate(3deg); }
  100% { filter: drop-shadow(0 0 4px rgba(255,157,0,0.9)) drop-shadow(0 0 10px rgba(255,69,0,0.6)); transform: scale(1.05) rotate(-1deg); }
}
@keyframes firePulseText {
  0% { text-shadow: 0 0 5px rgba(255, 157, 0, 0.5); }
  100% { text-shadow: 0 0 15px rgba(255, 157, 0, 1), 0 0 25px rgba(255, 69, 0, 0.8); color: #fffacd; }
}
.streak-break {
  animation: shatter 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes shatter {
  0% { transform: scale(1); opacity: 1; filter: brightness(2); }
  50% { transform: scale(1.5) rotate(15deg); opacity: 0.5; }
  100% { transform: scale(0) rotate(-30deg); opacity: 0; }
}

/* Phase 3: Obsidian Glitch Effect */
.glitch-card {
  animation: glitch-skew 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite;
  filter: drop-shadow(2px 0 0 rgba(255,0,0,0.8)) drop-shadow(-2px 0 0 rgba(0,255,255,0.8));
}
@keyframes glitch-skew {
  0% { transform: skew(0deg); }
  20% { transform: skew(-10deg); filter: invert(1); }
  40% { transform: skew(10deg); }
  60% { transform: skew(-5deg); filter: hue-rotate(90deg); }
  80% { transform: skew(5deg); }
  100% { transform: skew(0deg); }
}

.obsidian-intervention {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-size: 1.2rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 10000;
  text-shadow: 0 0 10px rgba(255,255,255,0.8);
  animation: fadeInOut 2.5s ease-in-out forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes fadeInOut {
  0% { opacity: 0; letter-spacing: 10px; }
  20% { opacity: 1; letter-spacing: 2px; }
  80% { opacity: 1; }
  100% { opacity: 0; filter: blur(5px); }
}

.miracle-card {
  background: linear-gradient(135deg, #111, #222) !important;
  color: #fff !important;
  box-shadow: 0 0 20px rgba(200,200,200,0.8), inset 0 0 5px #fff !important;
  animation: miraclePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes miraclePop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}


@keyframes bustShake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.shake-bust {
  animation: bustShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

