/* Real View TV App - Main Styles */

/* Self-hosted Montserrat font for TV compatibility */
@font-face {
    font-family: 'Montserrat';
    src: url('../assets/fonts/Montserrat-Black.ttf') format('truetype');
    font-weight: 900;
    font-style: normal;
    font-display: block;
}

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

:root {
    --primary-color: #11998e;
    --secondary-color: #38ef7d;
    --dark-bg: #141414;
    --card-bg: #1f1f1f;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --focus-color: #ffffff;
    --gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-primary);
    overflow: hidden;
}

/* Screen Management */
.screen {
    display: none;
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Press to Start Screen */
.press-to-start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.press-to-start-screen.active {
    display: flex;
}

.press-content {
    text-align: center;
}

.press-logo {
    font-size: 6rem;
    font-weight: 900;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4rem;
    letter-spacing: 0.1em;
}

.press-instruction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.press-text {
    font-size: 2rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.press-blink {
    font-size: 3rem;
    color: var(--secondary-color);
    animation: blinkButton 1.5s ease-in-out infinite;
}

@keyframes blinkButton {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Splash Screen - Netflix Style - ULTRA CINEMATIC */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: splashFadeOut 2s ease-in-out 5.5s forwards;
}

.splash-screen.active {
    display: flex;
}

.splash-content {
    text-align: center;
    width: 100%;
}

.splash-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 12vw;
    font-weight: 900;
    line-height: 1;
    position: relative;
}

.splash-word {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    filter: drop-shadow(0 0 60px rgba(17, 153, 142, 0.8));
    white-space: nowrap;
}

@keyframes starburstFlash {
    0% {
        filter: drop-shadow(0 0 60px rgba(17, 153, 142, 0.8));
    }
    30% {
        filter:
            drop-shadow(0 0 100px rgba(255, 255, 255, 1))
            drop-shadow(0 0 80px rgba(56, 239, 125, 1))
            drop-shadow(0 0 60px rgba(17, 153, 142, 1))
            brightness(3);
        transform: scale(1.05);
    }
    100% {
        filter: drop-shadow(0 0 60px rgba(17, 153, 142, 0.8));
        transform: scale(1);
    }
}

/* "Real" flies in from LEFT - ULTRA SLOW */
.splash-real {
    animation:
        slideInFromLeft 2.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards,
        starburstFlash 0.8s ease-out 2.9s;
}

/* "View" flies in from RIGHT - ULTRA SLOW */
.splash-view {
    animation:
        slideInFromRight 2.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards,
        starburstFlash 0.8s ease-out 2.9s;
}

/* Hyphen pops in AFTER the words meet - QUICK POP */
.splash-hyphen {
    color: #38ef7d;
    filter: drop-shadow(0 0 40px rgba(56, 239, 125, 0.8));
    opacity: 0;
    transform: scale(0);
    animation:
        popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 2.4s forwards,
        starburstFlash 0.8s ease-out 2.9s;
    margin: 0 -0.05em;
}

@keyframes slideInFromLeft {
    0% {
        transform: translateX(-200vw);
        opacity: 0;
    }
    60% {
        opacity: 1;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromRight {
    0% {
        transform: translateX(200vw);
        opacity: 0;
    }
    60% {
        opacity: 1;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes popIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes splashFadeOut {
    0% {
        opacity: 1;
        visibility: visible;
    }
    100% {
        opacity: 0;
        visibility: hidden;
    }
}

/* Logo - For Headers */
.logo {
    font-family: Verdana, sans-serif;
    font-size: 4rem;
    font-weight: bold;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 4rem;
    background: linear-gradient(to bottom, rgba(20,20,20,1) 0%, rgba(20,20,20,0) 100%);
    position: relative;
    z-index: 10;
}

.main-header .logo {
    font-size: 2.5rem;
    margin: 0;
}

.main-nav {
    display: flex;
    gap: 2rem;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

.nav-btn.active,
.nav-btn:hover {
    color: var(--text-primary);
}

/* Content Area */
.content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 4rem 4rem;
}

/* Hero Section */
.hero {
    width: 100%;
    height: 70vh;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
    padding: 4rem;
    margin-bottom: 3rem;
    border-radius: 10px;
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(20,20,20,1) 0%, rgba(20,20,20,0) 50%);
    border-radius: 10px;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 50%;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.6);
}

.hero-description {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    text-shadow: 1px 1px 6px rgba(0, 0, 0, 0.9), 0 0 15px rgba(0, 0, 0, 0.7);
}

.hero-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn-exit {
    background: rgba(255, 0, 0, 0.8);
}

/* Stream Rows */
.stream-rows {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    overflow: visible;
}

.stream-row {
    margin-bottom: 2rem;
    overflow: visible;
    position: relative;
}

.stream-row h3 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

.stream-carousel {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    overflow-y: visible;
    padding: 20px 4% 30px 20px;
    margin: -20px 0;
    scroll-behavior: smooth;
    position: relative;
}

.stream-carousel::-webkit-scrollbar {
    height: 8px;
}

.stream-carousel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.stream-carousel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

/* Stream Cards */
.stream-card {
    width: 320px;
    min-width: 320px;
    height: 180px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #2a2f4f 0%, #1a1e35 50%, #11998e 100%);
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, outline 0.2s ease;
    position: relative;
    overflow: hidden;
    transform-origin: left center;
}

/* Locked stream overlay */
.stream-locked {
    cursor: not-allowed;
}

.stream-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 10px;
}

.stream-lock-overlay .lock-icon {
    font-size: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stream-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}

.stream-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    z-index: 1;
}

.stream-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stream-card-location {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Blurred Premium Category - Stream Cards */
.stream-card-blurred {
    background: linear-gradient(135deg, #1a1e35 0%, #2a2f4f 50%, #11998e 100%) !important;
    background-size: cover;
    filter: blur(12px);
    cursor: pointer;
}

.stream-card-blurred .stream-card-info {
    visibility: hidden;
}

/* Browse Grid */
.category-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 5px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn.active {
    background: var(--gradient);
}

.stream-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

/* Video Player */
#player-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.video-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: black;
}

/* Time-of-day dimming overlay: a black layer over the video whose opacity the player drives from
   the viewer's local clock (0 by day, up to ~0.5 at deep night). Sits above the video (incl. the
   AVPlay hardware plane) but below the watermark (z 50). pointer-events:none so it never eats
   D-pad/clicks. The transition smooths the per-minute opacity steps. */
.dimming-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 40;
    transition: opacity 2s linear;
    /* display:none by default so the overlay is NOT in the compositing tree unless it is
       actually darkening. A full-rect DOM layer over the hardware video plane forces Fire TV's
       WebView to drop the <video> off the hardware overlay and re-create the surface, which
       blanks the HDMI output ("no signal" blink) and shows black instead of the loading
       spinner. applyDimming() flips this to block only when opacity > 0. */
    display: none;
}

/* Premium/Cloudflare Player Container */
.premium-player-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 1;
}

/* Stream Watermark Overlay */
.stream-watermark {
    position: absolute;
    z-index: 50;
    pointer-events: none;
    max-width: 12%;
    max-height: 12%;
    opacity: 0.85;
}

.stream-watermark img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.stream-watermark.top-left {
    top: 2%;
    left: 2%;
}

.stream-watermark.top-right {
    top: 2%;
    right: 2%;
}

.stream-watermark.bottom-left {
    bottom: 2%;
    left: 2%;
}

.stream-watermark.bottom-right {
    bottom: 2%;
    right: 2%;
}

/* No-frame video container - fullscreen with watermark support */
.noframe-video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* No-frame video letterboxes (contain) instead of cropping. On a 16:9 TV this still fills
   the screen, but on a portrait phone it shows the whole video centered — the same layout
   as the framed version, just without the frame — rather than a badly zoomed fullscreen crop. */
.noframe-video-container .video-player {
    object-fit: contain;
}

/* YouTube Player Container */
.youtube-player-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 1;
}

/* YouTube without frame container - fullscreen */
.youtube-noframe-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.youtube-noframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Fade overlay for looping video transitions */
.youtube-fade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    opacity: 0;
    z-index: 10;
    pointer-events: none;
    transition: opacity 1.5s ease-in-out;
}
.youtube-fade-overlay.visible {
    opacity: 1;
}

/* Window Frame - Centers a 16:9 video with frame around it */
.window-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #4a3728 0%, #3d2e22 50%, #2d221a 100%);
    box-sizing: border-box;
}

.window-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 100px,
            rgba(0,0,0,0.1) 100px,
            rgba(0,0,0,0.1) 102px
        ),
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent 100px,
            rgba(0,0,0,0.05) 100px,
            rgba(0,0,0,0.05) 102px
        );
    pointer-events: none;
    z-index: 0;
}

/* Video container - 16:9 aspect ratio, centered with minimum frame around it */
.window-frame-inner {
    position: relative;
    width: calc(100% - 60px);
    height: calc(100% - 60px);
    max-width: calc((100vh - 60px) * 16 / 9);
    max-height: calc((100vw - 60px) * 9 / 16);
    aspect-ratio: 16 / 9;
    margin-bottom: 20px;
    margin-top: 10px;
    border-radius: 4px;
    box-shadow:
        0 0 0 8px #2a1f16,
        0 0 20px rgba(0,0,0,0.5);
    overflow: hidden;
    z-index: 1;
}

.window-frame-inner iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Logo at bottom center of window frame */
.window-frame-logo {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.window-frame-logo .logo {
    font-size: 1.2rem;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Fire TV fix - border-radius + overflow:hidden breaks video rendering */
.fire-tv .window-frame-inner {
    border-radius: 0;
    overflow: visible;
}

/* YouTube Back Button - hidden by default, shown on focus for remote navigation */
.youtube-back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s ease;
    opacity: 0;
}

.youtube-back-btn:hover,
.youtube-back-btn:focus {
    opacity: 1;
    background: rgba(0, 0, 0, 0.9);
    border-color: white;
    transform: scale(1.05);
}

/* Player Loading Overlay */
.player-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a1128 0%, #1a2456 50%, #11998e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.player-loading.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.player-loading-content {
    text-align: center;
}

.player-loading-spinner {
    width: 80px;
    height: 80px;
    border: 6px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

.player-loading-text {
    font-size: 1.5rem;
    color: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* On-demand camera wake-up (replaces the spinner while spinning up): the TV (left)
   waking the camera (right) - animated dashes flow along the arrow from TV to camera,
   countdown above the arrow. */
.player-loading-countdown {
    text-align: center;
    color: #fff;
}

.player-loading-countdown.hidden {
    display: none;
}

.player-loading-countdown .spinup-scene {
    width: min(70vw, 600px);
    height: auto;
    display: block;
    margin: 0 auto;
}

.spinup-icon {
    /* Lucide icons: 24x24 grid, stroke-width 2, scaled up via transform */
    fill: none;
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.spinup-arrow {
    fill: none;
    stroke: var(--secondary-color);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 12 12;
    animation: spinup-flow 0.8s linear infinite;
}

@keyframes spinup-flow {
    /* dashes march forward along the path: camera (left) -> TV (right) */
    to { stroke-dashoffset: -24; }
}

.spinup-arrowhead {
    fill: var(--secondary-color);
}

.spinup-count {
    fill: #fff;
    font-size: 34px;
    font-weight: 600;
    animation: pulse 2s ease-in-out infinite;
}

.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 30%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.player-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.player-info h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.player-info p {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.player-controls {
    display: flex;
    gap: 1.5rem;
    justify-content: flex-end;
}

/* Night Mode - Simulated night sky */
.night-mode {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.night-mode canvas {
    /* Sit in the same letterboxed 16:9 area the video uses (centred, contained),
       not the whole screen - so the sleeping sky lines up with where the stream
       was, framed or not. The .night-mode black background fills the bars. */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    z-index: 1;
}

.night-content {
    text-align: center;
    position: relative;
    z-index: 2;
    display: none;
}

.night-content.visible {
    display: block;
}

.night-content.hidden {
    display: none !important;
}

.night-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.night-content p {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 1rem;
}

.sunrise-time {
    font-size: 1.6rem !important;
    color: var(--secondary-color) !important;
    margin-bottom: 2rem !important;
    text-shadow: 0 0 15px rgba(56, 239, 125, 0.4);
}

.night-content .btn {
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.night-content .btn:hover,
.night-content .btn:focus {
    opacity: 1;
}

/* Settings */
.settings-content h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.settings-section {
    margin-bottom: 3rem;
}

.settings-section h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section-btn {
    margin-top: 1.5rem;
}

.settings-select {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
}

.settings-help {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.5rem;
}

/* TV-Style Toggle Switch */
.settings-item-toggle {
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
}

button.toggle-switch {
    position: relative;
    width: 80px;
    height: 44px;
    cursor: pointer;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

.toggle-track {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 22px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.toggle-thumb {
    display: block;
    position: absolute;
    top: 4px;
    left: 4px;
    width: 36px;
    height: 36px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s ease, background 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Toggle ON state */
.toggle-switch.toggle-on .toggle-track {
    background: var(--gradient);
}

.toggle-switch.toggle-on .toggle-thumb {
    transform: translateX(36px);
}

/* Toggle focus state for TV remote */
.toggle-switch:focus {
    outline: none;
}

.toggle-switch:focus .toggle-track,
.toggle-switch.focused .toggle-track {
    box-shadow: 0 0 0 3px var(--secondary-color), 0 0 15px rgba(56, 239, 125, 0.5);
}

/* Locked toggle (free plan): shown ON but greyed to signal it can't be changed
   until the user upgrades to Real View Plus. Still focusable so TTS can read it. */
.toggle-switch.toggle-locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.toggle-label {
    font-size: 1.2rem;
    color: var(--text-primary);
}

/* Auth Screen */
#auth-screen {
    justify-content: center;
    align-items: center;
}

.auth-content {
    text-align: center;
    max-width: 900px;
    padding: 0 3rem;
}

.auth-content .logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.auth-content h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-content p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Auth Methods - Side by Side Layout */
.auth-methods {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin: 1.5rem 0;
}

.auth-method {
    flex: 1;
    max-width: 340px;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
}

.auth-method-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.auth-method-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 1rem;
}

.auth-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0 1rem;
}

.auth-divider .loading-spinner {
    margin: 0;
}

/* QR Code Container */
.qr-code-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px;
    display: inline-block;
    margin: 0.5rem auto;
}

.qr-code-container canvas {
    display: block;
}

.qr-loading,
.qr-error {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1rem;
}

.device-code {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.25rem;
    border-radius: 10px;
    margin: 1rem 0;
}

.code-digits {
    font-size: 3rem;
    font-weight: bold;
    letter-spacing: 0.4rem;
    color: var(--secondary-color);
}

.auth-instructions {
    font-size: 1.1rem;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 1rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: linear-gradient(135deg, #1a1e35 0%, #2a2f4f 100%);
    border-radius: 12px;
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content {
    margin-bottom: 2rem;
}

.modal-content p {
    font-size: 1.4rem;
    line-height: 1.6;
    color: var(--text-primary);
    text-align: center;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.modal-btn {
    min-width: 120px;
}

.modal-btn:focus {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

/* ===========================================
   MOBILE RESPONSIVE STYLES
   =========================================== */

/* Tablet and below */
@media screen and (max-width: 1024px) {
    .main-header {
        padding: 1.5rem 2rem;
    }

    .main-header .logo {
        font-size: 2rem;
    }

    .content {
        padding: 0 2rem 2rem;
    }

    .hero {
        height: 50vh;
        padding: 2rem;
    }

    .hero-content {
        max-width: 70%;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-description {
        font-size: 1.2rem;
    }

    .stream-card {
        width: 280px;
        min-width: 280px;
        height: 157px;
    }

    .stream-row h3 {
        font-size: 1.5rem;
    }
}

/* Mobile - Landscape and larger phones */
@media screen and (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .screen {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }

    /* Header becomes compact */
    .main-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 1.5rem;
        position: sticky;
        top: 0;
        background: var(--dark-bg);
        z-index: 100;
    }

    .main-header .logo {
        font-size: 1.8rem;
    }

    .main-nav {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .nav-btn {
        font-size: 1rem;
        padding: 0.5rem 0.75rem;
    }

    /* Content area */
    .content {
        padding: 0 1rem 2rem;
        overflow-y: visible;
    }

    /* Hero adjustments */
    .hero {
        height: auto;
        min-height: 40vh;
        padding: 1.5rem;
        margin-bottom: 2rem;
        aspect-ratio: 16/9;
    }

    .hero-content {
        max-width: 100%;
    }

    .hero-title {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }

    .hero-description {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .hero-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Buttons */
    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    /* Stream rows */
    .stream-row {
        margin-bottom: 1.5rem;
    }

    .stream-row h3 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
        padding: 0 0.5rem;
    }

    .stream-carousel {
        gap: 1rem;
        padding: 10px 1rem 20px 1rem;
        margin: -10px 0;
    }

    .stream-card {
        width: 240px;
        min-width: 240px;
        height: 135px;
    }

    .stream-card-title {
        font-size: 1rem;
    }

    .stream-card-location {
        font-size: 0.85rem;
    }

    /* Browse grid - 2 columns */
    .stream-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stream-grid .stream-card {
        width: 100%;
        min-width: unset;
        height: auto;
        aspect-ratio: 16/9;
    }

    .category-filters {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* Player overlay */
    .player-overlay {
        padding: 1.5rem;
    }

    .player-info h2 {
        font-size: 1.5rem;
    }

    .player-info p {
        font-size: 1rem;
    }

    .player-controls {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Night mode */
    .night-content h2 {
        font-size: 1.8rem;
    }

    .night-content p {
        font-size: 1.1rem;
    }

    .sunrise-time {
        font-size: 1.3rem !important;
    }

    /* Settings */
    .settings-content h2 {
        font-size: 1.8rem;
    }

    .settings-section h3 {
        font-size: 1.4rem;
    }

    .settings-item {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
        font-size: 1rem;
    }

    /* Keep toggle items in a row */
    .settings-item-toggle {
        flex-direction: row;
        align-items: center;
    }

    .toggle-switch {
        width: 70px;
        height: 38px;
    }

    .toggle-thumb {
        width: 30px;
        height: 30px;
    }

    .toggle-switch.toggle-on .toggle-thumb {
        transform: translateX(32px);
    }

    .toggle-label {
        font-size: 1rem;
    }

    /* Auth screen */
    .auth-content {
        padding: 1.5rem;
    }

    .auth-content .logo {
        font-size: 2.5rem;
    }

    .auth-content h2 {
        font-size: 1.5rem;
    }

    .auth-content p {
        font-size: 1.1rem;
    }

    .code-digits {
        font-size: 2.5rem;
        letter-spacing: 0.3rem;
    }

    /* Modal */
    .modal-box {
        padding: 1.5rem;
        margin: 1rem;
    }

    .modal-content p {
        font-size: 1.2rem;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .modal-btn {
        width: 100%;
    }
}

/* Mobile - Portrait phones */
@media screen and (max-width: 480px) {
    .main-header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .main-header .logo {
        font-size: 1.5rem;
    }

    .main-nav {
        gap: 0.25rem;
    }

    .nav-btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }

    .content {
        padding: 0 0.75rem 1.5rem;
    }

    /* Hero */
    .hero {
        min-height: 35vh;
        padding: 1rem;
        margin-bottom: 1.5rem;
        border-radius: 8px;
    }

    .hero-title {
        font-size: 1.4rem;
    }

    .hero-description {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }

    /* Stream rows */
    .stream-row h3 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .stream-carousel {
        gap: 0.75rem;
        padding: 8px 0.75rem 15px 0.75rem;
    }

    .stream-card {
        width: 200px;
        min-width: 200px;
        height: 112px;
    }

    .stream-card-info {
        padding: 0.75rem;
    }

    .stream-card-title {
        font-size: 0.9rem;
    }

    .stream-card-location {
        font-size: 0.75rem;
    }

    /* Browse grid - single column */
    .stream-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .category-filters {
        justify-content: center;
    }

    .filter-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Player */
    .player-overlay {
        padding: 1rem;
    }

    .player-info h2 {
        font-size: 1.2rem;
    }

    .player-info p {
        font-size: 0.9rem;
    }

    .player-controls {
        justify-content: center;
    }

    .player-controls .btn {
        flex: 1;
        min-width: auto;
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Night mode */
    .night-content {
        padding: 1rem;
    }

    .night-content h2 {
        font-size: 1.4rem;
    }

    .night-content p {
        font-size: 1rem;
    }

    .sunrise-time {
        font-size: 1.1rem !important;
        margin-bottom: 1.5rem !important;
    }

    /* Settings */
    .settings-content h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .settings-section {
        margin-bottom: 2rem;
    }

    .settings-section h3 {
        font-size: 1.2rem;
    }

    .settings-item {
        padding: 0.75rem 0;
        font-size: 0.95rem;
    }

    .settings-select {
        width: 100%;
        padding: 0.6rem 1rem;
        font-size: 1rem;
    }

    /* Auth */
    .auth-content .logo {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .auth-content h2 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }

    .auth-content p {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .device-code {
        padding: 1.25rem;
        margin: 1.5rem 0;
    }

    .code-digits {
        font-size: 2rem;
        letter-spacing: 0.2rem;
    }

    /* Modal */
    .modal-box {
        padding: 1.25rem;
    }

    .modal-content p {
        font-size: 1.1rem;
    }
}

/* Touch-friendly improvements for all mobile */
@media screen and (max-width: 768px) and (pointer: coarse) {
    /* Ensure touch targets are at least 44px */
    .btn,
    .nav-btn,
    .filter-btn,
    .stream-card,
    .focusable {
        min-height: 44px;
    }

    /* Add tap highlight for feedback */
    .btn,
    .nav-btn,
    .filter-btn,
    .stream-card {
        -webkit-tap-highlight-color: rgba(17, 153, 142, 0.3);
    }

    /* Show scrollbars on mobile for discoverability */
    .stream-carousel::-webkit-scrollbar {
        display: block;
        height: 4px;
    }

    .stream-carousel::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.4);
    }
}

/* Fix body cursor for mobile - override TV styles */
@media screen and (max-width: 1024px) {
    body {
        cursor: auto;
    }
}

/* ===========================================
   BROWSE SCREEN - TWO-STEP NAVIGATION
   =========================================== */

/* Category List View */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 800px;
    margin: 2rem auto 0;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.category-item:hover,
.category-item:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
    transform: translateX(10px);
}

.category-item-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.category-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.category-count {
    font-size: 1rem;
    color: var(--text-secondary);
}

.category-arrow {
    font-size: 2rem;
    color: var(--primary-color);
    opacity: 0.7;
    transition: all 0.2s ease;
}

.category-item:hover .category-arrow,
.category-item:focus .category-arrow {
    opacity: 1;
    transform: translateX(5px);
}

/* Browse Header (for streams view) */
.browse-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    margin-top: 2rem;
    padding-top: 1rem;
    position: relative;
    z-index: 100;
}

.browse-header h2 {
    margin: 0;
    font-size: 2rem;
}

.browse-header .btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    position: relative;
    z-index: 20;
}

.browse-header .btn:focus,
.browse-header .btn.focused {
    z-index: 100;
}

/* No content message */
.no-content {
    color: var(--text-secondary);
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
}

/* ===========================================
   BROWSE SCREEN - MOBILE RESPONSIVE
   =========================================== */

@media screen and (max-width: 768px) {
    .category-list {
        max-width: 100%;
    }

    .category-item {
        padding: 1.25rem 1.5rem;
    }

    .category-name {
        font-size: 1.2rem;
    }

    .category-count {
        font-size: 0.9rem;
    }

    .category-arrow {
        font-size: 1.5rem;
    }

    .browse-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .browse-header h2 {
        font-size: 1.5rem;
    }
}

@media screen and (max-width: 480px) {
    .category-item {
        padding: 1rem 1.25rem;
    }

    .category-name {
        font-size: 1.1rem;
    }

    .category-count {
        font-size: 0.85rem;
    }

    .category-arrow {
        font-size: 1.25rem;
    }
}

/* ---------- Channels feature ---------- */

/* Top Channels row: the channel cards share .stream-card sizing but get a subtle
   accent so they're visually distinct from individual stream tiles. */
.channel-card {
    border: 2px solid rgba(255, 215, 0, 0.35);
}
.channel-card:focus,
.channel-card.focused {
    border-color: rgba(255, 215, 0, 0.9);
}

/* Channel screen hero — gradient overlay so banner art doesn't drown the text. */
.channel-hero {
    position: relative;
    height: 46vh; /* ~2/3 of the default .hero height (70vh) */
}
.channel-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.7) 100%);
    pointer-events: none;
    z-index: 0;
}
.channel-hero .hero-content {
    position: relative;
    z-index: 1;
}

/* Unlock modal: matches the existing modal-overlay sizing but its own inner shell
   (we don't reuse .modal-box because it constrains height). */
#unlock-overlay .modal-content {
    background: linear-gradient(135deg, #1a1e35 0%, #2a2f4f 100%);
    border-radius: 12px;
    padding: 2.5rem;
    max-width: 480px;
    width: 90%;
    text-align: center;
    color: var(--text-primary);
}
#unlock-overlay h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.6rem;
}
#unlock-overlay .small {
    font-size: 0.95rem;
    opacity: 0.8;
    margin: 0 0 1.25rem 0;
}
#unlock-overlay .form-input,
#unlock-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 1rem;
    font-size: 1.25rem;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: 0.08em;
}
#unlock-input:focus { border-color: var(--accent-color, gold); outline: none; }
#unlock-overlay .error-text {
    font-size: 1rem;
    margin: 0.25rem 0 1rem 0;
}
#unlock-overlay .modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
}
