/* ========== B站风格配色系统 ========== */
:root {
    --bilibili-pink: #FB7299;
    --bilibili-blue: #00A1D6;
    --primary-color: #FB7299;
    --bg-color: #F4F4F4;
    --card-bg: #FFFFFF;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #E0E0E0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: var(--card-bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    padding-bottom: calc(65px + env(safe-area-inset-bottom)); /* 底部导航栏高度 */
    overflow-x: hidden;
}

.top-stack {
    position: sticky;
    top: 0;
    z-index: 120;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ========== 顶部栏 ========== */
.top-bar {
    position: relative;
    background: var(--card-bg);
    padding: 5px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    box-shadow: none;
    overflow: hidden;
}

.logo {
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
}

.logo-img {
    height: 26px;
    width: auto;
    max-width: 240px;
    object-fit: contain;
    display: block;
}

@media (min-width: 768px) {
    .logo-img {
        height: 48px;
        max-width: 320px;
    }
}

@media (max-width: 360px) {
    .logo-img {
        height: 26px;
        max-width: 200px;
    }
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
    flex-wrap: nowrap;
}

.top-help-btn {
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.035);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 800;
    padding: 7px 10px;
    border-radius: 999px;
    cursor: pointer;
    flex: 0 0 auto;
    min-height: 38px;
    white-space: nowrap;
}

.top-help-btn:active {
    transform: scale(0.98);
}

.top-search {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.035);
    min-width: 180px;
    flex: 1;
    min-width: 0;
    min-height: 38px;
    overflow: hidden;
    flex-basis: 0;
}

.top-search-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-secondary);
    opacity: 0.7;
}

.top-search-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    width: auto;
    flex: 1;
    min-width: 0;
    flex-basis: 0;
}

.top-search-input::placeholder {
    color: var(--text-secondary);
}

.top-search-clear {
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
    visibility: hidden;
    pointer-events: none;
}

.top-search-clear.is-visible{
    visibility: visible;
    pointer-events: auto;
}

.top-search-clear svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.top-search-clear:active {
    transform: scale(0.94);
}

.top-search-btn {
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    min-height: 30px;
}

.top-search-btn:active {
    transform: scale(0.96);
}

/* ========== 分类栏（横向滚动）========== */
.category-scroll-container {
    position: relative;
    background: var(--card-bg);
    padding: 3px 0;
    box-shadow: none;
    overflow: hidden;
    overflow-y: hidden;
    padding-right: 48px; /* 右侧留出"下拉更多"按钮空间 */
    touch-action: pan-x;
    overscroll-behavior-x: contain;
}

.category-list {
    display: flex;
    gap: 8px;
    padding: 0 12px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    /* 隐藏滚动条 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* 分类栏右侧下拉按钮 */
.category-more-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 5;
}

.category-more-btn:active {
    transform: translateY(-50%) scale(0.96);
}

/* 分类下拉面板 */
.category-dropdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 35000;
    padding: 12px;
}

.category-dropdown-panel {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.category-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
}

.category-dropdown-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.category-dropdown-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: none;
    background: rgba(0, 0, 0, 0.03);
    cursor: pointer;
    color: var(--text-secondary);
}

.category-dropdown-grid {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.category-dropdown-grid .category-btn {
    width: 100%;
    justify-content: center;
}

@media (max-width: 480px) {
    .category-dropdown-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ========== 解压密码说明弹窗内容排版 ========== */
.pwd-guide {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pwd-block {
    padding: 14px;
    border-radius: 14px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

.pwd-title {
    font-size: 15px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.pwd-line {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.pwd-code {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 900;
}

.pwd-note {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
}

.pwd-sub {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 900;
    color: var(--text-primary);
}

.pwd-paragraph {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.category-list::-webkit-scrollbar {
    display: none;
}

.category-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    line-height: 1.2;
}

.category-btn:active,
.category-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.category-btn:not(.active):hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ========== 主内容区 ========== */
.main-content {
    padding: 6px;
    min-height: calc(100vh - 200px);
}

@media (min-width: 768px) {
    /* PC 两侧留白，形成“侧边栏”空间 */
    .main-content {
        max-width: 1240px;
        margin: 0 auto;
        padding: 22px 56px;
    }
}
/* ========== 顶部Banner ========== */
.top-banner {
    width: 100%;
    margin-bottom: 10px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.top-banner.has-slides{
    cursor: default;
    background: transparent;
}

.top-banner-track{
    width: 100%;
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.top-banner-track::-webkit-scrollbar{display:none;}

.top-banner-slide{
    flex: 0 0 100%;
    width: 100%;
    scroll-snap-align: start;
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
}

.top-banner-slide img{
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.top-banner-dots{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    display: flex;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}

.top-banner-dot{
    width: 8px;
    height: 8px;
    border-radius: 999px;
    border: 0;
    background: rgba(255,255,255,0.55);
    box-shadow: 0 1px 6px rgba(0,0,0,0.25);
    pointer-events: auto;
}

.top-banner-dot.active{
    background: rgba(255,255,255,0.95);
}

.top-banner.is-fallback{
    background: var(--card-bg);
    cursor: default;
}

.top-banner-fallback-single{
    position: relative;
    width: 100%;
}

.top-banner-fallback-single-thumb{
    width: 100%;
    aspect-ratio: 16 / 9;
    background: rgba(0,0,0,0.035);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.top-banner-fallback-single-img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.top-banner-fallback-single-title{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(0,0,0,0.00) 0%, rgba(0,0,0,0.55) 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-banner-fallback{
    padding: 10px;
}

.top-banner-fallback-track{
    display: flex;
    align-items: stretch;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.top-banner-fallback-track::-webkit-scrollbar{display:none;}

.top-banner-fallback-card{
    flex: 0 0 148px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    padding: 0;
    text-align: left;
    cursor: pointer;
}

.top-banner-fallback-card:active{transform: scale(0.99);}

.top-banner-fallback-thumb{
    width: 100%;
    height: 86px;
    background: rgba(0,0,0,0.035);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.top-banner-fallback-thumb img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.top-banner-fallback-emoji{
    font-size: 34px;
    line-height: 1;
}

.top-banner-fallback-title{
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-banner img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.top-banner:active {
    transform: scale(0.99);
    transition: transform 0.1s;
}
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px;
}

/* ========== 游戏卡片 ========== */
.game-card {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.game-card:hover {
    box-shadow: var(--shadow-hover);
}

.game-card:active {
    transform: scale(0.99);
}

.game-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    position: relative;
}

/* 封面中心“水滴波纹”引导（叠在图片上方，常驻，轻量） */
.game-image::before,
.game-image::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
    z-index: 2;
    pointer-events: none;
}

.game-image::before {
    animation: cardRipple 1.8s ease-out infinite;
}

.game-image::after {
    animation: cardRipple 1.8s ease-out infinite;
    animation-delay: 0.9s;
}

@keyframes cardRipple {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 0.5;
    }
    100% {
        transform: translate(-50%, -50%) scale(4.5);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .game-image::before,
    .game-image::after {
        animation: none;
        opacity: 0;
    }
}

.game-category-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    max-width: calc(100% - 16px);
    padding: 4px 8px;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    box-shadow: var(--shadow);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 3;
    display: none;
}

.game-top-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 8px;
    background: var(--bilibili-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    box-shadow: var(--shadow);
    z-index: 3;
}

.game-image img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.game-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    min-height: calc(1.4em * 2); /* 固定两行高度：一行标题时也预留第二行 */
}

.game-meta,
.game-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.game-meta-row {
    justify-content: space-between;
    margin-top: 6px;
    width: 100%;
    flex-wrap: nowrap;
}

.meta-btn,
.meta-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 18px;
    padding: 0;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 49%;
}

.meta-btn-time,
.meta-time {
    color: #6b7280;
    max-width: 28%;
}

.meta-btn-category,
.meta-category {
    margin-left: auto;
    color: #6b7280;
    font-weight: 500;
}

.game-category-corner-badge {
    margin-left: auto;
    max-width: 72%;
    padding: 4px 9px;
    border-radius: 9px;
    background: linear-gradient(135deg, rgba(230,107,144,1) 0%, rgba(236,85,131,1) 100%);
    border: 1px solid rgba(255,255,255,0.32);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(230,107,144,0.30);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    transform: translateZ(0);
    transition: transform .12s ease, filter .12s ease;
}

.game-card:active .game-category-corner-badge {
    transform: scale(0.97);
    filter: brightness(0.96);
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(230, 107, 144, 0.12);
    color: var(--primary-color);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
}

.meta-chip.is-muted {
    background: rgba(107, 114, 128, 0.12);
    color: #6b7280;
}

.meta-link {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.game-footer {
    padding: 0 10px 10px;
    display: flex;
    gap: 6px;
    display: none;
}

.card-download-btn {
    width: 100%;
    border: none;
    background: var(--primary-color);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: var(--shadow);
}

.card-download-btn-half {
    flex: 1;
    min-width: 0;
    gap: 4px;
}

.card-download-btn:active {
    transform: scale(0.98);
}

.card-download-btn.is-disabled {
    background: #bdbdbd;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ========== B站风格底部导航栏 ========== */
html.settings-loading .bottom-nav {
    visibility: hidden;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(60px + env(safe-area-inset-bottom));
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 0;
    transition: transform .14s ease, color .18s ease, background-color .18s ease;
    color: var(--text-secondary);
    position: relative;
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
    border-radius: 12px;
}

.nav-item:active {
    transform: none;
    background: none;
}

.nav-item.is-pressing {
    transform: none;
    background: none;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.nav-has-dot::after {
    content: '';
    position: absolute;
    right: 22%;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff3b30;
    border: 1px solid #fff;
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
    stroke: currentColor;
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* ========== “我的”内嵌页（无跳转痕迹） ========== */
html.my-embed-open,
body.my-embed-open {
    height: 100%;
    overflow: hidden;
}

/* ========== 通用遮罩：禁止滚动 ========== */
html.overlay-open,
body.overlay-open {
    height: 100%;
    overflow: hidden;
}

.my-overlay {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: calc(60px + env(safe-area-inset-bottom)); /* 预留底部导航高度 + 安全区 */
    background: var(--bg-color);
    z-index: 900; /* 底部导航 z-index=1000，需保留可点 */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}

.my-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity .22s ease, transform .22s ease, visibility 0s;
}

.my-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: var(--bg-color);
}

/* ========== “影视”搜索弹层（浑然一体） ========== */
.video-overlay {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: calc(60px + env(safe-area-inset-bottom));
    /* 改为“独立界面”：不再是弹窗遮罩 */
    background: var(--bg-color);
    z-index: 950;
    padding: 0;
    box-sizing: border-box;
    display: block;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}

.video-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity .22s ease, transform .22s ease, visibility 0s;
}

.video-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: var(--bg-color);
}

/* 覆盖页加载提示：减少“空白等待”的割裂感 */
.overlay-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: #b8c6ff;
    background: linear-gradient(180deg, rgba(10, 16, 40, 0.72), rgba(10, 16, 40, 0.46));
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 2;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility 0s linear .18s;
}

.overlay-loading.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity .18s ease, visibility 0s;
}

.overlay-loading-spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(184, 198, 255, .35);
    border-top-color: rgba(184, 198, 255, .95);
    animation: overlaySpin .85s linear infinite;
}

.overlay-loading-text {
    font-size: 13px;
    letter-spacing: .2px;
    opacity: .95;
}

@keyframes overlaySpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .my-overlay,
    .video-overlay,
    .overlay-loading {
        transition: none !important;
    }
    .overlay-loading-spinner {
        animation: none !important;
    }
}

/* 弱网失败提示：居中小弹窗（可关闭） */
.net-fail-modal {
    position: fixed;
    inset: 0;
    z-index: 36000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.28);
}

.net-fail-modal.is-visible {
    display: flex;
}

.net-fail-card {
    width: min(88vw, 340px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    padding: 14px 14px 12px;
    color: #1f2a37;
}

.net-fail-title {
    font-size: 15px;
    font-weight: 800;
}

.net-fail-desc {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.55;
    color: #4b5563;
}

.net-fail-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.net-fail-btn {
    border: 0;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.net-fail-btn.secondary {
    background: #eef1f5;
    color: #344054;
}

.net-fail-btn.primary {
    background: var(--primary-color, #2f6bff);
    color: #fff;
}

.video-panel {
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 14px;
    margin-top: 0;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    /* iOS 上 touch-action 兼容不一致，过度限制会导致内部横向滚动失效 */
    touch-action: auto;
}

.video-content {
    position: relative;
    padding: calc(env(safe-area-inset-top) + 12px) 14px 18px;
    box-sizing: border-box;
}

.video-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.video-topbar-spacer {
    flex: 1;
}

.video-homeBox {
    margin-top: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 14px;
    box-shadow: none;
}

.video-homeBox-title {
    font-size: 15px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 10px;
}

/* 旧的 .video-header 不再使用（用户不喜欢顶部固定标题条） */

.video-back {
    appearance: none;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    font-weight: 900;
}

.video-back:hover {
    border-color: var(--primary-color);
}

.video-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-close {
    appearance: none;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.video-close:hover {
    border-color: var(--primary-color);
}

.video-searchbar {
    display: flex;
    gap: 10px;
    margin-top: 0;
    max-width: 100%;
}

.video-input {
    flex: 1;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
}

.video-input:focus {
    border-color: var(--primary-color);
}

.video-search-btn {
    appearance: none;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    min-width: 84px;
}

.video-search-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.video-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 16px;
}

.video-hint.is-loading::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.18);
    border-top-color: var(--primary-color);
    margin-right: 8px;
    vertical-align: -1px;
    animation: videoSpin 0.8s linear infinite;
}

@keyframes videoSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.video-home {
    margin-top: 14px;
    display: grid;
    gap: 14px;
    max-width: 100%;
}

.video-home.is-hidden {
    display: none;
}

.video-section-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.video-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 100%;
}

.video-chip {
    appearance: none;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
}

.video-chip:hover {
    border-color: var(--primary-color);
}

.video-categories {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: scroll;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    max-width: 100%;
}

.video-categories::-webkit-scrollbar {
    height: 6px;
}

.video-categories::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.18);
    border-radius: 999px;
}

.video-rank-blocks {
    display: grid;
    gap: 10px;
}

.video-rank-block {
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    border-radius: 14px;
    padding: 10px;
}

.video-rank-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.video-rank-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}

.video-rank-scroll::-webkit-scrollbar {
    height: 6px;
}

.video-rank-scroll::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.18);
    border-radius: 999px;
}

.video-poster {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    width: 92px;
    flex: 0 0 auto;
    text-align: left;
}

.video-poster-cover {
    position: relative;
    width: 92px;
    height: 128px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.08);
}

.video-poster-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-poster-rank {
    position: absolute;
    left: 8px;
    top: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    color: #fff;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.video-poster-title {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 32px;
}

.video-tags {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.video-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    color: var(--text-secondary);
}

.video-category {
    appearance: none;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.video-category.has-img {
    padding-left: 44px;
    background-repeat: no-repeat;
    background-size: 26px 26px;
    background-position: 12px center;
}

.video-category:hover {
    border-color: var(--primary-color);
}

.video-results {
    margin-top: 10px;
    display: grid;
    gap: 10px;
    max-width: 100%;
}

.video-results.is-hidden {
    display: none;
}

.video-item {
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    border-radius: 14px;
    padding: 12px;
}

.video-item-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.35;
}

.video-item-meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-all;
}

.video-item-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.video-action-btn {
    appearance: none;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
}

.video-action-btn:hover {
    border-color: var(--primary-color);
}

/* 中间大按钮（PWA安装）*/
.nav-center {
    position: relative;
    margin-top: -20px;
}

/* 下载引导流光圈 */
.nav-center::before,
.nav-center::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.nav-center::before {
    border: 2px solid rgba(251, 114, 153, 0.55);
    box-shadow: 0 0 0 0 rgba(251, 114, 153, 0.45);
    animation: navRingPulse 1.6s ease-out infinite;
}

.nav-center::after {
    background: conic-gradient(from 0deg, transparent 0deg, rgba(251, 114, 153, 0.85) 50deg, transparent 110deg);
    mask: radial-gradient(closest-side, transparent 62%, #000 63%);
    -webkit-mask: radial-gradient(closest-side, transparent 62%, #000 63%);
    animation: navRingSweep 2.1s linear infinite;
    opacity: 0.9;
}

@keyframes navRingPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.92);
        opacity: 0.9;
        box-shadow: 0 0 0 0 rgba(251, 114, 153, 0.35);
    }
    70% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 0;
        box-shadow: 0 0 0 14px rgba(251, 114, 153, 0);
    }
    100% {
        opacity: 0;
    }
}

@keyframes navRingSweep {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.center-plus {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), #FF6B9D);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(251, 114, 153, 0.4);
    transition: all 0.3s;
}

.center-plus .center-icon {
    width: 24px;
    height: 24px;
    display: block;
    stroke: #fff;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.nav-center:active .center-plus {
    transform: scale(0.9);
}

.center-plus span {
    font-size: 28px;
    color: white;
    font-weight: 300;
}

/* ========== 模态框 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--bg-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 详情页底部下载按钮常驻区 */
.modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.modal-footer .download-btn {
    margin-top: 10px;
}

.modal-image {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 16px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-section p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.download-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.download-btn:active {
    transform: scale(0.98);
    filter: brightness(0.95);
}

/* ========== 响应式设计 ========== */
@media (min-width: 768px) {
    .games-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 18px;
    }

    .game-image {
        height: 220px;
        font-size: 72px;
    }
    
    .bottom-nav {
        display: none; /* PC端隐藏底部导航 */
    }
    
    body {
        padding-bottom: 0;
    }
    
    .modal-content {
        max-width: 500px;
        left: 50%;
        transform: translateX(-50%);
        bottom: auto;
        top: 50%;
        transform: translate(-50%, -50%);
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }
    
    .game-image {
        aspect-ratio: 16 / 9;
        height: auto;
    }
}

/* ========== 加载更多（不闪烁）========== */
.load-more {
    grid-column: 1/-1;
    display: flex;
    justify-content: center;
    padding: 18px 0;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state.empty-state--centered {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(88vw, 360px);
    padding: 24px 18px 18px;
    border-radius: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18);
    z-index: 1200;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 14px;
    line-height: 1.6;
}

/* ========== 弹窗和广告样式（保留兼容性）========== */
.floating-ad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 40000;
    backdrop-filter: blur(5px);
}

.floating-ad {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 40001;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: popupFadeIn 0.3s ease;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.floating-ad img {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 20px;
}

.floating-ad-content {
    color: #333;
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 20px;
}

.floating-ad-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.floating-ad-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

.custom-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 40001;
    max-width: 500px;
    width: 90%;
    animation: popupSlide 0.3s ease;
}

.custom-popup .custom-popup-content {
    white-space: pre-line;
    word-break: break-word;
}

/* 小屏优化：顶部搜索更紧凑 */
@media (max-width: 480px) {
    .top-bar {
        padding: 5px 10px;
    }

    .logo {
        font-size: 18px;
    }

    .top-search-input {
        width: auto;
    }

    .top-actions {
        gap: 6px;
    }

    .top-help-btn {
        padding: 6px 9px;
        font-size: 11px;
        min-height: 36px;
    }

    .top-search {
        padding: 6px 8px;
        min-height: 36px;
        gap: 4px;
    }

    .top-search-btn {
        padding: 6px 10px;
        min-height: 28px;
        font-size: 12px;
    }

}

@keyframes popupSlide {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}
