/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
  --red-primary: #DC2626;
  --red-dark: #991B1B;
  --gray-900: #111827;
  --gray-800: #1F2937;
  --gray-700: #374151;
  --transition-fast: 150ms;
  --transition-normal: 300ms;
}

/* ============================================
   RESET PARA EVITAR SCROLL HORIZONTAL
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

/* Prevenir overflow en contenedores principales */
main, section {
  overflow-x: hidden;
  max-width: 100%;
}

/* ============================================
   FUENTES PERSONALIZADAS
   ============================================ */
.font-display {
  font-family: 'Oswald', sans-serif;
}

body {
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.skel {
  background: linear-gradient(
    90deg,
    var(--gray-800) 25%,
    var(--gray-700) 50%,
    var(--gray-800) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   BOLAS DE LOTERÍA
   ============================================ */
.ball-white {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f3f4f6 0%, #d1d5db 100%);
  color: #111827;
  font-weight: 700;
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px 0 rgba(255, 255, 255, 0.4);
  border: 2px solid #e5e7eb;
  transition: transform var(--transition-fast);
  will-change: transform;
  flex-shrink: 0;
}

.ball-white:hover {
  transform: scale(1.05);
}

.ball-red {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red-primary) 0%, var(--red-dark) 100%);
  color: white;
  font-weight: 700;
  font-size: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 4px 6px -1px rgba(220, 38, 38, 0.5),
    inset 0 2px 4px 0 rgba(255, 255, 255, 0.3);
  border: 3px solid #b91c1c;
  transition: transform var(--transition-fast);
  will-change: transform;
  flex-shrink: 0;
}

.ball-red:hover {
  transform: scale(1.05);
}

/* ============================================
   CARDS Y EFECTOS
   ============================================ */
.card-glow {
  box-shadow: 
    0 0 0 1px rgba(55, 65, 81, 0.5),
    0 10px 15px -3px rgba(0, 0, 0, 0.3),
    0 4px 6px -4px rgba(0, 0, 0, 0.2);
  transition: all var(--transition-normal);
  max-width: 100%;
}

.card-glow:hover {
  box-shadow: 
    0 0 0 1px rgba(220, 38, 38, 0.3),
    0 20px 25px -5px rgba(0, 0, 0, 0.4),
    0 8px 10px -6px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

/* ============================================
   HERO BACKGROUND
   ============================================ */
.hero-bg {
  background: 
    radial-gradient(circle at 50% 0%, rgba(220, 38, 38, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(220, 38, 38, 0.03) 0%, transparent 50%);
}

/* ============================================
   BADGE PULSE
   ============================================ */
.badge-pulse {
  animation: badge-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes badge-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* ============================================
   STEP CARDS
   ============================================ */
.step-card {
  transition: all var(--transition-normal);
  opacity: 0;
  transform: translateY(20px);
  will-change: transform;
}

.step-card.animate-in {
  opacity: 1;
  transform: translateY(0);
  animation: slide-up 0.5s ease-out forwards;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-card:nth-child(1).animate-in { animation-delay: 0.1s; }
.step-card:nth-child(2).animate-in { animation-delay: 0.2s; }
.step-card:nth-child(3).animate-in { animation-delay: 0.3s; }
.step-card:nth-child(4).animate-in { animation-delay: 0.4s; }

.step-card:hover {
  transform: translateY(-4px);
  border-color: var(--red-primary);
}

/* ============================================
   PRIZE ROWS
   ============================================ */
.prize-row {
  transition: background-color var(--transition-fast);
}

.prize-row:hover {
  background-color: rgba(31, 41, 55, 0.5);
}

/* ============================================
   FAQ ACCORDION
   ============================================ */
.faq-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding-bottom 0.3s ease-out;
  padding-bottom: 0;
}

.faq-body.open {
  max-height: 500px;
  padding-bottom: 1.25rem;
}

.faq-chevron {
  transition: transform var(--transition-normal);
}

.faq-chevron.open {
  transform: rotate(180deg);
}

/* ============================================
   NAVIGATION LINKS
   ============================================ */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--red-primary);
  transition: width var(--transition-normal);
  will-change: transform;
}

.nav-link:hover::after {
  width: 100%;
}

/* ============================================
   SCROLL TO TOP BUTTON
   ============================================ */
#scrollTop {
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  will-change: opacity, transform;
}

#scrollTop.visible {
  opacity: 1 !important;
  pointer-events: auto !important;
}

#scrollTop:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(220, 38, 38, 0.4);
}

#scrollTop:active {
  transform: translateY(-2px);
}

/* ============================================
   SCROLL BEHAVIOR
   ============================================ */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-gradient {
  background: linear-gradient(135deg, var(--red-primary), #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 640px) {
  .ball-white {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  .ball-red {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }
  
  /* Reducir gaps en móvil */
  #blancos {
    gap: 0.5rem !important;
  }
  
  /* Asegurar que los contenedores flex no causen overflow */
  .flex.flex-wrap {
    justify-content: center;
  }
}

/* ============================================
   DARK MODE ENHANCEMENTS
   ============================================ */
@media (prefers-color-scheme: dark) {
  .card-glow {
    box-shadow: 
      0 0 0 1px rgba(55, 65, 81, 0.6),
      0 10px 15px -3px rgba(0, 0, 0, 0.5),
      0 4px 6px -4px rgba(0, 0, 0, 0.4);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  #scrollTop,
  header,
  footer,
  #mobileMenu {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .bg-gray-900,
  .bg-gray-800 {
    background: white !important;
    border: 1px solid #ccc !important;
  }
}

/* ============================================
   FOCUS VISIBLE (ACCESSIBILIDAD)
   ============================================ */
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--red-primary);
  outline-offset: 2px;
}

/* ============================================
   LOADING STATE
   ============================================ */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--red-primary);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* ============================================
   SELECTION COLOR
   ============================================ */
::selection {
  background-color: var(--red-primary);
  color: white;
}

::-moz-selection {
  background-color: var(--red-primary);
  color: white;
}

/* ============================================
   FIX SCROLL HORIZONTAL EN MÓVIL - MEJORADO
   ============================================ */
/* Asegurar que ningún elemento exceda el ancho de viewport */
* {
  min-width: 0;
}

/* Cards de resultados */
#skeleton-card,
#real-card,
#error-card {
  max-width: 100%;
  width: 100%;
}

/* Contenedor de bolas - prevenir overflow */
#real-card > div:has(#blancos) {
  max-width: 100%;
  overflow-x: hidden;
}

#blancos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

/* Fix para tablas en móvil */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  max-width: 100vw;
}

@media (max-width: 640px) {
  /* Reducir padding de containers */
  .px-4 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* Asegurar que grids no causen overflow */
  .grid {
    gap: 0.5rem !important;
  }
  
  /* Fix para contenedor de premios */
  #real-card .grid.grid-cols-2 {
    gap: 0.75rem !important;
  }
}

@media (max-width: 375px) {
  .ball-white {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .ball-red {
    width: 50px;
    height: 50px;
    font-size: 1.35rem;
  }
  
  /* Reducir gaps aún más */
  #blancos {
    gap: 0.4rem !important;
  }
  
  /* Reducir padding de cards */
  #real-card,
  #skeleton-card {
    padding: 1.25rem !important;
  }
  
  /* Grid de premios en una columna */
  #real-card .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
  
  /* Reducir padding general */
  .px-4 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  
  /* Fix para step cards */
  .step-card {
    padding: 1rem !important;
  }
}

/* Asegurar que los max-width se respeten */
.max-w-4xl,
.max-w-5xl,
.max-w-6xl {
  max-width: 100% !important;
}

@media (min-width: 640px) {
  .max-w-4xl {
    max-width: 56rem !important;
  }
  
  .max-w-5xl {
    max-width: 64rem !important;
  }
  
  .max-w-6xl {
    max-width: 72rem !important;
  }
}