@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));
    }
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100svh;
    overflow: hidden;
}

#feature-preview-screen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100svh;
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -3;
    overflow: hidden;
}

.background-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center;
}
#star-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.star {
    position: absolute;
    opacity: 0.8;
    animation-name: twinkle;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}

@keyframes twinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/*.star {*/
/*    position: absolute;*/
/*    width: clamp(1vw, 2vw, 3vw);*/
/*    height: clamp(1vw, 2vw, 3vw);*/
/*    !*background: url('./fps-image8.png') no-repeat center;*!*/
/*    background-size: contain;*/
/*    opacity: 0;*/
/*    animation: starFade 3s ease-in-out infinite;*/
/*    filter: drop-shadow(0 0 5px rgba(255,255,255,0.5));*/
/*}*/

/*@keyframes starFade {*/
/*    0% { opacity: 0; transform: scale(0.5) rotate(0deg); }*/
/*    50% { opacity: 1; transform: scale(1) rotate(15deg); }*/
/*    100% { opacity: 0; transform: scale(0.5) rotate(0deg); }*/
/*}*/


#fps-wrapper {
    display: grid;
    place-items: center;
    grid-template-areas:
            "logo logo logo"
            "feature-block1 feature-block2 feature-block3"
            "feature-desc1 feature-desc2 feature-desc3"
            "start-button start-button start-button";
    grid-template-rows: 23svh 1fr 10svh 20svh;
    grid-template-columns: 26vw 30vw 26vw;
    height: 100svh;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 0 6vw;
    column-gap: 2vw;
    width: 100%;
    max-width: 100vw;
}

#logo-placeholder {
    position: absolute;
    grid-area: logo;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
    user-select: none;
}

.logo-image {
    height: clamp(12svh, 15svh, 20svh);
    display: block;
    opacity: 0;
    filter: drop-shadow(0 2px 10px rgba(255, 255, 255, 0.4));
    animation: logoFadeIn 1s ease-out 0.5s forwards,
    pulseGlow 6s ease-in-out infinite 2s;
    margin-bottom: 4svh;
}

#sound-toggle {
    position: absolute;
    right: clamp(2vw, 3vw, 4vw);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;

    width: clamp(40px, 2.5vw, 45px);
    height: clamp(40px, 2.5vw, 45px);
    bottom: max(env(safe-area-inset-bottom, 0px), clamp(12px, 2svh, 24px));
}

#sound-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#feature-block1 {
    grid-area: feature-block1;
}

#feature-block2 {
    grid-area: feature-block2;
    padding: 0;
    height: 50svh;
    position: relative;
    width: clamp(42vw, 27vw, 34vw);
    aspect-ratio: 1 / 1;
}

#feature-block3 {
    grid-area: feature-block3;
}

#feature-desc1 {
    grid-area: feature-desc1;
    height: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

#feature-desc2 {
    grid-area: feature-desc2;
    display: flex;
    height: 100%;
    justify-content: flex-start;
    align-items: center;

}

#feature-desc3 {
    grid-area: feature-desc3;
    height: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.feature-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-bottom: clamp(1svh, 2svh, 3svh);
    width: 100%;
    height: auto;
    max-width: 90%;
    min-width: 200px;
    padding: 0.2rem;
    justify-content: center;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: hidden;
    transform-origin: center;
}

.feature-block.small {
    width: clamp(40vw, 25vw, 32vw);
}

.feature-block.large {
    width: 100%;
    margin-top: 2svh;
}

.feature-image {
    display: block;
    object-fit: contain;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    height: auto;
}

#feature-block1, #feature-block3 {
    height: 35svh;
}

.feature-description {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;

    font-size: clamp(1rem, 2.5vw, 1.7rem);
    line-height: 1.3;
    padding: clamp(0.5svh, 1svh, 1.5svh) 0;
    margin: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    z-index: 2;
    font-family: "Noto Sans Bengali Condensed", sans-serif;
    font-weight: 900;
    color: white;
    letter-spacing: 0.5px;
    word-break: break-word;
    white-space: normal;
    flex-wrap: wrap;
}

#section-button {
    grid-area: start-button;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: clamp(1svh, 2svh, 3svh);
    text-align: center;
}

.start-button {
    position: relative;
    bottom: auto;
    transform: none;
    order: 1;
}

.loading-bar-wrapper {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: clamp(20vw, 25vw, 35vw);
    height: clamp(2svh, calc(2vw + 1svh), 3svh);
    background: radial-gradient(circle at center,
    rgba(60, 90, 120, 0.4),
    rgba(10, 30, 60, 0.6));
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.6);
    border: 2px solid #f8f8f8;
    z-index: 999;
}

.loading-bar {
    position: relative;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #FF5EDB;
    transition: width .3s ease;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 94, 219, 0.8),
    0 0 40px rgba(255, 62, 190, 0.6),
    0 0 60px rgba(255, 80, 200, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.loading-bar::after{
    content: "";
    position: absolute; inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(90deg,
    #FF5EDB 0%,
    #FF6EC7 25%,
    #FF3FA8 50%,
    #FF6EC7 75%,
    #FF5EDB 100%      /* той самий колір на 0% і 100% → немає шва */
    );
    background-size: 200% 100%;
    animation: shimmer 2.2s linear infinite; /* рух без «reverse» */
    will-change: background-position;
    transform: translateZ(0); /* менше артефактів у Safari */
}

@keyframes shimmer{
    to { background-position: -200% 0; }
}

@keyframes shimmer {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}

.loading-percent {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--main-font, sans-serif);
    font-size: clamp(0.5rem, calc(1vw + 1svh), 1.5rem);
    color: white;
    font-weight: bold;
    pointer-events: none;
}

/* region START BUTTON */
.start-button {
    width: clamp(40vw, 50vw, 60vw);
    font-size: clamp(0.5rem, 1.5vw, 1.3rem);
    text-transform: uppercase;

    text-align: center;

    letter-spacing: 0.05em;
    font-weight: 500;
    background-size: 200% auto;
    background: linear-gradient(to right, #ffc10d, white, #ffc10d);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: white;
    border: none;

    transform: scale(0.95);
    opacity: 0;
    pointer-events: none;

    transition: opacity 0.6s ease, transform 0.4s ease;
    animation: gradientShift 5s linear infinite;
}

#fps-button {
    animation: pulseZoom 5s ease-in-out infinite;
}

.start-button.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}
/* endregion */

@keyframes gradientShift {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}
@keyframes pulseZoom {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}
@keyframes logoFadeIn {
    0% { opacity: 0; transform: translateY(-20px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulseGlow {
    0%, 100% { filter: drop-shadow(0 2px 10px rgba(255, 255, 255, 0.45)); }
    50% { filter: drop-shadow(0 2px 12px rgba(255, 255, 255, 0.5)); }
}
@keyframes shimmer {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}

@media (orientation: landscape) {
    #fps-wrapper {
        display: grid;
        grid-template-areas:
            "logo logo logo"
            "feature-block1 feature-block2 feature-block3"
            "feature-desc1 feature-desc2 feature-desc3"
            "start-button start-button start-button";
        grid-template-columns: clamp(26vw, 28vw, 30vw) clamp(30vw, 32vw, 35vw) clamp(26vw, 28vw, 30vw);
        height: 100svh;
        justify-content: center;
        align-items: center;
        padding: 0 clamp(2vw, 3vw, 4vw);
        column-gap: clamp(1vw, 1.5vw, 2vw);
        row-gap: clamp(0.6svh, 0.8svh, 1svh);
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 2svh);
    }
    #fps-wrapper {
        height: 100svh;
        max-height: 100svh;
        display: grid;
        grid-template-rows:
            minmax(12svh, auto)
            auto
            auto
            minmax(8svh, auto);
    }

    .feature-block,
    .feature-description,
    #section-button {
        min-height: 0;
    }

    #feature-block1,
    #feature-block2,
    #feature-block3 {
        align-self: center;
    }

    .feature-block.small {
        width: clamp(24vw, 26vw, 28vw);
        height: clamp(28svh, 40svh, 50svh);
    }

    .feature-block.large {
        width: clamp(30vw, 32vw, 34vw);
        height: clamp(28svh, 45svh, 50svh);
        margin-top: 0;
    }

    .feature-description {
        font-size: clamp(0.5rem, calc(1vw + 1svh), 1.3rem);
        line-height: 1.1;
        padding: 0.3svh 0;
        /*margin: 0;*/
        max-width: 100%;
        word-break: break-word;
        white-space: normal;
        text-align: center;
        margin-top: -4svh;
        /*transform: translateY(-4vh);*/
    }

    #feature-desc1, #feature-desc2, #feature-desc3 {
        justify-content: unset;
        align-items: center;
    }

    #sound-toggle {
        bottom: max(env(safe-area-inset-bottom, 0px), clamp(12px, 2svh, 24px));
        right: clamp(1.5vw, 2vw, 3vw);
    }
    .start-button {
        font-size: clamp(0.5rem, calc(1vw + 1svh), 1.3rem);
    }
    /*.loading-bar-wrapper {*/
    /*    bottom: calc(*/
    /*            max(env(safe-area-inset-bottom, 0px), clamp(2svh, 2.6svh, 5svh))*/
    /*            + clamp(1svh, 1.2svh, 2svh)*/
    /*    );*/
    /*}*/
}

@media screen and (min-width: 1200px) and (orientation: landscape) {
    .feature-description {
        max-width: 80%;
        font-size: clamp(0.5rem, calc(1.2vw + 1.2svh), 1.7rem);
        line-height: 1.4;
    }
}

@media (orientation: portrait) {
    #feature-preview-screen {
        height: auto;
        min-height: 100svh;
        overflow-y: hidden;
    }

    #fps-wrapper {
        display: grid;
        grid-template-areas:
      "logo"
      "feature-block1"
      "feature-desc1"
      "feature-block2"
      "feature-desc2"
      "feature-block3"
      "feature-desc3"
      "start-button";
        grid-template-columns: 1fr;
        grid-template-rows:
            minmax(10svh, 14svh)
            minmax(14svh, 20svh)
            minmax(auto, 10svh)
            minmax(14svh, 20svh)
            minmax(auto, 10svh)
            minmax(14svh, 20svh)
            minmax(auto, 10svh)
            minmax(5svh, 10svh);
        margin-top: 2svh;
        row-gap: clamp(0.5svh, 1svh, 1.5svh);
        height: 100%;
        min-height: auto;
        overflow: hidden;
        box-sizing: border-box;
    }

    .feature-block {
        margin: 0 auto;
        padding: 0;
    }


    #feature-desc1, #feature-desc2, #feature-desc3 {
        justify-content: center;
        align-items: center;
    }

    #feature-block1, #feature-block3 {
        width: clamp(40vw, 50vw, 60vw);
        height: clamp(16svh, 20svh, 22svh);
        margin: 0 auto;
    }

    #feature-block2 {
        width: clamp(50vw, 60vw, 80vw);
        height: clamp(18svh, 22svh, 24svh);
        margin: 0 auto;
    }

    #logo-placeholder {
        position: relative;
        display: flex;
        justify-content: center;
    }

    #logo-placeholder {
        position: absolute;
        grid-area: logo;
        display: flex;
        justify-content: center;
        align-items: center;
        padding-top: 1svh;
        z-index: 2;
    }

    .logo-image {
        height: clamp(10svh, 13svh, 20svh);
        width: auto;
    }

    #feature-desc1 {
        grid-area: feature-desc1;
        margin-top: 0;
    }

    #feature-desc2 {
        grid-area: feature-desc2;
        margin-top: 0;
    }

    #feature-desc3 {
        grid-area: feature-desc3;
        margin-top: 0;
    }

    .feature-description {
        max-width: 90%;
        margin-top: 0;
        font-size: clamp(0.5rem, calc(1vw + 1svh), 1.3rem);
        line-height: 1.1;
        padding: 0.3svh 0;
        text-align: center;
    }

    /*#section-button {*/
    /*    width: 100%;*/
    /*    position: relative;*/
    /*    z-index: 10;*/
    /*    margin-top: auto;*/
    /*    padding-top: 2vh;*/
    /*    margin-bottom: env(safe-area-inset-bottom, 2dvh);*/
    /*}*/

    /*.start-fixed-portrait {*/
    /*    display: flex;*/
    /*    flex-direction: column;*/
    /*    align-items: center;*/
    /*    justify-content: flex-end;*/
    /*    width: 100%;*/
    /*    box-sizing: border-box;*/
    /*    position: relative;*/
    /*}*/

    #section-button {
        grid-area: start-button;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        gap: clamp(1svh, 2svh, 3svh);
        text-align: center;
    }
    .start-button {
        order: 1;
    }

    .start-button {
        /*position: absolute;*/
        bottom: max(env(safe-area-inset-bottom, 0px), clamp(14px, 2.6svh, 36px));
        font-size: clamp(0.5rem, calc(1vw + 1svh), 1.1rem);
        text-align: center;
        padding: 0;
        text-decoration: none;
        text-transform: uppercase;
        background: linear-gradient(to right, #ffc10d, white, #ffc10d);
        background-size: 200% auto;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        border: none;
        opacity: 0;
        pointer-events: none;
        transform: scale(0.95) translateX(-50%);
        transition: opacity 0.6s ease, transform 0.4s ease;
        animation: gradientShift 5s linear infinite, pulseZoom 5s ease-in-out infinite;
    }

    .loading-bar-wrapper {
        bottom: clamp(2svh, 3svh, 4svh);
        left: 50%;
        transform: translateX(-50%);
        width: clamp(40dvw, 45dvw, 50dvw);
        height: clamp(1.6dvh, 2dvh, 2.5dvh);
        background: radial-gradient(circle at center, rgba(60, 90, 120, 0.4), rgba(10, 30, 60, 0.6));
        border-radius: 999px;
        overflow: hidden;
        box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1), 0 4px 12px rgba(0, 0, 0, 0.6);
        border: 2px solid #f8f8f8;
        position: absolute;
    }

    .loading-bar {
        width: 0%;
        height: 100%;
        background: linear-gradient(90deg, #FF5EDB, #FF6EC7, #FF3FA8, #FF80E0);
        background-size: 300% 100%;
        animation: shimmer 2s linear infinite;
        transition: width 0.3s ease;
        border-radius: 999px;
        box-shadow: 0 0 20px rgba(255, 94, 219, 0.8),
        0 0 40px rgba(255, 62, 190, 0.6),
        0 0 60px rgba(255, 80, 200, 0.5);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .start-button.visible {
        opacity: 1;
        pointer-events: auto;
        transform: scale(1) translateX(-50%);
    }

    #sound-toggle {
        bottom: 1.5svh;
        right: clamp(3vw, 4vw, 5vw);
        z-index: 999;
    }
}

@media (orientation: portrait) and (min-height: 1000px) {
    .start-button {
        font-size: clamp(0.5rem, 1.5svh, 1.3rem);
    }
}

/* region Safari text stability */
@media (orientation: landscape) {
    @supports (font: -apple-system-body) {
        #fps-wrapper {
            display: grid;
            grid-template-areas:
                  "logo logo logo"
                  "feature-block1 feature-block2 feature-block3"
                  "feature-desc1 feature-desc2 feature-desc3"
                  "start-button start-button start-button";
            grid-template-columns: clamp(26vw, 28vw, 30vw) clamp(30vw, 32vw, 35vw) clamp(26vw, 28vw, 30vw);
            grid-template-rows:
                  minmax(12svh, 12svh)
                  minmax(0, 1fr)
                  minmax(10svh, 10svh)
                  minmax(8svh, 8svh);
            height: 100svh;
            max-height: 100svh;
            align-content: start;
            align-items: start;
            justify-content: center;
            padding: 0 clamp(2vw, 3vw, 4vw);
            column-gap: clamp(1vw, 1.5vw, 2vw);
            row-gap: clamp(1svh, 1.4svh, 2svh);
            padding-bottom: max(env(safe-area-inset-bottom, 0px), 2svh);
            contain: layout paint style;
        }
        .feature-description {
            font-size: clamp(0.5rem, calc(1.2vw + 1.2svh), 1.7rem);
            line-height: 1.2;
            padding: 0.3svh 0;
            max-width: 100%;
            word-break: break-word;
            white-space: normal;
            text-align: center;
            margin-top: 0;
        }
        #fps-button {
            animation: none !important;
            transform: none !important;
        }
        .start-button {
            transform: none !important;
        }
        .logo-image {
            animation: logoFadeIn 1s ease-out 0.5s forwards;
        }
    }
}
/* endregion */