.round-loading {
    --round-loading-duration: 5000ms;
    --round-loading-delay: 0ms;

    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 56px);
    left: 50%;
    right: auto;
    bottom: auto;
    z-index: 2;

    display: grid;
    width: auto;
    max-width: calc(100vw - 112px);
    justify-items: center;
    align-content: start;
    row-gap: 4px;

    pointer-events: none;
    transform: translateX(-50%) translateY(-4px);
    opacity: 0;
    visibility: hidden;

    transition:
            opacity 0.16s ease,
            visibility 0.16s ease,
            transform 0.16s ease;
}

.round-loading.hidden {
    display: none !important;
}

.round-loading:not(.hidden) {
    pointer-events: none;
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.round-loading-bar {
    position: relative;
    width: min(45vw, 250px);
    max-width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;

    background: linear-gradient(
            90deg,
            rgba(39, 42, 83, 0.88) 0%,
            rgba(73, 81, 123, 0.88) 100%
    );

    /*box-shadow:*/
    /*        0 1px 0 rgba(255, 255, 255, 0.42) inset,*/
    /*        0 -1px 0 rgba(0, 0, 0, 0.18) inset,*/
    /*        0 2px 5px rgba(9, 33, 63, 0.45),*/
    /*        0 0 12px rgba(25, 242, 113, 0.25);*/
}

.round-loading-bar::before {
    content: "";
    position: absolute;
    inset: 1px;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;

    background: linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.28) 0%,
            rgba(255, 255, 255, 0.04) 45%,
            rgba(0, 0, 0, 0.14) 100%
    );
}

.round-loading-fill {
    position: relative;
    z-index: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    transform-origin: left center;

    background: linear-gradient(
            90deg,
            #10b95f 0%,
            #19f271 48%,
            #7dff9f 100%
    );

    box-shadow:
            0 0 10px rgba(25, 242, 113, 0.68),
            0 0 18px rgba(25, 242, 113, 0.38);

    animation: round-loading-progress var(--round-loading-duration) linear var(--round-loading-delay) forwards;
    will-change: transform;
}

.round-loading-fill::after {
    content: "";
    position: absolute;
    inset: 0;

    background: linear-gradient(
            115deg,
            transparent 0%,
            transparent 34%,
            rgba(255, 255, 255, 0.82) 50%,
            transparent 66%,
            transparent 100%
    );

    transform: translateX(-120%);
    animation: loading-shine 1.15s ease-in-out infinite;
}

.round-loading-text {
    color: #344265;
    text-align: center;
    font-family: var(--basic-font);
    font-size: 16px;
    font-style: normal;
    font-weight: 800;
    line-height: 1;
}

@keyframes round-loading-progress {
    from {
        transform: scaleX(0);
    }

    to {
        transform: scaleX(1);
    }
}

@keyframes loading-shine {
    from {
        transform: translateX(-120%);
    }

    to {
        transform: translateX(120%);
    }
}

@media (orientation: portrait) and (min-height: 1024px) {
    .topbar-message {
        height: 40px;
        padding: 0 16px;
        max-width: min(30vw, 300px);
        border-radius: 12px;
        font-size: 18px;
    }

    .topbar-message-text {
        padding: 0 6px;
    }

    .topbar-message-text::before {
        -webkit-text-stroke: 4px #4758A9;
    }
}

@media (orientation: landscape) {
    .round-loading {
        top: calc(env(safe-area-inset-top, 0px) + 56px);
        max-width: calc(100vw - 112px);
        row-gap: 2px;
    }
    .round-loading-bar {
        width: min(40vw, 180px);
        height: 9px;
    }

    #game {
        --compact-top-center-x: 50%;
        --compact-top-left-slot-offset: clamp(56px, 9vw, 72px);
        --compact-top-right-slot-offset: clamp(118px, 18vw, 138px);
        --compact-top-open-shift: clamp(18px, 6vh, 40px);
    }

    #game:has(#bottom-tools.full) {
        --compact-top-center-x: calc(50% + var(--side-panel-open-shift));
    }

    .topbar-message-text,
    .topbar-message-text::before {
        white-space: nowrap;
    }

    .round-loading {
        top: calc(env(safe-area-inset-top, 0px) + 22px);
        left: calc(50% - var(--compact-top-left-slot-offset) - 68px);
        width: min(34vw, 200px);
        max-width: min(25vw, 240px);
        row-gap: 5px;
    }

    #game:has(#bottom-tools.full) .round-loading {
        left: calc(50% - var(--compact-top-left-slot-offset) - 24px + var(--compact-top-open-shift));
    }

    .round-loading-text {
        width: 100%;
        text-align: center;
        font-size: 13px;
    }

    .round-loading-bar {
        width: 100%;
        height: 8px;
    }

    .topbar-message {
        left: auto;
        right: calc(max(env(safe-area-inset-right), 2%) + 120px);
        max-width: min(22vw, 170px);
        padding: 0 10px;
        font-size: 13px;
        transform: translateY(-50%);
    }

    .topbar-message-text,
    .topbar-message-text::before {
        white-space: nowrap;
    }
}

@media (orientation: landscape) and (max-height: 375px) {
    .round-loading {
        /*top: calc(env(safe-area-inset-top, 0px) + 30px);*/
        left: calc(47% - var(--compact-top-left-slot-offset));
        width: min(30vw, 170px);
        max-width: min(30vw, 170px);
        justify-items: stretch;
        row-gap: 3px;
    }

    #game:has(#bottom-tools.full) .round-loading {
        left: calc(50% - var(--compact-top-left-slot-offset) + var(--compact-top-open-shift));
    }
}

@media (orientation: landscape) and (max-height: 375px) and (min-width: 800px) {
    .round-loading {
        left: calc(50% - var(--compact-top-left-slot-offset) - 80px);
        width: min(24vw, 170px);
    }
}

@media (orientation: landscape) and (min-width: 1024px) {
    .topbar-message {
        height: 40px;
        padding: 0 16px;
        max-width: min(20vw, 240px);
        border-radius: 12px;
        font-size: 18px;
    }
    .topbar-message-text {
        padding: 0 6px;
    }

    .round-loading-text {
        font-size: 18px;
    }

    .round-loading-bar {
        height: 10px;
    }

    .round-loading {
        top: calc(env(safe-area-inset-top, 0px) + 22px);
        left: calc(50% - var(--compact-top-left-slot-offset) - 100px);
        width: min(34vw, 200px);
        max-width: min(25vw, 240px);
        row-gap: 5px;
    }
}

@media (orientation: landscape) and (min-width: 1180px) {
    .round-loading,
    #game:has(#bottom-tools.full) .round-loading {
        left: 50%;
    }
    .round-loading {
        top: calc(env(safe-area-inset-top, 0px) + 22px);
        width: min(34vw, 200px);
        max-width: min(25vw, 240px);
        row-gap: 5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .round-loading-fill::after {
        animation: none;
    }
}
