:root {
    --bg-dark: #000000;
    --primary: #1d4ed8;
    --primary-glow: rgba(29, 78, 216, 0.4);
    --accent-red: #ef4444;
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --glass-bg: rgba(10, 31, 64, 0.85);
    /* Slightly more opaque for TV contrast */
    --glass-border: rgba(255, 255, 255, 0.15);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    /* TV Scaling Factors */
    --tv-base-font: 1.2rem;
    --tv-title-font: 3.5vw;
}

.tv-player-wp-container {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background-color: #000;
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    color: var(--text-main);
    overflow: hidden;
    font-size: var(--tv-base-font);
}

.tv-player-wp-container .hidden {
    display: none !important;
}

.tv-player-wp-container video {
    width: 100vw;
    height: 100vh;
    object-fit: cover;
}

/* --- LOADING SCREEN (Cinematic V3.1) --- */
.tv-player-wp-container .loading-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 1.2s ease, visibility 1.2s ease;
}

.tv-player-wp-container .loading-canvas {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(30, 64, 175, 0.25) 0%, transparent 75%);
    z-index: 1;
}

.tv-player-wp-container .loading-content {
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4vh;
}

.tv-player-wp-container .loading-logo {
    width: 35vw;
    max-width: 500px;
    filter: drop-shadow(0 0 50px rgba(255, 255, 255, 0.15));
    animation: loadingPulse 3s infinite ease-in-out;
}

.tv-player-wp-container .loading-shimmer {
    font-size: 1.2vw;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5vw;
    color: rgba(255, 255, 255, 0.25);
    background: linear-gradient(90deg, transparent, #fff, transparent);
    background-size: 80% 100%;
    background-repeat: no-repeat;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shimmer 2.5s infinite linear;
}

.tv-player-wp-container .loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes loadingPulse {
    0% {
        transform: scale(0.96);
        opacity: 0.85;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.96);
        opacity: 0.85;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* --- MINI-GUIDE (TV Optimized) --- */
.tv-player-wp-container .mini-guide-bar {
    position: absolute;
    bottom: 4vh;
    left: 5vw;
    right: 5vw;
    background: var(--glass-bg);
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
    border: 2px solid var(--glass-border);
    border-radius: 40px;
    z-index: 500;
    box-shadow: 0 50px 100px rgba(0, 0, 0, 1);
}

.tv-player-wp-container .mini-guide-inner {
    display: flex;
    align-items: center;
    height: 18vh;
    min-height: 160px;
}

.tv-player-wp-container .mini-logo {
    width: 15%;
    min-width: 180px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 2px solid rgba(255, 255, 255, 0.08);
}

.tv-player-wp-container .mini-number {
    font-size: 5vw;
    font-weight: 950;
    text-shadow: 0 0 30px var(--primary-glow);
}

.tv-player-wp-container .mini-info {
    flex: 1;
    padding: 0 4vw;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: flex-start !important;
    overflow: hidden;
    text-align: left;
}

.tv-player-wp-container .channel-main-name {
    display: block !important;
    font-size: 3.5vw;
    font-weight: 1000;
    margin-bottom: 0px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    width: 100%;
}

.tv-player-wp-container .program-now {
    display: block !important;
    font-size: 1.6vw;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: -2px !important;
    width: 100%;
}

.tv-player-wp-container .mini-right {
    display: flex;
    align-items: center;
    gap: 4vw;
    padding-right: 4vw;
}

.tv-player-wp-container .mini-clock {
    font-size: 2.5vw;
    font-weight: 800;
    letter-spacing: -2px;
}

.tv-player-wp-container .mini-btn-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5vh;
}

.tv-player-wp-container .btn-ver-grade {
    background: rgba(255, 255, 255, 0.05);
    border: 3px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 1.5vh 3vw;
    border-radius: 100px;
    font-size: 1.1vw;
    font-weight: 900;
    text-transform: uppercase;
    transition: all 0.3s var(--transition-smooth);
}

.tv-player-wp-container .btn-ver-grade.focused {
    background: #fff;
    color: #000;
    border-color: #fff;
    transform: scale(1.1);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.3);
}

.tv-player-wp-container .btn-ver-grade.primary-action {
    background: var(--primary);
    border-color: #3b82f6;
}

/* --- OVERLAY EPG (Dual View) --- */
.tv-player-wp-container .epg-container {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(10, 20, 50, 0.6) 0%, rgba(0, 0, 0, 0.98) 100%);
    backdrop-filter: blur(60px);
    -webkit-backdrop-filter: blur(60px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 5vh 5vw;
}

.tv-player-wp-container .epg-header h1 {
    font-size: 38px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -1.5px;
    margin-bottom: 25px;
}

.tv-player-wp-container .epg-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 5px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tv-player-wp-container .tab {
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.tv-player-wp-container .tab:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.tv-player-wp-container .tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.tv-player-wp-container .tab.focused {
    background: rgba(255, 255, 255, 0.2);
    border-color: #fff;
    color: #fff;
    transform: scale(1.03);
}

.tv-player-wp-container .epg-body {
    flex: 1;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
}

.tv-player-wp-container .epg-body::-webkit-scrollbar {
    width: 6px;
}

.tv-player-wp-container .epg-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* CHANNEL GRID & CARDS (V5.2 Refined) */
.tv-player-wp-container .channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.tv-player-wp-container .channel-card {
    aspect-ratio: 1/1;
    background: rgba(255, 255, 255, 0.03);
    border: 2.5px solid var(--glass-border);
    border-radius: 28px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.4s var(--transition-smooth);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
    /* Fixes touch delays (V5.2) */
    pointer-events: auto;
}

.tv-player-wp-container .card-logo-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 50px;
    /* Increased padding to prevent clipping */
    box-sizing: border-box;
}

.tv-player-wp-container .channel-card .card-logo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.4s var(--transition-smooth);
}

.tv-player-wp-container .channel-card .card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    display: flex;
    align-items: center;
    gap: 15px;
}

.tv-player-wp-container .channel-card.focused {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.06);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 255, 255, 0.2);
    z-index: 10;
}

.tv-player-wp-container .channel-card.focused .card-logo {
    transform: scale(1.1);
}

.tv-player-wp-container .channel-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
}

.tv-player-wp-container .channel-card .card-number {
    font-size: 26px;
    font-weight: 900;
    color: #ffffff;
}

.tv-player-wp-container .channel-card .card-name {
    font-size: 20px;
    font-weight: 700;
}

/* SCHEDULE LIST */
.tv-player-wp-container .schedule-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tv-player-wp-container .schedule-item {
    display: flex;
    align-items: center;
    gap: 25px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 15px 30px;
    border-radius: 20px;
    transition: all 0.3s;
}

.tv-player-wp-container .schedule-item .item-time {
    font-size: 24px;
    font-weight: 900;
    color: var(--primary);
    min-width: 80px;
}

.tv-player-wp-container .schedule-item .item-name {
    font-size: 22px;
    font-weight: 700;
}

.tv-player-wp-container .schedule-item.focused {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    transform: scale(1.02);
}

.tv-player-wp-container .schedule-item.active {
    border-color: var(--primary);
    background: rgba(29, 78, 216, 0.15);
    box-shadow: inset 0 0 20px rgba(29, 78, 216, 0.2);
}

.tv-player-wp-container .item-time-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.tv-player-wp-container .now-badge {
    background: var(--accent-red);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 4px;
    animation: pulseRed 2s infinite;
}

@keyframes pulseRed {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

.tv-player-wp-container .btn-back-to-grid {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 10px 24px;
    border-radius: 50px;
    font-weight: 800;
    cursor: pointer;
    margin-right: 20px;
    transition: all 0.3s;
}

.tv-player-wp-container .btn-back-to-grid.focused {
    background: #fff;
    color: #000;
    border-color: #fff;
}

/* HINT BAR */
.tv-player-wp-container .hint-bar {
    display: flex;
    justify-content: center;
    gap: 45px;
    margin-top: 20px;
}

.tv-player-wp-container .hint-item {
    font-size: 16px;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tv-player-wp-container .key {
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 12px;
    border-radius: 10px;
    color: #fff;
    font-weight: 900;
    font-size: 14px;
}

/* ANIMATIONS */
@keyframes wpSlideUp {
    from {
        transform: translate(-50%, 60px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* --- MOBILE & PC CONTROLS (V4.0) --- */
.tv-player-wp-container .player-controls-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 600;
    opacity: 1;
    transition: opacity 0.5s var(--transition-smooth);
}

.tv-player-wp-container .player-controls-overlay.ui-hidden {
    opacity: 0;
    pointer-events: none;
    /* Fix: Don't block background while hidden (V5.1) */
}

.tv-player-wp-container .btn-player-back {
    position: absolute;
    top: 25px;
    left: 25px;
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--glass-border);
    border-radius: 50px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s var(--transition-smooth);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.tv-player-wp-container .btn-player-back:hover {
    background: #fff;
    color: #000;
    transform: scale(1.05);
}

.tv-player-wp-container .channel-nav-controls {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    pointer-events: auto;
}

.tv-player-wp-container .btn-nav-channel {
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--glass-border);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--transition-smooth);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.tv-player-wp-container .btn-nav-channel:hover {
    background: var(--primary);
    border-color: #3b82f6;
    transform: scale(1.1);
}

.tv-player-wp-container .btn-nav-channel:active {
    transform: scale(0.95);
}

/* --- RESPONSIVENESS --- */

/* Force landscape on Mobile Portrait (V4.1) */
@media screen and (orientation: portrait) and (max-width: 900px) {
    .tv-player-wp-container {
        width: 100vh !important;
        height: 100vw !important;
        transform: translate(-50%, -50%) rotate(90deg);
        position: fixed;
        top: 50%;
        left: 50%;
        z-index: 9999999;
    }
}

/* Tablets & Small PCs */
@media (max-width: 1280px) {
    :root {
        --tv-base-font: 0.9rem;
    }

    .tv-player-wp-container .loading-logo {
        width: 50vw;
    }

    .tv-player-wp-container .channel-main-name {
        font-size: 4.5vw;
    }

    .tv-player-wp-container .program-now {
        font-size: 2vw;
    }

    .tv-player-wp-container .mini-number {
        font-size: 6vw;
    }

    .tv-player-wp-container .btn-ver-grade {
        font-size: 1.2vw;
        padding: 1.2vh 3vw;
    }
}

/* Mobile Devices (Landscape focus) */
@media (max-width: 900px) {
    .tv-player-wp-container .mini-guide-bar {
        bottom: 10px;
        left: 10px;
        right: 10px;
        border-radius: 15px;
    }

    .tv-player-wp-container .mini-guide-inner {
        height: 70px;
        min-height: 70px;
    }

    .tv-player-wp-container .mini-logo {
        min-width: 60px;
        border-right-width: 1px;
    }

    .tv-player-wp-container .mini-info {
        padding: 0 10px;
    }

    .tv-player-wp-container .channel-main-name {
        font-size: 18px;
    }

    .tv-player-wp-container .program-now {
        font-size: 11px;
    }

    .tv-player-wp-container .mini-clock {
        font-size: 16px;
    }

    .tv-player-wp-container .mini-btn-stack {
        flex-direction: row;
        gap: 6px;
    }

    .tv-player-wp-container .btn-ver-grade {
        padding: 6px 12px;
        font-size: 10px;
        border-width: 1.5px;
    }

    .tv-player-wp-container .btn-player-back {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 11px;
    }

    .tv-player-wp-container .btn-nav-channel {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .tv-player-wp-container .channel-nav-controls {
        right: 10px;
        gap: 10px;
    }

    .tv-player-wp-container .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .tv-player-wp-container .channel-card {
        border-radius: 15px;
    }

    .tv-player-wp-container .card-logo-wrapper {
        padding: 20px;
    }

    .tv-player-wp-container .card-info {
        padding: 10px;
    }

    .tv-player-wp-container .channel-card .card-number {
        font-size: 16px;
    }

    .tv-player-wp-container .channel-card .card-name {
        font-size: 13px;
    }

    .tv-player-wp-container .epg-container {
        padding: 15px;
    }

    .tv-player-wp-container .epg-header h1 {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .tv-player-wp-container .schedule-item {
        padding: 10px 15px;
        gap: 15px;
    }

    .tv-player-wp-container .schedule-item .item-time {
        font-size: 16px;
        min-width: 50px;
    }

    .tv-player-wp-container .schedule-item .item-name {
        font-size: 15px;
    }
}

/* --- UNMUTE BANNER (V5.1) --- */
.tv-player-wp-container .unmute-floating-banner {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ef4444;
    color: #fff;
    padding: 10px 25px;
    border-radius: 100px;
    z-index: 2000;
    font-weight: 900;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
    animation: bannerPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bannerPop {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}