html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.game-visibility {
    visibility: hidden;
}

#game {
    position: fixed;
    z-index: 0;
}

#menu-btn {
    pointer-events: auto;
}

@media (orientation: portrait) {
    #game-canvas.canvas-shifted {
        transform: translateX(0);
    }
}

@media (orientation: landscape) {
    #game-canvas.canvas-shifted {
        transform: translateX(8vh);
    }
}

.bottomBar {
    z-index: 100;
}

@supports (height: 100svh) {
    html,
    body,
    #feature-preview-screen,
    #fps-wrapper {
        height: 100svh !important;
        max-height: 100svh !important;
    }

    .start-button {
        bottom: max(env(safe-area-inset-bottom, 0px), clamp(14px, 2.6svh, 36px));
    }
}
#feature-preview-screen {
    position: fixed !important;
    inset: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    transition: opacity 1.2s ease, transform 1.2s ease;
}
.background-layer {
    width: 120vw;
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    top: 0;
    left: 50%;
    height: 100%;
    transform: translateX(-50%);
}
.background-layer .bg,
.background-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#fps-wrapper {
    position: relative;
    z-index: 1;

    display: grid;
    grid-template-areas:
        "logo"
        "feature"
        "desc"
        "start";
    grid-template-columns: 1fr;
    grid-template-rows:
        auto
        minmax(0, 1fr)
        auto
        auto;

    justify-items: center;
    align-items: center;

    width: 100%;
    height: 100vh;
    max-width: 100vw;
    box-sizing: border-box;

    padding: clamp(12px, 2vh, 24px) 6vw clamp(18px, 3vh, 32px);
    row-gap: clamp(8px, 1.5vh, 18px);
}
#logo-placeholder {
    grid-area: logo;
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
    user-select: none;
}
.logo-image {
    display: block;
    width: auto;
    height: clamp(70px, 12vh, 150px);
    opacity: 0;
    margin: 0;
    /*filter: drop-shadow(0 2px 10px rgba(0, 4, 78, 0.6));*/
    animation: logoFadeIn 1s ease-out 0.5s forwards,
    pulseGlow 6s ease-in-out infinite 0.5s;
}
#feature-block1 {
    grid-area: feature;

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

    width: min(78vw, 760px);
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}
.feature-block {
    position: relative;
    width: 100%;
    height: auto;
}
.feature-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}
#feature-desc1 {
    grid-area: desc;

    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.25em;

    width: min(90vw, 900px);
    margin: 0 auto;
    text-align: center;
    z-index: 1;
}
#feature-desc1 > .feature-description {
    position: relative;
    display: inline-block;
    margin: 0;
    padding: 0;

    font-family: var(--basic-font);
    font-size: clamp(0.95rem, calc(0.9vw + 1vh), 1.5rem);
    line-height: 1.2;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: center;
    word-break: break-word;
    white-space: normal;
    color: #FFFFFF;
    flex: 0 0 70%;
}
#feature-desc1 > .feature-description::before {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    z-index: -1;

    background: linear-gradient(180deg, #1C2343 0%, #4758A9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;

    -webkit-text-stroke: 4px #2b356a;
}
.feature-description.feature-inline {
    flex-direction: row;
    gap: 0.15em;
}
#section-button {
    grid-area: start;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.start-fixed-portrait {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 1.8vh, 20px);
    min-height: clamp(52px, 8vh, 90px);
}
.loading-bar-wrapper {
    position: relative;
    height: 20px;
    background: linear-gradient(270deg, #00C7FF 30.29%, #BDF0FF 100%);
    box-shadow: 0 4px 4px 0 #4758A9 inset, 0 4px 4px 0 rgba(48, 58, 105, 0.50);
    border-radius: 999px;
    overflow: hidden;
    border: 2px solid #f8f8f8;
    z-index: 2;
}
.loading-bar {
    width: 0;
    height: 90%;
    animation: shimmer 2s linear infinite;
    transition: width 0.3s ease;
    border-radius: 999px;
    background: linear-gradient(90deg, #FFF 0%, #9FEAFF 100%);
    box-shadow: 0 2px 2px 0 #4758A9 inset, 0 2px 2px 0 rgba(48, 58, 105, 0.50);
}
.loading-percent {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--basic-font);
    font-size: clamp(0.7rem, calc(0.7vw + 0.7vh), 1.2rem);
    line-height: 1;
    color: #242269;
    font-weight: 800;
    pointer-events: none;
}
@keyframes logoFadeIn {
    0% { opacity: 0; transform: translateY(-20px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes shimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}
@keyframes gradientShift {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}
@keyframes pulseZoom {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
/* region Sparkles */
#feature-block1 {
    grid-area: feature;
    position: relative;

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

    width: min(78vw, 760px);
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}
.fps-sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.fps-sparkle {
    position: absolute;
    height: auto;
    opacity: 0.9;
    transform-origin: center;
    animation:
            fpsSparkleFloat 3.2s ease-in-out infinite,
            fpsSparkleTwinkle 2.4s ease-in-out infinite;
}
.fps-sparkle.s1 {
    bottom: 32%;
    left: 20%;
    width: clamp(18px, 2.2vw, 30px);
    animation-duration: 3.6s, 2.2s;
    animation-delay: 0s, 0.1s;
}
.fps-sparkle.s2 {
    bottom: 24%;
    left: 10%;
    width: clamp(24px, 3.2vw, 40px);
    animation-duration: 3.1s, 1.8s;
    animation-delay: 0.4s, 0.3s;
}
.fps-sparkle.s3 {
    bottom: 22%;
    left: 64%;
    width: clamp(20px, 2.6vw, 34px);
    animation-duration: 3.8s, 2.6s;
    animation-delay: 0.8s, 0.5s;
}
.fps-sparkle.s4 {
    bottom: 22%;
    left: 64%;
    width: clamp(28px, 3.5vw, 44px);
    animation-duration: 2.9s, 1.9s;
    animation-delay: 0.2s, 0.2s;
}
.fps-sparkle.s5 {
    bottom: 30%;
    right: 13%;
    width: clamp(16px, 2vw, 26px);
    animation-duration: 3.4s, 2.8s;
    animation-delay: 0.7s, 0.6s;
}
.fps-sparkle.s6 {
    bottom: 18%;
    right: 5%;
    width: clamp(22px, 2.8vw, 36px);
    animation-duration: 3s, 2.1s;
    animation-delay: 1.1s, 0.4s;
}
.fps-sparkle.s7 {
    bottom: 8%;
    left: 24%;
    width: clamp(30px, 3.8vw, 48px);
    animation-duration: 4s, 3s;
    animation-delay: 1.5s, 0.9s;
}
@keyframes fpsSparkleFloat {
    0%, 100% {
        transform: translateY(0) scale(1) rotate(0deg);
    }
    50% {
        transform: translateY(-6px) scale(1.06) rotate(2deg);
    }
}
@keyframes fpsSparkleTwinkle {
    0%, 100% {
        opacity: 0.35;
        filter: brightness(0.9);
    }
    25% {
        opacity: 0.95;
        filter: brightness(1.15);
    }
    50% {
        opacity: 0.55;
        filter: brightness(1);
    }
    75% {
        opacity: 1;
        filter: brightness(1.3);
    }
}
/* endregion */
@media (orientation: portrait) {
    #fps-wrapper {
        grid-template-rows:
            auto
            minmax(0, 1fr)
            auto
            auto;
        padding: clamp(10px, 1.5vh, 18px) 5vw clamp(18px, 3vh, 28px);
        row-gap: clamp(6px, 1.2vh, 14px);
    }

    .logo-image {
        height: clamp(64px, 11vh, 120px);
    }

    #feature-block1 {
        width: min(88vw, 560px);
    }

    #feature-desc1 {
        width: min(92vw, 680px);
    }

    #feature-desc1 > .feature-description {
        font-size: clamp(0.9rem, calc(1.1vw + 1.1vh), 1.25rem);
        line-height: 1.15;
    }

    .loading-bar-wrapper {
        width: clamp(190px, 48vw, 320px);
    }

    .start-button {
        min-width: clamp(180px, 50vw, 320px);
        font-size: clamp(0.95rem, calc(1.2vw + 1vh), 1.3rem);
    }

    #sound-toggle {
        right: clamp(10px, 3vw, 16px);
        bottom: max(env(safe-area-inset-bottom, 0px), 1.5vh);
        z-index: 999;
    }
}
@media (orientation: landscape) {
    #fps-wrapper {
        grid-template-areas:
            "logo"
            "feature"
            "desc"
            "start";
        grid-template-columns: 1fr;
        grid-template-rows:
            auto
            minmax(0, 1fr)
            auto
            auto;

        padding:
                clamp(10px, 2vh, 18px)
                clamp(24px, 4vw, 56px)
                clamp(14px, 2vh, 24px);

        row-gap: clamp(8px, 1.6vh, 18px);
        align-items: center;
    }
    #logo-placeholder {
        align-self: start;
    }
    .logo-image {
        height: clamp(62px, 12vh, 208px);
    }
    #feature-block1 {
        width: min(44vw, 520px);
        max-width: 100%;
        align-self: center;
    }
    .feature-block {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .feature-image {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 60vh;
        object-fit: contain;
    }
    #feature-desc1 {
        width: min(72vw, 900px);
        margin: 0 auto;
        padding: 0;
    }
    #feature-desc1 > .feature-description {
        flex: 0 0 auto;
        max-width: 100%;
        font-size: clamp(1rem, 1.5vw, 1.55rem);
        line-height: 1.15;
        letter-spacing: 0.5px;
    }
    #section-button {
        align-self: end;
    }
    .loading-bar-wrapper {
        width: clamp(220px, 24vw, 340px);
    }
    .start-fixed-portrait {
        gap: clamp(8px, 1.4vh, 14px);
        min-height: auto;
    }
    .fps-sparkle.s1 {
        bottom: 32%;
        left: 30%;
        width: clamp(18px, 2.2vw, 30px);
    }
    .fps-sparkle.s2 {
        bottom: 24%;
        left: 20%;
        width: clamp(24px, 3.2vw, 40px);
    }
    .fps-sparkle.s3 {
        bottom: 22%;
        left: 54%;
        width: clamp(20px, 2.6vw, 34px);
    }
    .fps-sparkle.s4 {
        bottom: 22%;
        left: 64%;
        width: clamp(28px, 3.5vw, 44px);
    }
    .fps-sparkle.s5 {
        bottom: 30%;
        right: 23%;
        width: clamp(16px, 2vw, 26px);
    }
    .fps-sparkle.s6 {
        bottom: 18%;
        right: 25%;
        width: clamp(22px, 2.8vw, 36px);
    }
    .fps-sparkle.s7 {
        bottom: 8%;
        left: 28%;
        width: clamp(30px, 3.8vw, 48px);
    }
}
@media (orientation: landscape) and (max-height: 350px) {
    #fps-wrapper {
        grid-template-areas:
            "feature logo"
            "feature desc"
            "feature start";
        grid-template-columns: minmax(200px, 300px) minmax(220px, 300px);
        grid-template-rows: auto auto auto;
        padding:
            clamp(6px, 2vh, 10px)
            clamp(100px, 4vw, 110px)
            clamp(8px, 2vh, 14px);
        row-gap: clamp(4px, 1vh, 8px);
        column-gap: clamp(8px, 2vw, 18px);
        align-content: center;
        justify-content: center;
        justify-items: stretch;
        align-items: center;
    }

    #logo-placeholder {
        justify-content: center;
        align-self: end;
    }

    .logo-image {
        height: clamp(46px, 28vh, 90px);
    }

    #feature-block1 {
        width: min(42vw, 300px);
        align-self: center;
        justify-self: center;
        transform: scale(1.2);
    }

    .feature-image {
        max-height: 72vh;
    }

    #feature-desc1 {
        width: 100%;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.08em;
    }

    #feature-desc1 > .feature-description {
        width: 100%;
        flex: 0 0 auto;
    }

    #feature-desc1 > .feature-description::before {
        -webkit-text-stroke: 3px #2b356a;
    }

    #section-button {
        width: 100%;
        align-self: start;
    }

    .start-fixed-portrait {
        width: 100%;
        gap: 6px;
        align-items: center;
    }

    .loading-bar-wrapper {
        width: min(100%, clamp(180px, 24vw, 240px));
        height: 18px;
    }

    .loading-percent {
        font-size: clamp(0.65rem, 1.4vw, 0.8rem);
    }

    .fps-sparkles {
        display: block;
    }
}
#sound-toggle {
    display: none;
}
