: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;
  --transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

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

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%);
}

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

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

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

.table {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 20px;
  position: relative;
  perspective: 1000px;
}

.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;
  color: var(--accent-gold);
  pointer-events: none;
}

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

.card {
  width: 84px;
  height: 126px;
  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);
  }
}

.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;
  color: rgba(255, 255, 255, 0.6);
}

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

.betting-controls, .play-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  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 var(--accent-gold-dim);
  color: var(--accent-gold);
  position: relative;
  overflow: hidden;
  background: rgba(212, 175, 55, 0.03);
}

.btn.chip::before {
  content: '';
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  border: 1px dashed var(--accent-gold-dim);
  border-radius: 26px;
  pointer-events: none;
  opacity: 0.5;
}

.btn.chip:active {
  background: rgba(212, 175, 55, 0.15);
  transform: scale(0.96);
}

.btn.action-btn {
  background: linear-gradient(135deg, #ffffff, #e6e6e6);
  color: #000000;
  font-weight: 500;
  border: none;
  box-shadow: 0 8px 16px rgba(255,255,255,0.1);
}

.btn.action-btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 8px rgba(255,255,255,0.05);
}

.btn.outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: #ffffff;
}

.btn.outline:active {
  background: rgba(255,255,255,0.1);
  transform: scale(0.96);
}

.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;
}

@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 & Loss Effects */
.victory-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at center, rgba(212, 175, 55, 0.15) 0%, rgba(0,0,0,0.85) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  animation: victoryFadeIn 0.5s ease-out forwards;
  pointer-events: none;
}
.victory-title {
  font-size: 3.5rem;
  color: var(--accent-gold);
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.6), 0 0 40px rgba(212, 175, 55, 0.4);
  letter-spacing: 8px;
  margin-bottom: 10px;
  transform: scale(0.8);
  animation: victoryScale 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.victory-amount {
  font-size: 1.5rem;
  color: #fff;
  font-weight: 300;
  opacity: 0;
  animation: victoryFadeIn 0.5s 0.3s forwards;
}
@keyframes victoryFadeIn {
  to { opacity: 1; }
}
@keyframes victoryScale {
  to { transform: scale(1); }
}
.win-glow {
  box-shadow: 0 0 30px var(--accent-gold), inset 0 0 0 2px var(--accent-gold) !important;
  transform: translate(0, -15px) scale(1.05) !important;
  z-index: 5;
}
.lose-dim {
  filter: grayscale(100%) brightness(0.5);
}

/* === JUICE & EFFECTS === */

/* 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, -2px, 0) rotate(-1deg); }
  20%, 80% { transform: translate3d(4px, 2px, 0) rotate(1deg); }
  30%, 50%, 70% { transform: translate3d(-6px, -4px, 0) rotate(-2deg); }
  40%, 60% { transform: translate3d(6px, 4px, 0) rotate(2deg); }
}

/* Floating Text (Popups) */
.floating-text {
  position: absolute;
  color: var(--accent-gold);
  font-weight: 600;
  font-size: 1.2rem;
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
  z-index: 50;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.floating-text.negative {
  color: #ff453a;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(1.2); }
}

/* Particles / Confetti */
#particles-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}
.particle {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--accent-gold);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 12px var(--accent-gold);
  animation: fall 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0); opacity: 0; }
}

/* Win / Lose States on Cards */
.win-glow {
  box-shadow: 0 0 25px 8px rgba(212, 175, 55, 0.6), inset 0 0 0 1px rgba(255,255,255,1) !important;
  transform: scale(1.08) translateY(-10px) !important;
  border-color: var(--accent-gold);
  z-index: 10;
}
.lose-dim {
  filter: brightness(0.3) grayscale(0.8) !important;
  transform: scale(0.95) translateY(5px) !important;
}

/* Flash Screen Overlay */
.flash-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0;
}
.flash-overlay.flash-win {
  background: radial-gradient(circle, rgba(212,175,55,0.4) 0%, transparent 70%);
  animation: flashFade 1s ease-out forwards;
}
.flash-overlay.flash-lose {
  background: radial-gradient(circle, rgba(209,46,46,0.3) 0%, transparent 70%);
  animation: flashFade 0.8s ease-out forwards;
}
@keyframes flashFade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Epic Victory Overlay styling */
.victory-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  animation: victoryIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.victory-overlay.hidden { display: none !important; animation: none; }

@keyframes victoryIn {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}
.victory-title {
  font-size: 3.8rem;
  font-weight: 800;
  color: var(--accent-gold);
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.6), 0 5px 10px rgba(0,0,0,0.8);
  letter-spacing: 4px;
  margin-bottom: 10px;
  background: linear-gradient(to bottom, #fff, var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transform: scale(0.9);
  animation: pulseTitle 1.5s infinite alternate;
}
@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); }
}
.victory-amount {
  font-size: 2.5rem;
  color: #fff;
  font-weight: 300;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}


/* === PHYSICAL CHIPS === */
.table-bet-area {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  border: 2px dashed rgba(212, 175, 55, 0.15);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 5;
}

.physical-chip {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 6px 10px rgba(0,0,0,0.6), inset 0 0 3px rgba(0,0,0,0.8), inset 0 0 0 3px rgba(255,255,255,0.8);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 20;
}

.chip-inner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px dashed rgba(255,255,255,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.chip-flying {
  pointer-events: none;
  z-index: 100 !important;
  transform: scale(1.1);
}

/* Chip Colors with Casino Edge Patterns */
.chip-50 { 
  --chip-color: #2972b6; 
  background: repeating-conic-gradient(var(--chip-color) 0 18deg, #fff 18deg 36deg); 
}
.chip-50 .chip-inner { background: var(--chip-color); }

.chip-100 { 
  --chip-color: #1a1c1d; 
  background: repeating-conic-gradient(var(--chip-color) 0 18deg, #fff 18deg 36deg); 
}
.chip-100 .chip-inner { background: var(--chip-color); }

.chip-500 { 
  --chip-color: #6a2c91; 
  background: repeating-conic-gradient(var(--chip-color) 0 18deg, #fff 18deg 36deg); 
}
.chip-500 .chip-inner { background: var(--chip-color); }
