:root {
    --bg-color: #0f0f0f;
    --card-bg: #1a1a1a;
    --accent-color: #e50914;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --nav-height: 100px;
    --transition-speed: 0.3s;
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.5);
    --radius-md: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #111;
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Layout */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 20px;
}

.nav-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    flex: 1;
}

.nav-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.navbar {
    height: var(--nav-height);
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.logo-text span {
    color: var(--accent-color);
}

/* Source Dropdown */
.source-dropdown-wrapper {
    position: relative;
}

.source-dropdown {
    position: relative;
}

.dropdown-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 6px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed);
}

.dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-content {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    min-width: 150px;
    z-index: 1001;
    overflow: hidden;
    animation: fadeInDown 0.2s ease-out;
}

.source-dropdown:hover .dropdown-content {
    display: flex;
}

.dropdown-content .source-btn {
    width: 100%;
    text-align: left;
    border-radius: 0;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dropdown-content .source-btn:last-child {
    border-bottom: none;
}

.dropdown-content .source-btn.active {
    background: var(--accent-color);
}

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

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 5px 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.search-box input {
    background: transparent;
    border: none;
    color: white;
    outline: none;
    padding: 5px;
    width: 150px;
    font-size: 0.9rem;
}

.search-box button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* Update mobile behavior to keep layout consistent */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 15px;
    }
    .logo-text { font-size: 1.3rem; }
    .search-box input { width: 120px; }
}

/* Hero Section */
.hero-section {
    height: 450px;
    background: linear-gradient(to right, rgba(15, 15, 15, 0.9) 30%, transparent 100%), 
                url('https://images.unsplash.com/photo-1536440136628-849c177e76a1?auto=format&fit=crop&q=80&w=1400');
    background-size: cover;
    background-position: center;
    border-radius: var(--radius-md);
    margin-bottom: 50px;
    display: flex;
    align-items: center;
    padding: 0 50px;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.8);
    animation: fadeIn 0.8s ease-out;
    transition: background 1s ease-in-out, transform 0.5s ease-out;
}

.hero-content {
    max-width: 600px;
}

.hero-tag {
    background: var(--accent-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 15px;
    display: inline-block;
}

.hero-description {
    font-size: 1.1rem;
    color: #ccc;
    max-width: 600px;
    margin-bottom: 30px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Max 2 lines as requested */
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.hero-desc {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 30px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-btns {
    display: flex;
    gap: 15px;
}

.hero-btn-primary, .hero-btn-secondary {
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    border: none;
}

.hero-btn-primary {
    background: white;
    color: black;
}

.hero-btn-primary:hover {
    background: rgba(255, 255, 255, 0.8);
}

.hero-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(10px);
}

.hero-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .hero-section {
        height: 350px;
        padding: 0 20px;
    }
    .hero-title { font-size: 2rem; }
    .hero-desc { font-size: 0.9rem; }
}

/* Main Content */
main {
    margin-top: var(--nav-height);
    flex: 1;
    padding: 30px 20px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* Grid System */
.content-section {
    margin-bottom: 40px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    display: block;
    width: 4px;
    height: 24px;
    background: var(--accent-color);
    border-radius: 2px;
}

.grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5px; /* Perfect balance gap */
    padding-bottom: 40px;
    background: rgba(255, 255, 255, 0.02); /* Subtle background for the gap */
    border-radius: 4px;
    overflow: hidden;
}

@media (max-width: 640px) {
    .grid-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1.5px;
    }
}

/* Modern Tiled Card Styles */
.card-item {
    background: #111;
    border-radius: 4px; /* Sharper corners for tight gap */
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    border: none; /* Remove border to let the 1px gap shine */
}

.card-item:hover {
    z-index: 10;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    border-radius: 8px; /* Smooth corners on hover */
}

.card-poster-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    overflow: hidden;
    background: #000;
}

.card-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.card-item:hover .card-poster {
    transform: scale(1.1);
}

.card-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 152, 0, 0.9);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    z-index: 3;
}

.card-source-label {
    position: absolute;
    top: 10px;
    right: 10px;
    color: white;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    z-index: 3;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
}

.source-anime { background: rgba(229, 9, 20, 0.9); }
.source-donghua { background: rgba(0, 188, 212, 0.9); }
.source-movie { background: rgba(76, 175, 80, 0.9); }
.source-series { background: rgba(156, 39, 176, 0.9); }

.card-info {
    padding: 10px;
    background: rgba(20, 20, 20, 0.95);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
    height: 2.4em;
}

.card-meta-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    font-size: 0.7rem;
}

.card-rating {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #ffb400;
    font-size: 0.6rem;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.7);
    padding: 3px 10px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 3;
}

.card-status {
    color: #aaa;
    background: rgba(255,255,255,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.card-details p {
    font-size: 0.72rem;
    color: #ddd;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
}

.card-details p span {
    color: #888;
    font-weight: 400;
    margin-right: 6px;
    display: inline-block;
    min-width: 65px;
    flex-shrink: 0;
}

/* Remove old card styles */
.card-badge { display: none; }
.card-overlay { display: none; }

/* Detail Page */
.detail-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    animation: fadeIn 0.5s ease-out;
}

@media (min-width: 768px) {
    .detail-container {
        grid-template-columns: 300px 1fr;
    }
}

.detail-poster {
    width: 100%;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
}

.detail-info h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    line-height: 1.2;
}

.detail-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.detail-synopsis {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 30px;
    border-left: 3px solid var(--accent-color);
}

/* Episode List */
.episode-section {
    margin-top: 40px;
}

.episode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.episode-btn {
    background: #222;
    border: 1px solid #333;
    color: white;
    padding: 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.episode-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.episode-btn.active, .server-btn.active {
    background: var(--accent-color) !important;
    border-color: var(--accent-color) !important;
    color: white !important;
    box-shadow: 0 0 10px rgba(229, 9, 20, 0.5);
}

.download-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

@media (min-width: 992px) {
    .download-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Watch Page */
.watch-container {
    max-width: 1100px;
    margin: 0 auto;
}

.player-wrapper {
    position: relative;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.player-wrapper iframe, 
.player-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Loader */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.3s;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* Mobile Menu */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
}

@media (max-width: 768px) {
    .nav-center {
        display: none; /* Hide on mobile, show via menu or separate logic */
    }
    .mobile-menu-btn {
        display: none !important;
    }
    .logo-text { font-size: 1.2rem; }
}

/* Footer */
.footer {
    padding: 40px 20px;
    background: #080808;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 50px;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a:hover {
    color: var(--accent-color);
}
