/* Core viewport layout reset */
#body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #000;
    overflow-x: hidden; /* Prevents horizontal broken layout scrollbars */
    position: relative;
    box-sizing: border-box;
}

/* Force standard, predictable container bounds across devices */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Isolates background canvas animation layer */
canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* Main Flashcard interface wrapper */
#flashcard {
    display: flex;
    position: relative;
    height: 200px;
    width: min(350px, 90vw); /* Shrinks dynamically on small mobile devices */
    backdrop-filter: blur(2px);
    border: solid;
    border-color: #ffffff;
    border-radius: 15px;
    justify-content: center;
    align-items: center;
}

#flashcard-text {
    font-size: clamp(24px, 4vw, 40px); /* Text shrinks safely on small screens */
    font-family: Arial, Helvetica, sans-serif;
    color: rgb(255, 255, 255);
}

/* Side settings drawer converted to use responsive layouts */
#questionsanswers {
    height: min(800px, 85vh); 
    width: min(500px, 90vw);  
    border-radius: 15px;
    border: solid;
    display: flex;
    flex-direction: column; 
    position: absolute;
    left: calc(-1 * min(500px, 90vw) + 15px); 
    color: rgb(255, 255, 255);
    backdrop-filter: blur(2px);
}


#answers {
    height: 47%;
    width: 90%;
    margin: 10px auto;
    border-radius: 15px;
    border: solid;
    position: absolute;
    top: calc(50% + 10px);
    left: 35px;
}
#questions {
    height: 47%;
    width: 90%;
    margin: 10px auto;
    border-radius: 15px;
    border: solid;
    position: absolute;
    left: 35px;
    top: 30px;
}

#answer {
    position: absolute;
    top: 620px;
    height: 45px;
    width: min(235px, 50vw);
    left: calc(50% - min(175px, 50vw));
    background-color: rgba(0, 0, 0, 0);
    color: white;
    border: solid;
    border-radius: 15px;
    outline: none;
    text-align: center;
    backdrop-filter: blur(2px);
}

#skip {
    cursor: pointer;
    position: absolute;
    top: 620px;
    height: 45px;
    width: min(100px, 25vw);
    left: calc(50% + min(75px, 50vw));
    background-color: rgba(0, 0, 0, 0);
    color: white;
    border: solid;
    border-radius: 15px;
    outline: none;
    text-align: center;
    backdrop-filter: blur(2px);
}

/* SMALL DEVICE OPTIMISATION (Mobile / Tablet Responsive Engine Override) */
@media (max-width: 1024px) {
    #body {
        flex-direction: column; /* Shifts layouts into vertical structure safely */
        height: auto;
        padding: 40px 20px;
        gap: 30px;
    }

    #questionsanswers {
        position: relative; /* Breaks out of absolute layer mapping on mobile */
        left: 0;
        margin-top: 40px;
    }

    #answer, #skip {
        position: relative; /* Keeps button controls grouped within normal flow */
        top: 0;
        left: 0;
        width: 100%;
        margin: 5px 0;
    }
}
