/* ============================================
   RULETA DE LA SUERTE — NIVEL PREMIUM
   Atmosfera, profundidad, branding, resultado espectacular
   ============================================ */

:root {
    --rw-primary: var(--primary, #ff5722);
    --rw-primary-dark: var(--primary-dark, #e64a19);
    --rw-primary-light: var(--primary-light, #ff8a65);
    --rw-primary-rgb: var(--primary-rgb, 255, 87, 34);
    --rw-radius: 32px;
    --rw-ease-out: cubic-bezier(0.19, 1, 0.22, 1);
    --rw-ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --rw-ease-snap: cubic-bezier(0.23, 1, 0.32, 1);
}

/* ---- Overlay: atmósfera inmersiva ---- */
.roulette-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
    background: 
        radial-gradient(ellipse 100% 80% at 50% 20%, rgba(var(--rw-primary-rgb), 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 140% 120% at 50% 100%, rgba(0,0,0,0.6) 0%, transparent 50%),
        radial-gradient(ellipse 80% 80% at 50% 50%, #0c0c0f 0%, #050507 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: rwOverlayIn 0.5s var(--rw-ease-out) forwards;
}

@keyframes rwOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---- Caja: escenario principal ---- */
.roulette-box {
    position: relative;
    width: min(96vw, 720px);
    max-width: 720px;
    padding: 2.5rem 2.25rem;
    background: 
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 12%),
        linear-gradient(165deg, #1c1c22 0%, #141418 45%, #0d0d10 100%);
    border-radius: var(--rw-radius);
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.6),
        0 0 120px -30px rgba(var(--rw-primary-rgb), 0.25),
        0 48px 96px -32px rgba(0,0,0,0.85),
        0 24px 48px -24px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(255,255,255,0.06),
        inset 0 -1px 0 rgba(0,0,0,0.3);
    animation: rwBoxIn 0.6s var(--rw-ease-bounce) forwards;
    overflow: visible;
}

.roulette-box::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: calc(var(--rw-radius) + 3px);
    padding: 3px;
    background: linear-gradient(160deg, var(--rw-primary-dark) 0%, var(--rw-primary) 30%, var(--rw-primary-light) 55%, var(--rw-primary) 80%, var(--rw-primary-dark) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    box-shadow: 0 0 60px -20px rgba(var(--rw-primary-rgb), 0.5);
}

.roulette-box::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
}

@keyframes rwBoxIn {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(40px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ---- Título: impacto visual ---- */
.roulette-title {
    position: relative;
    z-index: 2;
    text-align: center;
    margin: 0 0 2.25rem;
    padding: 0 0.75rem;
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.2;
    background: linear-gradient(180deg, var(--rw-primary-light) 0%, var(--rw-primary) 50%, var(--rw-primary-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 0 32px rgba(var(--rw-primary-rgb), 0.5)) drop-shadow(0 2px 12px rgba(0,0,0,0.8));
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-family: inherit;
}

.roulette-title::after {
    content: '';
    display: block;
    width: 80px;
    height: 3px;
    margin: 14px auto 0;
    background: linear-gradient(90deg, transparent, var(--rw-primary), transparent);
    border-radius: 2px;
    opacity: 0.85;
}

/* ---- Contenedor rueda: protagonista ---- */
.roulette-wheel-wrap {
    position: relative;
    z-index: 2;
    width: min(480px, 88vw);
    height: min(480px, 88vw);
    max-width: 480px;
    max-height: 480px;
    margin: 0 auto 2rem;
    flex-shrink: 0;
    animation: rwWrapReady 0.8s var(--rw-ease-out) 0.3s both;
}

@keyframes rwWrapReady {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.roulette-wheel-wrap.rw-spin-launch {
    animation: rwLaunch 0.25s var(--rw-ease-snap) forwards;
}

@keyframes rwLaunch {
    0% { transform: scale(1); }
    40% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

/* Marco exterior: doble anillo + brillo */
.roulette-wheel-wrap::before {
    content: '';
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    padding: 5px;
    background: conic-gradient(from 0deg, var(--rw-primary-dark), var(--rw-primary), var(--rw-primary-light), var(--rw-primary), var(--rw-primary-dark)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: -1;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.5),
        0 0 80px -20px rgba(var(--rw-primary-rgb), 0.5),
        0 0 40px -15px rgba(var(--rw-primary-rgb), 0.35),
        0 12px 48px rgba(0,0,0,0.6);
    animation: rwRingPulse 4s ease-in-out infinite;
}

@keyframes rwRingPulse {
    0%, 100% { opacity: 1; filter: brightness(1); }
    50% { opacity: 0.98; filter: brightness(1.08); }
}

.roulette-wheel-wrap::after {
    content: '';
    position: absolute;
    inset: -16px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--rw-primary-rgb), 0.12) 0%, transparent 60%);
    z-index: -2;
    pointer-events: none;
}

/* ---- Puntero: claridad + detalle ---- */
.roulette-pointer {
    position: absolute;
    top: -26px;
    left: 50%;
    width: 0;
    height: 0;
    margin-left: -28px;
    border-left: 28px solid transparent;
    border-right: 28px solid transparent;
    border-top: 36px solid var(--rw-primary-light);
    filter: 
        drop-shadow(0 0 12px rgba(var(--rw-primary-rgb), 0.6))
        drop-shadow(0 6px 18px rgba(0,0,0,0.6));
    z-index: 12;
    pointer-events: none;
    animation: rwPointerIdle 2.5s ease-in-out infinite;
}

@keyframes rwPointerIdle {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(var(--rw-primary-rgb), 0.5)) drop-shadow(0 6px 18px rgba(0,0,0,0.6)); }
    50% { filter: drop-shadow(0 0 20px rgba(var(--rw-primary-rgb), 0.7)) drop-shadow(0 6px 18px rgba(0,0,0,0.6)); }
}

.roulette-pointer::before {
    content: '';
    position: absolute;
    top: -40px;
    left: -26px;
    width: 0;
    height: 0;
    border-left: 26px solid transparent;
    border-right: 26px solid transparent;
    border-top: 32px solid var(--rw-primary);
}

.roulette-pointer::after {
    content: '';
    position: absolute;
    top: -34px;
    left: -4px;
    width: 8px;
    height: 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255,255,255,0.6);
}

/* ---- Rueda: profundidad + giro ---- */
.roulette-wheel {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    transform-origin: center center;
    box-shadow:
        0 0 0 5px rgba(12,12,14,1),
        0 0 0 8px rgba(var(--rw-primary-rgb), 0.5),
        0 0 60px -15px rgba(var(--rw-primary-rgb), 0.3),
        0 18px 56px rgba(0,0,0,0.65),
        inset 0 0 60px rgba(0,0,0,0.55),
        inset 0 2px 0 rgba(255,255,255,0.04);
    will-change: transform;
    backface-visibility: hidden;
}

.roulette-wheel.spinning {
    transition: none !important;
    box-shadow:
        0 0 0 5px rgba(12,12,14,1),
        0 0 0 8px rgba(var(--rw-primary-rgb), 0.7),
        0 0 90px -20px rgba(var(--rw-primary-rgb), 0.5),
        0 18px 56px rgba(0,0,0,0.65),
        inset 0 0 60px rgba(0,0,0,0.55);
}

/* ---- Botón GIRAR: premium CTA ---- */
.roulette-center-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    border: 5px solid var(--rw-primary-dark);
    background: linear-gradient(170deg, var(--rw-primary-light) 0%, var(--rw-primary) 35%, var(--rw-primary-dark) 100%);
    color: #fff;
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: 0.14em;
    cursor: pointer;
    box-shadow:
        0 8px 0 rgba(0,0,0,0.4),
        0 14px 32px rgba(0,0,0,0.5),
        inset 0 3px 0 rgba(255,255,255,0.4),
        inset 0 -3px 0 rgba(0,0,0,0.2);
    transition: transform 0.2s var(--rw-ease-out), box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    line-height: 1.2;
    text-transform: uppercase;
}

.roulette-center-btn:hover:not(:disabled) {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow:
        0 6px 0 rgba(0,0,0,0.4),
        0 18px 40px rgba(var(--rw-primary-rgb), 0.45),
        inset 0 3px 0 rgba(255,255,255, 0.5);
}

.roulette-center-btn:active:not(:disabled) {
    transform: translate(-50%, -50%) scale(1.03);
    box-shadow:
        0 4px 0 rgba(0,0,0,0.4),
        0 8px 20px rgba(0,0,0,0.4),
        inset 0 2px 0 rgba(255,255,255,0.3);
}

.roulette-center-btn:disabled {
    cursor: not-allowed;
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.98);
    animation: rwBtnSpinPulse 1.2s ease-in-out infinite;
}

@keyframes rwBtnSpinPulse {
    0%, 100% { box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 12px 28px rgba(0,0,0,0.45), inset 0 2px 0 rgba(255,255,255,0.3); }
    50% { box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 12px 36px rgba(var(--rw-primary-rgb), 0.4), inset 0 2px 0 rgba(255,255,255,0.35); }
}

.roulette-center-btn .btn-icon {
    font-size: 2rem;
    color: #fff;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* ---- Área resultado: revelación ---- */
.roulette-result-area {
    position: relative;
    z-index: 2;
    text-align: center;
    min-height: 100px;
    margin-top: 1.5rem;
    padding: 0 0.5rem;
}

.roulette-result-card {
    padding: 2rem 1.75rem;
    border-radius: 24px;
    background: 
        linear-gradient(165deg, rgba(var(--rw-primary-rgb), 0.2) 0%, rgba(var(--rw-primary-rgb), 0.08) 50%, rgba(var(--rw-primary-rgb), 0.04) 100%);
    border: 2px solid rgba(var(--rw-primary-rgb), 0.55);
    box-shadow:
        0 0 60px -20px rgba(var(--rw-primary-rgb), 0.35),
        0 12px 48px rgba(0,0,0,0.55),
        inset 0 1px 0 rgba(255,255,255,0.1);
    animation: rwResultIn 0.7s var(--rw-ease-bounce) forwards;
    position: relative;
    overflow: hidden;
}

.roulette-result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    animation: rwResultShine 1.2s ease-out 0.4s forwards;
}

@keyframes rwResultShine {
    to { left: 150%; }
}

.roulette-result-card.grand {
    background: 
        linear-gradient(165deg, rgba(var(--rw-primary-rgb), 0.35) 0%, rgba(var(--rw-primary-rgb), 0.18) 50%, rgba(var(--rw-primary-rgb), 0.1) 100%);
    border-color: var(--rw-primary);
    box-shadow:
        0 0 80px -20px rgba(var(--rw-primary-rgb), 0.6),
        0 0 40px -15px rgba(var(--rw-primary-rgb), 0.4),
        0 12px 48px rgba(0,0,0,0.55),
        inset 0 1px 0 rgba(255,255,255,0.15);
    animation: rwResultGrandIn 0.8s var(--rw-ease-bounce) forwards;
}

.roulette-result-card.grand::before {
    animation: rwResultShine 1.5s ease-out 0.5s forwards;
}

@keyframes rwResultIn {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(24px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes rwResultGrandIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }
    60% {
        transform: scale(1.03) translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.roulette-result-label {
    font-size: 1.35rem;
    font-weight: 800;
    color: #f8f6f3;
    margin: 0 0 10px;
    line-height: 1.35;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}

.roulette-result-card.grand .roulette-result-label {
    background: linear-gradient(180deg, var(--rw-primary-light) 0%, var(--rw-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 24px rgba(var(--rw-primary-rgb), 0.6)) drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

.roulette-result-sublabel {
    font-size: 0.98rem;
    color: #b0aea8;
    margin: 0;
    line-height: 1.5;
}

.roulette-close-btn {
    margin-top: 1.5rem;
    padding: 16px 48px;
    border-radius: 16px;
    border: none;
    border-bottom: 5px solid rgba(0,0,0,0.35);
    background: linear-gradient(170deg, var(--rw-primary-light) 0%, var(--rw-primary) 50%, var(--rw-primary-dark) 100%);
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: transform 0.2s var(--rw-ease-out), box-shadow 0.2s;
    box-shadow:
        0 6px 24px rgba(0,0,0,0.4),
        inset 0 2px 0 rgba(255,255,255,0.3);
}

.roulette-close-btn:hover {
    transform: scale(1.06);
    box-shadow:
        0 8px 32px rgba(var(--rw-primary-rgb), 0.5),
        inset 0 2px 0 rgba(255,255,255,0.4);
}

/* ---- SVG rueda: sectores y texto ---- */
.roulette-wheel svg {
    display: block;
    width: 100%;
    height: 100%;
}

.roulette-wheel svg path {
    transition: filter 0.2s;
}

.roulette-wheel svg text {
    font-size: 13px;
    font-weight: 800;
    fill: rgba(255,255,255,0.98);
    text-anchor: middle;
    pointer-events: none;
    text-shadow:
        0 1px 6px rgba(0,0,0,0.95),
        0 0 4px rgba(0,0,0,0.8);
    letter-spacing: 0.03em;
}

.roulette-wheel svg .segment-grand text {
    fill: var(--rw-primary-light);
    text-shadow:
        0 0 18px rgba(var(--rw-primary-rgb), 0.9),
        0 1px 6px rgba(0,0,0,0.95);
}

/* ---- Loading ---- */
.roulette-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    padding: 2.5rem;
    color: var(--rw-primary);
}

.roulette-loading i {
    font-size: 3rem;
    animation: rwLoadingSpin 1s linear infinite;
    filter: drop-shadow(0 0 20px rgba(var(--rw-primary-rgb), 0.5));
}

.roulette-loading-text {
    margin-top: 1rem;
    font-size: 1rem;
    color: var(--rw-primary-light);
    opacity: 0.95;
}

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

/* ---- Flash al ganar ---- */
.roulette-win-flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: var(--rw-radius);
    background: 
        radial-gradient(circle at 50% 50%, rgba(var(--rw-primary-rgb), 0.5) 0%, rgba(var(--rw-primary-rgb), 0.2) 35%, transparent 65%);
    animation: rwWinFlash 0.9s var(--rw-ease-out) forwards;
    z-index: 8;
}

@keyframes rwWinFlash {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .roulette-box {
        padding: 2rem 1.5rem;
        max-width: 96vw;
    }
    .roulette-title {
        font-size: 1.6rem;
        margin-bottom: 1.75rem;
        letter-spacing: 0.08em;
    }
    .roulette-wheel-wrap {
        width: min(400px, 90vw);
        height: min(400px, 90vw);
        max-width: 400px;
        max-height: 400px;
    }
    .roulette-center-btn {
        width: 96px;
        height: 96px;
        font-size: 0.8rem;
    }
    .roulette-center-btn .btn-icon {
        font-size: 1.7rem;
    }
    .roulette-wheel svg text {
        font-size: 11px;
    }
    .roulette-result-label {
        font-size: 1.2rem;
    }
}

@media (max-width: 420px) {
    .roulette-wheel-wrap {
        width: min(340px, 92vw);
        height: min(340px, 92vw);
        max-width: 340px;
        max-height: 340px;
    }
    .roulette-wheel svg text {
        font-size: 9px;
    }
}
