/* ============================================================
   RESET + TOKENS
============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --brand: #7c3aed;
    --brand-light: #a78bfa;
    --brand-dim: rgba(124, 58, 237, 0.18);
    --brand-glow: rgba(124, 58, 237, 0.4);
    --bg: #07070f;
    --bg2: #0f0f1a;
    --bg3: #16162a;
    --card: #1a1a2e;
    --card-hover: #21213a;
    --border: rgba(255, 255, 255, 0.07);
    --text: #f0efff;
    --muted: #8585aa;
    --radius: 12px;
    --radius-lg: 20px;
    --shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
    --transition: 0.22s cubic-bezier(.4, .0, .2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Ambient glows */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 55% 40% at 10% 8%, rgba(124, 58, 237, .12) 0%, transparent 65%),
        radial-gradient(ellipse 40% 30% at 90% 90%, rgba(200, 80, 255, .07) 0%, transparent 60%);
}

/* ============================================================
   HEADER
============================================================ */
header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(7, 7, 15, .82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: auto;
}

.logo-img {
    height: 38px;
    width: auto;
    display: block;
    filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.5));
    transition: filter 0.2s ease, transform 0.2s ease;
}

.logo:hover .logo-img {
    filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.7));
    transform: scale(1.04);
}

/* Search bar */
.search-wrap {
    position: relative;
    flex: 1;
    max-width: 380px;
}

.search-wrap svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 2;
    pointer-events: none;
}

#search-input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px 8px 36px;
    font: inherit;
    font-size: .875rem;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

#search-input::placeholder {
    color: var(--muted);
}

#search-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-dim);
}

/* Sort */
#sort-select {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    font-size: .875rem;
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}

#sort-select:focus {
    border-color: var(--brand);
}

/* ============================================================
   HERO CAROUSEL
============================================================ */
#hero-carousel {
    position: relative;
    z-index: 1;
    height: clamp(340px, 52vw, 560px);
    overflow: hidden;
    background: var(--bg2);
}

.carousel-track {
    display: flex;
    height: 100%;
    transition: transform 0.65s cubic-bezier(.77, 0, .18, 1);
    will-change: transform;
}

.carousel-slide {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.carousel-slide-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.06);
    transition: transform 8s ease;
    filter: saturate(1.15);
}

.carousel-slide.active .carousel-slide-bg {
    transform: scale(1);
}

.carousel-slide::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        linear-gradient(to right, rgba(7, 7, 15, .92) 0%, rgba(7, 7, 15, .5) 50%, transparent 100%),
        linear-gradient(to top, rgba(7, 7, 15, .85) 0%, transparent 55%);
}

.carousel-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 80px 52px 48px;
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.55s 0.15s ease, transform 0.55s 0.15s ease;
}

.carousel-slide.active .carousel-content {
    opacity: 1;
    transform: translateY(0);
}

.carousel-cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #fff;
    background: var(--brand);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.carousel-cat-badge.live-badge {
    background: #ef4444;
}

.carousel-cat-badge.live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: pulse 1.2s infinite;
}

.carousel-title {
    font-size: clamp(1.5rem, 3.8vw, 3rem);
    font-weight: 900;
    line-height: 1.12;
    margin-bottom: 12px;
    text-shadow: 0 2px 20px rgba(0, 0, 0, .6);
    max-width: 640px;
}

.carousel-desc {
    font-size: .92rem;
    color: rgba(240, 239, 255, .75);
    line-height: 1.65;
    max-width: 480px;
    margin-bottom: 24px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.carousel-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: #fff;
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    padding: 12px 26px;
    font: inherit;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 24px rgba(0, 0, 0, .4);
}

.carousel-play-btn:hover {
    background: var(--brand-light);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--brand-glow);
}

.carousel-play-btn svg {
    flex-shrink: 0;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    z-index: 10;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background var(--transition), transform var(--transition);
}

.carousel-arrow:hover {
    background: rgba(255, 255, 255, .28);
}

.carousel-arrow.prev {
    left: 16px;
}

.carousel-arrow.next {
    right: 16px;
}

.carousel-arrow svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.carousel-dots {
    position: absolute;
    bottom: 16px;
    right: 48px;
    z-index: 10;
    display: flex;
    gap: 6px;
    align-items: center;
}

.carousel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .35);
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    padding: 0;
}

.carousel-dot.active {
    background: #fff;
    transform: scale(1.35);
}

.carousel-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    z-index: 10;
    background: var(--brand);
    width: 0%;
    transition: width linear;
    box-shadow: 0 0 8px var(--brand-glow);
}

.carousel-thumbs {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.carousel-thumb {
    width: 88px;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: .5;
    transition: opacity var(--transition), border-color var(--transition);
}

.carousel-thumb.active {
    opacity: 1;
    border-color: #fff;
}

.carousel-thumb:hover {
    opacity: .85;
}

.carousel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 900px) {
    .carousel-thumbs {
        display: none;
    }

    .carousel-content {
        padding: 0 56px 40px 20px;
    }
}

@media (max-width: 600px) {
    #hero-carousel {
        height: clamp(260px, 60vw, 340px);
    }

    .carousel-content {
        padding: 0 16px 32px;
    }

    .carousel-title {
        font-size: clamp(1.2rem, 6vw, 1.8rem);
    }

    .carousel-desc {
        display: none;
    }

    .carousel-dots {
        right: 16px;
    }

    .carousel-arrow {
        width: 36px;
        height: 36px;
    }
}

/* ============================================================
   CATEGORY TABS
============================================================ */
.tabs-wrap {
    position: sticky;
    top: 60px;
    z-index: 100;
    background: rgba(7, 7, 15, .9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    margin-bottom: 36px;
}

#category-tabs {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

#category-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex-shrink: 0;
    padding: 14px 18px;
    border: none;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--brand-light);
    border-bottom-color: var(--brand-light);
    font-weight: 700;
}

/* ============================================================
   MAIN CONTENT AREA
============================================================ */
#main {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 20px;
    background: linear-gradient(to bottom, var(--brand), var(--brand-light));
    border-radius: 2px;
    display: block;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

/* ============================================================
   CARDS
============================================================ */
.card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    position: relative;
}

.card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 16px 48px rgba(124, 58, 237, .25);
    background: var(--card-hover);
}

.card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg3);
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.card:hover .card-thumb img {
    transform: scale(1.07);
}

.badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 4px;
    letter-spacing: .06em;
}

.badge-live {
    background: #ef4444;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: pulse 1.2s infinite;
}

.badge-series {
    background: var(--brand);
    color: #fff;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .3;
    }
}

.ep-count {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, .7);
    color: rgba(255, 255, 255, .9);
    font-size: .7rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
}

.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .35);
    opacity: 0;
    transition: opacity var(--transition);
}

.card:hover .play-overlay {
    opacity: 1;
}

.play-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-circle svg {
    width: 18px;
    height: 18px;
    fill: var(--brand);
    margin-left: 2px;
}

.card-info {
    padding: 12px 14px 14px;
}

.card-title {
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.card-meta {
    font-size: .75rem;
    color: var(--muted);
}

/* ============================================================
   LOAD MORE
============================================================ */
#load-more-wrap {
    text-align: center;
    margin-top: 16px;
}

#load-more-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 32px;
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}

#load-more-btn:hover {
    border-color: var(--brand);
    background: var(--brand-dim);
    color: var(--brand-light);
}

/* ============================================================
   EMPTY / ERROR / LOADING STATES
============================================================ */
.state-msg {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: .95rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   MODAL
============================================================ */
#modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, .85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

#modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 920px;
    max-height: 95vh;
    /* flex column: zona fija arriba, lista scrollable abajo */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
    transform: translateY(30px);
    transition: transform 0.3s;
}

/* ── Zona fija: header + player + descripción ─────────── */
.player-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

/* Contenedor relativo para el logo overlay */
.player-container {
    position: relative;
}

/* Logo overlay en la esquina superior-izquierda del player */
.player-logo-overlay {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 10;
    pointer-events: none;
    opacity: 0.75;
    transition: opacity 0.3s;
}

.player-logo-overlay:hover {
    opacity: 1;
}

.player-logo-overlay img {
    height: 34px;
    width: auto;
    display: block;
    filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.7));
}

#modal-overlay.open #modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 0;
}

#modal-title {
    display: none;
}

#modal-close {
    flex-shrink: 0;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.1rem;
    transition: background var(--transition), color var(--transition);
}

#modal-close:hover {
    background: var(--card-hover);
    color: var(--text);
}

#modal-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    max-height: 46vh;   /* nunca ocupa más de ~la mitad del viewport */
    background: #000;
    margin: 16px 0 0;
    overflow: hidden;
}

/* Descripción del episodio — oculta en el modal */
#modal-desc {
    display: none;
}

#modal-player iframe,
#modal-player video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

#modal-player video {
    background: #000;
}

/* ── Zona scrollable: lista de episodios ─────────────── */
#episodes-section {
    /* Muestra ~3 ítems y luego permite scroll */
    flex: 1 1 auto;
    max-height: 400px;
    min-height: 220px;  /* garantiza al menos ~3 episodios visibles */
    overflow-y: auto;
    /* scroll suave en iOS */
    -webkit-overflow-scrolling: touch;
    /* Barra de scroll estilizada */
    scrollbar-width: thin;
    scrollbar-color: var(--brand) var(--bg3);
}

#episodes-section::-webkit-scrollbar {
    width: 5px;
}

#episodes-section::-webkit-scrollbar-track {
    background: var(--bg3);
    border-radius: 4px;
}

#episodes-section::-webkit-scrollbar-thumb {
    background: var(--brand);
    border-radius: 4px;
}

.episodes-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    padding: 16px 24px 0;
}

#episodes-list {
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ep-item {
    display: flex;
    gap: 12px;
    background: var(--bg3);
    border-radius: var(--radius);
    padding: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color var(--transition), background var(--transition);
}

.ep-item:hover {
    border-color: var(--brand);
    background: var(--card);
}

.ep-thumb {
    flex-shrink: 0;
    width: 120px;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    background: var(--card);
}

.ep-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ep-info {
    flex: 1;
    min-width: 0;
}

.ep-num {
    font-size: .72rem;
    color: var(--brand-light);
    font-weight: 600;
    margin-bottom: 3px;
}

.ep-title {
    font-size: .88rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}

.ep-desc {
    font-size: .75rem;
    color: var(--muted);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ep-loading {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    font-size: .88rem;
}

/* ============================================================
   ROTATE HINT (solo móvil portrait)
============================================================ */
#rotate-hint {
    display: none;
    /* por defecto oculto; la @media portrait lo activa */
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    color: var(--muted);
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    pointer-events: none;
    white-space: nowrap;
    animation: rotateHintPulse 2.5s ease infinite;
}

#rotate-hint svg {
    stroke: var(--brand-light);
    animation: wobble 2.5s ease infinite;
    transform-origin: center;
}

@keyframes wobble {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-20deg);
    }

    75% {
        transform: rotate(20deg);
    }
}

@keyframes rotateHintPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .6;
    }
}

/* ============================================================
   FOOTER
============================================================ */
#site-footer {
    position: relative;
    z-index: 1;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 48px 24px 32px;
}

.footer-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    text-align: center;
}

.footer-logo {
    height: 52px;
    width: auto;
    opacity: .85;
    filter: drop-shadow(0 0 10px var(--brand-glow));
}

.footer-banner {
    width: 100%;
    max-width: 780px;
    height: auto;
    border-radius: 14px;
    overflow: hidden;
}

.footer-copy {
    font-size: .78rem;
    color: var(--muted);
    line-height: 1.6;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 720px) {
    nav {
        padding: 0 14px;
        gap: 10px;
    }

    .search-wrap {
        max-width: 180px;
    }

    #main {
        padding: 0 14px 80px;
    }

    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }

    #modal {
        border-radius: 14px;
    }

    .modal-header {
        padding: 16px 16px 0;
    }

    #modal-desc {
        padding: 12px 16px;
    }

    #episodes-section {
        padding: 0 16px 20px;
    }

    .ep-thumb {
        width: 90px;
    }
}

@media (max-width: 600px) {
    #site-footer {
        padding: 32px 14px 24px;
    }

    .footer-logo {
        height: 38px;
    }
}

/* ============================================================
   LANDSCAPE MÓVIL — orientación horizontal en pantalla pequeña
============================================================ */
@media (max-height: 500px) and (orientation: landscape) {

    /* ── Header compacto ─────────────────────────── */
    nav {
        height: 46px;
        padding: 0 12px;
        gap: 8px;
    }

    .logo-img {
        height: 28px;
    }

    .search-wrap {
        max-width: 220px;
    }

    #search-input,
    #sort-select {
        padding-top: 5px;
        padding-bottom: 5px;
        font-size: .8rem;
    }

    /* ── Tabs compactos ──────────────────────────── */
    .tabs-wrap {
        top: 46px;
        margin-bottom: 16px;
    }

    .tab-btn {
        padding: 8px 14px;
        font-size: .8rem;
    }

    /* ── Carousel reducido ───────────────────────── */
    #hero-carousel {
        height: clamp(140px, 38vw, 200px);
    }

    .carousel-content {
        padding: 0 12px 16px;
    }

    .carousel-title {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }

    .carousel-desc {
        display: none;
    }

    .carousel-play-btn {
        padding: 8px 16px;
        font-size: .82rem;
    }

    .carousel-arrow {
        width: 30px;
        height: 30px;
    }

    .carousel-arrow svg {
        width: 14px;
        height: 14px;
    }

    .carousel-dots {
        bottom: 8px;
        right: 12px;
    }

    /* ── Grid adaptado ───────────────────────────── */
    #main {
        padding: 0 12px 40px;
    }

    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    /* ── Modal fullscreen horizontal ─────────────── */
    #modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    #modal {
        border-radius: 0;
        max-width: 100%;
        max-height: 100vh;
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Cabecera del modal más pequeña */
    .modal-header {
        padding: 8px 12px 0;
        flex-shrink: 0;
    }

    #modal-title {
        font-size: 1rem;
    }

    #modal-close {
        width: 28px;
        height: 28px;
        font-size: .9rem;
    }

    /* En landscape ocupar toda la ventana */
    .player-wrap {
        flex-shrink: 1;
    }

    /* Player ocupa todo el alto disponible */
    #modal-player {
        aspect-ratio: unset;
        margin: 4px 0 0;
        min-height: 0;
        flex: 1;
    }

    /* Descripción oculta para ganar espacio */
    #modal-desc {
        display: none;
    }

    /* Sección de episodios lateral cuando hay contenido */
    #episodes-section {
        padding: 0 10px 10px;
        overflow-y: auto;
        flex: 0 0 auto;
        max-height: calc(100vh - 56px);
    }

    /* Layout horizontal: player-wrap izq | episodios der */
    #modal:has(.episodes-open) {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    #modal:has(.episodes-open) .player-wrap {
        flex: 0 0 58%;
        display: flex;
        flex-direction: column;
        max-height: 100vh;
    }

    #modal:has(.episodes-open) .modal-header {
        display: none;
    }

    /* El player-container (con logo) ocupa el espacio restante en player-wrap */
    #modal:has(.episodes-open) .player-container {
        flex: 1;
        min-height: 0;
    }

    #modal:has(.episodes-open) #modal-player {
        aspect-ratio: unset;
        height: 100%;
        margin: 0;
    }

    /* Descripción compacta debajo del player en landscape */
    #modal:has(.episodes-open) #modal-desc {
        display: block;
        font-size: .75rem;
        padding: 6px 12px 8px;
        -webkit-line-clamp: 1;
        line-clamp: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #modal:has(.episodes-open) #episodes-section {
        flex: 1 1 auto;
        max-height: 100vh;
        padding: 0;
    }

    .ep-thumb {
        width: 72px;
    }

    .ep-title {
        font-size: .8rem;
    }

    .ep-desc {
        display: none;
    }

    .ep-item {
        padding: 7px;
        gap: 8px;
    }
}

/* ── Indicador de rotación en móvil vertical (portrait) ─────── */
@media (max-width: 600px) and (orientation: portrait) {

    /* Botón de rotar pantalla visible en el modal */
    #rotate-hint {
        display: flex;
    }
}

@media not ((max-width: 600px) and (orientation: portrait)) {
    #rotate-hint {
        display: none !important;
    }
}

/* ============================================================
   PiP LIVE TV WIDGET
============================================================ */
@keyframes pip-slide-up {
    from { opacity: 0; transform: translate(-50%, calc(-50% + 30px)) scale(.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#pip-widget {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1100;
    width: 640px;
    background: var(--bg2);
    border: 1px solid var(--brand);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(124, 58, 237, .35), 0 2px 12px rgba(0,0,0,.6);
    animation: pip-slide-up .35s cubic-bezier(.22,1,.36,1) both;
}

#pip-widget[hidden] {
    display: none;
}

.pip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    background: rgba(124, 58, 237, .15);
    border-bottom: 1px solid var(--border);
}

.pip-badge {
    font-size: .62rem;
    font-weight: 800;
    color: #ff4444;
    letter-spacing: .06em;
    white-space: nowrap;
    animation: pulse 1.5s infinite;
}

.pip-title {
    flex: 1;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pip-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.pip-btn {
    background: rgba(255,255,255,.08);
    border: 1px solid var(--border);
    border-radius: 7px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    transition: background var(--transition), color var(--transition);
    padding: 0;
}

.pip-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

.pip-btn:hover {
    background: var(--card-hover);
    color: var(--text);
}

.pip-player-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

#pip-player {
    position: absolute;
    inset: 0;
}

#pip-player video,
#pip-player iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
}

/* Móvil: widget más pequeño */
@media (max-width: 500px) {
    #pip-widget {
        width: 230px;
        border-radius: 10px;
    }
    .pip-title { font-size: .72rem; }
}