:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-hover: #252525;
    --card: #181818;
    --text: #ffffff;
    --text-muted: #a0a0a0;
    --accent: #e50914;
    --accent-hover: #f40612;
    --border: #2a2a2a;
    --radius: 6px;
    --shadow: 0 4px 20px rgba(0,0,0,0.5);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4%;
    height: 68px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
    transition: background 0.3s;
}

.navbar.scrolled {
    background: rgba(15,15,15,0.95);
    backdrop-filter: blur(10px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.nav-brand svg { color: var(--accent); }

.nav-search {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s;
    max-width: 400px;
    width: 100%;
}

.nav-search:focus-within {
    border-color: rgba(255,255,255,0.4);
    background: rgba(0,0,0,0.8);
}

.nav-search input {
    background: transparent;
    border: none;
    color: var(--text);
    padding: 8px 14px;
    font-size: 0.9rem;
    outline: none;
    width: 100%;
}

.nav-search input::placeholder { color: var(--text-muted); }

.nav-search button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-search button:hover { color: var(--text); }

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-link {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 0;
    position: relative;
    transition: color 0.2s;
}

.nav-link:hover { color: var(--text); }

.nav-link.active {
    color: var(--text);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

/* Hero */
.hero {
    position: relative;
    height: 85vh;
    min-height: 500px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.hero-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
    transition: background-image 0.5s;
}

.hero-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg) 0%, rgba(15,15,15,0.4) 50%, rgba(15,15,15,0.2) 100%);
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 0 4% 60px;
    max-width: 600px;
}

.hero-content h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.hero-content p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: rgba(255,255,255,0.85);
    margin-bottom: 24px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-buttons {
    display: flex;
    gap: 12px;
}

.btn-play {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--text);
    color: var(--bg);
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-play:hover { transform: scale(1.05); opacity: 0.9; }

.btn-more {
    background: rgba(255,255,255,0.15);
    color: var(--text);
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.btn-more:hover { background: rgba(255,255,255,0.25); }

.hero-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(to top, var(--bg), transparent);
    z-index: 1;
}

/* Main Content */
.main-content {
    padding: 20px 0 60px;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Rows */
.row {
    margin-bottom: 40px;
    padding: 0 4%;
}

.row-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.row-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface) transparent;
}

.row-scroll::-webkit-scrollbar { height: 6px; }
.row-scroll::-webkit-scrollbar-track { background: transparent; }
.row-scroll::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 3px; }

/* Card */
.card {
    flex-shrink: 0;
    width: 200px;
    cursor: pointer;
    transition: transform 0.3s, z-index 0s;
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
}

.card:hover {
    transform: scale(1.08);
    z-index: 10;
}

/* Delete button (appears on hover) */
.card-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(229, 9, 20, 0.9);
    color: white;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-bottom: 2px;
}

.card:hover .card-delete {
    opacity: 1;
}

.card-delete:hover {
    background: var(--accent-hover);
    transform: scale(1.15);
}

.card-img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius);
    display: block;
    background: var(--surface);
}

.card-info {
    padding: 10px 4px;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-rating {
    color: #46d369;
    font-weight: 700;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 0 4%;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    padding: 20px 4%;
    margin-bottom: 10px;
}

/* ==================== DETAIL PAGE ==================== */

.detail-page {
    min-height: 100vh;
}

.detail-hero {
    position: relative;
    height: 70vh;
    min-height: 500px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.detail-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
}

.detail-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg) 0%, rgba(15,15,15,0.5) 40%, rgba(15,15,15,0.3) 100%);
}

.detail-hero-content {
    position: relative;
    z-index: 2;
    padding: 0 4% 40px;
    display: flex;
    gap: 32px;
    align-items: flex-end;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.detail-poster {
    flex-shrink: 0;
    width: 220px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    display: none;
}

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

.detail-hero-info {
    flex: 1;
    padding-bottom: 8px;
}

.detail-hero-info h1 {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    text-shadow: 0 2px 20px rgba(0,0,0,0.8);
    line-height: 1.1;
}

.detail-year {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.7em;
}

.detail-tagline {
    font-size: 1.1rem;
    font-style: italic;
    color: rgba(255,255,255,0.7);
    margin-bottom: 16px;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.detail-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 1rem;
}

.detail-rating .star {
    color: #ffd700;
    font-size: 1.1rem;
}

.cert-badge {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.detail-actions {
    display: flex;
    gap: 12px;
}

.detail-body {
    padding: 40px 4%;
    max-width: 1400px;
    margin: 0 auto;
}

.detail-section {
    margin-bottom: 48px;
}

.detail-section h2,
.detail-section h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-overview p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: rgba(255,255,255,0.85);
    max-width: 800px;
}

/* Cast */
.cast-row {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface) transparent;
}

.cast-row::-webkit-scrollbar { height: 6px; }
.cast-row::-webkit-scrollbar-track { background: transparent; }
.cast-row::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 3px; }

.cast-card {
    flex-shrink: 0;
    width: 120px;
    text-align: center;
}

.cast-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 8px;
    background: var(--surface-hover);
    margin-bottom: 8px;
}

.cast-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cast-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Content Advisory */
.advisory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.advisory-item {
    background: var(--surface);
    border-radius: 10px;
    padding: 16px 20px;
    border: 1px solid var(--border);
}

.advisory-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.advisory-bar {
    display: flex;
    gap: 4px;
    height: 8px;
    margin-bottom: 8px;
}

.advisory-bar-segment {
    flex: 1;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.3s;
}

.advisory-bar-segment.active {
    background: var(--segment-color, var(--accent));
    box-shadow: 0 0 8px var(--segment-color, var(--accent));
}

.advisory-level {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.advisory-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 16px;
    font-style: italic;
}

/* Keyword tags */
.keyword-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-tag {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Detail info grid */
.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.detail-info-item {
    background: var(--surface);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Trailer */
.trailer-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.trailer-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Detail seasons */
.detail-seasons-list {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.detail-seasons-list .season-card {
    flex-shrink: 0;
    width: 160px;
    cursor: pointer;
    transition: transform 0.2s;
}

.detail-seasons-list .season-card:hover { transform: scale(1.05); }

.detail-seasons-list .season-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--surface-hover);
}

.detail-seasons-list .s-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-seasons-list .s-episodes {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Detail loading */
.detail-loading {
    min-height: 100vh;
    padding-top: 68px;
}

.detail-skeleton-backdrop {
    height: 50vh;
    width: 100%;
}

.detail-loading-content {
    padding: 40px 4%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

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

.modal {
    background: var(--surface);
    border-radius: 12px;
    max-width: 850px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(0,0,0,0.6);
    border: none;
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover { background: rgba(0,0,0,0.9); }

.modal-backdrop {
    height: 300px;
    background-size: cover;
    background-position: center;
    border-radius: 12px 12px 0 0;
    position: relative;
}

.modal-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--surface) 0%, transparent 60%);
    border-radius: 12px 12px 0 0;
}

.modal-content {
    padding: 24px 32px 32px;
    margin-top: -60px;
    position: relative;
    z-index: 2;
}

.modal-content h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.modal-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.modal-meta .match {
    color: #46d369;
    font-weight: 700;
}

.modal-meta .year { color: var(--text); }

.modal-content p {
    line-height: 1.7;
    color: rgba(255,255,255,0.85);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.btn-modal-play {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--text);
    color: var(--bg);
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-modal-play:hover { opacity: 0.85; }

.btn-modal-list {
    background: rgba(255,255,255,0.15);
    color: var(--text);
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-modal-list:hover { background: rgba(255,255,255,0.25); }

.seasons-area h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.seasons-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.season-card {
    flex-shrink: 0;
    width: 140px;
    cursor: pointer;
    transition: transform 0.2s;
}

.season-card:hover { transform: scale(1.05); }

.season-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--surface-hover);
}

.season-card .s-title {
    font-size: 0.8rem;
    margin-top: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Player Overlay */
.player-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0,0,0,0.95);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

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

.player-modal {
    width: 90%;
    max-width: 1100px;
    position: relative;
}

.player-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 2.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.player-close:hover { color: var(--accent); }

.player-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.player-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
}

.btn-ep-nav {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 18px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-ep-nav:hover { background: var(--border); }

.btn-ep-nav:disabled { opacity: 0.3; cursor: not-allowed; }

#ep-info {
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 120px;
    text-align: center;
}

/* Loading */
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Empty state */
.empty-msg {
    color: var(--text-muted);
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
        flex-wrap: wrap;
        height: auto;
        min-height: 68px;
        gap: 10px;
    }
    .nav-search { order: 3; width: 100%; max-width: none; margin-top: 4px; }
    .nav-links { gap: 14px; }
    .hero-content h1 { font-size: 1.8rem; }
    .hero-content p { font-size: 0.9rem; }
    .card { width: 140px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

    /* Detail page mobile */
    .detail-hero { height: 50vh; min-height: 350px; }
    .detail-hero-content { flex-direction: column; align-items: flex-start; gap: 20px; }
    .detail-poster { width: 140px; display: block; }
    .detail-hero-info h1 { font-size: 1.8rem; }
    .detail-meta { gap: 8px; font-size: 0.8rem; }
    .advisory-grid { grid-template-columns: 1fr; }
    .cast-card { width: 100px; }
    .modal-content { padding: 16px 20px 24px; }
    .modal-content h2 { font-size: 1.4rem; }
}

@media (min-width: 1024px) {
    .detail-poster { display: block; }
}

/* Watch Now Section */
.watch-now-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border);
}

.watch-now-section h3 {
    margin-bottom: 16px;
    font-size: 1.3rem;
}

.btn-watch-now {
    width: 100%;
    max-width: 300px;
    justify-content: center;
    padding: 14px 32px;
    font-size: 1.1rem;
}

.watch-now-section .detail-seasons-list {
    margin-top: 0;
}

/* Floating Home Button */
.floating-home-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(229, 9, 20, 0.4);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.floating-home-btn.visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.floating-home-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(229, 9, 20, 0.6);
    background: var(--accent-hover);
}

.floating-home-btn:active {
    transform: scale(0.95);
}

/* Advisory Single Bar */
.advisory-single-bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 8px;
}

.advisory-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
}