/* CSS Variables - Asian Casino Theme (Red & Gold) */
:root {
  --bg-primary: #1a0a0a;
  --bg-secondary: #2a1010;
  --bg-card: rgba(40, 15, 15, 0.95);
  
  --gold: #ffd700;
  --gold-dark: #cc9900;
  --gold-light: #ffe44d;
  
  --red-primary: #c41e3a;
  --red-dark: #8b0000;
  --red-light: #ff3355;
  
  --neon-blue: #00d4ff;
  --neon-purple: #a855f7;
  --neon-pink: #ff1493;
  --neon-green: #00ff88;
  --neon-red: #ff0033;
  
  --text-primary: #fff8e7;
  --text-secondary: rgba(255, 248, 231, 0.8);
  --text-muted: rgba(255, 248, 231, 0.5);
  
  --glass-bg: rgba(200, 50, 50, 0.1);
  --glass-border: rgba(255, 215, 0, 0.3);
  
  --header-height: 60px;
  --footer-height: 70px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
    overflow: hidden;
  font-family: 'Noto Sans', sans-serif;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(ellipse at top, rgba(139, 0, 0, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, rgba(139, 0, 0, 0.2) 0%, transparent 50%);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Background Effects - Asian Style */
.bg-pattern {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 20%, rgba(255, 215, 0, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(196, 30, 58, 0.1) 0%, transparent 40%),
    repeating-linear-gradient(45deg, transparent, transparent 100px, rgba(255, 215, 0, 0.02) 100px, rgba(255, 215, 0, 0.02) 101px);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
}

.bg-glow-1 {
  width: 400px;
  height: 400px;
  background: rgba(255, 215, 0, 0.2);
  top: -150px;
  right: -150px;
  animation: pulse-glow 5s ease-in-out infinite;
}

.bg-glow-2 {
  width: 350px;
  height: 350px;
  background: rgba(196, 30, 58, 0.25);
  bottom: -100px;
  left: -100px;
  animation: pulse-glow 5s ease-in-out infinite 2.5s;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Header - Asian Style */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(40, 10, 10, 0.98) 0%, rgba(26, 10, 10, 0.95) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, transparent, var(--gold), transparent) 1;
  z-index: 100;
}

.header-left, .header-right, .header-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 24px;
  animation: dice-shake 2s ease-in-out infinite;
}

@keyframes dice-shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

.logo-text {
  font-family: 'Cinzel Decorative', serif;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  letter-spacing: 3px;
}

/* Dice Count Dropdown */
.dice-select {
  padding: 10px 16px;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: 10px;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23d4af37' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  min-width: 90px;
}

.dice-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.dice-select option {
  background: #1a0a0a;
  color: var(--gold);
  padding: 10px;
}

/* Legacy mode selector (hidden on mobile) */
.dice-mode-selector {
  display: none;
}

/* Nav Buttons */
.nav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--glass-border);
  transform: scale(1.05);
}

/* Audio buttons */
.audio-btn.muted {
  opacity: 0.5;
  filter: grayscale(1);
}

/* Balance - Asian Style */
.balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(139, 0, 0, 0.3) 0%, rgba(40, 10, 10, 0.9) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.2), inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.balance-label {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.balance-value {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Streak Display */
.streak-display {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  z-index: 90;
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.3s ease;
}

.streak-display.active {
  opacity: 1;
  transform: translateX(0);
}

.streak-display.hot {
  border-color: var(--neon-red);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.streak-display.hot .streak-flames {
  animation: flame-pulse 0.3s ease-in-out infinite;
}

@keyframes flame-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.streak-flames {
  font-size: 20px;
}

.streak-info {
  display: flex;
  flex-direction: column;
}

.streak-label {
  font-size: 8px;
  color: var(--text-muted);
}

.streak-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--neon-red);
}

.streak-bonus {
  font-size: 12px;
  font-weight: 700;
  color: var(--neon-green);
  padding: 2px 6px;
  background: rgba(34, 197, 94, 0.2);
  border-radius: 4px;
}

/* Game Container */
.game-container {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: var(--footer-height);
  z-index: 1;
}

#canvas-container {
  width: 100%;
  height: 100%;
}

#canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Game Controls (Roll button on field) */
.game-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
}

.game-controls .roll-btn {
  padding: 16px 60px;
  font-size: 22px;
  box-shadow: 0 8px 30px rgba(196, 30, 58, 0.5), 0 0 20px rgba(255, 215, 0, 0.3);
}

/* Result Display */
.result-display {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}

.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 24px;
  background: linear-gradient(180deg, rgba(60, 15, 15, 0.95) 0%, rgba(30, 8, 8, 0.98) 100%);
  border: 3px solid;
  border-image: linear-gradient(135deg, var(--gold-light), var(--gold-dark)) 1;
  border-radius: 12px;
  backdrop-filter: blur(12px);
  min-width: 140px;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.15), inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.result-label {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.result-value {
  font-family: 'Cinzel Decorative', serif;
  font-size: 42px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.result-value.rolling {
  animation: result-pulse 0.3s ease-in-out infinite;
}

@keyframes result-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.result-breakdown {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.dice-result {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--glass-bg);
  border: 1px solid var(--neon-blue);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--neon-blue);
}

.result-plus {
  color: var(--text-muted);
  font-size: 12px;
}

.combo-name {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--neon-purple);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.combo-name:empty {
  display: none;
}

/* Footer - Compact */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 10px 15px;
  background: linear-gradient(0deg, rgba(40, 10, 10, 0.98) 0%, rgba(26, 10, 10, 0.95) 100%);
  backdrop-filter: blur(12px);
  border-top: 2px solid;
  border-image: linear-gradient(90deg, transparent, var(--gold), transparent) 1;
  z-index: 100;
}

/* Bet Section */
.bet-section {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bet-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bet-btn:active {
  transform: scale(0.95);
  background: var(--glass-border);
}

.bet-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(139, 0, 0, 0.2) 0%, rgba(40, 10, 10, 0.8) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 8px;
  min-width: 65px;
}

.bet-label {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 2px;
}

.bet-value {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Roll Button */
.roll-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 36px;
  background: linear-gradient(135deg, var(--red-dark) 0%, var(--red-primary) 50%, var(--red-light) 100%);
  border: 3px solid var(--gold);
  border-radius: 12px;
  color: var(--gold-light);
  font-family: 'Cinzel Decorative', serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(196, 30, 58, 0.5), 0 0 30px rgba(255, 215, 0, 0.2), inset 0 0 15px rgba(0, 0, 0, 0.3);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.roll-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shine 2s infinite;
}

@keyframes shine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

.roll-btn:active {
  transform: scale(0.98);
}

.roll-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.roll-btn:disabled::before {
  animation: none;
}

/* Multiplier Section */
/* Multiplier Button */
.multiplier-section {
  display: flex;
  align-items: center;
}

.multiplier-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: 10px;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.multiplier-btn:hover {
  background: var(--glass-border);
  border-color: var(--gold);
}

.multiplier-btn-icon {
  font-size: 16px;
}

/* Legacy multiplier tiers (hidden) */
.multiplier-tiers {
  display: none;
}

.tier {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--glass-bg);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.tier-mult {
  font-weight: 700;
}

.tier-tiny { color: #a0aec0; }
.tier-good { color: #48bb78; }
.tier-huge { color: var(--gold); }
.tier-jackpot {
  color: #ff4488;
  background: rgba(255, 68, 136, 0.2);
  animation: jackpot-glow 1.5s ease-in-out infinite;
}

@keyframes jackpot-glow {
  0%, 100% { box-shadow: 0 0 5px rgba(255, 68, 136, 0.3); }
  50% { box-shadow: 0 0 15px rgba(255, 68, 136, 0.6); }
}

/* Win animations */
.result-display.win .result-content {
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

.result-display.win .result-value {
  animation: win-glow 0.4s ease-in-out infinite;
}

@keyframes win-glow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5)); }
  50% { filter: drop-shadow(0 0 25px rgba(255, 215, 0, 1)); }
}

.result-display.loss .result-value {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

/* Win Overlay */
.win-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.win-overlay.active {
  opacity: 1;
}

.win-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.win-text {
  font-size: 60px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold) 0%, #fff 30%, var(--gold) 60%, #fff 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: win-text-shine 0.5s linear infinite;
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.win-overlay.active .win-text {
  transform: scale(1);
}

.win-amount {
  font-size: 42px;
  font-weight: 800;
  font-family: 'Cinzel Decorative', serif;
  color: #4ade80;
  text-shadow: 
    0 0 10px rgba(74, 222, 128, 0.9),
    0 0 25px rgba(74, 222, 128, 0.6),
    0 0 40px rgba(74, 222, 128, 0.4),
    2px 2px 4px rgba(0, 0, 0, 0.5);
  transform: scale(0) translateY(30px);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s;
  letter-spacing: 2px;
}

.win-overlay.active .win-amount {
  transform: scale(1) translateY(0);
  opacity: 1;
  animation: win-amount-bounce 0.6s ease-out 0.3s;
}

@keyframes win-amount-bounce {
  0% { transform: scale(0.5) translateY(20px); }
  50% { transform: scale(1.2) translateY(-5px); }
  70% { transform: scale(0.95) translateY(2px); }
  100% { transform: scale(1) translateY(0); }
}

/* Big win amount styling */
.win-overlay.big .win-amount {
  font-size: 52px;
  color: #ffd700;
  text-shadow: 
    0 0 15px rgba(255, 215, 0, 0.9),
    0 0 30px rgba(255, 215, 0, 0.6),
    0 0 50px rgba(255, 215, 0, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.5);
  animation: win-amount-pulse 0.6s ease-in-out infinite;
}

.win-overlay.jackpot .win-amount {
  font-size: 58px;
  animation: win-amount-pulse 0.5s ease-in-out infinite, win-amount-rainbow 3s linear infinite;
}

@keyframes win-amount-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes win-amount-rainbow {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

@keyframes win-text-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.win-overlay.jackpot .win-text {
  font-size: 50px;
  background: linear-gradient(135deg, #ff4488 0%, var(--gold) 25%, #fff 50%, var(--gold) 75%, #ff4488 100%);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  background-clip: text;
}

.win-overlay.jackpot .win-amount {
  color: #ffd700;
  font-size: 58px;
  background: linear-gradient(135deg, #ffd700 0%, #fff 30%, #ffd700 60%, #ff8800 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8)) 
          drop-shadow(0 0 40px rgba(255, 215, 0, 0.5));
  animation: win-amount-pulse 0.5s ease-in-out infinite, 
             jackpot-shine 2s linear infinite;
}

@keyframes jackpot-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === BALANCE ANIMATIONS === */
.balance {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.balance.winning {
  animation: balance-pop 0.5s ease-out;
  box-shadow: 
    0 0 20px rgba(74, 222, 128, 0.6),
    0 0 40px rgba(74, 222, 128, 0.3),
    inset 0 0 10px rgba(74, 222, 128, 0.2);
}

.balance.losing {
  animation: balance-shake 0.4s ease-out;
  box-shadow: 
    0 0 15px rgba(239, 68, 68, 0.5),
    inset 0 0 10px rgba(239, 68, 68, 0.2);
}

@keyframes balance-pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.15); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes balance-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* Balance amount counting animation */
.balance-amount {
  transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.1s ease;
  display: inline-block;
}

.balance-amount.counting-up {
  color: #4ade80;
  text-shadow: 0 0 10px rgba(74, 222, 128, 0.8);
  animation: counting-pulse 0.15s ease-in-out infinite;
}

.balance-amount.counting-down {
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

@keyframes counting-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Floating win indicator */
.win-float {
  position: fixed;
  pointer-events: none;
  font-family: 'Cinzel Decorative', serif;
  font-size: 28px;
  font-weight: 700;
  color: #4ade80;
  text-shadow: 
    0 0 10px rgba(74, 222, 128, 0.9),
    0 0 20px rgba(74, 222, 128, 0.6),
    0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 300;
  transform: translateX(-50%);
  animation: float-up 1.5s ease-out forwards;
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.5);
  }
  15% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.3);
  }
  30% {
    transform: translateX(-50%) translateY(-10px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-80px) scale(0.8);
  }
}

/* Coins sparkle effect on big wins */
.win-float::after {
  content: '✨';
  position: absolute;
  right: -20px;
  animation: sparkle-float 1s ease-out infinite;
}

@keyframes sparkle-float {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.5); }
  50% { opacity: 1; transform: translateY(-10px) scale(1); }
}

/* =================== MODALS =================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: linear-gradient(180deg, rgba(50, 15, 15, 0.98) 0%, rgba(30, 8, 8, 0.98) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.15), 0 0 80px rgba(196, 30, 58, 0.2);
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, transparent, var(--gold), transparent) 1;
  background: linear-gradient(180deg, rgba(139, 0, 0, 0.3) 0%, transparent 100%);
}

.modal-header h2 {
  font-family: 'Cinzel Decorative', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
}

.modal-btn {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--gold);
  border-radius: 10px;
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin: 16px 0;
  letter-spacing: 1px;
}

.modal-btn.primary {
  background: linear-gradient(135deg, var(--red-dark), var(--red-primary));
  color: var(--gold-light);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Daily Bonus Modal */
.daily-bonus-modal {
  text-align: center;
}

.daily-bonus-content {
  padding: 20px;
}

.daily-days {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.daily-day {
  width: 40px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 10px;
}

.daily-day.claimed {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--neon-green);
}

.daily-day.current {
  background: rgba(255, 215, 0, 0.2);
  border-color: var(--gold);
  animation: pulse-border 1s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.3); }
  50% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); }
}

.daily-day-num {
  font-weight: 700;
  color: var(--text-secondary);
}

.daily-day-reward {
  font-size: 8px;
  color: var(--gold);
}

.daily-reward {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.daily-reward-label {
  font-size: 12px;
  color: var(--text-muted);
}

.daily-reward-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--gold);
}

#claim-daily-btn {
  margin: 16px 20px 20px;
  width: calc(100% - 40px);
}

/* Shop Modal */
.shop-modal {
  max-height: 85vh;
}

.shop-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gold-dark);
}

.shop-tab {
  flex: 1;
  padding: 10px 8px;
  background: rgba(139, 0, 0, 0.2);
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shop-tab.active {
  background: linear-gradient(135deg, var(--red-dark), var(--red-primary));
  color: var(--gold-light);
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(196, 30, 58, 0.4);
}

.shop-content {
  padding: 16px;
  max-height: 350px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.shop-item {
  background: linear-gradient(135deg, rgba(60, 15, 15, 0.8) 0%, rgba(30, 8, 8, 0.9) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.shop-item:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* Not owned - default dark style */
.shop-item.not-owned {
  opacity: 0.85;
}

/* Owned but not equipped - green accent */
.shop-item.owned {
  border-color: var(--neon-green);
  background: linear-gradient(135deg, rgba(15, 50, 25, 0.7) 0%, rgba(8, 30, 15, 0.85) 100%);
}

.shop-item.owned:hover {
  border-color: #44ff88;
  box-shadow: 0 0 15px rgba(34, 255, 136, 0.3);
}

/* Equipped - golden glow with special styling */
.shop-item.equipped {
  border-color: var(--gold);
  border-width: 3px;
  background: linear-gradient(135deg, rgba(80, 60, 20, 0.8) 0%, rgba(50, 35, 10, 0.9) 100%);
  box-shadow: 
    0 0 25px rgba(255, 215, 0, 0.5),
    inset 0 0 15px rgba(255, 215, 0, 0.1);
}

.shop-item.equipped::before {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  background: var(--gold);
  color: var(--bg-primary);
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shop-item.equipped:hover {
  transform: none;
  cursor: default;
}

.shop-item-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.shop-item-name {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--gold-light);
}

.shop-item-effect {
  font-size: 9px;
  color: var(--neon-pink);
  margin-bottom: 8px;
  min-height: 24px;
}

.shop-item-price {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
}

/* Not owned - show price */
.shop-item-price.buyable {
  color: var(--gold);
}

/* Owned - show "EQUIP" button style */
.shop-item-price.owned {
  color: var(--neon-green);
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Equipped - show "EQUIPPED" badge */
.shop-item-price.equipped {
  color: var(--gold-light);
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.shop-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--gold-dark);
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.equipped-name {
  color: var(--neon-blue);
  font-weight: 700;
}

/* Leaderboard Modal */
.leaderboard-modal {
  max-height: 85vh;
}

.leaderboard-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gold-dark);
}

.lb-tab {
  flex: 1;
  padding: 10px 8px;
  background: rgba(139, 0, 0, 0.2);
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.lb-tab.active {
  background: var(--neon-blue);
  color: var(--bg-primary);
  border-color: var(--neon-blue);
}

.leaderboard-list {
  padding: 12px 16px;
  max-height: 300px;
  overflow-y: auto;
}

.lb-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(60, 15, 15, 0.6) 0%, rgba(30, 8, 8, 0.8) 100%);
  border: 1px solid var(--gold-dark);
  border-radius: 10px;
  margin-bottom: 8px;
}

.lb-entry.top-1 { border: 1px solid var(--gold); }
.lb-entry.top-2 { border: 1px solid #c0c0c0; }
.lb-entry.top-3 { border: 1px solid #cd7f32; }

.lb-rank {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 0, 0, 0.4);
  border: 1px solid var(--gold-dark);
  font-family: 'Cinzel', serif;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.lb-entry.top-1 .lb-rank { background: var(--gold); color: var(--bg-primary); }
.lb-entry.top-2 .lb-rank { background: #c0c0c0; color: var(--bg-primary); }
.lb-entry.top-3 .lb-rank { background: #cd7f32; color: var(--bg-primary); }

.lb-info {
  flex: 1;
}

.lb-name {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-light);
}

.lb-streak {
  font-size: 10px;
  color: var(--neon-red);
}

.lb-score {
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.leaderboard-player {
  padding: 12px 16px;
  border-top: 1px solid var(--gold-dark);
  background: linear-gradient(135deg, rgba(139, 0, 0, 0.2) 0%, rgba(60, 15, 15, 0.3) 100%);
}

.leaderboard-player .lb-entry {
  background: linear-gradient(135deg, rgba(80, 20, 20, 0.8) 0%, rgba(40, 10, 10, 0.9) 100%);
    margin: 0;
  border: 2px solid var(--gold);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

/* Payouts Modal */
.payouts-modal {
  max-width: 400px;
}

.payouts-content {
  padding: 20px;
  max-height: calc(80vh - 80px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.payouts-dice-count {
  text-align: center;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.payouts-dice-count span {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  color: var(--gold);
  padding: 8px 20px;
  background: var(--glass-bg);
  border: 2px solid var(--gold);
  border-radius: 10px;
}

.rtp-badge {
  font-size: 14px !important;
  color: #4ade80 !important;
  border-color: #4ade80 !important;
  background: rgba(74, 222, 128, 0.1) !important;
}

.payout-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0 16px;
  font-style: italic;
}

.payout-mult.partial {
  color: #fbbf24;
}

.jackpot-row td {
  color: var(--gold);
  font-weight: 600;
}

.payouts-table {
  width: 100%;
  border-collapse: collapse;
}

.payouts-table th,
.payouts-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.payouts-table th {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.payouts-table td {
  font-size: 14px;
}

.payout-category {
  font-weight: 600;
  color: var(--text-primary);
}

.payout-range {
  color: var(--text-secondary);
}

.payout-mult {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  text-align: right;
}

.payout-mult.x1-5 { color: var(--neon-blue); }
.payout-mult.x2 { color: var(--neon-green); }
.payout-mult.x3 { color: var(--neon-purple); }
.payout-mult.x5 { color: var(--gold); text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }

.payouts-combos {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--glass-border);
}

.payouts-combos h3 {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 12px;
}

.combo-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
}

.combo-name-item {
  color: var(--text-secondary);
}

.combo-bonus {
  color: var(--neon-green);
  font-weight: 600;
}

/* =================== MOBILE OPTIMIZATION =================== */

/* Tablets and small laptops */
@media (max-width: 768px) {
  :root {
    --header-height: 55px;
    --footer-height: 100px;
  }
  
  .header {
    padding: 0 10px;
  }
  
  .logo-text {
    font-size: 16px;
    letter-spacing: 1px;
  }
  
  .balance {
    padding: 6px 10px;
  }
  
  .balance-label {
    font-size: 8px;
  }
  
  .balance-value {
    font-size: 14px;
  }
  
  .nav-btn {
    width: 34px;
    height: 34px;
    font-size: 15px;
  }
  
  .result-display {
    padding: 12px 20px;
    min-width: 180px;
  }
  
  .result-label {
    font-size: 10px;
  }
  
  .result-value {
    font-size: 36px;
  }
  
  .roll-btn {
    padding: 14px 50px;
    font-size: 18px;
  }
  
  .payouts-content {
    max-height: calc(70vh - 60px);
    padding: 15px;
  }
  
  .payouts-table th,
  .payouts-table td {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  :root {
    --header-height: 50px;
    --footer-height: 65px;
  }
  
  .header {
    padding: 0 8px;
    overflow: hidden;
  }
  
  .header-left, .header-right {
    gap: 6px;
  }
  
  .header-left {
    flex-shrink: 0;
  }
  
  .header-right {
    flex-shrink: 1;
    min-width: 0;
  }
  
  .logo {
    gap: 3px;
  }
  
  .logo-icon {
    font-size: 16px;
  }
  
  .logo-text {
    display: none;
  }
  
  .dice-mode-selector {
    gap: 3px;
    padding: 3px;
    border-radius: 8px;
  }
  
  .mode-btn {
    width: 26px;
    height: 26px;
    font-size: 12px;
    border-radius: 5px;
  }
  
  .balance {
    padding: 5px 8px;
    border-radius: 8px;
  }
  
  .balance-label {
    font-size: 7px;
  }
  
  .balance-value {
    font-size: 13px;
    gap: 3px;
  }
  
  .balance-icon {
    font-size: 12px;
  }
  
  .nav-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
    border-radius: 6px;
    flex-shrink: 0;
  }
  
  /* Show music button, hide SFX on small screens */
  #sfx-btn {
    display: none;
  }
  
  /* Result display */
  .result-display {
    padding: 10px 15px;
    min-width: 150px;
    border-radius: 10px;
  }
  
  .result-label {
    font-size: 9px;
    letter-spacing: 1px;
  }
  
  .result-value {
    font-size: 32px;
  }
  
  .result-breakdown {
    gap: 4px;
    margin-top: 6px;
  }
  
  .dice-result {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
  
  .combo-name {
    font-size: 9px;
    margin-top: 4px;
  }
  
  /* Streak display */
  .streak-display {
    padding: 6px 10px;
    border-radius: 10px;
  }
  
  .streak-fire {
    font-size: 16px;
  }
  
  .streak-count {
    font-size: 16px;
  }
  
  .streak-bonus {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  /* Footer */
  .footer {
    padding: 10px 15px;
  }
  
  .bet-controls {
    gap: 6px;
  }
  
  .bet-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  
  .bet-display {
    padding: 6px 12px;
    min-width: 60px;
  }
  
  .bet-label {
    font-size: 8px;
  }
  
  .bet-value {
    font-size: 16px;
  }
  
  .roll-btn {
    padding: 12px 40px;
    font-size: 16px;
    border-radius: 12px;
  }
  
  .roll-btn .dice-icon {
    font-size: 16px;
  }
  
  /* Multiplier tiers */
  .multiplier-tiers {
    gap: 3px;
    padding: 6px;
    border-radius: 8px;
  }
  
  .tier {
    font-size: 9px;
    padding: 2px 4px;
  }
  
  /* Modals */
  .modal-content {
    width: 95%;
    max-width: 360px;
    max-height: 80vh;
    margin: 10px;
    padding: 15px;
    border-radius: 15px;
  }
  
  .modal-header h2 {
    font-size: 18px;
  }
  
  .modal-close {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
  
  .shop-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .shop-item {
    padding: 12px;
    border-radius: 10px;
  }
  
  .shop-item-icon {
    font-size: 28px;
  }
  
  .shop-item-name {
    font-size: 12px;
  }
  
  .shop-item-price {
    font-size: 11px;
  }
  
  .shop-item-btn {
    padding: 6px 12px;
    font-size: 11px;
  }
  
  /* Leaderboard */
  .leaderboard-entry {
    padding: 10px;
  }
  
  .lb-rank {
    font-size: 14px;
    width: 28px;
  }
  
  .lb-name {
    font-size: 13px;
  }
  
  .lb-score {
    font-size: 13px;
  }
  
  /* Daily bonus modal */
  .daily-content {
    padding: 20px 15px;
  }
  
  .daily-icon {
    font-size: 50px;
  }
  
  .daily-title {
    font-size: 20px;
  }
  
  .daily-amount {
    font-size: 28px;
  }
  
  .claim-btn {
    padding: 12px 30px;
    font-size: 16px;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  :root {
    --header-height: 50px;
    --footer-height: 60px;
  }
  
  .header {
    padding: 0 6px;
  }
  
  .header-left, .header-right {
    gap: 6px;
  }
  
  .logo-text {
    display: none;
  }
  
  .logo-icon {
    font-size: 18px;
  }
  
  .dice-select {
    padding: 6px 10px;
    font-size: 16px;
    padding-right: 25px;
    min-width: 75px;
  }
  
  .balance {
    padding: 5px 8px;
    flex-shrink: 1;
    min-width: 0;
  }
  
  .balance-label {
    font-size: 7px;
  }
  
  .balance-value {
    font-size: 12px;
    white-space: nowrap;
  }
  
  .nav-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .result-value {
    font-size: 28px;
  }
  
  .dice-result {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }
  
  .game-controls .roll-btn {
    padding: 12px 40px;
    font-size: 16px;
  }
  
  .bet-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  .bet-value {
    font-size: 14px;
  }
  
  .tier {
    font-size: 8px;
  }
}

/* Extra small screens (< 340px) */
@media (max-width: 340px) {
  :root {
    --header-height: 46px;
    --footer-height: 55px;
  }
  
  .header {
    padding: 0 4px;
  }
  
  .header-left, .header-right {
    gap: 3px;
  }
  
  .logo-icon {
    font-size: 14px;
  }
  
  .dice-select {
    padding: 4px 6px;
    font-size: 13px;
    border-radius: 6px;
    border-width: 1px;
    padding-right: 20px;
    min-width: 65px;
  }
  
  .balance {
    padding: 3px 6px;
    border-radius: 6px;
    border-width: 1px;
  }
  
  .balance-label {
    display: none;
  }
  
  .balance-value {
    font-size: 11px;
  }
  
  .balance-icon {
    font-size: 10px;
  }
  
  .nav-btn {
    width: 26px;
    height: 26px;
    font-size: 11px;
    border-radius: 5px;
  }
  
  /* Hide leaderboard and shop on very small screens */
  #leaderboard-btn,
  #shop-btn {
    display: none;
  }
  
  #music-btn {
    display: flex;
  }
}

/* Landscape mode optimization */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --header-height: 45px;
    --footer-height: 70px;
  }
  
  .result-display {
    padding: 8px 15px;
  }
  
  .result-value {
    font-size: 28px;
  }
  
  .streak-display {
    padding: 4px 8px;
  }
  
  .roll-btn {
    padding: 10px 35px;
  }
}

/* Telegram Safe Area */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-height) + env(safe-area-inset-top));
  }
  
  .footer {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--footer-height) + env(safe-area-inset-bottom));
  }
  
  .modal-content {
    margin-top: env(safe-area-inset-top);
    margin-bottom: env(safe-area-inset-bottom);
  }
}

/* Touch optimization */
@media (hover: none) and (pointer: coarse) {
  .mode-btn,
  .nav-btn,
  .bet-btn,
  .roll-btn,
  .shop-item,
  .shop-tab,
  .lb-tab {
    /* Larger touch targets */
    min-height: 44px;
    min-width: 44px;
  }
  
  .mode-btn {
    min-height: 32px;
    min-width: 32px;
  }
  
  /* Remove hover effects on touch */
  .roll-btn:hover {
    transform: none;
  }
  
  .roll-btn:active {
    transform: scale(0.95);
  }
}

/* === PERFORMANCE OPTIMIZATIONS FOR MOBILE === */
@media (max-width: 768px), (hover: none) {
  /* Reduce backdrop-filter blur intensity */
  .header,
  .footer,
  .result-display {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  
  /* Reduce box-shadow complexity */
  .balance,
  .nav-btn,
  .bet-btn,
  .bet-display,
  .roll-btn {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  /* Simplify modal shadows */
  .modal-content {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
  
  /* Use transform for GPU acceleration */
  * {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  /* Reduce animation complexity */
  .win-overlay,
  .jackpot-overlay {
    animation-duration: 0.3s;
  }
}

/* Very low-end devices - disable expensive effects */
@media (max-width: 480px) and (max-height: 700px) {
  .header,
  .footer,
  .result-display {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(26, 10, 10, 0.95);
  }
  
  .roll-btn {
    box-shadow: none;
    border: 2px solid var(--gold);
  }
}
