:root {
    color-scheme: light dark;
    
    /* Light theme variables */
    --bg-light: #f8f9fa;
    --text-light: #212529;
    --link-light: #0d6efd;
    --card-bg-light: #ffffff;
    --border-light: #dee2e6;
    --nav-bg-light: rgba(255,255,255,0.6);
    --nav-text-light: #212529;
    --nav-hover-light: #e9ecef;
    --button-bg-light: #0d6efd;
    --button-text-light: #ffffff;
    --shadow-light: rgba(0, 0, 0, 0.1);
    
    /* Dark theme variables */
    --bg-dark: #121212;
    --text-dark: #e9ecef;
    --link-dark: #8ab4f8;
    --card-bg-dark: #1e1e1e;
    --border-dark: #2c2c2c;
    --nav-bg-dark: rgba(30,30,30,0.6);
    --nav-text-dark: #e9ecef;
    --nav-hover-dark: #2c2c2c;
    --button-bg-dark: #0d6efd;
    --button-text-dark: #ffffff;
    --shadow-dark: rgba(0, 0, 0, 0.3);
    
    /* Universal variables */
    --transition-speed: 0.3s;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: light-dark(var(--bg-light), var(--bg-dark));
    color: light-dark(var(--text-light), var(--text-dark));
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    position: relative;
}

a {
    color: light-dark(var(--link-light), var(--link-dark));
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    text-decoration: underline;
}

/* Side navigation */
.nav-toggle {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 99;
}

#menuToggle {
    background: light-dark(var(--button-bg-light), var(--button-bg-dark));
    color: light-dark(var(--button-text-light), var(--button-text-dark));
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px light-dark(var(--shadow-light), var(--shadow-dark));
    transition: all 0.4s cubic-bezier(.4,2,.3,1);
    display: flex;
    align-items: center;
    justify-content: center;
}

#menuToggle.hide {
    opacity: 0;
    pointer-events: none;
}

.side-nav {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 0;
    height: 0;
    opacity: 0;
    background-color: light-dark(var(--nav-bg-light), var(--nav-bg-dark));
    box-shadow: 0 8px 32px light-dark(var(--shadow-light), var(--shadow-dark));
    z-index: 100;
    border-radius: 32px;
    transition: 
        width 0.1s cubic-bezier(0.455, 0.03, 0.515, 0.955),
        height 0.1s cubic-bezier(0.455, 0.03, 0.515, 0.955),
        border-radius 0.1s cubic-bezier(0.455, 0.03, 0.515, 0.955),
        box-shadow 0.1s cubic-bezier(0.455, 0.03, 0.515, 0.955),
        opacity 0.1s cubic-bezier(0.455, 0.03, 0.515, 0.955);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    backdrop-filter: blur(30px);
}

.side-nav.open {
    width: 280px;
    height: calc(100vh - 32px);
    opacity: 1;
    border-radius: 24px;
    box-shadow: 0 8px 32px light-dark(var(--shadow-light), var(--shadow-dark));
    pointer-events: auto;
}

.side-nav .nav-header,
.side-nav ul,
.side-nav .nav-footer {
    opacity: 0;
    transition: opacity 0.1s 0.1s;
    pointer-events: none;
}

.side-nav.open .nav-header,
.side-nav.open ul,
.side-nav.open .nav-footer {
    opacity: 1;
    pointer-events: auto;
}

.nav-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid light-dark(var(--border-light), var(--border-dark));
}

.side-nav ul {
    list-style: none;
    padding: 0;
    flex: 1;
}

.side-nav li {
    margin: 0;
}

.side-nav a {
    display: block;
    padding: 15px 20px;
    color: light-dark(var(--nav-text-light), var(--nav-text-dark));
    transition: background-color var(--transition-speed);
}

.side-nav a:hover {
    background-color: light-dark(var(--nav-hover-light), var(--nav-hover-dark));
    text-decoration: none;
}

.side-nav i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.nav-footer {
    padding: 20px;
    text-align: center;
    border-top: 1px solid light-dark(var(--border-light), var(--border-dark));
}

/* Main content and player */
.content {
    transition: margin-left var(--transition-speed);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.player-container {
    width: 100%;
    height: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stream-title {
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
    width: 100%;
}

.player-wrapper {
    /* 1. Force 16:9 aspect ratio */
    aspect-ratio: 16 / 9;
    
    /* 2. Slider controls the preferred width (defaults to 90%) */
    width: var(--video-width, 90%);
    
    /* 3. Constrain height to viewport minus header/nav padding (approx 140px) */
    max-height: calc(100vh - 140px);
    
    /* 4. Constrain width so that if height hits max-height, width stops growing 
          Width = Height * 16/9
    */
    max-width: calc((100vh - 140px) * 16 / 9);

    background-color: light-dark(var(--card-bg-light), var(--card-bg-dark));
    border-radius: var(--border-radius);
    box-shadow: 0 6px 18px light-dark(var(--shadow-light), var(--shadow-dark));
    overflow: hidden;
    transition: width 0.1s ease; /* Animate width changes from slider */
    margin: 0 auto;
}

/* Override Plyr styles to match our theme */
.plyr {
    border-radius: var(--border-radius);
    --plyr-color-main: var(--button-bg-light); /* Use our theme color */
    width: 100%;
}

/* Custom Resize Popup */
.resize-popup {
    position: fixed;
    z-index: 9999;
    background: rgba(20, 20, 20, 0.95);
    padding: 20px 40px;
    border-radius: 12px 12px 0 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    color: white;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: min(400px, 90vw);
    border: 1px solid rgba(255,255,255,0.1);
    border-bottom: none;
}

.resize-popup.active {
    transform: translate(-50%, 0);
}

.resize-popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.resize-popup label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #e9ecef;
}

/* Minimal Slider Style */
.resize-popup input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    outline: none;
}

.resize-popup input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--button-bg-light);
    cursor: pointer;
    transition: background .15s ease-in-out;
}

.resize-popup input[type=range]::-webkit-slider-thumb:hover {
    background: #fff;
}

.custom-resize-btn {
    padding: 7px;
    background: transparent;
    border: 0;
    border-radius: 3px;
    color: inherit;
    cursor: pointer;
    transition: background .3s;
}
.custom-resize-btn:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

/* Responsive adjustments */
@media (max-width: 1300px) {
    .player-wrapper {
        max-width: 99%;
    }
}
