:root {
    --bg-dark: #0f0f13;
    --bg-panel: rgba(30, 30, 35, 0.9);
    --accent-color: #ffd700;
    --text-main: #ffffff;
    --radius: 8px;
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    width: 100vw;
    height: 100vh;
    overflow-x: hidden;
}

/* --- LAYOUT WRAPPER --- */
.main-container {
    width: 100%;
    height: 100%;
    padding: 10px;
    gap: 10px;
    display: flex;
    flex-direction: column;
}

/* --- PORTRAIT MODE (Mobile / Default) --- */
/* Stacks vertically. Scrolling allowed if content is too tall. */
@media (orientation: portrait) {
    .main-container {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        /* Allow scrolling */
        height: auto;
        min-height: 100vh;
    }

    .header-ticker {
        order: 1;
        height: 50px;
        flex-shrink: 0;
    }

    .video-section {
        order: 2;
        width: 100%;
        aspect-ratio: 16/9;
        flex-shrink: 0;
    }

    .info-panel {
        order: 3;
        height: auto;
        padding: 10px 0;
        flex-shrink: 0;
    }

    /* VERTICAL AD - PORTRAIT */
    .ad-vertical {
        order: 4;
        width: 100%;
        /* Force a tall vertical aspect ratio */
        aspect-ratio: 9/16;
        max-height: 60vh;
        /* Cap height so it doesn't take 2 pages */
        display: flex !important;
        /* Force show */
        background: #1a1a2e;
        border-radius: var(--radius);
        margin: 10px 0;
    }

    .ad-horiz-1 {
        order: 5;
        height: 100px;
        margin-bottom: 5px;
        flex-shrink: 0;
    }

    .ad-horiz-2 {
        order: 6;
        height: 100px;
        flex-shrink: 0;
    }
}

/* --- LANDSCAPE MODE (TV / Desktop) --- */
/* Fixed screen, no scroll, grid layout */
@media (orientation: landscape) {
    body {
        overflow: hidden;
        /* Lock viewport */
    }

    .main-container {
        display: grid;
        height: 100vh;
        /* Force fill screen */
        max-height: 100vh;
        width: 100vw;
        overflow: hidden;
        /* No scroll inside wrapper */

        /* 
         * GRID DEFINITION 
         * Columns: 20% | 40% | 40%
         * Rows:    12% | AUTO (Fill) | 18%
         */
        grid-template-columns: 20% 40% 40%;
        grid-template-rows: 12vh minmax(0, 1fr) 18vh;

        grid-template-areas:
            "info   header header"
            "ppt    video  video"
            "ppt    ad1    ad2";
    }

    /* AREA MAPPING */
    .info-panel {
        grid-area: info;
    }

    .header-ticker {
        grid-area: header;
    }

    .ad-vertical {
        grid-area: ppt;
    }

    .video-section {
        grid-area: video;
    }

    .ad-horiz-1 {
        grid-area: ad1;
    }

    .ad-horiz-2 {
        grid-area: ad2;
    }

    /* STYLING ADJUSTMENTS FOR LANDSCAPE */
    .header-ticker {
        height: 100%;
        font-size: 2.5vh;
        /* Responsive text */
    }

    .info-panel {
        flex-direction: row;
        /* Or column depending on preference, column implies stacking time/weather */
        flex-direction: column;
        justify-content: center;
        gap: 10px;
        height: 100%;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: var(--radius);
        background: var(--bg-panel);
    }

    .video-section {
        width: 100%;
        height: 100%;
        background: #000;
        border-radius: var(--radius);
        overflow: hidden;
        /* Contains the player */
        position: relative;
    }

    /* VERTICAL AD - LANDSCAPE */
    .ad-vertical {
        display: flex !important;
        height: 100%;
        width: 100%;
        background: #1a1a2e;
        border-radius: var(--radius);
        /* In landscape, the slot IS vertical, so we let it fill */
    }

    /* BOTTOM BANNERS */
    .ad-horiz-1,
    .ad-horiz-2 {
        height: 100%;
        width: 100%;
        background: #1a1a2e;
        border-radius: var(--radius);
    }
}

/* --- COMMON COMPONENT STYLES --- */
.header-ticker {
    background: linear-gradient(90deg, #b91d47 0%, #2b2b2b 30%);
    display: flex;
    align-items: center;
    border-radius: var(--radius);
    padding: 0 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    color: white;
}

.ticker-label {
    font-weight: 800;
    margin-right: 15px;
    color: #fff;
    text-transform: uppercase;
    white-space: nowrap;
}

.ticker-content {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    color: #ddd;
}

#news-ticker {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 20s linear infinite;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

.info-panel {
    display: flex;
    align-items: center;
    justify-content: space-around;
    color: #fff;
    container-type: inline-size;
}

.widget-time {
    text-align: center;
}

.widget-time .clock {
    font-size: clamp(1rem, 4cqw, 3rem);
    font-weight: bold;
    color: var(--accent-color);
}

.widget-time .date {
    font-size: clamp(0.7rem, 2cqw, 1.5rem);
    opacity: 0.8;
}

.widget-weather {
    text-align: center;
}

.weather-temp {
    font-size: clamp(1rem, 3.5cqw, 2.5rem);
    font-weight: bold;
}

.weather-desc {
    font-size: clamp(0.6rem, 1.8cqw, 1.2rem);
    opacity: 0.8;
    text-transform: capitalize;
}

.weather-icon {
    display: none !important;
}

/* AD CONTENTS */
.ad-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.ad-content img {
    /* DEFAULT: Fill the container */
    width: 100%;
    height: 100%;
    object-fit: fill;
}

/* Specific Override for Portrait Vertical Ad to prevent flattening */
@media (orientation: portrait) {
    .ad-vertical .ad-content img {
        object-fit: contain;
        /* Don't squash in portrait */
        background: #000;
        /* Letterboxing if needed */
    }
}

.ad-label {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.7);
    padding: 2px 5px;
    font-size: 10px;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
}

/* PLAYER OVERRIDES - CLEAN AND SIMPLE FOR NEW ABSOLUTE WRAPPER */
.video-section {
    background: black;
    border-radius: var(--radius);
    border: var(--glass-border);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    min-width: 0;
}

.video-section>div {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    display: flex;
    justify-content: center;
    align-items: center;
}

#player,
media-player {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    aspect-ratio: auto !important;
    /* Forces Vidstack to surrender its intrinsic height computation to our absolute constraint */
}

media-player video,
video {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    max-width: 100% !important;
    object-fit: contain !important;
}

media-controls,
.vds-controls {
    opacity: 1 !important;
    visibility: visible !important;
}