/* Make sure containers take up the full screen */
html, body {
    background-color: #f0f8ff;
    overflow: hidden;
    /* --- ADDED: Ensure 100% height --- */
    height: 100%;
}

/* --- ADDED: Standard Home Button Style --- */
/* Copied from Number/style.css for consistency */
.home-btn-subpage {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.8em;
    color: #333;
    text-decoration: none;
    padding: 10px;
    z-index: 100;
    transition: transform 0.1s;
}

.home-btn-subpage:active {
    transform: scale(0.9);
}
/* --- END OF ADDITION --- */


.video-page-container {
    width: 100%;
    /* --- MODIFICATION: Use dynamic viewport height (dvh) --- */
    height: 100%; /* Fallback */
    height: 100dvh;
    /* --- END MODIFICATION --- */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 20px;
}

.video-page-container.visible {
    display: flex;
}

/* --- Playlist Menu --- */
#playlist-menu h1 {
    margin-top: 60px; /* Make space for home button */
}

#playlist-buttons .menu-btn {
    font-size: 1.8em;
    padding: 15px 30px;
    background-color: #673AB7;
}


/* --- Player Container --- */
#player-container {
    padding: 10px;
    justify-content: flex-start; /* Align children to top */
}

#player-header {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    /* --- ADDED: Prevent header from shrinking --- */
    flex-shrink: 0;
}

.control-btn {
    font-family: 'Comic Neue', sans-serif;
    font-size: 1em;
    font-weight: 700;
    padding: 10px 15px;
    background-color: #f4f4f4;
    border: 2px solid #ccc;
    border-radius: 12px;
    cursor: pointer;
}

#timer-display {
    font-size: 1.2em;
    font-weight: 700;
    padding: 10px 15px;
    background: #fff;
    border-radius: 12px;
    border: 2px solid #ccc;
    color: #333;
}

#player-wrapper {
    width: 100%;
    max-width: 800px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);

    /* --- KEY FIXES: Use Flexbox to fill remaining space --- */
    /* 1. REMOVED 'position: relative;' */
    /* 2. REMOVED 'padding-top: 56.25%;' (The problem-causer) */
    
    /* 3. ADDED flex-grow to fill available space */
    flex-grow: 1;
    /* 4. ADDED min-height to allow shrinking */
    min-height: 0;
    /* --- END OF KEY FIXES --- */
}

#player-wrapper iframe,
#player-wrapper #player {
    /* --- KEY FIXES: Make iframe a simple block element --- */
    /* 1. REMOVED 'position: absolute;' */
    /* 2. REMOVED 'top: 0;' and 'left: 0;' */
    
    /* 3. Kept these, which will now work correctly */
    width: 100%;
    height: 100%;
    /* --- END OF KEY FIXES --- */
}

/* --- Lockout Screen --- */
#lockout-screen p {
    font-size: 1.2em;
}

#lockout-timer-display {
    font-size: 2.5em;
    font-weight: 700;
    color: #f44336;
    margin-top: 20px;
}

/* --- Responsive Fixes --- */

/* --- Rule for PORTRAIT phones --- */
@media (max-width: 600px) and (orientation: portrait) {
    .video-page-container {
        padding: 10px;
    }
    
    #playlist-menu h1,
    #lockout-screen h1 {
        font-size: 2em;
        margin-top: 40px;
    }

    #playlist-buttons .menu-btn {
        font-size: 1.5em;
        padding: 12px 20px;
        width: 90%;
    }

    #player-header {
        flex-direction: column; /* Stack header items vertically */
        gap: 10px;
        margin-top: 40px; /* Space for home button */
    }

    /* REMOVED the 'max-height' rule from #player-wrapper here */

    .control-btn {
        font-size: 0.9em;
        padding: 8px 12px;
    }

    #timer-display {
        font-size: 1em;
        padding: 8px 12px;
    }

    #lockout-timer-display {
        font-size: 1.8em;
    }

    .home-btn-subpage {
        top: 10px;
        left: 10px;
    }
}


/* --- Rule for LANDSCAPE phones (and other very short screens) --- */
@media (orientation: landscape) and (max-height: 500px) {
    .video-page-container {
        padding: 5px; /* Reduced all padding */
    }

    .home-btn-subpage {
        top: 8px;
        left: 8px;
        font-size: 1.5em;
    }

    #playlist-menu h1,
    #lockout-screen h1 {
        font-size: 1.5em;
        margin-top: 30px;
        margin-bottom: 10px;
    }

    #playlist-buttons {
        gap: 10px;
    }

    #playlist-buttons .menu-btn {
        font-size: 1.2em;
        padding: 8px 12px;
        width: 80%;
        max-width: 350px;
    }

    #player-header {
        flex-direction: row;
        margin-top: 30px;
        margin-bottom: 5px;
        max-width: 100%;
        gap: 8px;
    }
     
    /* REMOVED the 'max-height' rule from #player-wrapper here */

    .control-btn {
        font-size: 0.8em;
        padding: 4px 8px;
    }

    #timer-display {
        font-size: 0.9em;
        padding: 4px 8px;
    }

    #lockout-timer-display {
        font-size: 1.4em;
        margin-top: 10px;
    }
}