@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;800&display=swap");

:root {
  --coop-blue: #002D62;
  --coop-blue-light: #0072CE;
  --coop-orange: #F57C00;
  --coop-yellow: #FFC72C;
  --coop-dark: #001A3A;
}

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(180deg,
      #ffffff 0%,
      #e6f0fa 30%,
      #b3d4f5 70%,
      #002D62 100%);
  min-height: 100vh;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Copos de nieve */
.snowflake {
  position: fixed;
  top: -10px;
  z-index: 9999;
  color: rgba(255, 255, 255, 0.95);
  font-size: 2em;
  pointer-events: none;
  animation: fall linear infinite;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  will-change: transform;
}

@keyframes fall {
  0% {
    transform: translateY(-10vh) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0;
  }
}

/* Nuevas animaciones de carga */
@keyframes bounce-slight {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

/* --- Animaciones Premium Coopidrogas --- */
@keyframes neonPulse {
  0% {
    box-shadow: 0 0 10px rgba(0, 45, 98, 0.4), 0 0 20px rgba(0, 114, 206, 0.3);
  }

  50% {
    box-shadow: 0 0 25px rgba(0, 45, 98, 0.8), 0 0 50px rgba(0, 114, 206, 0.5), 0 0 80px rgba(255, 199, 44, 0.2);
  }

  100% {
    box-shadow: 0 0 10px rgba(0, 45, 98, 0.4), 0 0 20px rgba(0, 114, 206, 0.3);
  }
}

@keyframes sunburst {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes spinPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.04);
  }
}

.animate-bounce-slight {
  animation: bounce-slight 2s infinite ease-in-out;
}

@keyframes loading-bar {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.animate-loading-bar {
  animation: loading-bar 1.5s infinite linear;
}

/* Confetti Canvas Fix */
canvas[style*="position: fixed"] {
  z-index: 9999 !important;
  pointer-events: none !important;
}

#confetti-canvas {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
}

.wheel-container {
  position: relative;
  width: 75vw;
  /* Reduced from 80vw to avoid edge cutoff */
  max-width: 320px;
  aspect-ratio: 1;
  margin: 0 auto;
  /* El drop-shadow recalculado en cada frame es muy costoso */
  /* filter: drop-shadow(0 20px 40px rgba(0, 45, 98, 0.4)); */
  transition: all 0.5s ease;
}

/* Pseudo-elemento con NEON PULSE — aro de luz corporativo */
.wheel-container::before {
  content: '';
  position: absolute;
  top: 2%;
  left: 2%;
  right: 2%;
  bottom: 2%;
  border-radius: 50%;
  box-shadow: 0 20px 40px rgba(0, 45, 98, 0.4);
  animation: neonPulse 2.5s infinite alternate ease-in-out;
  z-index: -1;
  pointer-events: none;
}

@media (min-width: 768px) {
  .wheel-container {
    width: 60vh;
    max-width: 450px;
  }
}

/* Ruleta en pantalla completa */
.wheel-container.fullscreen {
  width: 90vw;
  /* Wider on mobile play mode */
  max-width: 400px;
}

@media (min-width: 768px) {
  .wheel-container.fullscreen {
    max-width: 550px;
    width: 65vh;
  }
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  /* Start at top */
  transition: transform 0s;
}

/* El triángulo indicador */
.stopper {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 60px;
  background: linear-gradient(to bottom, #FFC72C, #F57C00);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  z-index: 10;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.glass-panel {
  background: rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: none;
}

/* Animación suave para las pestañas */
.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active {
  display: flex;
  /* Changed to flex for better layout control */
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Centro de la ruleta con imagen */
.center-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24%;
  /* Tamaño ajustado */
  height: 24%;
  transform: translate(-50%, -50%);
  z-index: 20;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  border: 5px solid #FFC72C;
  overflow: hidden;
  padding: 4%;
}

.center-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Footer */
footer {
  padding: 0.5rem;
  text-align: center;
  margin-top: 0;
  color: #ffffff;
  font-weight: 500;
  font-size: 0.75rem;
  flex-shrink: 0;
}

footer a {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

footer a:hover {
  text-decoration: underline;
}

/* Layout Transitions */
#sidebar-section {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
}

/* Main container flexible */
.main-container {
  flex: 1;
  display: flex;
  overflow-y: auto;
  /* Always scrollable if needed */
  overflow-x: hidden;
  width: 100%;
}

@media (min-width: 768px) {
  .main-container {
    overflow: hidden;
    /* Desktop keeps it fixed if possible */
    max-height: calc(100vh - 120px);
  }
}

/* Hidden State for Sidebar */
.sidebar-hidden {
  width: 0 !important;
  opacity: 0;
  padding: 0 !important;
  margin: 0 !important;
}

/* Expanded State for Wheel Section */
.w-full-expanded {
  width: 100% !important;
}

/* Modal de Ganador */
#winner-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  transition: opacity 0.3s;
  opacity: 0;
}

#winner-modal.show {
  display: flex;
  opacity: 1;
}

/* Efecto SUNBURST — Rayos de luz dorados detrás del ganador */
#winner-modal::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: repeating-conic-gradient(rgba(255, 199, 44, 0.12) 0 15deg,
      rgba(255, 255, 255, 0.0) 15deg 30deg);
  animation: sunburst 25s linear infinite;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  transition: opacity 1.2s ease;
}

#winner-modal.show::before {
  opacity: 1;
}

#winner-card {
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
  border-radius: 1.5rem;
  padding: 1.5rem;
  max-width: 90vw;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  transform: scale(0.3) rotate(-10deg);
  transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
  border: 4px solid #002D62;
  position: relative;
  z-index: 2;
}

@media (min-width: 768px) {
  #winner-card {
    padding: 3rem;
    border-radius: 2rem;
    max-width: 40rem;
  }
}

#winner-modal.show #winner-card {
  transform: scale(1) rotate(0deg);
  animation: bounce-in 0.8s ease-out;
}

@keyframes bounce-in {
  0% {
    transform: scale(0.3) rotate(-10deg);
  }

  50% {
    transform: scale(1.1) rotate(5deg);
  }

  70% {
    transform: scale(0.95) rotate(-2deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

#winner-card h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: #002D62;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: slide-down 0.5s ease-out 0.3s backwards;
}

@media (min-width: 768px) {
  #winner-card h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    letter-spacing: 3px;
  }
}

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#modal-winner-name {
  font-size: 2.5rem;
  line-height: 1.1;
  font-weight: 900;
  margin: 1rem 0;
  word-break: break-word;
  background: linear-gradient(135deg, #002D62 0%, #1a1a1a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 8px rgba(0, 45, 98, 0.3);
  animation: pulse-name 2s ease-in-out infinite;
  letter-spacing: 2px;
  text-transform: uppercase;
}

@keyframes pulse-name {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

#winner-card button {
  padding: 0.75rem 2rem;
  border-radius: 9999px;
  color: white;
  font-weight: bold;
  font-size: 1.125rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s;
  background: linear-gradient(135deg, #002D62 0%, #001A3A 100%);
  border: none;
}

#winner-card button:hover {
  transform: scale(1.05);
}

@media (min-width: 768px) {
  #modal-winner-name {
    font-size: 3.75rem;
  }
}

/* Botón Girar Premium */
.btn-spin-premium {
  position: relative;
  padding: 0.75rem 3rem;
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: white;
  background: linear-gradient(135deg, #002D62 0%, #0072CE 100%);
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow:
    0 4px 15px rgba(0, 45, 98, 0.4),
    0 10px 40px rgba(0, 45, 98, 0.2),
    inset 0 0 15px rgba(255, 255, 255, 0.2);
  outline: none;
  overflow: hidden;
  white-space: nowrap;
  z-index: 10;
  /* Latido magnético — invita al clic */
  animation: spinPulse 2s infinite ease-in-out;
}

.btn-spin-premium::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.4),
      transparent);
  transition: 0.5s;
}

.btn-spin-premium:hover {
  transform: scale(1.08) translateY(-3px) !important;
  animation: none;
  /* Detener pulso en hover */
  box-shadow:
    0 8px 25px rgba(0, 45, 98, 0.6),
    0 15px 50px rgba(0, 45, 98, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
}

.btn-spin-premium:hover::before {
  left: 100%;
}

.btn-spin-premium:active {
  transform: scale(0.95) translateY(2px) !important;
  animation: none;
  box-shadow: 0 4px 10px rgba(0, 45, 98, 0.5);
}

.btn-spin-premium:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
  transform: scale(1) translateY(0);
}

@media (max-width: 768px) {
  .btn-spin-premium {
    padding: 0.6rem 2rem;
    font-size: 1.25rem;
  }
}

/* Custom Scrollbar for Winners List */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(0, 45, 98, 0.3);
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 45, 98, 0.5);
}

#play-history-list li {
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Título Slogan Premium */
.banner-title {
  font-size: 2.5rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
  margin-bottom: 0.5rem;
  color: #e0e0e0;
  -webkit-text-fill-color: #002D62;
  text-shadow:
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 8px 16px rgba(0, 0, 0, 0.2),
    0 12px 24px rgba(0, 45, 98, 0.1);
  /* filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.1)); Redundante y pesado */
  display: inline-block;
}

@media (max-width: 640px) {
  .banner-title {
    font-size: 2rem;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .banner-title {
    font-size: 2.8rem;
  }
}

/* Estilos de Contenedores Premium */
#prize-stock-box,
#play-history-box {
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04),
    0 0 30px rgba(0, 45, 98, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
  backdrop-filter: blur(12px);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#prize-stock-box:hover,
#play-history-box:hover {
  transform: translateY(-4px);
  box-shadow:
    0 30px 35px -5px rgba(0, 0, 0, 0.2),
    0 20px 20px -5px rgba(0, 0, 0, 0.1),
    0 0 40px rgba(0, 45, 98, 0.25);
}

/* Stock de Premios Ultra Compacto */
.stock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.6rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 45, 98, 0.1);
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  margin-bottom: 0.3rem;
}

.stock-item.empty {
  opacity: 0.5;
  background: rgba(0, 0, 0, 0.05);
  text-decoration: line-through;
}

.stock-count {
  background: #002D62;
  color: white;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  min-width: 1.6rem;
  text-align: center;
  font-weight: 900;
  box-shadow: 0 4px 6px rgba(0, 45, 98, 0.2);
}

.stock-count.zero {
  background: #666;
  box-shadow: none;
}