/* ==================== 全局重置与变量 ==================== */
:root {
    --primary: #1a6bff;
    --primary-dark: #0f4fd4;
    --primary-light: #4d8fff;
    --accent: #ff6b2b;
    --accent-dark: #e05515;
    --accent-light: #ff8f5e;
    --bg: #f5f6fa;
    --bg-white: #ffffff;
    --bg-dark: #1a1d2e;
    --text: #2d3042;
    --text-light: #6b7280;
    --text-white: #ffffff;
    --border: #e2e5ee;
    --shadow: 0 2px 12px rgba(26, 29, 46, 0.08);
    --shadow-hover: 0 6px 24px rgba(26, 107, 255, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --nav-height: 64px;
    --max-width: 1280px;
    --transition: 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition);
}

img {
    max-width: 100%;
    display: block;
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: inherit;
    background: none;
}

input {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 顶部导航栏 ==================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: box-shadow var(--transition);
}

.navbar.scrolled {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.nav-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    font-size: 18px;
}

.nav-logo-text span {
    color: var(--accent);
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.nav-categories-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition);
    position: relative;
}

.nav-categories-btn:hover {
    background: var(--primary);
    color: var(--text-white);
}

.nav-categories-btn .arrow {
    font-size: 10px;
    transition: transform var(--transition);
}

.nav-categories-btn.open .arrow {
    transform: rotate(180deg);
}

.nav-categories-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 12px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition);
    z-index: 100;
}

.nav-categories-btn.open .nav-categories-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-categories-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    transition: all var(--transition);
}

.nav-categories-dropdown a:hover {
    background: var(--bg);
    color: var(--primary);
}

.nav-categories-dropdown a .cat-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-light);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 12px;
}

.nav-search {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: 24px;
    padding: 0 16px;
    height: 40px;
    width: 280px;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.nav-search:focus-within {
    border-color: var(--primary);
    background: var(--bg-white);
    width: 320px;
}

.nav-search-icon {
    color: var(--text-light);
    font-size: 16px;
    margin-right: 8px;
    flex-shrink: 0;
}

.nav-search input {
    width: 100%;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

.nav-search input::placeholder {
    color: var(--text-light);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    transition: all var(--transition);
    white-space: nowrap;
}

.nav-btn:hover {
    background: var(--bg);
}

.nav-btn.btn-accent {
    background: var(--accent);
    color: var(--text-white);
}

.nav-btn.btn-accent:hover {
    background: var(--accent-dark);
}

.nav-favorites {
    position: relative;
}

.nav-favorites .fav-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: var(--text-white);
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 移动端菜单按钮 */
.nav-mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    cursor: pointer;
}

.nav-mobile-toggle span {
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

.nav-mobile-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-mobile-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-mobile-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* 移动端侧边菜单 */
.mobile-menu {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--nav-height));
    background: var(--bg-white);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform var(--transition);
    overflow-y: auto;
    padding: 20px;
}

.mobile-menu.open {
    transform: translateX(0);
}

.mobile-menu .mobile-search {
    width: 100%;
    margin-bottom: 20px;
}

.mobile-menu .mobile-search input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 16px;
    color: var(--text);
}

.mobile-menu .mobile-categories {
    margin-bottom: 20px;
}

.mobile-menu .mobile-categories h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.mobile-menu .mobile-categories a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
}

.mobile-menu .mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mobile-menu .mobile-actions .nav-btn {
    justify-content: center;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

/* ==================== 页面主体间距 ==================== */
main {
    padding-top: var(--nav-height);
    min-height: calc(100vh - 300px);
}

/* ==================== 通用区块标题 ==================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .icon {
    font-size: 28px;
}

.section-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    transition: all var(--transition);
}

.section-link:hover {
    color: var(--primary-dark);
    gap: 8px;
}

/* ==================== 游戏卡片 ==================== */
.game-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.game-card-thumb {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bg);
}

.game-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

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

.game-card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-new {
    background: var(--accent);
    color: var(--text-white);
}

.badge-hot {
    background: #ff3b3b;
    color: var(--text-white);
}

.game-card-fav {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-light);
    transition: all var(--transition);
    backdrop-filter: blur(4px);
}

.game-card-fav:hover,
.game-card-fav.active {
    color: #ff3b3b;
    background: rgba(255, 59, 59, 0.1);
}

.game-card-fav.active {
    color: #ff3b3b;
}

.game-card-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(26, 107, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.game-card:hover .game-card-play-overlay {
    opacity: 1;
}

.game-card-play-btn {
    width: 56px;
    height: 56px;
    background: var(--bg-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.game-card-info {
    padding: 14px 16px;
}

.game-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.game-card-category {
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 10px;
    font-weight: 500;
    color: var(--primary);
    font-size: 11px;
}

.game-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
}

.game-card-rating .stars {
    color: #ffc107;
    font-size: 12px;
}

.game-card-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-light);
}

.game-card-plays {
    display: flex;
    align-items: center;
    gap: 4px;
}

.game-card-difficulty {
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 11px;
}

.difficulty-Easy {
    background: #e8f5e9;
    color: #2e7d32;
}

.difficulty-Medium {
    background: #fff3e0;
    color: #ef6c00;
}

.difficulty-Hard {
    background: #ffebee;
    color: #c62828;
}

/* ==================== 游戏卡片网格 ==================== */
.game-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.game-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.game-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* ==================== 按钮样式 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(26, 107, 255, 0.3);
}

.btn-accent {
    background: var(--accent);
    color: var(--text-white);
}

.btn-accent:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 16px rgba(255, 107, 43, 0.3);
}

.btn-outline {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--text-white);
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    border-radius: var(--radius);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* ==================== 分页 ==================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
    padding-bottom: 40px;
}

.pagination-btn {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background: var(--bg-white);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.pagination-btn:hover:not(.active):not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn.active {
    background: var(--primary);
    color: var(--text-white);
    border-color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==================== 底部 ==================== */
.footer {
    background: var(--bg-dark);
    color: var(--text-white);
    padding: 60px 0 30px;
    margin-top: 60px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand .footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 16px;
}

.footer-brand .footer-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.footer-brand .footer-logo span {
    color: var(--accent);
}

.footer-brand p {
    font-size: 14px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
}

.footer-brand .footer-stats {
    display: flex;
    gap: 24px;
}

.footer-brand .footer-stat-item {
    text-align: center;
}

.footer-brand .footer-stat-num {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.footer-brand .footer-stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.footer-col h4 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.9);
}

.footer-col a {
    display: block;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    padding: 6px 0;
    transition: color var(--transition);
}

.footer-col a:hover {
    color: var(--accent);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

.footer-bottom-links {
    display: flex;
    gap: 20px;
}

.footer-bottom-links a {
    color: rgba(255, 255, 255, 0.4);
    transition: color var(--transition);
}

.footer-bottom-links a:hover {
    color: var(--accent);
}

/* ==================== 标签云 ==================== */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    padding: 6px 14px;
    background: var(--bg-white);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
}

.tag-item:hover {
    background: var(--primary);
    color: var(--text-white);
    border-color: var(--primary);
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
}

/* ==================== 消息提示 ==================== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    background: var(--bg-dark);
    color: var(--text-white);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ==================== 面包屑 ==================== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0;
    font-size: 14px;
    color: var(--text-light);
}

.breadcrumb a {
    color: var(--text-light);
    transition: color var(--transition);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .separator {
    font-size: 12px;
}

.breadcrumb .current {
    color: var(--text);
    font-weight: 500;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
    .nav-search {
        width: 200px;
    }
    .nav-search:focus-within {
        width: 240px;
    }
}

@media (max-width: 768px) {
    :root {
        --nav-height: 56px;
    }
    .nav-center, .nav-right {
        display: none;
    }
    .nav-mobile-toggle {
        display: flex;
    }
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .section-title {
        font-size: 20px;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    .footer-bottom {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    .footer-bottom-links {
        justify-content: center;
    }
    .container {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .game-card-info {
        padding: 10px 12px;
    }
    .game-card-title {
        font-size: 13px;
    }
    .game-card-meta {
        font-size: 11px;
    }
    .pagination-btn {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

/* ==================== 图片加载占位 ==================== */
.img-placeholder {
    background: linear-gradient(135deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
    background-size: 200% 200%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 200%; }
    100% { background-position: -200% -200%; }
}

/* ==================== 筛选栏 ==================== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    background: var(--bg-white);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--text-white);
    border-color: var(--primary);
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.sidebar h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-item:last-child {
    border-bottom: none;
}

.sidebar-item:hover {
    color: var(--primary);
}

.sidebar-item .rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-item .rank.top {
    background: var(--accent);
    color: var(--text-white);
}

.sidebar-item img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.sidebar-item .sidebar-item-info {
    flex: 1;
    min-width: 0;
}

.sidebar-item .sidebar-item-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item .sidebar-item-plays {
    font-size: 11px;
    color: var(--text-light);
}
