:root {
    --bg-color: #121212;
    --transition-speed: 0.3s;
    --primary: #e50914;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-color);
    color: #fff;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    transition: background var(--transition-speed) ease;
}

#homepageBg {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(40px) brightness(0.65);
    /* Increased from 0.42 */
    transform: scale(1.08);
    transition: opacity 0.6s ease, background-image 0.6s ease;
    opacity: 0;
    pointer-events: none;
}

#homepageBg::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Softened the black gradient so it doesn't crush the colors */
    background: linear-gradient(180deg, rgba(18, 18, 18, 0.4), rgba(18, 18, 18, 0.95));
}

.player-wrapper {
    display: flex;
    flex-direction: column;
    width: calc(100% + 40px) !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    margin-top: 10px;
    background: #000;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none !important;
}

#playerFrame {
    border: none;
    width: 100%;
    height: 680px;
    background: #000;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    position: relative;
    justify-content: center;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    justify-content: center;
}

.search-field {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 720px;
    margin: 0 auto;
}

@media (max-width:768px) {
    .search-field {
        max-width: none;
    }
}

input[type="text"] {
    width: 100%;
    padding: 14px 18px;
    font-size: 16px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #fff;
    outline: 0;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--primary);
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: 0;
    border: 0;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    display: none;
}

select,
button {
    padding: 10px 15px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #222;
    color: #fff;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

button.primary {
    background: var(--primary);
    border: 0;
    font-weight: bold;
}

button.primary:hover:not(:disabled) {
    background: #f6121d;
}

.btn-icon {
    background: #222;
    border: 1px solid #444;
    color: #ccc;
    padding: 10px;
    border-radius: 8px;
}

.btn-icon:hover:not(:disabled) {
    color: #fff;
    border-color: #fff;
    background: #333;
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #333;
    list-style: 0;
    padding: 0;
    margin: 5px 0 0;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    border-radius: 8px;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
}

.suggestions-list li {
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #222;
    transition: 0.2s;
}

.suggestions-list li:hover {
    background: #282828;
}

.suggestion-poster {
    width: 45px;
    height: 65px;
    object-fit: cover;
    border-radius: 4px;
}

.badge {
    background: var(--primary);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-right: 5px;
}

.cw-container {
    display: none;
    flex-direction: column;
    margin-bottom: 25px;
}

.cw-header {
    font-size: 12px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    margin-bottom: 10px;
}

.cw-list::-webkit-scrollbar {
    display: none;
}

.cw-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    gap: 15px;
    padding-top: 10px;
    padding-bottom: 15px;
    margin-top: -10px;
    user-select: none;
    touch-action: pan-x;
}

.cw-card {
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    border: 0;
    background: 0;
    gap: 8px;
    cursor: pointer;
    position: relative;
    min-width: 0;
    user-select: none;
}

.cw-card * {
    user-select: none;
}

.cw-card img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

.cw-card:hover {
    background: 0;
    border-color: 0;
    box-shadow: none;
}

.cw-poster {
    width: 100%;
    height: 290px;
    min-width: 0;
    max-width: 100%;
    aspect-ratio: 2/3;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
}

.cw-card:hover .cw-poster {
    transform: scale(1.03);
    box-shadow: 0 6px 15px rgba(255, 255, 255, 0.08);
}

.cw-info {
    padding: 0 5px;
    width: 100%;
}

.cw-title {
    font-size: 15px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    display: block;
    transition: color 0.2s ease;
}

.cw-card:hover .cw-title {
    color: var(--primary);
}

.cw-meta {
    font-size: 13px;
    color: #888;
}

@media (max-width:768px) {
    .cw-card {
        flex: 0 0 140px;
    }

    .cw-poster {
        height: 210px;
    }
}

.bottom-tv-controls {
    display: none;
    justify-content: space-between;
    align-items: center;
    background: #111;
    padding: 15px 20px;
    border-top: 1px solid #222;
}

.tv-status {
    font-size: 15px;
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tv-status-title {
    color: #fff;
    font-weight: bold;
    margin-right: 8px;
}

.ep-nav-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

#shareToast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    padding: 12px 25px;
    border-radius: 30px;
    font-weight: bold;
    z-index: 9999;
    display: none;
    box-shadow: 0 5px 15px rgba(229, 9, 20, 0.4);
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    display: none;
}

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

.episode-section {
    display: none;
    margin-top: 30px;
}

.season-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.season-header h2 {
    margin: 0;
    font-size: 22px;
}

.season-select {
    padding: 8px 15px;
    background: #1a1a1a;
    border: 1px solid #444;
    font-weight: bold;
}

.episode-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    user-select: none;
    touch-action: pan-x;
}

.episode-card {
    display: flex;
    gap: 20px;
    padding: 15px;
    background: #161616;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: 0.2s ease;
    align-items: flex-start;
}

.episode-card:hover {
    background: #1e1e1e;
    border-color: #333;
}

.episode-card.active-ep {
    border-color: #444;
    background: #161616;
}

.ep-thumb-wrapper {
    width: 220px;
    height: 124px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    background: #000;
}

.ep-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0;
}

.ep-number-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.ep-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding-top: 5px;
}

.ep-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #fff;
    transition: 0.2s;
}

.active-ep .ep-title {
    color: var(--primary);
}

.ep-overview {
    font-size: 14px;
    color: #999;
    line-height: 1.5;
    max-width: 800px;
}

@media (max-width:768px) {
    #playerFrame {
        height: 260px;
        border-radius: 0;
    }

    .player-wrapper {
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid #222;
    }

    .bottom-tv-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        padding: 15px;
    }

    .tv-status {
        text-align: center;
        font-size: 14px;
        background: #1a1a1a;
        padding: 10px;
        border-radius: 6px;
    }

    .ep-nav-container {
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 8px;
    }

    #serverSelect {
        flex-grow: 1;
        min-width: 0;
    }

    .episode-list {
        flex-direction: row;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 15px;
        gap: 15px;
        -webkit-overflow-scrolling: touch;
    }

    .episode-list::-webkit-scrollbar {
        display: none;
    }

    .episode-card {
        flex: 0 0 75%;
        flex-direction: column;
        padding: 10px;
        scroll-snap-align: center;
        opacity: 0.4;
    }

    .episode-card.active-ep {
        opacity: 1;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    }

    .ep-thumb-wrapper {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }

    .ep-details {
        padding-top: 10px;
        width: 100%;
    }

    .ep-title {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 0;
    }

    .ep-overview {
        display: none;
    }

    .ep-number-badge {
        font-size: 11px;
        padding: 3px 6px;
    }
}

.cw-list,
.episode-list {
    cursor: grab;
}

.cw-list.dragging,
.episode-list.dragging {
    cursor: grabbing;
    user-select: none;
    scroll-behavior: auto !important;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    width: 100%;
}

.filter-row select,
.filter-row button {
    min-width: 140px;
    flex: 1 1 140px;
}

/* DOWNLOAD MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #111;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    border: 1px solid #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #222;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 18px;
}

.modal-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.download-item {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 8px;
    color: #ccc;
    text-decoration: none;
    border: 1px solid #333;
    font-size: 14px;
    transition: 0.2s;
    white-space: pre-wrap;
    line-height: 1.5;
}

.download-item:hover {
    border-color: var(--primary);
    background: #222;
    color: #fff;
}