.flip-book-container {
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Arial Black";
    color: rgb(25, 25, 25);
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    background-color: rgb(245, 245, 245);
}

input {
    display: none;
}

#flip_book {
    position: relative;
    width: min(400px, 70vw);    /* Changed from 90vw to 70vw */
    height: min(400px, 70vw);   /* Keep it square */
    transition-duration: 1s;
    perspective: 2000px;
}

.front_cover, .back_cover {
    display: flex;
    justify-content: center;
    align-items: center;
    width: min(400px, 70vw);
    height: min(400px, 70vw);
    border-radius: 2.5px 5px 5px 2.5px;
    background-image: url(./resources/images/flip_book_edge_shading.png);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgb(31, 116, 57);
    box-shadow: 0 0 5px 0 rgb(25, 25, 25, 0.25);
}

.front_cover {
    position: absolute;
    cursor: pointer;
    transform-origin: center left;
    transition: transform 0.5s;
    z-index: 99;
}

.front_cover label {
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.page {
    position: absolute;
    top: 5px;
    left: 1px;
    width: calc(min(400px, 70vw) - 10px);
    height: calc(min(400px, 70vw) - 10px);
    border-radius: 0 5px 5px 0;
    background-color: white;
    transform-origin: left;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition-duration: 0.5s;
}

.front_page {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.front_page label {
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 100;
}

.back_page {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    z-index: 100;
}

.back_page label {
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 100;
}

.edge_shading {
    position: absolute;
    width: calc(min(400px, 70vw) - 10px);
    height: calc(min(400px, 70vw) - 10px);
    z-index: 98;
}

.front_content, .back_content {
    position: absolute;
    top: 1px;
    width: calc(min(400px, 70vw) - 11px);
    height: calc(min(400px, 70vw) - 12px);
    border-radius: 0 5px 5px 0;
    z-index: 97;
}

.back_cover {
    position: relative;
    z-index: -1;
}

#page1 {
    z-index: 8;
}

#page2 {
    z-index: 5;
}

#page3 {
    z-index: 4;
}

#page4 {
    z-index: 3;
}

#page5 {
    z-index: 2;
}

#cover_checkbox:checked~#flip_book {
    transform: translateX(min(195px, 45vw));
}

#cover_checkbox:checked~#flip_book .front_cover {
    transform: rotateY(-180deg);
    transition: transform 1.5s, z-index 0.5s 0.5s;
    z-index: 1;
}

#cover_checkbox:checked~#flip_book #cover {
    position: absolute;
    width: 80%;
    height: 80%;
}

#page1_checkbox:checked~#flip_book #page1 {
    transform: rotateY(-180deg);
    z-index: 2;
}

#page2_checkbox:checked~#flip_book #page2 {
    transform: rotateY(-180deg);
    z-index: 3;
}

#page3_checkbox:checked~#flip_book #page3 {
    transform: rotateY(-180deg);
    z-index: 4;
}

#page4_checkbox:checked~#flip_book #page4 {
    transform: rotateY(-180deg);
    z-index: 5;
}

#page5_checkbox:checked~#flip_book #page5 {
    transform: rotateY(-180deg);
    z-index: 6;
}

.cover_image {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 2.5px 5px 5px 2.5px;
    object-fit: cover;
    z-index: -1;
}

/* Media query for very small screens */
@media screen and (max-width: 480px) {
    body {
        padding: 20px 0;
    }

    #cover_checkbox:checked~#flip_book {
        transform: translateX(45vw);
    }

    /* Adjust page turning animation for smaller screens */
    .front_cover, .page {
        transition-duration: 0.3s;  /* Slightly faster animation on mobile */
    }
}

/* Media query for landscape orientation on mobile */
@media screen and (max-height: 480px) and (orientation: landscape) {
    body {
        height: auto;
        min-height: 100vh;
        padding: 20px 0;
    }

    #flip_book {
        width: min(400px, 70vh);  /* Use viewport height instead */
        height: min(400px, 70vh);
        margin: 20px auto;
    }

    .front_cover, .back_cover {
        width: min(400px, 70vh);
        height: min(400px, 70vh);
    }

    .page {
        width: calc(min(400px, 70vh) - 10px);
        height: calc(min(400px, 70vh) - 10px);
    }

    .edge_shading {
        width: calc(min(400px, 70vh) - 10px);
        height: calc(min(400px, 70vh) - 10px);
    }

    .front_content, .back_content {
        width: calc(min(400px, 70vh) - 11px);
        height: calc(min(400px, 70vh) - 12px);
    }

    #cover_checkbox:checked~#flip_book {
        transform: translateX(min(195px, 35vh));
    }
}
}