:root {
    --bg-dark: #090d16;
    --bg-card: rgba(22, 30, 46, 0.75);
    --bg-card-hover: rgba(30, 42, 66, 0.95);
    --primary: #ff477e;
    --primary-glow: rgba(255, 71, 126, 0.35);
    --accent: #7000ff;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --radius-lg: 18px;
    --radius-md: 12px;
    --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.4);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 71, 126, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(112, 0, 255, 0.12) 0%, transparent 40%);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    padding-bottom: 60px;
    touch-action: manipulation;
}

/* High Visibility Focus States for Android TV Remote D-Pad Navigation */
:focus-visible, button:focus, input:focus, .video-card:focus, .season-pill:focus, a:focus {
    outline: 3px solid var(--primary) !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 25px rgba(255, 71, 126, 0.85) !important;
    transform: scale(1.04);
    z-index: 10;
}

.app-wrapper {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Header */
.main-header {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-soft);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-hub-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.back-hub-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: translateX(-3px);
}

.logo-icon {
    font-size: 2.6rem;
    background: linear-gradient(135deg, #ff477e, #ff8fa3);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 0 20px var(--primary-glow);
    overflow: hidden;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-icon.bluey-theme {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

h1 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(90deg, #ffffff, #ff8fa3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge-english {
    background: linear-gradient(135deg, #7000ff, #ff477e);
    -webkit-text-fill-color: #fff;
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    vertical-align: middle;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 4px;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 14px;
}

.play-all-btn {
    background: linear-gradient(135deg, #7000ff, #ff477e);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 30px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(112, 0, 255, 0.4);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.play-all-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(255, 71, 126, 0.6);
}

.stat-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-badge.highlight {
    background: linear-gradient(135deg, rgba(255, 71, 126, 0.2), rgba(112, 0, 255, 0.2));
    border-color: rgba(255, 71, 126, 0.4);
    font-weight: 600;
    color: #ff8fa3;
}

/* Controls */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 28px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    opacity: 0.6;
}

.search-box input {
    width: 100%;
    background: rgba(22, 30, 46, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px 20px 14px 50px;
    color: #fff;
    font-size: 1rem;
    font-family: var(--font-body);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 16px var(--primary-glow);
}

.clear-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
}

/* Season Filters */
.season-filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.season-filter-bar::-webkit-scrollbar {
    height: 4px;
}
.season-filter-bar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.season-pill {
    background: rgba(22, 30, 46, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s ease;
}

.season-pill:hover {
    background: rgba(255, 71, 126, 0.15);
    color: #fff;
    border-color: rgba(255, 71, 126, 0.4);
}

.season-pill.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 4px 16px var(--primary-glow);
}

/* Video Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 22px;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    backdrop-filter: blur(12px);
    cursor: pointer;
    user-select: none;
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-soft), 0 0 20px rgba(255, 71, 126, 0.25);
    border-color: rgba(255, 71, 126, 0.5);
    background: var(--bg-card-hover);
}

.thumbnail-box {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 ratio */
    background: #000;
    overflow: hidden;
}

.thumbnail-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.video-card:hover .thumbnail-box img {
    transform: scale(1.06);
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-card:hover .play-overlay {
    opacity: 1;
}

.play-btn-circle {
    width: 52px;
    height: 52px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    padding-left: 4px;
    box-shadow: 0 0 20px var(--primary-glow);
}

.duration-tag {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
}

.card-info {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.season-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ff8fa3;
    background: rgba(255, 71, 126, 0.15);
    padding: 3px 9px;
    border-radius: 8px;
}

.ep-num {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.title-en {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.35;
    margin-bottom: 6px;
}

.title-vi {
    font-size: 0.88rem;
    color: #cbd5e1;
    line-height: 1.3;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: rgba(22, 30, 46, 0.4);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* Modal Backdrop & Popup */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.closed {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.modal-content {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 920px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 71, 126, 0.2);
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.modal-close:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.1);
}

/* Player Container 16:9 Aspect Ratio */
.player-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 ratio */
    background: #000;
    overflow: hidden;
}

#player-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#player-wrapper iframe, #yt-player-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0;
}

/* Opaque Visual Mask Box covering specifically 'More videos' (Bottom-Left) */
.yt-mask-box {
    position: absolute;
    z-index: 12;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    pointer-events: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    user-select: none;
}

.yt-mask-left {
    bottom: 34px;
    left: 12px;
    height: 48px;
    min-width: 220px;
    border-radius: 14px;
}

.mask-icon {
    font-size: 1.3rem;
}

.mask-text {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: #f1f5f9;
}

/* Full transparent shield overlay */
.yt-full-shield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 15;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.shield-play-icon {
    width: 70px;
    height: 70px;
    background: rgba(255, 71, 126, 0.85);
    border-radius: 50%;
    color: #fff;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 4px;
    box-shadow: 0 0 30px rgba(255, 71, 126, 0.6);
    pointer-events: none;
    animation: pulseIcon 0.4s ease;
}

@keyframes pulseIcon {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Next Countdown Overlay */
.countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 13, 22, 0.94);
    backdrop-filter: blur(10px);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.countdown-box {
    max-width: 480px;
}

.next-label {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ff8fa3;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.countdown-num {
    font-family: var(--font-heading);
    font-size: 3.8rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-bottom: 12px;
    text-shadow: 0 0 20px var(--primary-glow);
}

#next-title-preview {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 20px;
}

.countdown-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 30px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--primary-glow);
    transition: transform 0.2s ease;
}
.btn-primary:hover { transform: scale(1.05); }

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    border: 1px solid var(--border-color);
    padding: 10px 22px;
    border-radius: 30px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }

/* Modal Info Footer */
.modal-info {
    padding: 20px 24px;
}

.modal-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.modal-info h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}

.modal-sub {
    color: #94a3b8;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Autoplay Toggle Switch */
.autoplay-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    user-select: none;
}

.autoplay-toggle input {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background: #334155;
    border-radius: 20px;
    position: relative;
    transition: background 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: transform 0.3s ease;
}

.autoplay-toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.autoplay-toggle input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.toggle-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
}

.modal-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.tag {
    font-size: 0.82rem;
    padding: 4px 10px;
    border-radius: 6px;
}

.season-tag { background: rgba(255,71,126,0.2); color: #ff8fa3; font-weight: 600; }
.length-tag { background: rgba(255,255,255,0.1); color: #e2e8f0; }

.player-nav-btns {
    display: flex;
    gap: 10px;
    margin-left: auto;
    align-items: center;
    flex-wrap: wrap;
}

.nav-ep-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: #f1f5f9;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-ep-btn.fs-btn {
    background: rgba(112, 0, 255, 0.25);
    border-color: rgba(112, 0, 255, 0.5);
    color: #c084fc;
}

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

.nav-ep-btn.highlight {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-color: transparent;
    box-shadow: 0 4px 14px var(--primary-glow);
}

/* TV & Large Display 10ft UI Optimization */
@media (min-width: 1400px) {
    .app-wrapper {
        max-width: 1600px;
        padding: 40px;
    }
    h1 { font-size: 2.2rem; }
    .season-pill { font-size: 1.05rem; padding: 12px 26px; }
    .title-en { font-size: 1.25rem; }
}

@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
        gap: 16px;
    }
    .main-header { padding: 18px 20px; }
    .modal-content { border-radius: 12px; }
}
