/**
 * @file games/sugar-rush-x/game.css
 * @description Visual theme for "Sugar Rush X" adhering to KASINO SSOT design tokens.
 * Features dark obsidian slate backgrounds with candy-cyber neon highlights (Pink, Cyan, Gold).
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --bg-main: #07090E;
  --bg-surface: #0E121D;
  --bg-elevated: #151B2B;
  --bg-glass: rgba(21, 27, 43, 0.72);

  --candy-pink: #FF2E93;
  --candy-pink-glow: rgba(255, 46, 147, 0.45);
  --candy-cyan: #00D9F5;
  --candy-cyan-glow: rgba(0, 217, 245, 0.45);
  --candy-violet: #8B5CF6;
  --candy-gold: #F59E0B;
  --candy-green: #00F5A0;

  --font-display: 'Outfit', sans-serif;
  --font-primary: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-main);
  font-family: var(--font-primary);
  color: #F8FAFC;
}

#game-stage-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 40%, #1F102E 0%, #11091B 55%, #07090E 100%);
  overflow: hidden;
}

/* Background Cyber Grid Lines */
#game-stage-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 46, 147, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 46, 147, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 1;
}

/* ==========================================================================
   TOP BAR HUD
   ========================================================================== */

.game-top-bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.4rem;
  background: linear-gradient(180deg, rgba(14, 18, 29, 0.9) 0%, rgba(14, 18, 29, 0.4) 100%);
  border-bottom: 1px solid rgba(255, 46, 147, 0.2);
  backdrop-filter: blur(8px);
}

.game-logo-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #FFFFFF 0%, #FFB3DC 40%, #FF2E93 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px var(--candy-pink-glow));
}

.game-badge-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.55rem;
  background: linear-gradient(135deg, #FF2E93 0%, #8B5CF6 100%);
  border: 1px solid #FFB3DC;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 900;
  color: #FFFFFF;
  box-shadow: 0 0 14px rgba(255, 46, 147, 0.6);
  letter-spacing: 0.05em;
}

/* Multiplier & Free Spins HUD Badges */
.top-hud-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.top-multiplier-meter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(21, 27, 43, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 20px;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
  transition: all 0.25s ease;
}

.top-multiplier-meter.active {
  border-color: #F59E0B;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.55);
}

.multiplier-meter-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #94A3B8;
  text-transform: uppercase;
}

.multiplier-meter-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: #F59E0B;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.free-spins-counter-pill {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(255, 46, 147, 0.15);
  border: 1px solid var(--candy-pink);
  border-radius: 20px;
  box-shadow: 0 0 16px var(--candy-pink-glow);
  animation: pulseNeonPink 2s infinite ease-in-out;
}

.free-spins-counter-pill.active {
  display: flex;
}

.fs-counter-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #FFB3DC;
  text-transform: uppercase;
}

.fs-counter-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: #FFFFFF;
}

@keyframes pulseNeonPink {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 46, 147, 0.4); }
  50% { box-shadow: 0 0 22px rgba(255, 46, 147, 0.8); }
}

/* ==========================================================================
   MAIN CANVAS & SIDE PANELS
   ========================================================================== */

#game-main-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  width: 100%;
  z-index: 10;
  overflow: hidden;
}

/* Left Side Actions (Ante Bet, Bonus Buy, Tumble History) */
.side-bet-actions {
  width: 210px;
  padding: 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: linear-gradient(90deg, rgba(14, 18, 29, 0.85) 0%, rgba(14, 18, 29, 0.35) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 15;
  overflow-y: auto;
}

.bet-action-card {
  padding: 0.75rem;
  background: rgba(21, 27, 43, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.bet-action-card:hover {
  transform: translateY(-2px);
}

/* Ante Bet Card */
.ante-bet-card {
  border-color: rgba(0, 245, 160, 0.3);
}

.ante-bet-card.active {
  border-color: var(--candy-green);
  background: rgba(0, 245, 160, 0.12);
  box-shadow: 0 0 16px rgba(0, 245, 160, 0.35);
}

.ante-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--candy-green);
  letter-spacing: 0.08em;
}

.ante-title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 800;
  color: #FFFFFF;
}

.ante-sub {
  font-size: 0.7rem;
  color: #94A3B8;
}

.ante-toggle-btn {
  margin-top: 0.3rem;
  padding: 0.4rem;
  background: rgba(0, 245, 160, 0.18);
  border: 1px solid var(--candy-green);
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--candy-green);
  cursor: pointer;
  transition: all 0.18s ease;
}

.ante-bet-card.active .ante-toggle-btn {
  background: var(--candy-green);
  color: #07090E;
}

/* Bonus Buy Card */
.bonus-buy-card {
  border-color: rgba(255, 46, 147, 0.35);
  background: linear-gradient(135deg, rgba(255, 46, 147, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
}

.bonus-buy-card:hover {
  border-color: var(--candy-pink);
  box-shadow: 0 0 20px var(--candy-pink-glow);
}

.buy-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--candy-pink);
  letter-spacing: 0.08em;
}

.buy-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
  color: #FFFFFF;
}

.buy-cost-pill {
  margin-top: 0.2rem;
  padding: 0.4rem;
  background: linear-gradient(135deg, #FF2E93 0%, #8B5CF6 100%);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
  color: #FFFFFF;
  text-align: center;
  box-shadow: 0 0 12px var(--candy-pink-glow);
}

/* Live Tumble Feed */
.tumble-feed-panel {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  background: rgba(14, 18, 29, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 0.6rem;
  overflow: hidden;
}

.tumble-feed-header {
  font-size: 0.65rem;
  font-weight: 800;
  color: #94A3B8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.3rem;
}

.tumble-feed-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tumble-feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.4rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  font-size: 0.72rem;
  animation: fadeInTumble 0.25s ease-out;
}

.tumble-feed-item-sym {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: #E2E8F0;
  font-weight: 600;
}

.tumble-feed-item-win {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--candy-green);
}

@keyframes fadeInTumble {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Canvas Container */
#game-canvas-container {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas-container canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* Win Presentation Root */
#celebration-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
}

/* Controls Bar Root */
#controls-root {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  z-index: 50;
}

/* ==========================================================================
   MODALS (BONUS INTRO / RESULT / CONFIRM / RULES)
   ========================================================================== */

.bonus-overlay-modal,
.rules-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 14, 0.88);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.bonus-overlay-modal.open,
.rules-modal-overlay.open {
  display: flex;
}

.bonus-modal-content {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 2rem;
  background: linear-gradient(135deg, #151B2B 0%, #0E121D 100%);
  border: 1px solid var(--candy-pink);
  border-radius: 20px;
  box-shadow: 0 0 40px var(--candy-pink-glow);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.bonus-modal-icon {
  width: 76px;
  height: 76px;
  filter: drop-shadow(0 0 20px var(--candy-pink-glow));
}

.bonus-modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #FFFFFF 0%, #FFB3DC 50%, #FF2E93 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.bonus-modal-desc {
  font-size: 0.88rem;
  color: #94A3B8;
  line-height: 1.5;
}

.bonus-modal-highlight {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  color: #00F5A0;
  text-shadow: 0 0 16px rgba(0, 245, 160, 0.6);
  padding: 0.4rem 1.2rem;
  background: rgba(0, 245, 160, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(0, 245, 160, 0.3);
}

.bonus-modal-btn {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #FF2E93 0%, #8B5CF6 100%);
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 0 20px var(--candy-pink-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bonus-modal-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 0 30px var(--candy-pink-glow);
}

.bonus-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.bonus-confirm-actions {
  display: flex;
  gap: 0.8rem;
  width: 100%;
}

/* Paytable Rules Modal */
.rules-modal-card {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.8rem;
  background: #111625;
  border: 1px solid rgba(255, 46, 147, 0.3);
  border-radius: 20px;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.85);
}

.rules-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.8rem;
}

.rules-modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 900;
  color: #FFFFFF;
}

.rules-close-btn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: #94A3B8;
  cursor: pointer;
  line-height: 1;
}

.rules-section-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--candy-pink);
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.paytable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.paytable-card {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.paytable-sym-img {
  width: 52px;
  height: 52px;
}

.paytable-sym-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #FFFFFF;
}

.paytable-sym-val {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #94A3B8;
  line-height: 1.4;
}

/* Toast Notifications */
.kasino-toast-container {
  position: absolute;
  top: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.kasino-toast {
  padding: 0.5rem 1.2rem;
  background: rgba(14, 18, 29, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: #FFFFFF;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  animation: toastFade 2.8s ease-in-out forwards;
}

.kasino-toast.gold {
  border-color: #F59E0B;
  color: #F59E0B;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

.kasino-toast.danger {
  border-color: #EF4444;
  color: #EF4444;
}

@keyframes toastFade {
  0% { opacity: 0; transform: translateY(-10px); }
  10% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .side-bet-actions {
    display: none;
  }
}
