/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Tablet portrait and larger phones in landscape: also hide Theatre */
@media (max-width: 1024px) {
  #theatreModeBtn { display: none !important; }
}

/* ===== 1920x1080 desktop optimization (exact 1080p screens) ===== */
@media screen and (min-width: 1900px) and (max-width: 1940px) and (min-height: 1060px) and (max-height: 1100px) {
  /* Use tighter time header and more compact rows to show more lines */
  .epg-header-area {
    min-height: 360px; /* slightly shorter header to free grid space */
    padding: 16px;
    gap: 20px;
  }
  .epg-corner-player {
    width: 560px;
    height: 315px;
  }
  .current-program-title { font-size: 32px; }
  .current-program-time { font-size: 22px; }
  .current-program-desc { font-size: 16px; max-height: 100px; }

  .epg-time-header { border-bottom-width: 1px; }
  .epg-time-slot, .epg-time-cell {
    min-width: 110px;
    padding: 10px 8px;
    font-size: 0.85em;
  }

  /* Channel row height slightly reduced to fit more rows on 1080p */
  .epg-channel-row { min-height: 52px; }
  .epg-channel-logo-cell {
    min-width: 90px; max-width: 90px; flex: 0 0 90px;
    padding: 8px;
  }
  .epg-channel-logo-large, .epg-channel-logo-fallback-large { width: 44px; height: 32px; }
  .epg-feed-label { font-size: 9px; padding: 2px 5px; }
}

/* ===== Language/Variant Picker Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000; /* Above drawer (3001) */
}

.lang-modal {
  width: min(560px, 92vw);
  max-height: 80vh;
  background: #0d0f12;
  border: 1px solid #253041;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  color: #e7edf5;
}

.lang-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(180deg, #12161c, #0d1016);
  border-bottom: 1px solid #253041;
}

.lang-modal-title {
  font-size: 16px;
  font-weight: 700;
}

.lang-modal-close {
  background: transparent;
  border: none;
  color: #9fb3c8;
  font-size: 20px;
  cursor: pointer;
}
.lang-modal-close:hover { color: #cfe1f0; }

.lang-modal-body {
  max-height: calc(80vh - 56px);
  overflow-y: auto;
  padding: 8px 0;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
}
.lang-option:hover { background: rgba(255,255,255,0.05); }

.lang-option-label {
  font-size: 14px;
  color: #d7e3ef;
}

body {
    font-family: 'Arial', sans-serif;
    background: #000000;
    color: #ffffff;
    overflow-x: hidden;
}

/* No global scrolling restrictions - only EPG screen specific */

.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 50px; /* Offset for persistent sidebar */
    width: calc(100% - 50px);
    min-height: 100vh;
    z-index: 1;
}

.screen.active {
    display: block;
}

/* Force login to fully cover the app (above sidebar) */
#loginScreen.screen {
    left: 0 !important;
    width: 100% !important;
    position: fixed !important;
    top: 0 !important;
    z-index: 5000 !important; /* Above sidebar (2000), drawer (3001) */
    background: #000 !important;
}

/* During login, hide the sidebar and drawer entirely */
body.login-active .sidebar-nav { visibility: hidden !important; }
body.login-active .category-drawer { display: none !important; }

/* Global minimal dark scrollbars (to avoid white scrollbars in dark UI) */
* {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent; /* Firefox */
}
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #333;
    border-top: 3px solid #ff6b6b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0px;
}

.logo-image {
    width: clamp(300px, 40vw, 600px);
    height: auto;
    margin-bottom: 0px;
    /* Remove drop shadow to blend with black background */
    filter: none;
    transition: transform 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.05);
}

.login-form {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group input {
    width: 100% !important;
    padding: 15px 20px !important;
    background-color: #CCCCCC !important;
    border: 2px solid #AAAAAA !important;
    border-radius: 10px !important;
    color: #000000 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
}

.input-group input:focus {
    outline: none !important;
    border-color: #999999 !important;
    background-color: #DDDDDD !important;
}

.input-group input::placeholder {
    color: #666666 !important;
    font-weight: 400 !important;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(45deg, #2196F3, #1976D2);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(45deg, #1976D2, #1565C0);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

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

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.app-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-spacer {
    flex: 1;
}

/* Refresh Button Animation */
#refreshDataBtn {
    position: relative;
    transition: all 0.3s ease;
}

#refreshDataBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.refresh-spinner {
    animation: spin 1s linear infinite;
}

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

/* Refresh Loading Overlay */
.refresh-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.refresh-loading-overlay.hidden {
    display: none;
}

.refresh-loading-content {
    text-align: center;
    color: white;
}

.refresh-loading-content .refresh-spinner {
    font-size: 3rem;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.refresh-loading-content .refresh-spinner::before {
    content: '🔄';
}

.refresh-loading-content p {
    font-size: 1.2rem;
    margin: 0;
}

/* Content Type Selection Screen */
.content-type-container {
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 80px);
    justify-content: center;
}

.content-type-container h2 {
    font-size: clamp(2rem, 6vw, 3rem);
    margin-bottom: 50px;
    text-align: center;
}

.content-type-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: 1 column */
    gap: 30px;
    max-width: 1200px;
    width: 100%;
}

@media (min-width: 768px) {
    .content-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.content-type-card {
    background: linear-gradient(135deg, #000, #111);
    border: 2px solid #222;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s ease;
    backdrop-filter: blur(10px);
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    user-select: none;
}

.content-type-card:hover {
    background: linear-gradient(135deg, #222, #111);
    border-color: #444;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.9);
}

.content-type-card:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 1);
    background: linear-gradient(135deg, #000, #000);
}

.content-type-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}

.content-type-card h3 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 15px;
    font-weight: bold;
}

.content-type-card p {
    color: #ccc;
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin-bottom: 15px;
}

.content-type-card .channel-count {
    color: #888;
    font-size: 14px;
    font-weight: normal;
}

/* Netflix-Style Sidebar Navigation */
#mainAppScreen {
    display: flex;
    height: 100vh;
    background: #000;
}

.sidebar-nav {
    width: 50px;
    background: linear-gradient(180deg, #000 0%, #111 100%);
    border-right: 1px solid #222;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 2000;
}

.sidebar-header {
    padding: 10px 5px;
    border-bottom: 1px solid #222;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1em;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.sidebar-menu {
    flex: 1;
    padding: 10px 5px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav-item {
    width: 40px;
    height: 35px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #aaa;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    padding: 3px 2px;
    margin-bottom: 4px;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: scale(1.05);
}

.sidebar-nav-item.active {
    background: rgba(0, 217, 255, 0.2);
    color: #00d9ff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 217, 255, 0.4);
}

.nav-icon {
    font-size: 1.2em;
    margin-bottom: 3px;
}

.nav-label {
    font-size: 7px;
    font-weight: 500;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
}

/* Cast launcher sizing in sidebar */
#castBtnWrap { align-items: center; }
.cast-launcher { width: 22px; height: 22px; }

/* Dropdown Sidebar Functionality */
.sidebar-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-arrow {
    position: absolute;
    right: 2px;
    top: 2px;
    font-size: 6px;
    transition: transform 0.3s ease;
}

.sidebar-dropdown.expanded .dropdown-arrow {
    transform: rotate(180deg);
}

.sidebar-dropdown-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    margin-top: 2px;
}

.sidebar-dropdown.expanded .sidebar-dropdown-content {
    max-height: 300px;
}

.sidebar-dropdown-item {
    width: 40px;
    height: 25px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 6px;
    font-weight: 400;
    text-align: center;
    padding: 2px;
    margin-bottom: 1px;
    line-height: 1;
}

.sidebar-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-dropdown-item.active {
    background: rgba(0, 217, 255, 0.3);
    color: #00d9ff;
}

/* Side Drawer for Categories (replaces dropdown) */
.category-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 3001; /* Above persistent sidebar (2000) */
    pointer-events: none;
    transition: all 0.3s ease;
}

.category-drawer.open {
    pointer-events: all;
}

.drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-drawer.open .drawer-overlay {
    opacity: 1;
}

.drawer-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 380px; /* wider so long names don't feel clipped */
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    border-right: 1px solid rgba(0, 217, 255, 0.2);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.category-drawer.open .drawer-content {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.6);
}

.drawer-title {
    color: #00d9ff;
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

.drawer-close {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.drawer-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #00d9ff;
}

.drawer-categories {
    height: calc(100% - 80px);
    overflow-y: auto;
    padding: 10px 10px 10px 18px; /* more left padding, prevents cut-off look */
    scrollbar-width: none; /* Firefox: hide */
    -ms-overflow-style: none; /* IE/Edge legacy */
}

/* Minimal dark scrollbars for drawer (Chromium/WebKit) */
.drawer-categories::-webkit-scrollbar {
    width: 0; /* Chromium/WebKit: hide */
    height: 0;
}

.drawer-category-item {
    display: flex;
    align-items: center;
    padding: 12px 16px 12px 20px; /* extra left pad for text breathing room */
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #bbb;
    font-size: 14px;
    border-left: 3px solid transparent;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* clean truncation on very long titles */
}

.drawer-category-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-left-color: #00d9ff;
    transform: translateX(4px);
}

.drawer-category-item.active {
    background: rgba(0, 217, 255, 0.15);
    color: #00d9ff;
    border-left-color: #00d9ff;
    font-weight: bold;
}

/* Mobile responsiveness for drawer */
@media screen and (max-width: 768px) {
    .drawer-content {
        width: 85%;
        max-width: 300px;
    }
    
    .drawer-category-item {
        padding: 16px;
        font-size: 16px;
    }
    
    .drawer-title {
        font-size: 16px;
    }
}

@media screen and (max-width: 480px) {
    .drawer-content {
        width: 90%;
    }
}

/* ===================== Search Drawer ===================== */
.search-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000;
}

.search-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 520px;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #141414 100%);
    border-right: 1px solid rgba(0, 217, 255, 0.2);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,0.6);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.search-drawer.open { pointer-events: auto; }
.search-drawer.open .search-overlay { opacity: 1; }
.search-drawer.open .search-content { transform: translateX(0); }

.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.45);
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 10px 12px;
}

.search-icon { color: #9adfff; font-size: 16px; }

#searchInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 14px;
}

.search-clear {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
}

.search-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 20px 18px;
}

.search-section { margin-top: 12px; }
.search-section-title {
    color: #00d9ff;
    font-size: 13px;
    letter-spacing: 0.4px;
    margin: 6px 0 8px 2px;
    text-transform: uppercase;
}

.search-results-list { display: flex; flex-direction: column; gap: 6px; }

.search-result-item {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-result-item:hover { background: rgba(255,255,255,0.07); border-color: rgba(0,217,255,0.25); transform: translateX(2px); }

/* Remote focus state */
.search-result-item.active {
  background: rgba(0, 217, 255, 0.15);
  border-color: rgba(0, 217, 255, 0.35);
  box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.18) inset;
  transform: none;
}

.search-thumb {
    width: 44px; height: 44px; border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.08); color: #999; font-size: 18px;
}
.search-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.search-info { display: flex; flex-direction: column; min-width: 0; }
.search-title { color: #fff; font-size: 14px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-meta { color: #9aa; font-size: 12px; opacity: 0.9; margin-top: 2px; }

@media screen and (max-width: 768px) {
    .search-content { width: 85%; max-width: 480px; }
}

@media screen and (max-width: 480px) {
    .search-content { width: 90%; }
}

/* Main Content Area */
.main-content-area {
    flex: 1;
    margin-left: 0; /* Sidebar offset handled by .screen now */
    background: #000;
    overflow-y: auto;
    height: 100vh;
}

.content-section {
    display: none;
    width: 100%;
    height: 100%;
    padding: 0;
}

.content-section.active {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar-nav {
        width: 45px;
    }
    /* Adjust screen offset for smaller sidebar width */
    .screen {
        left: 45px;
        width: calc(100% - 45px);
    }
    
    .sidebar-nav-item {
        width: 35px;
        height: 30px;
    }
    
    .nav-label {
        font-size: 6px;
    }
}

/* Categories Screen */
.categories-container {
    padding: 20px;
}

.categories-container h2 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 30px;
    text-align: center;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.category-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.category-card:hover {
    transform: translateY(-5px);
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(78, 205, 196, 0.1));
    border-color: #ff6b6b;
}

.category-card h3 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    margin-bottom: 10px;
}

.category-card .channel-count {
    color: #888;
    font-size: 14px;
}

/* Channels Screen */
.channels-container {
    padding: 20px;
}

/* Hide header (Back/Logout + title) when in posters mode for Movies/Series */
#channelsScreen.posters-mode .app-header,
#channelsScreen.posters-mode .player-header {
    display: none !important;
}

/* Hide Back/Logout header on VOD player */
#playerScreen.vod-mode .player-header {
    display: none !important;
}

/* Posters-mode layout: 40% top header, 3-row poster rail below */
#channelsScreen.posters-mode {
    /* Shared sizing variables for header and rail */
    --poster-w: 120px; /* default; overridden by breakpoints below */
    --grid-gap: 12px;
}

/* ============================= */
/* Series Detail (Netflix style) */
/* ============================= */
#seriesDetailScreen .series-detail {
  background: #000;
  color: #fff;
  min-height: 100vh;
  overflow-y: auto;
}

#seriesDetailScreen .series-hero {
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.95) 90%);
  border-bottom: 1px solid #1f1f1f;
}

#seriesDetailScreen .series-hero-inner {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: end;
  padding: 32px;
}

#seriesDetailScreen .series-hero-left { align-self: start; }

#seriesDetailScreen .series-poster {
  width: 260px;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  background: #111;
}

#seriesDetailScreen .series-brand {
  font-size: 12px;
  letter-spacing: 2px;
  color: #9aa4af;
  margin-bottom: 8px;
}

#seriesDetailScreen .series-title {
  font-size: clamp(28px, 3.2vw, 56px);
  font-weight: 900;
  line-height: 1.05;
  margin: 0 0 10px 0;
}

#seriesDetailScreen .series-badges { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
#seriesDetailScreen .badge {
  background: #16181a;
  border: 1px solid #2a2e33;
  color: #cfd7df;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
}

#seriesDetailScreen .series-overview { color: #c7cdd4; margin: 8px 0 6px 0; max-width: 90ch; }
#seriesDetailScreen .series-genres { color: #9aa4af; font-size: 13px; }

#seriesDetailScreen .episodes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-top: 1px solid #111;
  border-bottom: 1px solid #111;
  background: #0a0a0a;
}

#seriesDetailScreen .episodes-header h2 { margin: 0; font-size: 20px; letter-spacing: 0.2px; }

#seriesDetailScreen .season-select { display: flex; align-items: center; gap: 8px; }
#seriesDetailScreen .season-select label { color: #9aa4af; font-size: 13px; }
#seriesDetailScreen .season-select select {
  background: #111;
  color: #e5e9ef;
  border: 1px solid #2a2e33;
  border-radius: 8px;
  padding: 8px 12px;
}

#seriesDetailScreen .episodes-list { display: flex; flex-direction: column; }

#seriesDetailScreen .episode-row {
  display: grid;
  grid-template-columns: 56px 1fr 80px;
  gap: 16px;
  align-items: center;
  padding: 14px 32px;
  border-bottom: 1px solid #151515;
  background: #0c0c0c;
  cursor: pointer;
  transition: background 0.15s ease;
}
#seriesDetailScreen .episode-row:hover { background: #121212; }

#seriesDetailScreen .ep-num {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #15181b;
  border: 1px solid #23282e;
  color: #cfd7df;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

#seriesDetailScreen .ep-title { font-weight: 700; color: #e9edf2; margin-bottom: 4px; }
#seriesDetailScreen .ep-plot { color: #9aa4af; font-size: 13px; }
#seriesDetailScreen .ep-meta { color: #9aa4af; text-align: right; font-size: 13px; }

@media (max-width: 900px) {
  #seriesDetailScreen .series-hero-inner { grid-template-columns: 1fr; }
  #seriesDetailScreen .series-poster { width: 200px; margin-bottom: 10px; }
  #seriesDetailScreen .episode-row { grid-template-columns: 40px 1fr 60px; padding: 12px 16px; }
}

#seriesDetailScreen .episodes-header {
  display: flex;
  align-items: center;
  justify-content: center; /* center the dropdown */
  gap: 12px;
  padding: 8px 12px;
}

/* Hide heading and label; keep only the centered dropdown */
#seriesDetailScreen .episodes-header h2,
#seriesDetailScreen .episodes-header .season-select label {
  display: none !important;
}

#seriesDetailScreen .episodes-header .season-select select#seasonSelect {
  min-width: clamp(180px, 50vw, 360px);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(17, 17, 17, 0.9); /* force dark background */
  color: #e9edf2;
  font-size: 14px;
  color-scheme: dark; /* request dark native UI where applicable */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

#seriesDetailScreen .episodes-header .season-select select#seasonSelect:focus {
  outline: none;
  border-color: #4ecdc4;
  box-shadow: 0 0 0 2px rgba(78,205,196,0.25);
}

/* Dark dropdown menu items (supported in Chromium/Firefox) */
#seriesDetailScreen .episodes-header .season-select select#seasonSelect option {
  background-color: #111;
  color: #e9edf2;
}

#channelsScreen.posters-mode .channels-container {
    display: grid;
    /* Use dynamic heights: header gets --header-h (defaults to 40vh), posters rail uses JS-computed --poster-rail-h */
    grid-template-rows: minmax(200px, var(--header-h, 40vh)) var(--poster-rail-h);
    gap: 8px;
    height: 100vh;
    padding: 8px 12px 10px 12px;
    min-height: 0; /* allow inner grids to manage overflow */
}

/* Mobile: make header row auto-sized and bring posters closer (small gap) */
@media (max-width: 768px) {
  #channelsScreen.posters-mode .channels-container {
    --header-h: auto;
    grid-template-rows: auto var(--poster-rail-h);
    gap: 6px;
  }
}

/* Tablet: reduce header height to free space for an extra row, keep small gap */
@media (min-width: 769px) and (max-width: 1024px) {
  #channelsScreen.posters-mode .channels-container {
    --header-h: 32vh;
    gap: 8px;
  }
}

/* Centered media info header (Netflix-style, no trailer) */
.media-info-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* text at the very top of header space */
    text-align: center;
    padding: 6px 12px 4px 12px;
    background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.00) 100%);
    border-radius: 0;
}

.media-title {
    font-weight: 900;
    letter-spacing: 0.5px;
    font-size: clamp(22px, 3.6vw, 48px);
    margin-bottom: 8px;
}

.media-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.media-badge {
    font-size: clamp(10px, 1.4vw, 13px);
    font-weight: 700;
    color: #ddd;
    border: 1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.08);
    padding: 4px 8px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}

.media-desc {
    max-width: 1100px;
    color: #ddd;
    font-size: clamp(12px, 1.5vw, 16px);
    line-height: 1.35;
    margin: 4px 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 2–3 lines like Netflix */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.media-tag {
    font-size: clamp(10px, 1.3vw, 12px);
    color: #00d9ff;
    background: rgba(0, 217, 255, 0.12);
    padding: 3px 8px;
    border-radius: 8px;
}

/* Poster grid fills the rail height computed by container (3 rows visible) */
#channelsScreen.posters-mode .channels-grid.posters-grid {
    height: 100%;
    overflow-y: auto;
    padding-bottom: 8px;
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* Poster-only grid for Movies/Series (Netflix-style)
   Exactly two rows visible by fixing column width and computing total height */
.channels-grid.posters-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    justify-content: center;
    gap: var(--grid-gap);
    padding: 6px 12px;
    grid-auto-rows: calc(var(--poster-w) * 1.5); /* every row equals poster height */
    align-content: start; /* stack rows from the top, no distribution compression */
    min-height: 0; /* prevent compression that causes overlaps */
}

.poster-card {
    position: relative;
    background: #111;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    /* Explicit height to match grid-auto-rows; width comes from column */
    height: calc(var(--poster-w) * 1.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.poster-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
}

.poster-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    aspect-ratio: 2 / 3;
}

.poster-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: linear-gradient(135deg, #0b0b0b, #161616);
}

.poster-fallback.hidden { display: none; }

/* Fallback title text (show movie/series name when image is missing) */
.poster-fallback-title {
    color: #f2f2f2;
    font-weight: 700;
    text-align: center;
    line-height: 1.15;
    font-size: clamp(10px, 1.6vw, 14px);
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Responsive poster sizing for larger screens (fixed column width) */
@media (min-width: 1024px) { #channelsScreen.posters-mode { --poster-w: 130px; } }
@media (min-width: 1280px) { #channelsScreen.posters-mode { --poster-w: 140px; } }
@media (min-width: 1440px) { #channelsScreen.posters-mode { --poster-w: 150px; } }
@media (min-width: 1600px) { #channelsScreen.posters-mode { --poster-w: 160px; } }
@media (min-width: 1920px) { #channelsScreen.posters-mode { --poster-w: 180px; } }
@media (min-width: 2560px) { #channelsScreen.posters-mode { --poster-w: 220px; } }

.channel-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.channel-card:hover {
    transform: translateY(-5px);
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(78, 205, 196, 0.1));
    border-color: #ff6b6b;
}

.channel-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
}

.channel-card h4 {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    margin-bottom: 5px;
}

/* Player Screen */
.player-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.video-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    position: relative;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 70px);
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

/* Prevent Chromium browsers from darkening video on hover */
#videoPlayer::-webkit-media-controls-overlay-enclosure {
    display: none !important;
}

/* Remove dark gradient overlay on video hover */
video::-webkit-media-controls-overlay-enclosure {
    display: none !important;
}

/* Edge/Chromium: fully neutralize overlay on VOD player */
#playerScreen video::-webkit-media-controls-overlay-enclosure { display: none !important; }
#playerScreen video::-webkit-media-controls-enclosure { background: transparent !important; }
#playerScreen video::-webkit-media-controls { background: transparent !important; }
#playerScreen video::-webkit-media-controls-start-playback-button { display: none !important; }
/* Extra suppression for Edge build overlays */
#playerScreen video::-webkit-media-controls-panel { background-color: transparent !important; }
#playerScreen #videoPlayer::-webkit-media-controls-panel { background-color: transparent !important; }
#playerScreen video::-webkit-media-controls-overlay-play-button { display: none !important; }
#playerScreen video::-webkit-media-controls-decorative-container { display: none !important; }
#playerScreen video::-webkit-media-controls-timeline-container { background: transparent !important; }
#playerScreen video::-webkit-media-controls-timeline { background: transparent !important; }
#playerScreen video::-webkit-media-controls-toggle-closed-captions-button { background: transparent !important; }

/* Responsive Design */
@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .app-header {
        padding: 15px;
    }
    
    .categories-container, .channels-container {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .category-card {
        padding: 20px 15px;
    }
    
    .channel-logo {
        width: 60px;
        height: 60px;
    }
}

/* Audio Warning Overlay */
.audio-warning {
    position: absolute !important;
    top: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(255, 193, 7, 0.95) !important;
    color: #000 !important;
    padding: 12px 24px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    z-index: 10000 !important;
    max-width: 80% !important;
    text-align: center !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
    border: 2px solid rgba(255, 193, 7, 1) !important;
    backdrop-filter: blur(4px) !important;
    animation: audioWarningFade 0.3s ease-in !important;
}

@keyframes audioWarningFade {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Enhanced video player controls for audio */
#videoPlayer::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
}

#videoPlayer::-webkit-media-controls-current-time-display,
#videoPlayer::-webkit-media-controls-time-remaining-display {
    color: white;
}

/* EPG Styles - CRITICAL: Fixed height container with no page scrolling */
.epg-container {
    position: relative;
    height: 100vh; /* Full viewport height */
    overflow: hidden; /* No page-level scrolling */
    background: #1a1a1a;
}

/* Theatre mode: overlay the corner player to fill the entire main area (excluding sidebar) */
.theatre-mode .epg-header-area { position: static; }
.theatre-mode #cornerVideoPlayer {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 2000; /* Below drawer (3001), above grid */
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}
.theatre-mode #cornerVideo {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}
.theatre-mode .epg-program-info { display: none; }
.theatre-mode .epg-time-header,
.theatre-mode .epg-channels-and-programs { pointer-events: none; opacity: 0; }

/* Ensure drawer overlays over theatre player as requested */
.category-drawer { z-index: 3001; }
.epg-container { z-index: 1; }

/* MOBILE/TABLET: Disable theatre feature on small and medium screens */
@media (max-width: 768px) {
  /* Hide the Theatre button entirely on mobile */
  #theatreModeBtn { display: none !important; }

  /* Neutralize theatre-mode state if toggled before resizing */
  #epgGridScreen.theatre-mode #cornerVideoPlayer {
    position: static !important;
    width: auto !important;
    height: auto !important;
  }
  #epgGridScreen.theatre-mode .epg-program-info { display: block !important; }
  #epgGridScreen.theatre-mode .epg-time-header,
  #epgGridScreen.theatre-mode .epg-channels-and-programs {
    pointer-events: auto !important;
    opacity: 1 !important;
  }
}

/* EPG Header Area - Static player and program info - MUCH LARGER */
.epg-header-area {
    display: flex;
    background: #2a2a2a;
    border-bottom: 2px solid #404040;
    padding: 20px;
    gap: 30px;
    min-height: 420px; /* 4x larger than original 160px */
    flex-shrink: 0; /* Prevent shrinking */
    position: relative;
    z-index: 5;
}

/* EPG Corner Player (Left side) - MUCH LARGER */
.epg-corner-player {
    width: 600px; /* 4x larger than original 280px */
    height: 350px; /* 4x larger than original 140px */
    background: #000;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.epg-corner-player .corner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Android Chrome cropping fix: prefer contain to avoid top/bottom cutoff */
body.android-chrome .epg-corner-player .corner-video,
body.android-chrome #playerScreen video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  background-color: #000 !important;
}

/* Theatre Mode override for Android Chrome */
body.android-chrome .theatre-mode #cornerVideo {
  object-fit: contain !important;
}

/* Fullscreen overrides: when containers are fullscreen, ensure inner video contains */
body.android-chrome .epg-corner-player:fullscreen .corner-video,
body.android-chrome .epg-corner-player:-webkit-full-screen .corner-video,
body.android-chrome .video-container:fullscreen video,
body.android-chrome .video-container:-webkit-full-screen video {
  object-fit: contain !important;
  object-position: center center !important;
  background-color: #000 !important;
}

.epg-corner-player .corner-player-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.corner-control-btn {
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 6px;
    width: 48px; /* Larger buttons for larger player */
    height: 48px;
    cursor: pointer;
    font-size: 18px; /* Larger text for larger buttons */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.corner-control-btn:hover {
    background: rgba(0,0,0,0.9);
    transform: scale(1.05);
}

/* EPG Program Info (Right side) - MUCH LARGER TEXT AND EXPANDED */
.epg-program-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px; /* Much larger gaps */
    color: white;
    max-width: none; /* Remove width limit to span farther right */
    padding-left: 20px; /* Add spacing from player */
}

.program-info-channel {
    display: flex;
    align-items: center;
    gap: 20px; /* Larger gap */
    padding-bottom: 16px; /* Larger padding */
    border-bottom: 2px solid #404040; /* Thicker border */
}

.current-channel-logo {
    width: 80px; /* 2x larger than original 40px */
    height: 60px; /* 2x larger than original 30px */
    border-radius: 8px; /* Larger border radius */
    object-fit: contain;
    background: rgba(255,255,255,0.1);
}

.current-channel-name {
    font-size: 32px; /* Much larger than original 18px */
    font-weight: 700; /* Bolder */
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3); /* Add text shadow for better visibility */
}

.program-info-details {
    display: flex;
    flex-direction: column;
    gap: 16px; /* Much larger gaps between elements */
}

.current-program-title {
    font-size: 36px; /* Much larger than original 20px */
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.current-program-time {
    font-size: 28px; /* Much larger than original 16px */
    font-weight: 600; /* Bolder */
    color: #ff453a;
    letter-spacing: 1px; /* More letter spacing */
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.current-program-desc {
    font-size: 20px; /* Much larger than original 14px */
    color: rgba(255,255,255,0.9); /* Slightly more opaque */
    line-height: 1.5; /* Better line height for larger text */
    max-height: 120px; /* Double the height for larger text */
    overflow: hidden;
}

/* Legacy corner video player (keep for compatibility) */
.corner-video-player {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 320px;
    height: 180px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 10;
    display: none;
}

.corner-video-player.active {
    display: block;
}

.corner-player-controls {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
    z-index: 11;
}

.corner-control-btn {
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.corner-control-btn:hover {
    background: rgba(0,0,0,0.9);
}

.corner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* EPG Categories Screen Styles */
.epg-categories-container {
    padding: 30px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.epg-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.epg-category-item {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 30px 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.epg-category-item:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.epg-category-icon {
    font-size: 3em;
    margin-bottom: 15px;
    display: block;
}

.epg-category-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}

.epg-category-count {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
}

/* EPG Program Details Popup */
.epg-program-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.epg-popup-content {
    background: linear-gradient(135deg, #1a1a1a, #0f0f0f);
    border: 2px solid #333;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.9);
}

.epg-popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #333;
    border: none;
    color: #fff;
    font-size: 24px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.epg-popup-close:hover {
    background: #555;
    transform: scale(1.1);
}

.epg-popup-header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

.popup-channel-logo {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    margin-right: 15px;
    object-fit: contain;
}

.popup-channel-name {
    font-size: 1.4em;
    font-weight: bold;
    color: #fff;
}

.popup-program-title {
    font-size: 1.8em;
    font-weight: bold;
    color: #fff;
    margin-bottom: 10px;
}

.popup-program-time {
    font-size: 1.1em;
    color: #ff6b35;
    margin-bottom: 15px;
    font-weight: 600;
}

.popup-program-description {
    font-size: 1em;
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 25px;
}

.epg-popup-upcoming h4 {
    color: #fff;
    font-size: 1.2em;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}

.popup-upcoming-list {
    max-height: 200px;
    overflow-y: auto;
}

.popup-upcoming-item {
    padding: 10px 0;
    border-bottom: 1px solid #222;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.popup-upcoming-item:last-child {
    border-bottom: none;
}

.popup-upcoming-title {
    font-size: 1em;
    color: #fff;
    font-weight: 600;
    margin-bottom: 5px;
}

.popup-upcoming-time {
    font-size: 0.9em;
    color: #ff6b35;
    font-weight: 500;
}

.popup-upcoming-description {
    font-size: 0.85em;
    color: #999;
    line-height: 1.4;
}

/* EPG Category Cards - True Black Theme Interactive Button Style */
.epg-category-card {
    background: linear-gradient(135deg, #000, #111);
    border: 2px solid #222;
    border-radius: 12px;
    padding: 25px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    position: relative;
    overflow: hidden;
    user-select: none;
}

.epg-category-card:hover {
    background: linear-gradient(135deg, #222, #111);
    border-color: #444;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.9);
}

.epg-category-card:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 1);
    background: linear-gradient(135deg, #000, #000);
}

.epg-category-card .epg-category-icon {
    font-size: 3em;
    margin-bottom: 15px;
    display: block;
    text-align: center;
    width: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.epg-category-card h3 {
    font-size: 1.0em;
    font-weight: 600;
    color: #fff;
    margin: 10px 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

.epg-category-card p {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.8);
    margin: 8px 0;
}

.epg-category-card .epg-category-count {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    margin-top: 8px;
}

/* EPG Grid Screen Styles */
.epg-grid-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 12px 12px 12px;
}

.epg-time-header {
    display: flex;
    background: #2d2d2d;
    border-bottom: 2px solid #404040;
    position: sticky;
    top: 0;
    z-index: 10;
}

.epg-time-slot {
    min-width: 120px;
    padding: 15px 10px;
    text-align: center;
    font-weight: 600;
    color: #fff;
    border-right: 1px solid #404040;
    font-size: 0.9em;
}

.epg-time-slot.current-time {
    background: rgba(255, 0, 0, 0.2);
    border-color: #ff0000;
}

/* EPG Time Navigation - Clean corner arrows like image 2 */
.epg-time-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #1a1a1a;
    border-bottom: 1px solid #404040;
    height: 50px;
}

.epg-nav-corner-left, .epg-nav-corner-right {
    width: 60px;
}

.epg-corner-arrow {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.epg-corner-arrow:hover {
    background: #444;
    border-color: #666;
}

.epg-nav-center-clean {
    flex: 1;
    text-align: center;
}

.epg-current-time-clean {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.epg-channels-and-programs {
    flex: 1;
    overflow-y: auto;
}

.epg-channel-row {
    display: flex;
    border-bottom: 1px solid #404040;
    min-height: 60px;
    align-items: stretch;
    width: 100%;
}

/* Channel Logo Cell - Fixed responsive */
.epg-channel-logo-cell {
    min-width: 100px;
    max-width: 100px;
    flex: 0 0 100px;
    background: #2d2d2d;
    border-right: 2px solid #404040;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    left: 0;
    z-index: 5;
}

.epg-channel-logo-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 4px;
}

.epg-channel-logo-large {
    width: 50px;
    height: 38px;
    border-radius: 8px;
    object-fit: contain;
    background: rgba(255,255,255,0.1);
}

.epg-channel-logo-fallback-large {
    width: 50px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #888;
}

.epg-feed-label {
    font-size: 10px;
    font-weight: 600;
    color: #00d9ff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    padding: 2px 6px;
    background: rgba(0, 217, 255, 0.15);
    border-radius: 4px;
    white-space: nowrap;
}

/* EPG Time Header - Fixed responsive grid */
.epg-time-header {
    display: flex;
    background: #1a1a1a;
    border-bottom: 2px solid #404040;
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
}

.epg-time-cell {
    padding: 10px 8px;
    text-align: center;
    color: #fff;
    border-right: 1px solid #404040;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    flex: 1;
}

.epg-channel-name-header {
    background: #2d2d2d !important;
    font-weight: 600;
    border-right: 2px solid #404040 !important;
    min-width: 100px;
    max-width: 100px;
    flex: 0 0 100px;
}

/* EPG Program Timeline - NEW: Replaces old program cells with positioned timeline */
.epg-program-timeline {
    position: relative;
    flex: 1;
    min-width: 0;
    border-right: 1px solid #404040;
    background: #1e1e1e;
    min-height: clamp(60px, 8vw, 80px);
    overflow: hidden;
}

/* EPG Program Items - NEW: Positioned elements within timeline */
.epg-program-item {
    position: absolute;
    top: 2px;
    bottom: 2px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid rgba(255, 69, 58, 0.6);
    box-sizing: border-box;
    overflow: hidden;
    min-width: 60px; /* Ensure programs are always wide enough to be readable */
}

.epg-program-item:hover {
    background: rgba(255, 255, 255, 0.12);
    border-left-color: rgba(255, 69, 58, 1);
    z-index: 2;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Program text container - Centers content within positioned item */
.epg-program-text {
    padding: clamp(3px, 0.4vw, 6px);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.epg-program-title {
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    line-height: 1.2;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.epg-program-time {
    font-size: 9px;
    color: #aaa;
    line-height: 1;
}

/* DESKTOP ONLY: Fix EPG scrolling on 4K displays and large screens */
@media (min-width: 1025px) {
    /* CRITICAL: Lock page-level scrolling on EPG screens */
    body.epg-active {
        overflow: hidden;
        height: 100vh;
    }
    
    /* CRITICAL: EPG container must use full viewport height */
    .epg-container {
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    /* CRITICAL: EPG grid container must be height-constrained for internal scrolling */
    .epg-grid-container {
        display: flex;
        flex-direction: column;
        height: 100vh; /* No app-header at top; fill full viewport */
        overflow: hidden;
    }
    
    /* CRITICAL: EPG channels and programs must scroll internally only */
    .epg-channels-and-programs {
        flex: 1;
        overflow-y: auto; /* Only grid scrolls vertically */
        overflow-x: hidden; /* No horizontal page scroll */
        height: 0; /* Force flex child to respect parent height */
    }
}

/* Responsive adjustments - WIDER breakpoint to catch Samsung Galaxy Z Fold 4 */
@media (max-width: 1024px) {
    /* CRITICAL: EPG page must fit 100vh with no page scrolling */
    .epg-container {
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    /* CRITICAL MOBILE FIX: Drastically reduce EPG header to show multiple channels */
    .epg-header-area {
        flex-direction: column;
        min-height: 140px; /* EVEN smaller to fit viewport */
        padding: 4px; /* Minimal padding */
        gap: 4px; /* Minimal gap */
        flex-shrink: 0; /* Don't allow shrinking */
    }
    
    .epg-corner-player {
        width: 100%;
        height: 120px; /* MUCH smaller - was 200px */
        max-width: 280px; /* MUCH smaller - was 400px */
        align-self: center;
    }
    
    .epg-program-info {
        max-width: none;
        padding: 8px 0; /* Reduced padding */
    }
    
    .current-channel-name {
        font-size: 14px; /* MUCH smaller - was 24px */
        line-height: 1.2;
        margin-bottom: 4px;
    }
    
    .current-program-title {
        font-size: 14px; /* Slightly smaller but still prominent */
        line-height: 1.1; /* Tighter line height */
        margin-bottom: 2px; /* Much less spacing */
        text-align: center; /* Center text with logo */
    }
    
    .current-program-time {
        font-size: 11px; /* Smaller but readable */
        line-height: 1.1; /* Tighter line height */
        margin-bottom: 1px; /* Minimal spacing before description */
        text-align: center; /* Center with logo */
    }
    
    .current-program-desc {
        font-size: 9px; /* Smaller to fit more text */
        max-height: 55px; /* More height for description */
        line-height: 1.15; /* Tighter line spacing */
        overflow: hidden;
        text-align: left; /* Left-align description for readability */
        padding: 0 4px; /* Small padding */
    }
    
    .current-channel-logo {
        width: 40px; /* Larger for centered positioning */
        height: 30px; /* Larger for centered positioning */
        display: block; /* Block element for centering */
        margin: 0 auto 6px auto; /* Centered above program name */
        border-radius: 4px; /* Rounded corners */
    }

    /* CRITICAL: Logo centered above program name - vertical layout */
    .program-info-channel {
        display: block; /* Vertical stacking */
        text-align: center; /* Center everything */
        margin-bottom: 2px; /* Minimal spacing */
    }
    
    .corner-control-btn {
        width: 28px; /* MUCH smaller - was 40px */
        height: 28px; /* MUCH smaller - was 40px */
        font-size: 12px; /* MUCH smaller - was 16px */
    }
    
    /* EPG Grid - Mobile adjustments */
    .epg-channel-logo-cell {
        min-width: 80px;
        max-width: 80px;
        flex: 0 0 80px;
        padding: 8px;
    }
    
    .epg-channel-name-header {
        min-width: 80px;
        max-width: 80px;
        flex: 0 0 80px;
    }
    
    .epg-channel-logo-large {
        width: 35px;
        height: 26px;
    }
    
    .epg-channel-logo-fallback-large {
        width: 35px;
        height: 26px;
        font-size: 16px;
    }
    
    .epg-program-title {
        font-size: 10px;
    }
    
    .epg-program-time {
        font-size: 8px;
    }
    
    /* CRITICAL: Reduce channel row heights to show multiple channels */
    .epg-channel-row {
        min-height: 40px; /* MUCH smaller - was 60px */
        border-bottom: 1px solid #333;
    }
    
    .epg-time-cell {
        padding: 6px 4px; /* Reduced padding */
        font-size: 10px; /* Smaller text */
    }
    
    .epg-time-slot {
        min-width: 90px; /* Smaller - was 120px */
        padding: 8px 5px; /* Reduced padding */
        font-size: 10px; /* Smaller text */
    }
    
    /* CRITICAL: Make Back/Logout buttons TINY corner elements */
    .nav-btn, .category-btn, .back-btn, 
    #backToEPGCategories, #logoutBtn6,
    .btn-secondary {
        padding: 2px 6px !important; /* TINY buttons */
        font-size: 8px !important; /* TINY text */
        height: 20px !important; /* TINY height */
        min-width: 40px !important; /* Minimal width */
        border-radius: 10px !important; /* Rounded corners */
        margin: 2px !important; /* Tiny margins */
    }
    
    /* CRITICAL: Remove arrow from back button on mobile - not enough space */
    #backToEPGCategories {
        font-size: 0 !important; /* Hide original text */
    }
    
    #backToEPGCategories::after {
        content: "Back" !important; /* Show only "Back" without arrow */
        font-size: 8px !important; /* Restore font size */
    }
    
    /* CRITICAL: Hide category title completely */
    #epgCategoryTitle, .content-type-title, .category-title {
        display: none !important; /* Completely remove from layout */
    }
    
    /* CRITICAL: Remove header padding to save space */
    .app-header {
        padding: 4px 8px !important; /* Minimal padding */
        height: 32px !important; /* Tiny header */
        min-height: 32px !important;
    }
    
    /* CRITICAL: Ensure EPG grid takes remaining space and ONLY scrolls */
    .epg-channels-and-programs {
        flex: 1;
        overflow-y: auto; /* Only grid scrolls vertically */
        overflow-x: hidden; /* No horizontal page scroll */
        height: calc(100vh - 220px); /* Adjusted for tiny header + compact EPG header */
        min-height: 0; /* Allow flex shrinking */
    }
    
    /* CRITICAL: Move ESPN logo to program info area next to program name */
    .program-info-details {
        display: flex;
        flex-direction: column;
    }
    
    .current-program-title {
        display: flex;
        align-items: center;
        gap: 8px; /* Space between logo and title */
    }
    
    /* Move channel logo from under player to inside program title */
    .current-channel-logo {
        order: -1; /* Put logo first */
        width: 24px !important;
        height: 18px !important;
        flex-shrink: 0;
    }
    
    /* CRITICAL: EPG time navigation - only controls left/right arrows */
    .epg-time-navigation {
        flex-shrink: 0; /* Don't allow shrinking */
        height: 40px; /* Compact height */
        padding: 4px 8px; /* Minimal padding */
    }
    
    /* CRITICAL: EPG time header - static, no scrolling */
    .epg-time-header {
        flex-shrink: 0; /* Don't allow shrinking */
        position: sticky;
        top: 0;
        z-index: 10;
    }
}

.epg-program-block {
    min-width: 120px;
    border-right: 1px solid #404040;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #1a1a1a;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.epg-program-block:hover {
    background: rgba(0, 150, 255, 0.2);
    border-color: #0096FF;
}

.epg-program-block.current-program {
    background: rgba(255, 0, 0, 0.15);
    border-color: #ff0000;
}

.epg-program-title {
    font-weight: 600;
    color: #fff;
    font-size: 0.85em;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.epg-program-time {
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2px;
}

.epg-program-desc {
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.epg-loading, .epg-category-loading {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1em;
}

/* TV/Large Screen Optimizations */
@media (min-width: 1920px) {
    .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 30px;
    }
    
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 25px;
    }
    
    .channel-logo {
        width: 100px;
        height: 100px;
    }
}

/* EPG Corner Player Controls */
.epg-corner-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 1000;
    pointer-events: auto;
}

.epg-corner-btn {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.epg-corner-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.epg-corner-btn svg {
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.epg-corner-btn:hover svg {
    opacity: 1;
}

.epg-fullscreen-btn:hover {
    background: rgba(33, 150, 243, 0.2);
    border-color: rgba(33, 150, 243, 0.5);
}

.epg-close-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.5);
}

/* TV Remote: focused EPG row highlight (applied only via JS on Tizen/webOS 4K) */
.tv-remote-focused-row {
  outline: 2px solid #00d9ff;
  background: rgba(0, 217, 255, 0.08);
  border-radius: 6px;
}
