*{
    box-sizing: border-box;
}

body{
    width: 90%;
    height: 100vh;
    background-color: aqua;
}

header{
    font-size: calc(10px + 2vw);
}

.navBar{
    display: flex;
    justify-content: space-around;
    list-style: none;
    background-color: aquamarine;
    padding: 1em;
    width: 98vw;
}

.navBar a{
    color:red;
    text-decoration: none;
    font-size: calc(18px + 0.5vw);
    width: 90vw;
}

.up{
    width:100px;
    height: 100px;
    border-radius: 50%;
    position: fixed;
    right: 5px;
    bottom: 0px;
    background-color: rgb(134, 91, 158);
    color: black;
    text-decoration: none;
    font-size: calc(10px + 3vw);
    text-align: center;
    border:2px purple solid;
    border-right-style:dotted;
}

 #first{
        width: 100vw;
        border: 10px green solid;

    }

    .auto{
        width: 100vw;
    }
    


main{
    width: 100%;
    text-align: center;
}

section{
    margin-top: 100px;
}

/* FIXED: Stronger constraints for 3D viewport */
#threeD {
    border: 10px green solid;
    background-color: rgb(195, 45, 45);
    width: 98vw;
    height: 400px; /* Fixed height instead of vh */
    min-height: 400px !important; /* Force minimum height */
    max-height: 600px; /* Prevent it from getting too large */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: relative;
    overflow: hidden; /* Prevent content overflow */
}

/* Ensure the canvas never collapses */
#threeD canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px !important;
    max-width: 100% !important;
    max-height: 100% !important;
    display: block !important;
}

/* Ensure the text in 3D container is visible */
#threeD p {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background-color: rgba(0,0,0,0.5);
    padding: 5px 10px;
    border-radius: 5px;
    margin: 0;
}

video{
    background-color: black;
    width: 50vw;
}

div{
    color: azure;
}

.appear{
    display: block;
    background-color: rgba(11, 11, 11, 0.9);
    position: fixed;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
}

.viewThree{
    display: block;
    z-index: 20;
    position: fixed;
    top:20vh;
    width:100%;
}

footer, header{
    background-color: rgba(7, 209, 142, 0.707);
    width: 98vw;
    padding: 2vh 0;
    text-align: center;
}

/* IMPROVED: Better mobile handling */
@media screen and (max-width:600px){
    body{
        display: flex;
        flex-direction: column;
        align-items: center;
    }
   
    nav{
        width: 100vw;
        padding-left: 10px;
    }

    .navBar{
        flex-direction: column;
        align-items: center;
        background-color: red;
        width: 99vw;
    }
   
    .navBar li{
        padding: 0.5rem;
        background-color: azure;
        width: 99vw;
        text-align: center;
        border-bottom: 1px green solid;
    }

    h3{
        margin-bottom: 100px;
    }

    /* FIXED: Specific mobile dimensions */
    #threeD{
        width: 95vw !important;
        height: 350px !important;
        min-height: 350px !important;
        max-height: 350px !important;
    }

    #threeD canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px !important;
    max-height: 100% !important;
    display: block !important;
}

    .up{
        width:60px;
        height: 60px;
        font-size:40px;
    }

   

    header, footer{
        width:100vw;
        margin-left: 10px;
    }
}

/* Even smaller screens */
@media screen and (max-width:400px){
    #threeD{
        width: 95vw !important;
        height: 300px !important;
        min-height: 300px !important;
        max-height: 300px !important;
    }
    #threeD canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px !important;
    max-height: 100% !important;
    display: block !important;
}
}

/* Extra safety for very small screens */
@media screen and (max-width:320px){
    #threeD{
        width: 95vw !important;
        height: 250px !important;
        min-height: 250px !important;
        max-height: 250px !important;
    }
    #threeD canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px !important;
    max-height: 100% !important;
    display: block !important;
}
}