/* Prevent scroll during load */
body {
    margin: 0;
    font-family: sans-serif;
}

/* Mobile keeps the original full-browser loading presentation. */
#loadingScreen {
    position: fixed;
    inset: 0;
    background-color: #d8baf3;
    background-image: url("../images/UI/loadingscreen/loadingscreen_background.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    color: white;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    z-index: 9999;
}

/* Center content */
.loader {
    position: absolute;
    top: 63%;
    left: 50%;
    width: min(82vw, 460px);
    transform: translateX(-50%);
    text-align: center;
}

.loader h1 {
    margin: 10px 0 0;
    font-size: clamp(18px, 4.5vw, 28px);
}

/* Simple spinner */
.spinner {
    margin: 0 auto;
    width: 40px;
    height: 40px;
    border: 4px solid #444;
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Hidden utility class */
.hidden {
    display: none;
}

#loadingError {
    margin: 12px auto 0;
    color: #d71920;
    font-size: clamp(14px, 3.5vw, 20px);
    font-weight: 700;
    line-height: 1.25;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

#loadingError.visible {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 769px) {
    /* Desktop alone presents the loader inside the same scaled phone frame. */
    #loadingScreen {
        inset: auto;
        top: 50%;
        left: 50%;
        width: 375px;
        height: 812px;
        border: 2px solid #333;
        border-radius: 25px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
        overflow: hidden;
        transform: translate(-50%, -50%) scale(var(--desktop-stage-scale, 1));
        transform-origin: center;
        visibility: hidden;
    }

    #loadingScreen .loader {
        width: 82%;
    }
}
