/*
 * Scorpion Arena Games V3
 * Visual enhancement only.
 * No wallet, balance or backend actions.
 */

:root {
    --ag3-gold: #ffd76a;
    --ag3-gold-soft: rgba(255, 215, 106, 0.28);
    --ag3-green: #54f0a5;
    --ag3-red: #ff5e78;
    --ag3-blue: #5ba7ff;
    --ag3-purple: #9b71ff;
    --ag3-dark: #070812;
}

/* =========================
   GLOBAL GAME ATMOSPHERE
   ========================= */

#arenaGamesV2Root {
    overflow: hidden;
}

#arenaGamesV2Root .ag2-modal,
#arenaGamesV2Root .ag2-panel,
#arenaGamesV2Root .ag2-content {
    position: relative;
}

#arenaGamesV2Root .ag2-modal::before {
    position: absolute;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
        radial-gradient(
            circle at 50% 15%,
            rgba(124, 92, 255, 0.15),
            transparent 34%
        ),
        radial-gradient(
            circle at 15% 80%,
            rgba(41, 181, 255, 0.08),
            transparent 30%
        );
    z-index: 0;
}

#arenaGamesV2Root .ag2-modal > * {
    position: relative;
    z-index: 1;
}

/* =========================
   DICE STAGE
   ========================= */

.ag2-dice-stage {
    position: relative;
    min-height: 270px;
    padding: 26px 12px 20px;
    overflow: hidden;
    isolation: isolate;
    border-radius: 24px;
    background:
        radial-gradient(
            ellipse at center bottom,
            rgba(92, 78, 180, 0.24),
            transparent 57%
        ),
        linear-gradient(
            180deg,
            rgba(18, 20, 43, 0.94),
            rgba(7, 8, 19, 0.98)
        );
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 18px 50px rgba(0, 0, 0, 0.28);
}

.ag2-dice-stage::before {
    content: "";
    position: absolute;
    left: 7%;
    right: 7%;
    bottom: 36px;
    height: 2px;
    border-radius: 100%;
    background:
        linear-gradient(
            90deg,
            transparent,
            rgba(112, 102, 255, 0.5),
            transparent
        );
    box-shadow:
        0 0 35px rgba(112, 102, 255, 0.35);
}

.ag2-dice-stage.ag3-stage-win {
    animation: ag3StageWin 900ms ease;
}

.ag2-dice-stage.ag3-stage-loss {
    animation: ag3StageLoss 650ms ease;
}

.ag2-dice-stage.ag3-stage-draw {
    animation: ag3StageDraw 700ms ease;
}

@keyframes ag3StageWin {
    0%, 100% {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.06),
            0 18px 50px rgba(0, 0, 0, 0.28);
    }

    45% {
        box-shadow:
            inset 0 0 42px rgba(255, 215, 106, 0.21),
            0 0 55px rgba(255, 215, 106, 0.28);
    }
}

@keyframes ag3StageLoss {
    0%, 100% {
        transform: translateX(0);
        box-shadow: none;
    }

    20% {
        transform: translateX(-5px);
    }

    40% {
        transform: translateX(5px);
        box-shadow: inset 0 0 45px rgba(255, 65, 95, 0.18);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(3px);
    }
}

@keyframes ag3StageDraw {
    50% {
        box-shadow:
            inset 0 0 40px rgba(91, 167, 255, 0.18),
            0 0 40px rgba(91, 167, 255, 0.16);
    }
}

.ag2-dice-player {
    position: relative;
    z-index: 2;
    min-width: 0;
}

.ag3-player-glow {
    position: absolute;
    width: 126px;
    height: 126px;
    top: 48%;
    left: 50%;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.5);
    background:
        radial-gradient(
            circle,
            rgba(255, 223, 113, 0.38),
            rgba(255, 199, 76, 0.08) 48%,
            transparent 70%
        );
    filter: blur(4px);
}

.ag2-dice-player.ag3-winner .ag3-player-glow {
    animation: ag3WinnerGlow 1.8s ease forwards;
}

@keyframes ag3WinnerGlow {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4);
    }

    35% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.18);
    }

    100% {
        opacity: 0.45;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Hide old flat dice visual but preserve its container. */
.ag2-dice-face {
    width: 104px !important;
    height: 104px !important;
    min-width: 104px;
    display: grid !important;
    place-items: center;
    overflow: visible !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: transparent !important;
    perspective: 720px;
    perspective-origin: 50% 42%;
}

.ag3-dice-scene {
    position: relative;
    width: 78px;
    height: 78px;
    transform-style: preserve-3d;
}

.ag3-dice-shadow {
    position: absolute;
    width: 77px;
    height: 21px;
    left: 50%;
    top: calc(50% + 47px);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.48;
    transform: translate(-50%, -50%) scale(0.92);
    background: rgba(0, 0, 0, 0.72);
    filter: blur(8px);
}

.ag3-dice-cube {
    --ag3-half: 39px;

    position: absolute;
    inset: 0;
    width: 78px;
    height: 78px;
    transform-style: preserve-3d;
    transform:
        rotateX(-18deg)
        rotateY(28deg)
        rotateZ(0deg);
    will-change: transform;
}

.ag3-dice-cube.ag3-rolling {
    animation:
        ag3DiceJump 1500ms cubic-bezier(.18,.78,.27,1),
        ag3DiceBlur 1500ms ease;
}

.ag3-dice-face {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
    padding: 12px;
    border-radius: 17px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    backface-visibility: hidden;
    background:
        linear-gradient(
            145deg,
            #ffffff 0%,
            #eef1f9 44%,
            #c7cbd8 100%
        );
    box-shadow:
        inset 7px 7px 12px rgba(255, 255, 255, 0.9),
        inset -7px -7px 13px rgba(68, 75, 98, 0.24),
        0 4px 8px rgba(0, 0, 0, 0.34);
}

.ag3-dice-face::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 13px;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.48);
}

.ag3-dice-face[data-side="1"] {
    transform: rotateY(0deg) translateZ(var(--ag3-half));
}

.ag3-dice-face[data-side="6"] {
    transform: rotateY(180deg) translateZ(var(--ag3-half));
}

.ag3-dice-face[data-side="3"] {
    transform: rotateY(90deg) translateZ(var(--ag3-half));
}

.ag3-dice-face[data-side="4"] {
    transform: rotateY(-90deg) translateZ(var(--ag3-half));
}

.ag3-dice-face[data-side="2"] {
    transform: rotateX(90deg) translateZ(var(--ag3-half));
}

.ag3-dice-face[data-side="5"] {
    transform: rotateX(-90deg) translateZ(var(--ag3-half));
}

.ag3-pip {
    width: 12px;
    height: 12px;
    align-self: center;
    justify-self: center;
    border-radius: 50%;
    opacity: 0;
    background:
        radial-gradient(
            circle at 35% 30%,
            #535969,
            #131620 56%,
            #000 100%
        );
    box-shadow:
        inset 1px 1px 2px rgba(255, 255, 255, 0.17),
        0 1px 1px rgba(255, 255, 255, 0.7);
}

.ag3-pip.ag3-on {
    opacity: 1;
}

.ag3-dice-face[data-side="1"] .ag3-pip.ag3-on {
    background:
        radial-gradient(
            circle at 35% 30%,
            #ff667e,
            #c81335 58%,
            #680012
        );
}

@keyframes ag3DiceJump {
    0% {
        translate: 0 0;
    }

    15% {
        translate: 0 -34px;
    }

    39% {
        translate: 4px -58px;
    }

    61% {
        translate: -3px -23px;
    }

    74% {
        translate: 0 0;
    }

    82% {
        translate: 0 -11px;
    }

    91% {
        translate: 0 0;
    }

    95% {
        translate: 0 -4px;
    }

    100% {
        translate: 0 0;
    }
}

@keyframes ag3DiceBlur {
    0%, 100% {
        filter: blur(0);
    }

    18%, 63% {
        filter: blur(0.65px);
    }
}

.ag3-dice-scene.ag3-shadow-roll .ag3-dice-shadow {
    animation: ag3ShadowBounce 1500ms ease;
}

@keyframes ag3ShadowBounce {
    0%, 74%, 91%, 100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(0.92);
    }

    39% {
        opacity: 0.18;
        transform: translate(-50%, -50%) scale(0.54);
    }

    82% {
        opacity: 0.34;
        transform: translate(-50%, -50%) scale(0.72);
    }
}

/* =========================
   RESULT ANNOUNCEMENT
   ========================= */

.ag3-result-banner {
    position: absolute;
    z-index: 30;
    left: 50%;
    top: 50%;
    width: min(88%, 360px);
    padding: 17px 18px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transform:
        translate(-50%, -50%)
        scale(0.55);
    border-radius: 22px;
    text-align: center;
    backdrop-filter: blur(17px);
    -webkit-backdrop-filter: blur(17px);
    background:
        linear-gradient(
            135deg,
            rgba(18, 21, 45, 0.94),
            rgba(8, 9, 21, 0.97)
        );
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow:
        0 22px 70px rgba(0, 0, 0, 0.52),
        inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.ag3-result-banner.ag3-show {
    animation: ag3ResultIn 2.35s ease forwards;
}

.ag3-result-banner.ag3-win {
    border-color: rgba(255, 215, 106, 0.7);
    box-shadow:
        0 22px 70px rgba(0, 0, 0, 0.52),
        0 0 42px rgba(255, 215, 106, 0.27),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ag3-result-banner.ag3-loss {
    border-color: rgba(255, 94, 120, 0.58);
}

.ag3-result-banner.ag3-draw {
    border-color: rgba(91, 167, 255, 0.58);
}

@keyframes ag3ResultIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.55);
    }

    13% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.08);
    }

    21% {
        transform: translate(-50%, -50%) scale(0.98);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -57%) scale(0.95);
    }
}

.ag3-result-crown {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 7px;
    animation: ag3CrownFloat 780ms ease-in-out infinite alternate;
}

@keyframes ag3CrownFloat {
    from {
        transform: translateY(1px) rotate(-4deg);
    }

    to {
        transform: translateY(-4px) rotate(4deg);
    }
}

.ag3-result-title {
    font-size: clamp(26px, 8vw, 38px);
    line-height: 1;
    font-weight: 950;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 4px 22px rgba(0, 0, 0, 0.55);
}

.ag3-result-banner.ag3-win .ag3-result-title {
    color: var(--ag3-gold);
    text-shadow:
        0 0 20px rgba(255, 215, 106, 0.45),
        0 4px 22px rgba(0, 0, 0, 0.55);
}

.ag3-result-banner.ag3-loss .ag3-result-title {
    color: #ff8094;
}

.ag3-result-banner.ag3-draw .ag3-result-title {
    color: #86bdff;
}

.ag3-result-subtitle {
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 13px;
    font-weight: 700;
}

/* =========================
   CONFETTI + COINS
   ========================= */

.ag3-celebration-layer {
    position: absolute;
    z-index: 40;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.ag3-confetti {
    --ag3-x: 0px;
    --ag3-r: 360deg;
    --ag3-delay: 0ms;
    --ag3-duration: 1500ms;

    position: absolute;
    width: 8px;
    height: 13px;
    top: -22px;
    left: 50%;
    opacity: 0;
    border-radius: 2px;
    background: var(--ag3-colour, #ffd76a);
    animation:
        ag3ConfettiFall
        var(--ag3-duration)
        cubic-bezier(.1,.65,.25,1)
        var(--ag3-delay)
        forwards;
}

@keyframes ag3ConfettiFall {
    0% {
        opacity: 1;
        transform:
            translate3d(0, -20px, 0)
            rotate(0deg);
    }

    100% {
        opacity: 0;
        transform:
            translate3d(
                var(--ag3-x),
                410px,
                0
            )
            rotate(var(--ag3-r));
    }
}

.ag3-coin {
    --ag3-x: 0px;
    --ag3-y: -150px;
    --ag3-delay: 0ms;

    position: absolute;
    z-index: 42;
    left: 50%;
    top: 56%;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    opacity: 0;
    color: #8e5e00;
    font-size: 10px;
    font-weight: 950;
    border: 2px solid #ffec9b;
    background:
        radial-gradient(
            circle at 32% 27%,
            #fff7ba,
            #ffd44d 42%,
            #bd7400 100%
        );
    box-shadow:
        0 0 14px rgba(255, 207, 64, 0.45);
    animation:
        ag3CoinBurst
        1200ms
        cubic-bezier(.18,.7,.2,1)
        var(--ag3-delay)
        forwards;
}

@keyframes ag3CoinBurst {
    0% {
        opacity: 1;
        transform:
            translate(-50%, -50%)
            scale(0.5)
            rotateY(0deg);
    }

    68% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform:
            translate(
                calc(-50% + var(--ag3-x)),
                calc(-50% + var(--ag3-y))
            )
            scale(1)
            rotateY(720deg)
            rotateZ(180deg);
    }
}

/* =========================
   PVP WHEEL ENHANCEMENTS
   ========================= */

.ag2-wheel-area {
    isolation: isolate;
}

.ag2-wheel {
    will-change: transform, filter;
    box-shadow:
        0 0 0 7px rgba(255, 255, 255, 0.045),
        0 0 0 10px rgba(117, 92, 255, 0.14),
        0 22px 55px rgba(0, 0, 0, 0.5) !important;
}

.ag2-wheel.ag3-wheel-spinning {
    filter:
        saturate(1.25)
        brightness(1.08);
}

.ag2-wheel.ag3-wheel-landed {
    animation: ag3WheelLanded 750ms ease;
}

@keyframes ag3WheelLanded {
    0%, 100% {
        scale: 1;
    }

    32% {
        scale: 1.045;
        filter:
            brightness(1.22)
            saturate(1.35);
    }
}

.ag2-wheel-pointer {
    z-index: 12 !important;
    filter:
        drop-shadow(0 4px 5px rgba(0, 0, 0, 0.55))
        drop-shadow(0 0 8px rgba(255, 215, 106, 0.5));
    transform-origin: 50% 15%;
}

.ag2-wheel-pointer.ag3-pointer-tick {
    animation: ag3PointerTick 105ms ease;
}

@keyframes ag3PointerTick {
    50% {
        transform: rotate(-9deg);
    }
}

.ag3-wheel-winner-card {
    position: absolute;
    z-index: 25;
    left: 50%;
    top: 50%;
    width: min(82%, 300px);
    padding: 18px 16px;
    opacity: 0;
    pointer-events: none;
    text-align: center;
    transform:
        translate(-50%, -50%)
        scale(0.62);
    border-radius: 24px;
    border: 1px solid rgba(255, 220, 105, 0.7);
    background:
        linear-gradient(
            145deg,
            rgba(28, 23, 52, 0.96),
            rgba(8, 9, 20, 0.98)
        );
    box-shadow:
        0 20px 65px rgba(0, 0, 0, 0.56),
        0 0 45px rgba(255, 215, 106, 0.22);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ag3-wheel-winner-card.ag3-show {
    animation: ag3WheelWinner 2.5s ease forwards;
}

@keyframes ag3WheelWinner {
    0% {
        opacity: 0;
        transform:
            translate(-50%, -50%)
            scale(0.62);
    }

    14% {
        opacity: 1;
        transform:
            translate(-50%, -50%)
            scale(1.08);
    }

    23%, 80% {
        opacity: 1;
        transform:
            translate(-50%, -50%)
            scale(1);
    }

    100% {
        opacity: 0;
        transform:
            translate(-50%, -58%)
            scale(0.94);
    }
}

.ag3-winner-avatar {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin: 0 auto 10px;
    border-radius: 50%;
    color: #171108;
    font-size: 25px;
    font-weight: 950;
    text-transform: uppercase;
    border: 3px solid #ffe79a;
    background:
        radial-gradient(
            circle at 32% 27%,
            #fff7c4,
            #ffce45 52%,
            #a95e00
        );
    box-shadow:
        0 0 0 6px rgba(255, 216, 87, 0.12),
        0 0 30px rgba(255, 208, 64, 0.38);
    animation: ag3AvatarPulse 700ms ease-in-out infinite alternate;
}

@keyframes ag3AvatarPulse {
    from {
        transform: scale(0.97);
    }

    to {
        transform: scale(1.05);
    }
}

.ag3-wheel-winner-label {
    color: rgba(255, 255, 255, 0.67);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.ag3-wheel-winner-name {
    margin-top: 4px;
    color: #ffe178;
    font-size: 24px;
    font-weight: 950;
    overflow-wrap: anywhere;
}

.ag3-wheel-winner-prize {
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    font-weight: 750;
}

/* =========================
   SOUND CONTROL
   ========================= */

.ag3-sound-button {
    position: absolute;
    z-index: 50;
    top: 12px;
    right: 52px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 12px;
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.065);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ag3-sound-button:active {
    transform: scale(0.94);
}

/* Prevent repeated actions during animation. */
.ag3-game-busy button:not(.ag3-sound-button) {
    pointer-events: none;
}

@media (max-width: 420px) {
    .ag2-dice-stage {
        min-height: 252px;
        padding-inline: 4px;
    }

    .ag2-dice-face {
        width: 92px !important;
        height: 92px !important;
        min-width: 92px;
        transform: scale(0.9);
    }

    .ag3-result-banner {
        top: 48%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ag3-dice-cube.ag3-rolling,
    .ag3-confetti,
    .ag3-coin,
    .ag3-result-banner.ag3-show,
    .ag3-wheel-winner-card.ag3-show {
        animation-duration: 1ms !important;
    }
}
