/* GachaVault - Animación del Gachapon
   Adaptado del CodePen de wheatup (https://codepen.io/wheatup/pen/BawKVYe)*/

.gacha-game {
    position: relative;
    width: 100%;
    height: 65vh;
    min-height: 400px;
    overflow: hidden;
    background: #666;
    border-radius: 18px;
    color: #fff;
    font-family: 'Roboto Mono', monospace;
    user-select: none;
}

.gacha-game *,
.gacha-game *::before,
.gacha-game *::after {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

.gacha-game .game-layer,
.gacha-game .ui-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.gacha-game .game-layer {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.5s linear;
}

.gacha-game.is-dim .game-layer {
    filter: brightness(0.6) saturate(0.8);
}

.gacha-game .machine-container {
    position: relative;
    white-space: nowrap;
}

.gacha-game .machine {
    position: relative;
    z-index: 1;
    display: block;
    max-height: 55vh;
    pointer-events: none;
}

.gacha-game .backboard {
    position: absolute;
    z-index: 0;
    top: 65%;
    left: 48%;
    width: 15vh;
    height: 13vh;
    background-color: #e288bb;
}

.gacha-game .title {
    position: absolute;
    z-index: 3;
    top: 10%;
    width: 100%;
    text-align: center;
    font-size: 5vh;
    color: #ffc7e5;
    text-shadow:
        0 0 2px var(--gacha-stroke, #ad8bd6),
        0 0 2px var(--gacha-stroke, #ad8bd6),
        0 0 2px var(--gacha-stroke, #ad8bd6),
        0 0 2px var(--gacha-stroke, #ad8bd6);
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.2));
}

.gacha-game .title span {
    animation: gacha-blink 0.8s linear infinite both;
}

.gacha-game .title span:nth-child(1) {
    animation-delay: 0.12s;
}

.gacha-game .title span:nth-child(2) {
    animation-delay: 0.24s;
}

.gacha-game .title span:nth-child(3) {
    animation-delay: 0.36s;
}

.gacha-game .title span:nth-child(4) {
    animation-delay: 0.48s;
}

.gacha-game .title span:nth-child(5) {
    animation-delay: 0.60s;
}

.gacha-game .title span:nth-child(6) {
    animation-delay: 0.72s;
}

.gacha-game .title span:nth-child(7) {
    animation-delay: 0.84s;
}

.gacha-game .title span:nth-child(8) {
    animation-delay: 0.96s;
}

.gacha-game .title span:nth-child(9) {
    animation-delay: 1.08s;
}

.gacha-game .title span:nth-child(10) {
    animation-delay: 1.20s;
}

.gacha-game .price {
    position: absolute;
    z-index: 3;
    top: 80%;
    left: 15%;
    color: #fb91c9;
    font-size: 2.5vh;
}

.gacha-game .handle {
    position: absolute;
    z-index: 3;
    top: 69%;
    left: 13%;
    height: 3.9vh;
    cursor: pointer;
}

.gacha-game .balls {
    position: absolute;
    top: 22%;
    left: 2%;
    width: 96%;
    height: 34.5%;
}

.gacha-game .pointer {
    position: absolute;
    z-index: 5;
    top: 75%;
    left: 15%;
    height: 15vh;
    pointer-events: none;
}

.gacha-game .pointer img {
    display: block;
    height: 100%;
    transform: rotate(-30deg);
    transform-origin: 0 0;
    animation: gacha-click 1s ease-in-out infinite both;
}

.gacha-game .ball {
    --size: 8vh;
    --outline: #4c3fc2;
    --color1: #2facff;
    --color2: #ff8ff6;
    position: absolute;
    width: var(--size);
    height: var(--size);
    border-radius: 100%;
    background-color: var(--color1);
    border: solid 0.8vh var(--outline);
    overflow: hidden;
}

.gacha-game .ball::after {
    content: '';
    display: block;
    position: absolute;
    top: 50%;
    width: 200%;
    height: 200%;
    background-color: var(--color2);
    border-radius: 100%;
    border: inherit;
    transform: translate(-25%, -5%);
}

.gacha-game .ui-layer {
    z-index: 1;
    pointer-events: none;
}

.gacha-game .title-container,
.gacha-game .prize-container,
.gacha-game .prize-ball-container,
.gacha-game .prize-reward-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.gacha-game .title-container {
    z-index: 10;
}

.gacha-game .title-container h2 {
    --gacha-stroke: #f06e5b;
    text-align: center;
    font-family: 'Bungee', monospace;
    font-size: 4vh;
    color: #fff;
    text-shadow:
        0 0 2px var(--gacha-stroke),
        0 0 2px var(--gacha-stroke),
        0 0 2px var(--gacha-stroke),
        0 0 2px var(--gacha-stroke);
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.2));
}

.gacha-game .prize-reward-container {
    z-index: 1;
}

.gacha-game .prize-reward-container>* {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
}

.gacha-game .prize img {
    height: 40vh;
    max-height: 80%;
    object-fit: contain;
}

.gacha-game .shine img {
    height: 100vh;
    animation: gacha-spin 5s linear infinite forwards;
}

.gacha-game .gacha-wiggle {
    animation: gacha-wiggle 2s ease-in-out infinite both;
}

.gacha-game .confetti {
    position: absolute;
    inset: 0;
    z-index: 10;
    overflow: hidden;
    pointer-events: none;
    perspective: 100vmin;
}

.gacha-game .confetti span {
    --size: 5;
    display: block;
    position: absolute;
    width: calc(var(--size) * 1px);
    height: calc(var(--size) * 1px);
    background-color: blue;
    animation: gacha-rotate linear calc(var(--rs) * 1s) infinite both;
}

@keyframes gacha-blink {
    0% {
        color: #ffc7e5;
    }

    20% {
        color: #fcff33;
    }

    100% {
        color: #ffc7e5;
    }
}

@keyframes gacha-wiggle {
    0% {
        transform: rotate(-5deg);
    }

    50% {
        transform: rotate(5deg);
    }

    100% {
        transform: rotate(-5deg);
    }
}

@keyframes gacha-click {
    0% {
        transform: rotate(-30deg) translateY(0);
    }

    80% {
        transform: rotate(-30deg) translateY(5vh);
    }

    100% {
        transform: rotate(-30deg) translateY(0);
    }
}

@keyframes gacha-spin {
    from {
        transform: rotate(1turn);
    }

    to {
        transform: rotate(0turn);
    }
}

@keyframes gacha-rotate {
    from {
        transform: rotate3d(var(--rx), var(--ry), var(--rz), 0turn);
    }

    to {
        transform: rotate3d(var(--rx), var(--ry), var(--rz), 1turn);
    }
}

@media (max-width: 767px) {
    .gacha-game {
        height: 55vh;
        min-height: 320px;
    }

    .gacha-game .machine {
        max-height: 40vh;
    }

    .gacha-game .title-container h2 {
        font-size: 3vh;
    }
}

/* Botón "Girar Gachapon" que reemplaza a la palanca */
.gacha-spin-button {
    display: block;
    margin: 1.5rem auto 0;
    min-width: 260px;
    font-size: 1rem;
}

.gacha-spin-button[disabled] {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
    transform: translateY(2px);
}