/* Estilos Generales */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden; /* Evita scroll */
    font-family: sans-serif;
    background-color: #f0f0f0; /* Color de fondo temporal */
}

/* Loading Indicator Styles */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #222; /* Solid dark background */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: #ffffff;
    font-size: 1.2rem;
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}
#loader .spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid #f0c021;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

#loader.hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Contenedor Principal */
.app-container {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 100vh;
    padding: 10px;
    box-sizing: border-box;
    background-image: url('assets/images/FONDO.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Estilos para Imágenes */
.app-container img {
    max-width: 80%; /* Limita el ancho máximo de las imágenes */
    height: auto; /* Mantiene la proporción */
    display: block; /* Evita espacios extra debajo */
}

/* Logo */
.logo {
    max-width: 30%; /* Keep a max-width */
    max-height: 15vh; /* User adjusted */
    margin-bottom: 0.5vh; /* Reduced margin */
}

/* Text Group Container */
.text-group {
    display: flex;
    flex-direction: column; /* Stack images vertically */
    align-items: center; /* Center images horizontally */
    margin-top: 2vh; /* Added margin to push down from logo */
    margin-bottom: 2vh; /* Space below the group */
    width: 100%; /* Take full width to center content */
}

/* Textos Juega/Gira/Gana */
.text-juega, 
.text-gira,
.text-gana { 
    max-width: 40%; 
    max-height: 8vh; /* User adjusted */
    margin-bottom: 0.5vh; /* Restored previous smaller margin */
}

/* Remove margin from last text item in the group */
.text-group img:last-child {
    margin-bottom: 0;
}

/* Contenedor de la Ruleta */
.roulette-container {
    position: relative; 
    width: 100%; 
    max-width: 590px; 
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2vh 0 4vh 0; /* Top margin kept at 2vh, increased bottom margin to 4vh for separation from bottom */
    aspect-ratio: 1 / 1; 
}

.roulette-base,
.roulette-wheel,
.roulette-indicator {
    position: absolute; 
    height: auto;
}

.roulette-base {
    width: 100%; /* Base takes full container width */
    top: 43%;   
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1; 
}

.roulette-wheel {
    width: 70%; /* Reduced from 85% to show more base border */
    top: 43%;   
    left: 50%;
    transform: translate(-50%, -50%); 
    transition: transform 4s ease-out; 
    z-index: 2; 
}

.roulette-indicator {
    z-index: 10; 
    width: 10%; /* Adjust this value to scale the indicator */
    top: 7%; /* Lowered significantly from 1% */ 
    left: 50%; 
    transform: translateX(-50%); 
    height: auto; 
}

/* Botón Girar */
.spin-button {
    position: absolute;
    width: 15%;
    max-width: 100px;
    top: 43%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11; /* Changed from 3 to 11 to be above roulette-indicator (z-index: 10) */
    cursor: pointer;
    opacity: 1;
    --base-transform: translate(-50%, -50%);
}

/* Disabled state handled by CSS */
.spin-button.disabled {
    opacity: 0.7; /* Slightly dimmed but not fully transparent */
    cursor: not-allowed;
}

/* Efecto al hacer clic */
.spin-button:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Result Display */
.result-display {
    margin-top: 3vh; /* Space above the result */
    min-height: 5vh; /* Ensure it takes some space even when empty */
    font-size: 1.5rem; /* Adjust size as needed */
    font-weight: bold;
    color: #333; /* Adjust color as needed */
    text-align: center;
    padding: 5px 10px;
    background-color: rgba(255, 255, 255, 0.7); /* Semi-transparent background */
    border-radius: 10px;
    max-width: 80%;
}

/* Texto Prueba (Oculto por defecto) */
.text-prueba {
    max-width: 30%;
    margin-top: 5px;
}

/* Media Query for Smaller Screens */
@media (max-width: 600px) {
    #loader p {
        font-size: 1rem;
    }
    #loader .spinner {
        width: 30px;
        height: 30px;
    }
    .app-container img {
        max-width: 90%; /* Increase max-width on small screens */
    }
    .roulette-container {
        margin: 2vh 0 4vh 0; /* Adjusted for smaller screens, keeping bottom margin */
    }
    .result-display {
        font-size: 1.2rem; /* Slightly smaller font for smaller screens */
    }
}

/* --- Entry Animation (Button - with base transform) --- */
@keyframes popup-in {
    0% {
        opacity: 0;
        transform: var(--base-transform) scale(0.0);
    }
    60% { /* First overshoot */
        opacity: 1;
        transform: var(--base-transform) scale(1.55); /* User adjusted overshoot */
    }
    85% { /* Undershoot (second bounce) */
        opacity: 1;
        transform: var(--base-transform) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: var(--base-transform) scale(1);
    }
}

/* Initial state for animated elements */
.logo,
.text-group,
.roulette-container {
    opacity: 0;
    transform: scale(0.5); 
    transition: none !important; 
}

/* Separate initial state for spin button to define variable */
.spin-button {
    opacity: 0;
    --base-transform: translate(-50%, -50%); /* Define variable */
    transform: var(--base-transform) scale(1); /* Start at normal scale */
}

/* When .visible is added, run the animation */
.logo.visible,
.text-group.visible,
.roulette-container.visible {
    opacity: 1; 
    transform: scale(1); /* Set final transform for non-button elements */
    animation: popup-in-simple 0.15s ease-out forwards;
    will-change: transform, opacity; 
}

/* Spin button visibility triggers scale-up animation with double bounce */
.spin-button.visible {
    opacity: 1; 
    animation: scaleUpDoubleBounce 0.5s ease-in-out forwards; /* Double bounce on load */
    will-change: transform, opacity; 
}

/* --- Simplified Entry Animation (Other elements) --- */
@keyframes popup-in-simple {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    60% { /* First overshoot */
        opacity: 1;
        transform: scale(1.2); /* User adjusted overshoot */
    }
    85% { /* Undershoot (second bounce) */
        opacity: 1;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Ensure roulette elements inherit visibility from container initially */
.roulette-container > img {
    opacity: inherit;
}

/* When container is visible, allow its children to animate/be visible */
.roulette-container.visible > img {
     opacity: 1; /* Override inherit */
}

/* Override for spin button which animates separately */
.roulette-container.visible > .spin-button:not(.visible) {
    opacity: 0 !important; /* Keep button hidden until its turn */
}

/* --- Spin Button Animations --- */
/* Scale up with double bounce (used on load) */
@keyframes scaleUpDoubleBounce {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    40% { /* First overshoot */
        transform: translate(-50%, -50%) scale(1.5);
    }
    70% { /* Undershoot */
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.3);
    }
}

/* Scale down with ease-out (used when pressed) */
@keyframes scaleDownEaseOut {
    0% {
        transform: translate(-50%, -50%) scale(1.3);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Scale back up with double bounce (used after spin) */
@keyframes scaleBackUpDoubleBounce {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    40% { /* First overshoot */
        transform: translate(-50%, -50%) scale(1.5);
    }
    70% { /* Undershoot */
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.3);
    }
}

/* Classes to trigger the new animations */
.spin-button.scale-up-double-bounce {
    animation: scaleUpDoubleBounce 0.5s ease-in-out forwards;
}

.spin-button.scale-down-ease-out {
    animation: scaleDownEaseOut 0.3s ease-out forwards;
}

.spin-button.scale-back-up-double-bounce {
    animation: scaleBackUpDoubleBounce 0.5s ease-in-out forwards;
}

/* Remove previous pulse animations since we're replacing them */
.spin-button {
    transform: var(--base-transform) scale(1); /* Start at normal scale */
}

/* Ensure visibility animation doesn’t override our new scale animations */
.spin-button.visible {
    opacity: 1;
    animation: scaleUpDoubleBounce 0.5s ease-in-out forwards; /* Double bounce on load */
  
}

/* --- Prize Modal Styles --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 10000; /* Above everything */
    align-items: center;
    justify-content: center;
}

.modal.modal-visible {
    display: flex; /* Show when class is added */
}

.modal-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent dark background */
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 1; /* Behind content */
}

.modal-content {
    position: relative;
    background: transparent; /* Or a subtle background if needed */
    padding: 20px;
    border-radius: 10px;
    z-index: 2; /* Above overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 90%; /* Max width/height relative to viewport */
    height: 90%;
}

#prize-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure image fits without distortion */
    transform: scale(0);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease-out; /* Bounce effect on scale */
}

#prize-image.visible {
    transform: scale(1);
    opacity: 1;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 24px;
    line-height: 35px; /* Center the 'x' */
    text-align: center;
    cursor: pointer;
    z-index: 3; /* Above image */
    padding: 0;
}

.close-button:hover {
    background: rgba(0, 0, 0, 0.8);
}