html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

html, body {
    width: 100%;
    height: 100%;
    touch-action: none;
}

canvas { display: block; }

body {
    margin: 0;
    background: #1a1633 url('Images/side_background.png') center / cover no-repeat;
}

#unity-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#unity-canvas {
    width: 100%;
    height: 100%;
    background: #231F20;
    touch-action: none;
}

.unity-desktop {
    display: flex;
    align-items: center;
    justify-content: center;
}

.unity-desktop #unity-canvas {
    width: min(100vw, calc(100vh * 0.75));
    height: min(100vh, calc(100vw / 0.75));
    box-shadow: 0 0 42px rgba(0, 0, 0, 0.55);
}

.unity-mobile #unity-canvas {
    width: 100%;
    height: 100%;
}

#orientation-cover {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
        max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    background:
        radial-gradient(circle at 50% 45%, rgba(110, 75, 205, 0.32), transparent 42%),
        #1a1633 url('Images/side_background.png') center / cover no-repeat;
    color: #fff;
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
}

body.orientation-blocked #orientation-cover { display: flex; }
body.orientation-blocked #unity-container,
body.orientation-blocked #loading-cover { visibility: hidden; }

.orientation-message {
    display: flex;
    max-width: min(78vw, 520px);
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 2.5vh, 18px);
}

#orientation-title {
    font-size: clamp(24px, 6vmin, 42px);
    font-weight: 700;
    line-height: 1.1;
}

#orientation-description {
    max-width: 28em;
    color: rgba(255, 255, 255, 0.82);
    font-size: clamp(15px, 3.5vmin, 22px);
    line-height: 1.35;
}

.orientation-phone {
    position: relative;
    width: clamp(44px, 11vmin, 70px);
    aspect-ratio: 0.56;
    margin-bottom: 5px;
    border: clamp(4px, 1vmin, 6px) solid #fff;
    border-radius: 18%;
    filter: drop-shadow(0 10px 12px rgba(6, 3, 22, 0.4));
    animation: phone-turn 1.8s ease-in-out infinite;
}

.orientation-phone span {
    position: absolute;
    bottom: 5%;
    left: 50%;
    width: 16%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #fff;
    transform: translateX(-50%);
}

@keyframes phone-turn {
    0%, 18% { transform: rotate(90deg); }
    55%, 100% { transform: rotate(0deg); }
}

#loading-cover {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 43%, rgba(110, 75, 205, 0.28), transparent 36%),
        linear-gradient(rgba(26, 22, 51, 0.72), rgba(26, 22, 51, 0.86)),
        url('Images/side_background.png') center / cover no-repeat;
    opacity: 1;
    transition: opacity 280ms ease;
}

#loading-cover.is-ready {
    opacity: 0;
    pointer-events: none;
}

#unity-loading-bar {
    display: flex;
    width: min(68vw, 340px);
    flex-direction: column;
    align-items: center;
    gap: clamp(28px, 5vh, 48px);
}

.block-loader {
    display: grid;
    width: clamp(124px, 25vmin, 190px);
    aspect-ratio: 1;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5%;
    filter: drop-shadow(0 14px 18px rgba(6, 3, 22, 0.42));
    transform: rotate(-5deg);
}

.loader-block {
    border-radius: 24%;
    background: var(--block-color);
    box-shadow:
        inset 0 -7px 0 rgba(0, 0, 0, 0.17),
        inset 0 5px 0 rgba(255, 255, 255, 0.24),
        0 4px 0 rgba(255, 255, 255, 0.12);
    animation: block-pop 1.45s cubic-bezier(.4, 0, .2, 1) infinite;
    animation-delay: var(--delay);
}

.loader-block:nth-child(1) { --block-color: #ff4c91; --delay: -0.90s; grid-column: 1; grid-row: 2; }
.loader-block:nth-child(2) { --block-color: #6d52e8; --delay: -0.75s; grid-column: 2; grid-row: 1; }
.loader-block:nth-child(3) { --block-color: #2da9f7; --delay: -0.60s; grid-column: 2; grid-row: 2; }
.loader-block:nth-child(4) { --block-color: #ffbd38; --delay: -0.45s; grid-column: 2; grid-row: 3; }
.loader-block:nth-child(5) { --block-color: #ff5b62; --delay: -0.30s; grid-column: 3; grid-row: 1; }
.loader-block:nth-child(6) { --block-color: #5bcf68; --delay: -0.15s; grid-column: 3; grid-row: 2; }
.loader-block:nth-child(7) { --block-color: #8d49d7; --delay: 0s; grid-column: 3; grid-row: 3; }

#unity-progress-bar-empty {
    position: relative;
    width: 100%;
    height: 18px;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.86);
    border-radius: 999px;
    background: rgba(9, 5, 31, 0.55);
    box-shadow: 0 8px 18px rgba(6, 3, 22, 0.32), inset 0 2px 4px rgba(0, 0, 0, 0.38);
}

#unity-progress-bar-full {
    width: 4%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ff4c91 0%, #ffbd38 34%, #5bcf68 66%, #2da9f7 100%);
    box-shadow: 0 0 12px rgba(255, 189, 56, 0.65);
    transition: width 220ms ease-out;
}

#unity-progress-bar-full::after {
    content: '';
    display: block;
    width: 100%;
    height: 45%;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.28);
}

@keyframes block-pop {
    0%, 58%, 100% { transform: translateY(0) scale(1); }
    68% { transform: translateY(-18%) scale(1.08); }
    79% { transform: translateY(2%) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
    .loader-block { animation: none; }
    .orientation-phone { animation: none; }
    #unity-progress-bar-full, #loading-cover { transition: none; }
}
