* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body { height: 100%; }
body {
    background-color: #FFF0E5; /* Warm cream background */
    color: #3e2613; /* Dark text for easy reading */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
    line-height: 1.6;
    overflow-y: auto; /* Allow scrolling when content overflows */
}

/* MAIN CARD CONTAINERS*/
/* Shared styles for start screen, video, and quiz questions */
/* Keep containers flexible to avoid creating unwanted scrollbars */
#play, #main, .page {
    background-color: #ffffff;
    width: 100%;
    max-width: 1100px;
    min-height: auto;
    max-height: calc(100vh - 40px);
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(110, 70, 39, 0.15); /* Soft shadow */
    border: 1px solid #e0ccb8;
    position: relative;
    overflow: hidden;
    display: none; /* Hidden by default */
}

/* Show containers when they're active */
.page.active, 
#main[style*="flex"] {
    display: flex !important;
    flex-direction: column;
}

/* =========================================
   SPLASH SCREEN
   ========================================= */
.splash-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #FFF0E5;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s ease;
}
.splash-screen.hide { opacity: 0; pointer-events: none; }
.splash-screen img { width: 100%; max-width: 400px; border-radius: 20px; }

/* Make splash image bigger and more prominent */
.splash-screen img { width: auto; max-width: 90%; max-height: 70vh; border-radius: 20px; }

/* =========================================
   START SCREEN (#play)
   ========================================= */
#play {
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    gap: 20px;
}

#play img {
    display: none; /* Image is now a background, not inline */
}

/* Use the background image for #play with a soft overlay for readability */
#play {
    background-image: url("../assets/web gfx/focus.jpeg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center left;
    position: relative;
}

#play::before {
    content: "";
    position: absolute;
    inset: 0;
    /* Warm overlay to keep colors nice and improve text readability */
    background: linear-gradient(rgba(255,240,229,0.72), rgba(255,240,229,0.72));
    z-index: 0;
}

/* Make sure all content sits on top of the overlay */
#play > * {
    position: relative;
    z-index: 1;
}

/* Single panel that holds all the start screen controls */
.play-panel {
    background: rgba(255,255,255,0.96);
    border-radius: 16px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
    max-width: 680px;
    width: calc(100% - 48px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}

/* Style the button inside the panel */
.play-panel > button {
    padding: 14px 36px;
    margin-top: 6px;
}

/* Full-bleed mode makes the background cover the whole viewport */
#play.full-bleed {
    border-radius: 0;
    max-width: none;
    width: 100%;
    min-height: 100vh;
    box-shadow: none;
    padding: 0 20px;
}

#play.full-bleed::before {
    /* Stronger overlay for better text contrast when full-bleed */
    background: linear-gradient(rgba(255,240,229,0.78), rgba(255,240,229,0.78));
}

/* Center the panel vertically when full-bleed */
#play.full-bleed .play-panel {
    margin: 6vh auto;
}

/* Show responsive start layout when JS sets inline display */
#play[style*="display:flex"], #play[style*="display: flex"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#play h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: #3e2613;
    margin-bottom: 5px;
}

#play h3 {
    font-size: 1.1rem;
    color: #ac7952; /* Light Brown Subtitle */
    font-weight: 500;
}

/* Category & Level Selectors */
.category {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    width: 100%;
}
/* hide level selector until a category is chosen */
#level-select { display: none; }

.category h3 {
    width: 100%;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #ac7952;
    margin-bottom: 8px;
}

.category label { cursor: pointer; position: relative; }

.category label span {
    display: inline-block;
    padding: 10px 20px;
    background: #FFF0E5;
    border: 1px solid #e0ccb8;
    color: #6e4627;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.category input { display: none; }

.category input:checked + span {
    background-color: #cb7b3e; /* Active Orange */
    color: white;
    border-color: #cb7b3e;
    box-shadow: 0 4px 10px rgba(203, 123, 62, 0.3);
}
/* Disabled option appearance for difficulty buttons inside .category */
.category input:disabled + span {
    background-color: #f0e9e2;
    color: #a08a7a;
    border-color: #e6ddd5;
    cursor: not-allowed;
    opacity: 0.8;
    box-shadow: none;
}

/* Main Call to Action Button */
/* Make sure buttons contrast well over the translucent panels */
#play > button, button {
    background-color: #cb7b3e;
    color: white;
    border: none;
    padding: 16px 50px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 20px rgba(203, 123, 62, 0.25);
}

button:hover {
    background-color: #b36b32;
    transform: translateY(-2px);
}

/* Make buttons stand out when inside #play */
#play > button { z-index: 2; color: #fff; font-weight: 800; }

/* Keep text visible inside #play and panel */
#play h1, #play h3, .play-panel h1, .play-panel h3 {
    color: #3e2613;
}

/* =========================================
   QUIZ PAGE LAYOUT (.page)
   ========================================= */
.page.active {
    padding: 0;
    overflow-y: auto;
}

/* Left side: the question and category info */
.page > div:nth-child(2) {
    background-color: #FFF8F3; /* Slight contrast on mobile */
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid #e0ccb8;
}

.page h4 {
    color: #cb7b3e;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 2px;
    font-weight: 700;
    margin-bottom: 20px;
}

.page h1 {
    font-size: 1.8rem;
    line-height: 1.4;
    color: #3e2613;
    font-weight: 700;
}

/* Question number and difficulty label */
.page > div:nth-child(2) > div {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: #ac7952;
    font-weight: 600;
    text-transform: uppercase;
}

/* Right side: the answer options and buttons */
.page > div:nth-child(3) {
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
    background-color: #ffffff;
}

/* Answer option cards */
.page h5 {
    background-color: #ffffff;
    border: 2px solid #e0ccb8;
    color: #6e4627;
    padding: 18px 25px;
    border-radius: 12px;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-weight: 500;
}

.page h5:hover {
    border-color: #cb7b3e;
    background-color: #FFF0E5;
}

.page h5.selected {
    border-color: #cb7b3e;
    background-color: #cb7b3e;
    color: white;
}

/* Locked answer option after submission */
.page h5.locked {
    pointer-events: none;
    opacity: 0.85;
    filter: saturate(0.95);
}

.page {
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    position: relative;
}

/* Warm overlay to keep text readable over the background */
.page::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,240,229,0.75), rgba(255,240,229,0.75));
    z-index: 0;
}

/* Make sure all content sits on top of the overlay */
.page > * {
    position: relative;
    z-index: 1;
}

/* Navigation buttons container */
.page > div:nth-child(3) > div {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    width: 100%;
}

/* Next/Finish button styling */
.page > div:nth-child(3) > div button {
    background-color: #6e4627;
    flex: 1;
    width: 100%;
}

/* =========================================
   RESPONSIVE LAYOUTS
   ========================================= */

/* --- DESKTOP & TABLET (Wide screens) --- */
@media (min-width: 900px) {
    
    /* Start screen: split image and controls */
    #play[style*="display:flex"], #play[style*="display: flex"] {
        display: grid;
        grid-template-columns: 40% 60%;
        text-align: center;
        padding: 0;
        align-items: center;
        justify-items: center;
    }

    #play > img {
        width: 100%; height: 100%;
        border-radius: 0; border: none;
        object-fit: cover;
        grid-row: 1 / span 5;
    }

    #play > div, #play > .category, #play > button, #play > h3 {
        padding-left: 40px;
        padding-right: 40px;
        justify-content: center;
        align-self: center;
    }

    /* Quiz pages: split question and answers side-by-side */
    .page.active {
        flex-direction: row;
        align-items: stretch;
    }

    /* Left column: question and category */
    .page > div:nth-child(2) {
        width: 45%;
        border-bottom: none;
        border-right: 1px solid #e0ccb8;
        padding: 60px;
        background-color: transparent;
    }

    /* Right column: answer options */
    .page > div:nth-child(3) {
        width: 55%;
        padding: 60px;
        background-color: transparent;
    }

    .page h1 { font-size: 2rem; }
}

/* --- MOBILE (Stacked layout) --- */
@media (max-width: 899px) {
    body {
        padding: 0;
        align-items: flex-start; /* Start from top */
        background-color: #ffffff; /* White bg for seamless mobile feel */
    }

    #play, #main, .page {
        border-radius: 0;
        border: none;
        box-shadow: none;
        max-width: none;
        min-height: 100vh;
    }

    #play { padding: 30px 20px; }
    
    /* Sticky Footer Logic for Mobile Buttons */
    .page.active {
        padding-bottom: 90px; /* Space for sticky footer */
    }

    .page h1 { font-size: 1.4rem; }

    .page > div:nth-child(2) {
        padding: 30px 20px;
        background-color: #FFF0E5; /* Keep contrast on mobile */
    }

    .page > div:nth-child(3) { padding: 20px; }
    .page h5 { padding: 15px; font-size: 1rem; }

    /* Sticky Bottom Buttons */
    .page > div:nth-child(3) > div {
        position: fixed;
        bottom: 0; left: 0; width: 100% !important;
        background: white;
        padding: 15px 20px;
        border-top: 1px solid #e0ccb8;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
        z-index: 100;
        margin-top: 0;
    }
    
    .page button {
        padding: 12px 24px;
        font-size: 1rem;
    }
}