html, body {
    /* 確保 HTML 元素也有背景色，防止滾動超出 body 範圍時露出白色 */
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); 
    background-attachment: fixed; /* 確保背景不會隨著內容滾動，有助於穩定 */
    min-height: 100vh;
}

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

body {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    font-family: 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 装饰性背景元素 */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
    opacity: 0.1;
}

.bg-dot {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #fff;
    border-radius: 50%;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-1000px) rotate(720deg); }
}

/* 顶部导航栏 */
.top-nav {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 18px;
    color: #ff4d6d;
}

.logo-icon {
    font-size: 24px;
}

.user-stats {
    display: flex;
    gap: 15px;
    font-size: 12px;
    opacity: 0.8;
}

/* 主容器 */
.main-container {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 图片展示区域 */
#main {
    width: 100%;
    max-width: 800px;
    height: auto;
    margin: 20px auto;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    background: #000;
    transition: all 0.3s ease;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#imageDisplay {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    border-radius: 20px;
    transition: opacity 0.3s ease;
    display: block;
}

#imageDisplay.loading {
    opacity: 0.7;
}

.image-info {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.image-badge {
    background: linear-gradient(45deg, #ff4d6d, #ff758c);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.image-count {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 图片加载动画 */
.image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ff4d6d;
    animation: spin 1s ease-in-out infinite;
    display: none;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 功能卡片区域 */
.features-section {
    width: 100%;
    max-width: 900px;
    margin: 30px 0;
}

.features-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #ff4d6d;
    display: flex;
    align-items: center;
    gap: 10px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.feature-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 77, 109, 0.2);
    border-color: #ff4d6d;
}

.feature-icon {
    font-size: 30px;
    margin-bottom: 10px;
    display: block;
}

.feature-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #fff;
}

.feature-desc {
    font-size: 12px;
    opacity: 0.8;
}

/* 视频信息提示 */
.video-info {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.live-badge {
    background: linear-gradient(45deg, #ff4d6d, #ff758c);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.view-count {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 按钮区域 */
#buttons {
    width: 100%;
    max-width: 800px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px auto;
    padding: 0;
    height: auto;
    z-index: 10;
    position: relative;
    justify-content: center; 
}

#buttons button {
    height: 50px;
    border: none;
    border-radius: 15px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    color: white;
}

#next {
    background: linear-gradient(135deg, #2196F3, #21CBF3);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

#lineBtn {
    background: linear-gradient(135deg, #00c853, #00e676);
    box-shadow: 0 5px 15px rgba(0, 200, 83, 0.3);
}

#randomBtn {
    background: linear-gradient(135deg, #9C27B0, #E91E63);
    box-shadow: 0 5px 15px rgba(156, 39, 176, 0.3);
}

#buttons button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

#buttons button:active {
    transform: translateY(-1px);
}

/* 图片分类 */
.categories {
    width: 100%;
    max-width: 800px;
    margin: 30px 0;
}

.categories-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #ff4d6d;
    display: flex;
    align-items: center;
    gap: 10px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

/* ===== 終極修復：雙層結構解決移動設備變白問題 ===== */
.category-btn-wrapper {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
}

.category-btn {
    position: relative;
    width: 100%;
    background: transparent !important;
    background-color: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    color: white !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    overflow: hidden;
    z-index: 2;
}

/* 背景層 - 真正的顏色在這裡 */
.btn-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    z-index: -1;
    transition: background 0.3s ease;
}

/* 活動狀態 */
.category-btn.active {
    border-color: #ff4d6d !important;
}

.category-btn.active .btn-bg {
    background: linear-gradient(45deg, #ff4d6d, #ff758c) !important;
}

/* 文字層 */
.btn-text {
    position: relative;
    z-index: 1;
}

/* 移除所有可能的狀態影響 */
.category-btn:hover,
.category-btn:active,
.category-btn:focus,
.category-btn:visited {
    background: transparent !important;
    color: white !important;
    outline: none !important;
}

/* 热门推荐 */
.hot-section {
    width: 100%;
    max-width: 800px;
    margin: 30px 0;
}

.hot-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #ff4d6d;
    display: flex;
    align-items: center;
    gap: 10px;
}

.hot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.hot-card {
    background: linear-gradient(45deg, #ff4d6d, #ff758c);
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    aspect-ratio: 3/4;
}

.hot-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(255, 77, 109, 0.4);
}

.hot-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.hot-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 10px;
    color: white;
}

.hot-name {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 3px;
}

.hot-number {
    font-size: 11px;
    opacity: 0.8;
}

/* 使用指南 */
.guide-section {
    width: 100%;
    max-width: 800px;
    margin: 30px 0;
    background: rgba(255, 193, 7, 0.1);
    border-left: 4px solid #ffc107;
    border-radius: 15px;
    padding: 20px;
}

.guide-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #ffc107;
    display: flex;
    align-items: center;
    gap: 10px;
}

.guide-steps {
    padding-left: 20px;
}

.guide-step {
    margin-bottom: 10px;
    padding: 8px 0;
    position: relative;
    font-size: 14px;
}

.guide-step::before {
    content: '✓';
    position: absolute;
    left: -20px;
    color: #ffc107;
}

/* 联系渠道 */
.contact-section {
    width: 100%;
    max-width: 800px;
    margin: 30px 0;
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.contact-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    text-decoration: none;
    color: white;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.contact-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.2);
}

/* 页脚 */
.footer {
    width: 100%;
    text-align: center;
    padding: 20px;
    font-size: 12px;
    opacity: 0.6;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 20px;
}

/* 视频容器专用样式 */
.video-container {
    margin-top: 40px;
    border-top: 2px solid rgba(255, 77, 109, 0.3);
    padding-top: 30px;
}

/* 视频播放时放大 */
#videoMain.playing {
    max-width: 900px;
    margin: 20px auto;
}

#videoPlayer {
    width: 100%;
    height: auto;
    max-height: 400px;
    display: block;
    border-radius: 20px;
    transition: all 0.5s ease;
}

/* 播放时视频高度增加 */
#videoMain.playing #videoPlayer {
    max-height: 600px;
}

/* 视频控制按钮 */
#videoButtons {
    width: 100%;
    max-width: 800px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px auto;
}

#videoButtons button {
    height: 50px;
    border: none;
    border-radius: 15px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

#videoSwitch {
    background: linear-gradient(to bottom, #FF2, #FB0);
    color: #AF2E08;
}

#videoNext {
    background: linear-gradient(135deg, #2196F3, #21CBF3);
}

#videoLineBtn {
    background: linear-gradient(135deg, #00c853, #00e676);
}

#videoButtons button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* 刪除所有舊的 @media (max-width: 768px) 塊，並替換為以下統一的塊 */
@media (max-width: 768px) {
    
    /* === 終極背景修復：強制所有內容區塊透明，繼承 body 背景 === */
    .main-container,
    .features-section,
    .hot-section,
    .guide-section,
    .contact-section {
        background: transparent !important;
        /* 確保元素之間的間隙不會露出白色，如果問題仍存在，可嘗試添加以下兩行：*/
        /* margin: 0 !important; */
        /* padding: 0 !important; */
    }
    
    /* 1. 全面的佈局響應式設計 */
    .main-container {
        padding: 10px;
    }
    
    #main {
        max-width: 95%;
        min-height: 300px;
    }
    
    #imageDisplay {
        max-height: 400px;
    }
    
    .top-nav {
        padding: 10px;
        flex-direction: column;
        gap: 10px;
    }
    
    /* 2. 按鈕網格佈局 */
    #buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 95%;
    }
    
    #buttons button {
        height: 45px;
        font-size: 14px;
        padding: 0 10px;
        transform: none; /* 禁用 hover 效果，因為移動端沒有 hover */
    }
    
    #videoButtons {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 95%;
    }
    
    #videoButtons button {
        height: 45px;
        font-size: 14px;
        transform: none;
    }
    
    /* 3. 網格佈局重排 */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px !important;
    }
    
    .hot-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px !important;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 12px !important;
    }
    
    /* 4. 卡片背景和邊緣處理 (防止變白、確保圓角) */
    .feature-card {
        background: rgba(255, 255, 255, 0.1) !important;
        backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 12px !important;
        transform: none;
    }
    
    .feature-card:hover {
        background: rgba(255, 77, 109, 0.2) !important;
        transform: none !important;
    }
    
    .contact-card {
        background: rgba(255, 255, 255, 0.1) !important;
        border-radius: 12px !important;
        transform: none;
    }
    
    .contact-card:hover {
        background: rgba(255, 255, 255, 0.2) !important;
        transform: none !important;
    }
    
    /* 5. 分類按鈕的雙層結構修復 (確保在移動端正確顯示背景) */
    .category-btn-wrapper {
        min-height: 44px;
        background: transparent !important;
        border-radius: 12px !important;
        overflow: hidden !important;
    }
    
    .category-btn {
        padding: 10px 8px;
        font-size: 13px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background: transparent !important;
        transform: none;
        /* iOS 點擊閃白修復 */
        -webkit-tap-highlight-color: rgba(255, 77, 109, 0.3) !important;
    }
    
    .category-btn:hover {
        transform: none;
    }
    
    .btn-bg {
        /* 重點：確保背景層在移動端始終可見並有正確的半透明顏色 */
        background: rgba(255, 255, 255, 0.1) !important; 
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .category-btn.active .btn-bg {
        background: linear-gradient(45deg, #ff4d6d, #ff758c) !important;
    }
    
    .category-btn.active:hover .btn-bg {
        /* 確保活動狀態的 hover 效果在移動端是正確的 */
        background: linear-gradient(45deg, #ff4d6d, #ff758c) !important;
    }
    
    /* 6. iOS Safari Backdrop Filter 兼容性修復 */
    @supports (-webkit-touch-callout: none) {
        .feature-card, 
        .category-btn-wrapper,
        .contact-card {
            -webkit-backdrop-filter: blur(10px) !important;
            backdrop-filter: blur(10px) !important;
        }
    }
}
@media (max-width: 480px) {
    #buttons {
        grid-template-columns: 1fr;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .hot-grid {
        grid-template-columns: 1fr;
    }
    
    #imageDisplay {
        max-height: 300px;
    }
    
    #videoButtons {
        grid-template-columns: 1fr;
    }
    
    .category-btn {
        padding: 8px 6px;
        font-size: 12px;
    }
}

/* 基础样式 */
html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

/* 图片加载样式 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}



/* 打印样式 */
@media print {
    body * {
        visibility: hidden;
    }
    #main, #main * {
        visibility: visible;
    }
    #main {
        position: absolute;
        left: 0;
        top: 0;
    }
}


