html,
body {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #0f1116;
    color: #e9edf5;
}

.tpl-header-spacer {
    height: 68px;
}

.header-search,
.nav-search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-search input,
.nav-search input {
    height: 38px;
    min-width: 0;
    border: 1px solid #262d3a;
    background: rgba(255, 255, 255, .05);
    color: #e9edf5;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 13px;
}

.header-search input,
.nav-search input {
    width: 180px;
}

.header-search button,
.nav-search button {
    height: 38px;
    flex-shrink: 0;
    white-space: nowrap;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff5c35, #ff8a3d);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    padding: 0 14px;
    cursor: pointer;
}

.nav-search {
    display: flex;
    margin-left: 8px;
    flex-shrink: 0;
}

.tpl-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 200px;
    background: #0f1116;
    border-radius: 14px;
    overflow: visible;
}

.tpl-player .MacPlayer {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 200px !important;
    overflow: visible !important;
}

.tpl-player .MacPlayer table,
.tpl-player .MacPlayer tr,
.tpl-player .MacPlayer td,
.tpl-player #playleft {
    width: 100% !important;
    height: 100% !important;
    position: relative;
    z-index: 2;
}

.tpl-player #playleft iframe,
.tpl-player #playleft video,
.tpl-player .MacPlayer video {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    pointer-events: auto !important;
    background: #000;
}

.tpl-player #buffer,
.tpl-player #install,
.MacPlayer #buffer,
.MacPlayer #install {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    z-index: 0 !important;
}

.tpl-eps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .5rem;
}

.tpl-eps a {
    display: block;
    text-align: center;
    padding: .5rem .25rem;
    border-radius: 8px;
    border: 1px solid #262d3a;
    background: #1a1f29;
    font-size: .8125rem;
    color: #e9edf5;
}

.tpl-eps a.active {
    background: linear-gradient(135deg, #ff5c35, #ff8a3d);
    border-color: #ff5c35;
    color: #fff;
}

.tpl-page {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 1.5rem;
}

.tpl-page a,
.tpl-page span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 .75rem;
    border-radius: 8px;
    border: 1px solid #262d3a;
    color: #ffb03a;
    font-size: .875rem;
}

.tpl-filter,
.tpl-source {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

.tpl-filter a,
.tpl-source a {
    display: inline-flex;
    padding: .35rem .85rem;
    border-radius: 20px;
    font-size: .8125rem;
    color: #94a0b5;
    background: #1a1f29;
    border: 1px solid #262d3a;
}

.tpl-filter a.active,
.tpl-source a.active {
    background: linear-gradient(135deg, #ff5c35, #ff8a3d);
    color: #fff;
    border-color: #ff5c35;
}

.tpl-play-btn,
.tpl-play-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .7rem 1.4rem;
    border-radius: 11px;
    font-size: .875rem;
    font-weight: 600;
}

.tpl-play-btn {
    background: linear-gradient(135deg, #ff5c35, #ff8a3d);
    color: #fff;
}

.tpl-play-link {
    border: 1px solid #262d3a;
    background: rgba(255, 255, 255, .06);
    color: #e9edf5;
}

.tpl-poster {
    display: block;
    position: relative;
    width: 220px;
    max-width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #141821;
}

.tpl-poster img {
    width: 100%;
    display: block;
}

.tpl-poster-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 3.25rem;
    height: 3.25rem;
    margin: -1.625rem 0 0 -1.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: linear-gradient(135deg, #ff5c35, #ffb03a);
    color: #fff;
    font-size: 1.2rem;
}

.page-hero {
    background: #1a1f29;
    border: 1px solid #262d3a;
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 24px;
}

.page-hero h1 {
    font-size: clamp(22px, 3vw, 32px);
}

.page-hero p {
    color: #94a0b5;
    margin-top: 8px;
}

.rank-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.rank-col,
.rank-list,
.panel {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.rank-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px 0;
    border-bottom: 1px solid #262d3a;
    color: inherit;
    overflow: hidden;
    box-sizing: border-box;
}

.rank-row:last-child { border-bottom: none; }

.rank-num {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    background: #262d3a;
    color: #94a0b5;
    flex-shrink: 0;
}

.rank-num.hot {
    background: linear-gradient(135deg, #ff5c35, #ffb03a);
    color: #fff;
}

.rank-thumb {
    width: 48px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    background: #141821;
    flex-shrink: 0;
}

.rank-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.rank-body {
    min-width: 0;
    flex: 1 1 0%;
    overflow: hidden;
}

.rank-title,
.rank-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-title { font-size: 14px; font-weight: 700; }
.rank-meta { margin-top: 2px; font-size: 12px; color: #94a0b5; }
.rank-date { flex-shrink: 0; font-size: 12px; color: #6f7b8e; }

a.card {
    display: block;
    color: inherit;
}

a.card.card-wide {
    display: flex;
}

.hero-poster {
    display: block;
    color: inherit;
}

.detail-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.detail-main { flex: 1; min-width: 220px; }
.detail-list { margin-top: 16px; color: #b8c2d2; font-size: 14px; line-height: 1.9; }
.detail-actions { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; }

.f-col .d-flex{
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 0
}

@media (min-width: 768px) {
    .tpl-eps { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .rank-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .header-search { display: none !important; }
    .nav-search {
        display: flex;
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
        order: 99;
    }
    .nav-search input { flex: 1 1 auto; width: auto; }
    .nav.open {
        min-height: 0 !important;
        max-height: calc(100vh - 68px) !important;
        max-height: calc(100dvh - 68px) !important;
        overflow-x: hidden !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .nav.open > a {
        flex-shrink: 0;
    }
    .nav-search {
        position: sticky;
        bottom: 0;
        background: rgba(15, 17, 22, .99);
        border-top: 1px solid #262d3a;
        padding-top: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        z-index: 2;
        flex-shrink: 0;
    }
    .tpl-eps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
