
/* ========== 基础与背景 ========== */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(-45deg, #0d1117, #161b22, #1a1f35, #0d1117);
    background-size: 400% 400%;
    animation: gradient 10s ease infinite;
    min-height: 100vh;
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ========== 顶部导航栏 ========== */
.navbar {
    background: rgba(13, 17, 23, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .brand {
    font-size: 1.2em;
    font-weight: bold;
    color: #e6e6e6;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.navbar .nav-links {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.navbar .nav-links a {
    color: #c8c8c8;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.06);
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.navbar .nav-links a:hover,
.navbar .nav-links a.active {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

/* ========== 导航栏用户气泡按钮 ========== */
.navbar .nav-links .nav-user-btn {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px !important;
    border-radius: 24px !important;
    background: rgba(255,255,255,0.1) !important;
    border: 1px solid rgba(255,255,255,0.12);
    transition: all 0.3s ease !important;
}

.navbar .nav-links .nav-user-btn:hover {
    background: rgba(255,255,255,0.18) !important;
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.nav-avatar-img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.2);
}

.nav-avatar-fallback {
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.nav-username {
    font-size: 0.85em;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navbar .nav-links .nav-logout-btn {
    padding: 6px 10px !important;
    font-size: 0.85em;
}

/* ========== 侧边栏头像 ========== */
.sidebar-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.2);
}

.sidebar-avatar-fallback {
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
}

/* 侧边栏用户副标题（统计信息） */
.sidebar-user-sub {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

/* ========== 主布局：侧边栏 + 内容 ========== */
.layout {
    display: flex;
    min-height: calc(100vh - 52px);
}

/* ========== 侧边栏 ========== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: rgba(13, 17, 23, 0.55);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid rgba(255,255,255,0.06);
    padding: 16px 0;
    overflow-y: auto;
    position: sticky;
    top: 52px;
    height: calc(100vh - 52px);
}

/* iPad / Safari 修复：backdrop-filter 在可滚动容器上会渲染为黑色 */
@supports (-webkit-touch-callout: none) {
    .sidebar {
        background: rgba(13, 17, 23, 0.95);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* 侧边栏滚动条样式 */
.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}
/* Firefox 滚动条 */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.sidebar-search {
    padding: 0 16px 12px;
}

.sidebar-search input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.08);
    color: #e0e0e0;
    font-size: 0.9em;
    outline: none;
    border: 1px solid rgba(255,255,255,0.08);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.sidebar-search input::placeholder {
    color: rgba(255,255,255,0.35);
}

.sidebar-search input:focus {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.18);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.sidebar-section {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-title {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.08);
    color: #e0e0e0;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
}

/* ========== 玩法分类标签（胶囊风格，一行两个） ========== */
#sidebarGameplay {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

#sidebarGameplay a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 5px;
    border-radius: 20px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.7em;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.2s ease;
    cursor: pointer;
}

#sidebarGameplay a span {
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

#sidebarGameplay a:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.18);
    color: #e0e0e0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#sidebarGameplay a.active {
    background: #4da3ff;
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 12px rgba(77,163,255,0.35);
}

#sidebarGameplay a .badge {
    margin-left: 2px;
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

#sidebarGameplay a.active .badge {
    background: rgba(255,255,255,0.25);
}

.sidebar-info {
    font-size: 0.8em;
    color: rgba(255,255,255,0.45);
    line-height: 1.8;
}

.sidebar-info img {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin: 0 2px;
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ========== 首页区域 ========== */
.home-section {
    margin-bottom: 36px;
}

.section-title {
    font-size: 1.4em;
    color: #e0e0e0;
    margin: 0 0 16px 0;
    padding-left: 12px;
    border-left: 4px solid rgba(77,163,255,0.5);
}

/* ========== 游戏网格（首页 + 分类） ========== */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* ========== 游戏卡片 ========== */
.game-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    aspect-ratio: 3/2;
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    text-decoration: none;
    display: block;
}

.game-card:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 12px 30px rgba(0,0,0,0.6), 0 0 20px rgba(77,163,255,0.15);
    z-index: 2;
}

.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 60%);
    z-index: 1;
}

.game-card .card-icon {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.game-card .card-label {
    position: absolute;
    bottom: 22px;
    left: 0;
    right: 0;
    padding: 6px 12px 0;
    color: #e0e0e0;
    font-weight: 600;
    font-size: 0.9em;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    z-index: 3;
}

.game-card .card-desc {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 12px 8px;
    color: rgba(255,255,255,0.55);
    font-size: 0.65em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    z-index: 3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card .card-plays {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    color: rgba(255,255,255,0.8);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.6em;
    font-weight: 600;
    z-index: 3;
}

.game-card .card-plays:empty {
    display: none;
}

/* ========== 收藏按钮 ========== */
.game-card .card-fav {
    position: absolute;
    top: 24px;
    right: 8px;
    z-index: 4;
    font-size: 1.1em;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    user-select: none;
    -webkit-user-select: none;
}
.game-card:hover .card-fav {
    opacity: 1;
}
.game-card .card-fav.faved {
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
}
.game-card .card-fav:hover {
    transform: scale(1.3);
}

.game-card .card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    color: #ddd;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7em;
    z-index: 3;
}

/* ========== 分类浏览 ========== */
.category-section {
    margin-bottom: 24px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: rgba(255,255,255,0.06);
    border-radius: 14px;
    cursor: pointer;
    color: #d0d0d0;
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.category-header:hover {
    background: rgba(255,255,255,0.1);
    color: #e0e0e0;
}

.category-header .arrow {
    transition: transform 0.3s ease;
}

.category-header .arrow.open {
    transform: rotate(90deg);
}

.category-games {
    padding: 0 0 8px 0;
    transition: all 0.3s ease;
}

/* ========== 须知/协议/下载视图 ========== */
.info-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
    color: #c8c8c8;
    line-height: 1.8;
    border: 1px solid rgba(255,255,255,0.06);
}

.info-card h2 {
    margin-top: 0;
    font-size: 1.3em;
    color: #e0e0e0;
}

.info-card h3 {
    font-size: 1.1em;
    margin: 12px 0 6px;
    color: #d0d0d0;
}

.info-card details {
    margin: 8px 0;
}

.info-card summary {
    cursor: pointer;
    font-weight: bold;
    color: #d0d0d0;
}

.download-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin: 8px 0;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
}

.download-item a {
    color: #d0d0d0;
    background: rgba(255,255,255,0.08);
    padding: 6px 16px;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.download-item a:hover {
    background: rgba(77,163,255,0.3);
    color: #fff;
}

/* ========== 游戏图标 ========== */
.game-icon {
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

.game-icon-sm {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 4px;
}

/* ========== 动画 ========== */
@keyframes cardAppear {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.game-card {
    animation: cardAppear 0.4s ease forwards;
    opacity: 0;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-width: 100%;
        position: relative;
        top: 0;
        height: auto;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .main-content {
        padding: 16px;
    }
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .navbar {
        flex-direction: column;
        text-align: center;
    }
}
