/* TV Player Styles (Performance Optimized for Large EPG on Older Devices) */

/* Global TV variables */
#tv-view {
    --tv-accent: #00BFFF;
    --tv-bg: #121212;
    --tv-panel: #1e1e1e;
    --tv-border: #333;
    --tv-bar-height: 28px;
    --tv-group-height: 25px;
    --tv-row-height: 45px;
    --tv-ch-width: 80px;
    --tv-prog-bg: #333;
    --tv-current-bg: #00BFFF;

    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.tv-video-container { flex-shrink: 0; }

/* Controls Container */
#tv-controls {
    display: flex; flex-direction: column;
    background: var(--tv-panel); flex-shrink: 0;
}

.bar-channel, .bar-program, .bar-search {
    height: var(--tv-bar-height); border-bottom: 1px solid var(--tv-border);
    display: flex; align-items: center; padding: 0 10px; box-sizing: border-box; transition: background-color 0.3s;
}

.bar-channel { background: var(--tv-panel); justify-content: space-between; }
.bar-channel.bg-active { background: #004085 !important; }

.ch-info-box { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; flex: 1; min-width: 0; }
.ch-name { font-size: 13px; font-weight: bold; color: #fff; overflow: hidden; text-overflow: ellipsis; }
.ch-separator { color: #666; font-size: 12px; margin-top: 1px; flex-shrink: 0; }
.ch-group { font-size: 11px; color: #ccc; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.ch-playlist { font-size: 11px; color: #888; overflow: hidden; text-overflow: ellipsis; }

/* Group filter button: inherits #ccc from .btn-ctrl when no group active */
#btn-group-filter { color: #ccc; }

.stat-badges { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.badge { font-size: 9px; font-weight: bold; padding: 2px 4px; border-radius: 3px; background: #333; color: #aaa; border: 1px solid #444; min-width: 35px; text-align: center; }
.badge.interactive { cursor: pointer; min-width: 55px; color: #fff; border-color: #666; }
.badge.interactive:active { background: #555; color: #fff; }
#badge-info { font-size: 11px; font-weight: 700; min-width: 60px; }
#badge-res, #badge-fps { color: #aaa; border-color: #444; }

/* 進度條 (GPU 加速) */
.bar-program {
    --prog-percent: 0%;
    justify-content: space-between; background: #252525; font-size: 11px; position: relative; overflow: hidden;
    cursor: pointer;
}
.bar-program::before {
    content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: var(--prog-percent);
    background: rgba(0, 86, 179, 0.8); transition: width 0.5s linear; z-index: 1; will-change: width;
}
.bar-program.scrubbing-active::before {
    background: rgba(0, 191, 255, 0.6) !important;
    transition: none !important;
}

.prog-title { font-size: 12px; color: #ddd; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; position: relative; z-index: 2; }
.prog-time { font-size: 10px; color: #fff; position: relative; z-index: 2; text-shadow: 0 1px 2px #000; }

.bar-search { background: var(--tv-panel); gap: 12px; }
.tv-search-input { flex-grow: 1; height: 22px; padding: 0 8px; border-radius: 3px; border: 1px solid #444; background: #333; color: white; font-size: 11px; outline: none; min-width: 0; }
.tv-search-input:focus { border-color: #555; }
.btn-ctrl { width: 30px; height: 30px; background: transparent; color: #ccc; border: none; cursor: pointer; font-size: 19px; display: flex; align-items: center; justify-content: center; transition: color 0.2s, filter 0.2s; flex-shrink: 0; }
.btn-ctrl:hover { color: #fff; }
.btn-ctrl:active { color: var(--tv-accent); transform: scale(0.95); }
#btn-bg-mode { filter: grayscale(100%) brightness(1.2); }
#btn-bg-mode.active-mode { filter: none; color: #4CAF50; text-shadow: 0 0 5px rgba(76, 175, 80, 0.5); }

/* Main TV Content */
#tv-content { flex: 1; position: relative; overflow: hidden; background: var(--tv-bg); min-height: 0; }

.view-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; background: var(--tv-bg); contain: content; }
#view-epg { z-index: 1; } #view-grid { z-index: 2; } #view-list { z-index: 3; }

/* Grid View */
.grid-wrapper { padding: 0 8px; overflow-y: auto; scrollbar-gutter: stable; height: 100%; width: 100%; position: relative; }
.grid-container { display: grid; grid-template-columns: repeat(var(--grid-cols, 5), 1fr); gap: 3px; padding-bottom: 20px; }
.grid-group-header { grid-column: 1 / -1; background: #555; color: #fff; font-size: 12px; font-weight: bold; padding: 4px 10px; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); margin-top: 0; margin-bottom: 2px; border-radius: 0 0 4px 4px; }
.grid-item { height: 96px; background: var(--tv-panel); border-radius: 6px; overflow: hidden; cursor: pointer; border: 2px solid transparent; display: flex; flex-direction: column; padding: 6px 5px; align-items: center; justify-content: flex-start; box-sizing: border-box; }
.grid-item.active { border: 2px solid var(--tv-accent); background: #252525; }
.grid-thumb { width: 95%; height: 48px; aspect-ratio: 4 / 3; background: #fff; border-radius: 3px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; margin: 0 auto 4px auto; position: relative; }
.grid-thumb img { width: 95%; height: 95%; object-fit: contain; z-index: 1; }
.fallback-text { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #333; color: #888; font-weight: bold; font-size: 16px; z-index: 0; }
.grid-info { width: 92%; text-align: center; overflow: hidden; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.grid-title { font-size: 11px; font-weight: bold; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0px; line-height: 14px; height: 14px; }
.grid-prog { font-size: 9px; color: #aaa; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 12px; line-height: 12px; text-align: center; width: 100%; display: block; }

/* EPG View */
.epg-grid-container {
    display: grid; grid-template-columns: var(--tv-ch-width) 1fr; grid-template-rows: var(--tv-bar-height) 1fr;
    height: 100%; width: 100%; overflow: auto; background: var(--tv-bg);
}
.epg-grid-container.dragging-scroll { cursor: grabbing !important; user-select: none; }
.epg-grid-container:not(.dragging-scroll) { cursor: default; }

.corner-cell {
    grid-column: 1/2; grid-row: 1/2; background: #555; border-bottom: 1px solid var(--tv-border); border-right: 1px solid var(--tv-border);
    position: sticky; top: 0; left: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: bold; color: #fff; text-align: center; cursor: pointer;
}

.timeline-header {
    grid-column: 2/3; grid-row: 1/2; background: #222; border-bottom: 1px solid var(--tv-border);
    position: sticky; top: 0; z-index: 40; overflow: hidden; cursor: pointer;
}
.timeline-track { display: flex; height: 100%; overflow: hidden; }
.time-marker {
    flex-shrink: 0; border-right: 1px solid #444; display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: #aaa; white-space: pre-line; text-align: center; line-height: 1.1;
}

.channels-col {
    grid-column: 1/2; grid-row: 2/3; background: #222; border-right: 1px solid var(--tv-border);
    position: sticky; left: 0; z-index: 38;
}

.channel-cell {
    height: var(--tv-row-height); border-bottom: 1px solid var(--tv-border);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2px; cursor: pointer; overflow: hidden;
}
.channel-cell.active { background: #1976D2; border-color: #BBDEFB; box-shadow: inset 0 0 10px rgba(0,0,0,0.5); }
.channel-cell:hover { background: #333; }
.ch-logo { width: 100%; height: 100%; object-fit: contain; background: #fff; border-radius: 2px; }
.ch-text { font-size: 10px; margin-top: 1px; text-align: center; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-container { position: relative; width: 45px; height: 28px; background: #fff; padding: 1px; border-radius: 2px; flex-shrink: 0; }
.logo-container img { width: 100%; height: 100%; object-fit: contain; }
.ch-fallback { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #444; color: #fff; font-size: 11px; font-weight: bold; display: flex; align-items: center; justify-content: center; border-radius: 2px; }

.group-header-cell { height: var(--tv-group-height); background: #555; color: #fff; font-size: 12px; font-weight: bold; display: flex; align-items: center; justify-content: center; padding: 0 4px; border-bottom: 1px solid #666; position: sticky; top: var(--tv-bar-height); z-index: 39; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-sizing: border-box; }
.group-header-row-empty { height: var(--tv-group-height); background: #555; border-bottom: 1px solid #666; position: sticky; top: var(--tv-bar-height); z-index: 35; width: 100%; box-sizing: border-box; }

.programs-area { grid-column: 2/3; grid-row: 2/3; background: var(--tv-panel); position: relative; }
.program-track { position: relative; }

/* 效能優化：讓瀏覽器忽略螢幕外的行渲染 */
.program-row {
    height: var(--tv-row-height); border-bottom: 1px solid var(--tv-border);
    position: relative; background: var(--tv-panel);
    content-visibility: auto; contain-intrinsic-size: var(--tv-row-height); 
}

/* 移除 transform GPU 加速，改回傳統佈局，避免 6 天資料塞爆 VRAM */
.prog-block {
    position: absolute; top: 2px; bottom: 2px;
    background: #333; border-left: 1px solid #555; padding: 2px 5px; font-size: 11.5px;
    display: flex; flex-direction: column; justify-content: center; overflow: hidden;
    white-space: nowrap; text-overflow: ellipsis; border-radius: 2px; color: #ddd; z-index: 1; cursor: pointer;
}
.prog-block.current { background: var(--tv-accent) !important; color: #000 !important; font-weight: bold; z-index: 2; border: 1px solid rgba(255, 255, 255, 0.7); }
.prog-block.playing-catchup { background: #90EE90 !important; color: #000 !important; font-weight: bold; z-index: 3; border: 1px solid #fff; }

/* 紅線依然保持 GPU 加速 */
.now-line {
    position: absolute; top: 0; bottom: 0; width: 2px; background: red; z-index: 10; display: none; pointer-events: none; left: 0;
    will-change: transform; transform: translate3d(var(--now-line-x, 0px), 0, 0);
}

/* Modals */
.tv-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.85); z-index: 2147483647; display: flex; align-items: center; justify-content: center; }
.tv-modal-box { background: #252525; padding: 15px; width: 95%; max-width: 400px; border-radius: 12px; border: 1px solid #444; color: #fff; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; }
.tv-modal-title { font-size: 16px; font-weight: bold; margin-bottom: 10px; color: var(--tv-accent); display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }

/* Playlist Form Styles */
.playlist-list { 
    margin-bottom: 10px; 
    border: none; 
    flex: 1; 
    min-height: 200px; 
    overflow-y: auto; 
    overflow-x: hidden;
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    padding: 6px;
    position: relative;
}
.playlist-item { 
    display: flex; 
    flex-direction: column; 
    padding: 12px 14px; 
    background: linear-gradient(145deg, rgba(40, 40, 40, 0.85), rgba(25, 25, 25, 0.9));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px; 
    cursor: pointer; 
    user-select: none; 
    position: relative;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    gap: 4px;
}
.playlist-item:hover {
    background: linear-gradient(145deg, rgba(45, 45, 45, 0.9), rgba(30, 30, 30, 0.95));
    border-color: rgba(255, 255, 255, 0.12);
}
.playlist-item.active-list { 
    border-color: var(--tv-accent); 
    background: linear-gradient(145deg, rgba(0, 191, 255, 0.08), rgba(20, 20, 20, 0.95));
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.1);
}
.playlist-item.active-list::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: var(--tv-accent);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 8px var(--tv-accent);
}
/* iOS TableView Style Active Dragging Item */
.playlist-item.is-dragging { 
    z-index: 50 !important;
    touch-action: none !important;
    transition: none !important;
    opacity: 1 !important;
    border-color: var(--tv-accent) !important;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.75), 0 0 18px rgba(0, 191, 255, 0.45) !important;
    background: linear-gradient(145deg, rgba(48, 48, 48, 0.98), rgba(28, 28, 28, 0.98)) !important;
    cursor: grabbing !important;
}
.pl-info { width: 100%; display: flex; flex-direction: column; gap: 2px; padding-right: 70px; box-sizing: border-box; }
.pl-info:active { opacity: 0.7; }
.pl-name { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 0; }
.pl-url { font-size: 11px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; font-family: 'JetBrains Mono', 'Consolas', monospace; opacity: 0.7; }
.pl-meta { 
    font-size: 10px; 
    color: #999; 
    margin-top: 6px; 
    display: flex; 
    gap: 12px; 
    border-top: 1px solid rgba(255, 255, 255, 0.04); 
    padding-top: 6px;
    align-items: center;
}
.pl-meta span { display: flex; align-items: center; gap: 4px; }
.pl-meta i { color: var(--tv-accent); font-size: 12px; opacity: 0.9; }
.pl-actions { 
    position: absolute; 
    right: 8px; 
    top: 10px; 
    display: flex;
    align-items: center;
    gap: 6px;
}
.pl-drag-handle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 15px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pl-drag-handle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}
.pl-drag-handle:active,
.playlist-item.is-dragging .pl-drag-handle {
    cursor: grabbing;
    color: var(--tv-accent);
    background: rgba(0, 191, 255, 0.15);
    border-color: var(--tv-accent);
}
.btn-mini { height: 28px; min-width: 28px; width: auto; padding: 0 10px; font-size: 12px; border-radius: 6px; border: none; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; font-weight: 600; }
.btn-mini:active { transform: scale(0.95); }
.btn-edit { width: 28px; height: 28px; padding: 0; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); color: #bbb; } 
.btn-edit:hover { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.btn-add { background: #2ea44f !important; box-shadow: 0 2px 4px rgba(46, 164, 79, 0.2); }
.btn-add:hover { background: #34bc5a !important; }
.form-label { font-size: 11px; color: #aaa; margin-bottom: 3px; display: block; font-weight: bold; }
.full-input, .full-select { width: 100%; padding: 10px; background: #111; border: 1px solid #444; color: #fff; font-size: 13px; border-radius: 4px; margin-bottom: 10px; box-sizing: border-box; outline: none; }
.full-input:focus { border-color: var(--tv-accent); }
.section-box { background: #333; padding: 12px; border-radius: 6px; border: 1px solid #444; margin-bottom: 12px; }
.shift-btn { width: 36px; height: 36px; background: #444; border-radius: 4px; border: 1px solid #555; color: #fff; font-size: 20px; font-weight: bold; cursor: pointer; }

/* Toggle Button Style */
.toggle-btn { background: #444; color: #aaa; border: 1px solid #555; padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: bold; cursor: pointer; transition: all 0.2s; }
.toggle-btn.active { background: var(--tv-accent); color: #000; border-color: var(--tv-accent); }

/* Data Usage Styles */
.du-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid #444; padding-bottom: 10px; }
.du-title { font-size: 18px; font-weight: bold; color: var(--tv-accent); }
.du-month { font-size: 14px; color: #ccc; }
.du-total-box { background: #333; padding: 10px; border-radius: 6px; text-align: center; margin-bottom: 15px; border: 1px solid #555; }
.du-total-label { font-size: 12px; color: #aaa; text-transform: uppercase; letter-spacing: 1px; }
.du-total-value { font-size: 24px; font-weight: bold; color: #fff; margin-top: 5px; }
.du-toggle-row { display: flex; justify-content: center; gap: 10px; margin-bottom: 15px; }
.du-btn { padding: 6px 12px; font-size: 12px; background: #444; border: none; border-radius: 4px; cursor: pointer; color: #bbb; transition: 0.2s; }
.du-btn.active { background: var(--tv-accent); color: #000; font-weight: bold; }
.du-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.du-col { flex: 1; min-width: 140px; background: #222; border-radius: 6px; padding: 8px; }
.du-row { display: flex; justify-content: space-between; font-size: 11px; padding: 4px 6px; border-bottom: 1px solid #333; color: #ddd; }
.du-row:last-child { border-bottom: none; }

/* Video Overlays */
#video-gesture-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; cursor: pointer; background: transparent; touch-action: none; }
#play-icon-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 60px; color: rgba(255, 255, 255, 0.9); pointer-events: none; z-index: 11; opacity: 0; transition: opacity 0.2s; text-shadow: 0 2px 10px #000; }
#fs-info-bar { 
    position: absolute; bottom: 70px; left: 4%; width: 92%; 
    background: rgba(0, 0, 0, 0.85); 
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    padding: 15px 20px; z-index: 100; pointer-events: none; 
    display: none; opacity: 0; transition: opacity 0.3s ease; 
    flex-direction: column; gap: 8px; 
    box-sizing: border-box;
}

.tv-video-container.show-info #fs-info-bar { opacity: 1; }

.fs-top-row { display: flex; align-items: center; gap: 15px; width: 100%; }

.fs-logo { 
    height: 44px; width: 44px; object-fit: contain; 
    background: #fff; border-radius: 4px; padding: 2px; flex-shrink: 0;
}

.fs-text-col { display: flex; flex-direction: column; color: #ffffff !important; text-shadow: 0 2px 4px #000; flex-grow: 1; min-width: 0; }

.fs-ch-name { 
    font-size: 24px; font-weight: bold; color: var(--tv-accent) !important; 
    margin: 0; line-height: 1.1;
}

.fs-prog-now { 
    font-size: 18px; font-weight: 600; color: #ffffff !important; 
    margin-top: 5px; line-height: 1.2;
}

.fs-prog-next { 
    font-size: 14px; color: #aaaaaa !important; margin-top: 4px;
}

.fs-progress-bg { 
    width: 100%; height: 6px; background: rgba(255, 255, 255, 0.2); border-radius: 3px; 
    margin-top: 15px; cursor: pointer; pointer-events: auto; position: relative;
}
.fs-progress-bg::after {
    content: ''; position: absolute; top: -12px; bottom: -12px; left: 0; right: 0; z-index: 1;
}
.fs-progress-fill { height: 100%; background: var(--tv-accent); width: 0%; transition: width 0.5s ease; position: relative; z-index: 2; }
.fs-progress-bg.scrubbing-active .fs-progress-fill { transition: none !important; background: #fff; box-shadow: 0 0 10px #fff; }
#video-placeholder { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #000; color: #555; font-size: 6.5vw; font-weight: bold; font-style: italic; display: flex; align-items: center; justify-content: center; z-index: 2; pointer-events: none; }

/* Fullscreen Fixes */
/* Video Container Stability (Legacy Hack for Older Android) */
.tv-video-container { 
    width: 100%; 
    height: 0; 
    padding-bottom: 56.25%; 
    background: #000; 
    position: relative; 
    overflow: hidden;
    /* Pixel Stability Locks */
    font-size: 0;
    line-height: 0;
    transform: translateZ(0); /* Force GPU acceleration immediately */
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.tv-video-container:fullscreen, .tv-video-container:-webkit-full-screen { 
    width: 100% !important; 
    height: 100% !important; 
    padding-bottom: 0 !important; 
}

#tv-player { 
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
    display: block; /* Eliminate descender space */
}

/* Program Reminders & Slide-down Banner */
.reminder-list {
    max-height: 140px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 6px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
}
.reminder-list:empty::after {
    content: 'No active reminders';
    display: block;
    text-align: center;
    color: #666;
    font-size: 11px;
    padding: 10px 0;
}
.reminder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    border-left: 3px solid var(--tv-accent);
}
.reminder-item-info {
    flex: 1;
    min-width: 0;
    padding-right: 8px;
    text-align: left;
}
.reminder-item-title {
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reminder-item-meta {
    font-size: 10px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.btn-remove-reminder {
    background: transparent;
    border: none;
    color: #e50914;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}
.btn-remove-reminder:hover {
    opacity: 0.8;
}

.tv-reminder-banner {
    position: absolute;
    top: -100px;
    left: 10px;
    right: 10px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid var(--tv-accent);
    border-radius: 8px;
    padding: 10px 14px;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.tv-reminder-banner.show {
    top: 10px;
}
.rb-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.rb-text {
    flex: 1;
    min-width: 0;
    text-align: left;
}
.rb-actions {
    display: flex;
    gap: 6px;
    margin-left: 10px;
}
.rb-btn {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.rb-btn.watch {
    background: var(--tv-accent);
    color: #000;
}
.rb-btn.watch:active {
    transform: scale(0.95);
}
.rb-btn.close {
    background: #444;
    color: #ccc;
    min-width: 25px;
    padding: 5px;
}

/* Settings sliding pages layout */
.settings-viewport {
    width: 100%;
    overflow: hidden;
    position: relative;
    flex: 1;
    min-height: 250px;
    margin-bottom: 12px;
}

.settings-slider {
    display: flex;
    width: 200%;
    height: 100%;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.settings-slide {
    width: 50%;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 0 4px;
}

.settings-nav-header {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

.settings-tab {
    font-size: 13px;
    color: #888;
    cursor: pointer;
    font-weight: bold;
    padding: 4px 8px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-tab:hover {
    color: #fff;
}

.settings-tab.active {
    color: var(--tv-accent);
    border-bottom-color: var(--tv-accent);
}

@media (max-width: 768px) and (orientation: portrait) {
    #play-icon-overlay {
        font-size: 36px !important;
    }
}

/* Android Native player: hide the HTML5 video element when native player is active */
body.android-native-active #tv-player {
    opacity: 0;
    pointer-events: none;
}
body.android-native-active .tv-video-container {
    background: transparent !important;
}
html.android-native-active,
body.android-native-active {
    background: transparent !important;
}

.tv-video-container.pseudo-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    background: transparent !important;
}

body.pseudo-fullscreen-active #tv-content,
body.pseudo-fullscreen-active #tv-controls,
body.pseudo-fullscreen-active .player-module,
body.pseudo-fullscreen-active .bottom-nav {
    display: none !important;
}

/* Spinner and buffering state styles */
#video-placeholder.buffering {
    background: transparent !important;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    border-top-color: var(--tv-accent, #7C3AED);
    animation: placeholder-spin 0.8s linear infinite;
}

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

/* Catchup Playback Interrupted / Resume Overlay */
.tv-catchup-resume-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 120;
    padding: 16px;
    box-sizing: border-box;
    text-align: center;
}

.tv-catchup-resume-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--tv-accent, #00BFFF);
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 12px;
    box-shadow: 0 4px 15px rgba(0, 191, 255, 0.4);
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    outline: none;
}

.tv-catchup-resume-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 191, 255, 0.6);
}

.tv-catchup-resume-btn:active {
    transform: scale(0.95);
}

.tv-catchup-resume-title {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    max-width: 85%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.tv-catchup-resume-info {
    font-size: 12px;
    color: #00BFFF;
    margin-bottom: 12px;
}

.tv-catchup-close-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #ddd;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.tv-catchup-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* Portrait Video Mode Transitions & Layout */
#tv-controls,
#tv-content,
.bottom-nav {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.portrait-video-mode {
    overflow: hidden;
}

/* In non-Android mode, set background to black */
html:not(.android-native-active).portrait-video-mode,
body:not(.android-native-active).portrait-video-mode {
    background: #000 !important;
}

/* In Android Native mode, ensure WebView stays 100% transparent so native ExoPlayer shows through */
html.android-native-active,
body.android-native-active,
body.android-native-active #tv-view,
body.android-native-active .content-area,
body.android-native-active .tv-video-container {
    background: transparent !important;
}

body.portrait-video-mode #tv-controls,
body.portrait-video-mode #tv-content,
body.portrait-video-mode .bottom-nav,
body.portrait-video-mode #video-placeholder {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    display: none !important;
}

body.portrait-video-mode .tv-video-container {
    transform: translate3d(0, var(--portrait-video-y, calc(50vh - 28.125vw)), 0);
    z-index: 100;
    overflow: visible;
}

body.portrait-video-mode #fs-info-bar {
    top: calc(100% + 14px);
    bottom: auto;
    left: 4%;
    width: 92%;
}

