/* ===================================
   UI LAYER OVERLAY SYSTEM
   =================================== */

#ui-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Allow clicks to pass through to PixiJS canvas */
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#ui-layer>* {
  pointer-events: auto;
  /* Enable clicks on UI elements */
}

/* ===================================
   THEME VARIABLES
   =================================== */

/* ===================================
   THEME VARIABLES SYSTEM
   =================================== */

/* 
   HOW TO ADD A NEW THEME:
   1. Define a new class (e.g., .theme-newname)
   2. Override the variables below
   3. Add the mapping in ComponentInitializer.js
*/

:root {
  /* -----------------------------------
     TYPOGRAPHY SYSTEM
     ----------------------------------- */
  /* Font Families - Centralized from typography.js */
  --font-primary: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Arial', sans-serif;
  --font-mono: 'Poppins', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  --font-display: 'Poppins', system-ui, -apple-system, 'Arial Black', sans-serif;
  --font-gemstone: 'Rubik Gemstones', cursive;

  /* Font Sizes */
  --font-size-xs: 10px;
  --font-size-sm: 12px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 20px;
  --font-size-xxl: 24px;
  --font-size-xxxl: 32px;
  --font-size-display: 48px;

  /* Font Weights */
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-black: 900;

  /* -----------------------------------
     DEFAULT THEME (Sea / Planet1000)
     ----------------------------------- */
  --primary-color: #00ffff;
  --primary-color-dim: rgba(0, 255, 255, 0.1);
  --secondary-color: #0088aa;
  --text-color: white;
  --label-color: #88aacc;

  /* Footer Backgrounds */
  --footer-glass-bg: rgba(0, 20, 40, 0.15);
  --footer-border-color: rgba(74, 144, 226, 0.1);

  /* Button Styles */
  --btn-bg: rgba(0, 20, 40, 0.6);
  --btn-border: #00ffff;
  --btn-square-bg: rgba(10, 30, 50, 0.8);
  --btn-square-border: #2a4a6a;
  --btn-main-bg: linear-gradient(180deg, #00ffff 0%, #0088aa 100%);
  --btn-main-text: #002233;

  /* Effects */
  --shadow-color: rgba(0, 255, 255, 0.5);
  --shadow-color-dim: rgba(0, 255, 255, 0.2);
}

/* -----------------------------------
   PLANET1000 THEME (Sea)
   ----------------------------------- */
.theme-planet1000 {
  --primary-color: #00ffff;
  --primary-color-dim: rgba(0, 255, 255, 0.1);
  --secondary-color: #0088aa;
  --text-color: white;
  --label-color: #88aacc;

  --footer-glass-bg: rgba(0, 20, 40, 0.15);
  --footer-border-color: rgba(74, 144, 226, 0.1);

  --btn-bg: rgba(0, 20, 40, 0.6);
  --btn-border: #00ffff;
  --btn-square-bg: rgba(10, 30, 50, 0.8);
  --btn-square-border: #2a4a6a;
  --btn-main-bg: #00ffff;
  --btn-main-text: #002233;

  --shadow-color: rgba(0, 255, 255, 0.5);
  --shadow-color-dim: rgba(0, 255, 255, 0.2);
}

/* -----------------------------------
   PLANET3000 THEME (Desert)
   ----------------------------------- */
.theme-planet3000 {
  --primary-color: #ffd700;
  --primary-color-dim: rgba(255, 215, 0, 0.1);
  --secondary-color: #ff8c00;
  --text-color: #fff8e7;
  --label-color: #deb887;

  --footer-glass-bg: rgba(40, 20, 0, 0.15);
  --footer-border-color: rgba(255, 215, 0, 0.1);

  --btn-bg: rgba(40, 20, 0, 0.6);
  --btn-border: #ffd700;
  --btn-square-bg: rgba(50, 30, 10, 0.8);
  --btn-square-border: #8b4500;
  --btn-main-bg: linear-gradient(180deg, #ffd700 0%, #ff8c00 100%);
  --btn-main-text: #2a1a0a;

  --shadow-color: rgba(255, 215, 0, 0.5);
  --shadow-color-dim: rgba(255, 215, 0, 0.2);
}

/* -----------------------------------
   PLANET2000 THEME (Deep Space)
   ----------------------------------- */
.theme-planet2000 {
  --primary-color: #B967FF;
  --primary-color-dim: rgba(185, 103, 255, 0.1);
  --secondary-color: #00CC70;
  --text-color: #e6e6fa;
  --label-color: #b0c4de;

  --footer-glass-bg: rgba(20, 0, 40, 0.15);
  --footer-border-color: rgba(185, 103, 255, 0.1);

  --btn-bg: rgba(30, 0, 60, 0.6);
  --btn-border: #B967FF;
  --btn-square-bg: rgba(40, 10, 70, 0.8);
  --btn-square-border: #9D4EDD;
  --btn-main-bg: #B967FF;
  --btn-main-text: #1a0033;

  --shadow-color: rgba(185, 103, 255, 0.5);
  --shadow-color-dim: rgba(185, 103, 255, 0.2);
}

/* -----------------------------------
   PLANET4000 THEME (Cyber)
   ----------------------------------- */
.theme-planet4000 {
  --primary-color: #00F0FF;
  --primary-color-dim: rgba(0, 240, 255, 0.1);
  --secondary-color: #FF006E;
  --text-color: #FFFFFF;
  --label-color: #AAAAAA;

  --footer-glass-bg: rgba(5, 0, 20, 0.15);
  --footer-border-color: rgba(0, 240, 255, 0.1);

  --btn-bg: rgba(5, 0, 20, 0.6);
  --btn-border: #00F0FF;
  --btn-square-bg: rgba(10, 0, 30, 0.8);
  --btn-square-border: #FF006E;
  --btn-main-bg: linear-gradient(180deg, #00F0FF 0%, #FF006E 100%);
  --btn-main-text: #000000;

  --shadow-color: rgba(0, 240, 255, 0.5);
  --shadow-color-dim: rgba(0, 240, 255, 0.2);
}

/* ===================================
   SECOND FOOTER (Top Controls)
   =================================== */

.footer-controls-top {
  position: fixed;
  bottom: 80px;
  /* Above main footer */
  left: 0;
  right: 0;
  height: 60px;
  padding: 10px 20px;

  background: transparent;
  border-bottom: 1px solid var(--footer-border-color);

  display: flex;
  justify-content: space-between;
  align-items: center;

  z-index: 1001;
}

.control-group-left,
.control-group-center,
.control-group-right {
  display: flex;
  gap: 10px;
  flex: 1;
}

.control-group-center {
  justify-content: center;
}

.control-group-right {
  justify-content: flex-end;
}

.btn-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 5px var(--shadow-color-dim);
  font-size: 16px;
  font-weight: bold;
}

.btn-circle:hover {
  background: var(--primary-color-dim);
  box-shadow: 0 0 10px var(--shadow-color);
  transform: scale(1.05);
}

.btn-circle:active {
  transform: scale(0.95);
}

#btn-music {
  color: var(--secondary-color);
}

#btn-music:hover {
  color: var(--secondary-color);
}

.music-playing {
  animation: music-pulse 2s infinite;
  box-shadow: 0 0 10px var(--shadow-color);
}

.music-playing svg {
  animation: music-icon-bounce 1s ease-in-out infinite;
}

@keyframes music-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--primary-color, rgba(0, 255, 255, 0.7));
    transform: scale(1);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(0, 255, 255, 0);
    transform: scale(1.05);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(0, 255, 255, 0);
    transform: scale(1);
  }
}

@keyframes music-icon-bounce {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  25% {
    transform: translateY(-1px) scale(1.03);
  }

  50% {
    transform: translateY(0) scale(1);
  }

  75% {
    transform: translateY(-0.5px) scale(1.02);
  }
}

.footer-betting-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  padding: 15px 40px;
  /* Reverted to fixed height as requested */

  background: var(--footer-glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--footer-border-color);
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);

  display: flex;
  justify-content: space-between;
  align-items: center;

  z-index: 1001;
}

.footer-betting-bottom::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 80px;
  /* Extend well below screen */
  background: var(--footer-glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  z-index: -1;
}

/* Footer Alignment (Global) */
#balance-display {
  flex: 0 0 20%;
  display: flex;
  justify-content: center;
  overflow: hidden;
  /* Prevent spillover */
}

.bet-controls {
  flex: 0 0 60%;
  justify-content: center;
}

#win-display {
  flex: 0 0 20%;
  display: flex;
  justify-content: center;
  /* overflow: hidden; - Removed to allow conversion text */
}

.info-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-color);
  min-width: 80px;
  position: relative;
  /* For absolute positioning of conversion */
}

.info-block .label {
  font-size: 0.75rem;
  color: var(--label-color);
  letter-spacing: 1px;
  margin-bottom: 0;
  text-transform: uppercase;
  line-height: 1;
}

.info-block .value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.5px;
  line-height: 1.1;
}

/* ... (bet controls) ... */

.conversion-indicator {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  text-align: center;

  font-size: 0.7rem;
  color: var(--label-color);
  opacity: 0.8;
  font-style: italic;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1;
}

.animate-conversion {
  animation: conversion-flash 0.4s ease-out;
}

@keyframes conversion-flash {
  0% {
    transform: translateX(-50%) scale(1.2);
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color);
  }

  100% {
    transform: translateX(-50%) scale(1);
    color: var(--label-color);
    text-shadow: none;
  }
}

.bet-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-square {
  width: 50px;
  height: 50px;
  background: var(--btn-square-bg);
  border: 1px solid var(--btn-square-border);
  border-radius: 8px;
  color: #fff;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-square:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-square:active {
  transform: scale(0.95);
}

.btn-square:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-main-bet {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--btn-main-bg);
  border: none;
  border-radius: 8px;
  padding: 6px 32px;
  min-width: 180px;
  height: 70px;
  cursor: pointer;
  box-shadow: 0 0 15px var(--shadow-color-dim);
  transition: all 0.2s;
}

.btn-main-bet:hover {
  transform: scale(1.02);
  box-shadow: 0 0 20px var(--shadow-color);
  filter: brightness(1.1);
}

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

.btn-main-bet:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-main-bet .bet-label {
  font-size: 0.85rem;
  color: var(--btn-main-text);
  font-weight: bold;
  letter-spacing: 1px;
}

.btn-main-bet .bet-value {
  font-size: 1.6rem;
  color: var(--btn-main-text);
  font-weight: 900;
}

/* ===================================
   FLOATING MENU
   =================================== */

.floating-menu-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  pointer-events: none;
}

.floating-menu-container.active {
  pointer-events: auto;
}

.menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
}

.floating-menu-container.active .menu-backdrop {
  background: rgba(0, 0, 0, 0.2);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  /* Increased spacing between items */
  pointer-events: auto;
}

.menu-item {
  position: relative;
  /* For absolute positioning of label */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(0, 20, 40, 0.4);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0;
  transform: translateY(10px) scale(0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.floating-menu-container.active .menu-item {
  animation: menuItemSlideIn 0.4s ease-out forwards;
}

.menu-item:hover {
  background: rgba(0, 20, 40, 0.6);
  transform: translateY(0) scale(1.1);
  box-shadow: 0 0 15px var(--shadow-color);
}

.menu-icon {
  color: var(--primary-color);
  opacity: 0.8;
  transition: opacity 0.2s;
}

.menu-item:hover .menu-icon {
  opacity: 1;
}

.menu-label {
  position: absolute;
  top: -4px;
  /* Positioned at button edge */
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  color: var(--label-color);
  opacity: 0.7;
  font-style: italic;
  white-space: nowrap;
  pointer-events: none;
}

.menu-item:hover .menu-label {
  opacity: 0.9;
}

@keyframes menuItemSlideIn {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.8);
  }

  60% {
    transform: translateY(-2px) scale(1.05);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===================================
   MOBILE RESPONSIVENESS
   =================================== */

@media (max-width: 768px) {
  .footer-controls-top {
    bottom: 80px;
    /* Adjust for smaller main footer */
    height: 50px;
    padding: 5px 10px;
  }

  .btn-circle {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }

  .footer-betting-bottom {
    height: 80px;
    padding: 10px 20px;
  }

  .info-block {
    min-width: auto;
    flex: 0 1 auto;
  }

  .info-block .label {
    font-size: 0.6rem;
    margin-bottom: 0;
    line-height: 1;
  }

  .info-block .value {
    font-size: 1rem;
    line-height: 1.1;
  }

  .bet-controls {
    gap: 8px;
    flex: 1 0 auto;
    justify-content: center;
  }

  .btn-square {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    border-radius: 8px;
  }

  .btn-main-bet {
    min-width: 120px;
    height: 55px;
    padding: 3px 12px;
  }

  .btn-main-bet .bet-label {
    font-size: 0.65rem;
  }

  .btn-main-bet .bet-value {
    font-size: 1.2rem;
  }

  .conversion-indicator {
    transform: translateX(-50%);
    bottom: -12px;
    font-size: 0.65rem;
    line-height: 1;
  }
}

@media (max-width: 360px) {
  .footer-betting-bottom {
    padding: 5px 10px;
  }

  .btn-main-bet {
    min-width: 90px;
  }

  .info-block .value {
    font-size: 0.9rem;
  }
}