/* ========================================
   55GM 手游平台 - 统一公共样式表
   ======================================== */

/* --- CSS 变量定义 (统一主题) --- */
:root {
    /* 主色调 */
    --theme-color: #f04494;
    --theme-color-light: #ff6b9d;
    --theme-gradient: linear-gradient(135deg, #f04494 0%, #ff6b00 100%);
    --theme-gradient-light: linear-gradient(135deg, #ff6b9d 0%, #ff8c42 100%);
    
    /* 背景色 */
    --bg-body: #f7f8fa;
    --bg-card: #ffffff;
    --bg-card-hover: #fffafc;
    
    /* 文字颜色 */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-white: #ffffff;
    
    /* 标签渐变背景 */
    --tag-bg-hot: linear-gradient(135deg, #ff6b00 0%, #ff4757 100%);
    --tag-bg-gameplay: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --tag-bg-theme: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --tag-bg-default: linear-gradient(135deg, #f04494 0%, #ec4899 100%);
    --platform-bg-gm: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    --platform-bg-buyout: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    
    /* 布局常量 */
    --header-height: 56px;
    --bottom-nav-height: 60px;
    --container-max-width: 1080px;
    
    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 50px;
    
    /* 阴影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* 过渡 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* --- 基础重置 --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-top: var(--header-height);
    padding-bottom: calc(var(--bottom-nav-height));
    /*padding-bottom: calc(var(--bottom-nav-height) + 20px);*/
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

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

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

/* --- 容器 --- */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ========================================
   统一头部样式
   ======================================== */
.site-header {
    background: var(--bg-card);
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    height: var(--header-height);
    display: flex;
    align-items: center;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 1080px;
    overflow: visible;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 16px;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.header-left,
.header-right {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1100;
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 18px;
    color: var(--theme-color);
}

.header-logo img {
    height: 43px;
    width: auto;
}

.header-logo-text {
    display: none;
}

.header-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.header-btn:hover,
.header-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.header-btn svg {
    width: 22px;
    height: 22px;
}

.mobile-menu-btn {
    font-size: 22px;
    color: var(--text-primary);
}

/* ========================================
   头部下拉菜单
   ======================================== */
.header-menu-wrapper {
    position: relative;
}

.mobile-menu-dropdown {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    z-index: 2000;
}

.mobile-menu-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.dropdown-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.dropdown-item:hover,
.dropdown-item:active {
    background: rgba(240, 68, 148, 0.08);
    color: var(--theme-color);
}

.dropdown-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* 下拉菜单箭头 */
.mobile-menu-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 16px;
    width: 12px;
    height: 12px;
    background: var(--bg-card);
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.03);
}

/* ========================================
   搜索弹窗
   ======================================== */
.search-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
    max-width: 100vw;
    overflow-x: hidden;
}

.search-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    transform: translateY(-20px);
    transition: transform var(--transition-normal);
}

.search-modal-overlay.active .search-modal-content {
    transform: translateY(0);
}

.search-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 24px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
}

.search-modal-title {
    margin: 0 0 15px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.search-form-modal {
    display: flex;
    gap: 8px;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-full);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.search-input:focus {
    border-color: var(--theme-color);
}

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

.search-submit-btn {
    background: var(--theme-gradient);
    color: white;
    padding: 0 24px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.search-submit-btn:active {
    transform: scale(0.96);
}

/* ========================================
   Hero 区域 (首页专用)
   ======================================== */
.hero-section {
    background: var(--theme-gradient);
    padding: 40px 16px 24px;
    color: white;
    text-align: center;
    border-radius: 0 0 24px 24px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
    margin-left: 0;
    margin-right: 0;
}

.hero-section .container {
    max-width: 100%;
    padding: 0;
    overflow-x: hidden;
}

.hero-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
}

.hero-desc {
    font-size: 13px;
    opacity: 0.9;
    max-width: 500px;
    margin: 0 auto 20px;
}

.hero-search-box {
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    padding: 4px;
    max-width: 350px;
    margin: 0 auto;
}

.hero-search-input {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: white;
    outline: none;
}

.hero-search-input::placeholder {
    color: rgba(255, 255, 255, 0.8);
}

.hero-search-btn {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    padding: 0 20px;
    border-radius: calc(var(--radius-full) - 4px);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
}

/* ========================================
   促销卡片
   ======================================== */
.promo-cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 24px 16px;
    max-width: calc(100% - 32px);
    overflow: hidden;
    box-sizing: border-box;
}

.promo-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    overflow: hidden;
    min-width: 0;
    box-sizing: border-box;
}

.promo-card:active {
    transform: scale(0.98);
}

.promo-card:last-child {
    grid-column: span 2;
}

.promo-icon-box {
    width: 55px;
    height: 55px;
    flex-shrink: 0;
    background: #f5f5f5;
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-width: 48px;
}

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

.promo-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.promo-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.promo-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.promo-tag {
    font-size: 10px;
    color: var(--theme-color);
    white-space: nowrap;
    flex-shrink: 0;
}

.promo-desc {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   区块标题
   ======================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title-group {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.view-all-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    color: var(--theme-color);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(240, 68, 148, 0.2);
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.view-all-btn:active {
    background: #fff0f5;
    transform: scale(0.98);
}

/* ========================================
   游戏列表项
   ======================================== */
.game-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}

.game-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: transform var(--transition-fast);
}

.game-item:active {
    transform: scale(0.99);
}

.game-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.game-icon-box {
    width: 65px;
    height: 65px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #f5f5f5;
}

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

.game-info-box {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.game-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.game-desc {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.game-tags-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.game-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    color: white;
    white-space: nowrap;
}

.tag-hot { background: var(--tag-bg-hot); }
.tag-gameplay { background: var(--tag-bg-gameplay); }
.tag-theme { background: var(--tag-bg-theme); }
.tag-default { background: var(--tag-bg-default); }

.platform-tag-gm {
    background: var(--platform-bg-gm) !important;
    box-shadow: 0 2px 6px rgba(255, 65, 108, 0.4);
    order: -1;
}

.platform-tag-buyout {
    background: var(--platform-bg-buyout) !important;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.4);
    order: -1;
}

.game-action {
    flex-shrink: 0;
}

.download-btn {
    background: var(--theme-gradient);
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   分页 & 无限滚动
   ======================================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.pagination a:hover {
    border-color: var(--theme-color);
    color: var(--theme-color);
}

.pagination .active {
    background: var(--theme-gradient);
    color: white;
    border-color: transparent;
}

/* 无限滚动加载容器 */
.load-more-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    margin-bottom: 20px;
}

.load-more-btn {
    background: var(--bg-card);
    color: var(--theme-color);
    border: 2px solid var(--theme-color);
    padding: 12px 32px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.load-more-btn:hover {
    background: var(--theme-color);
    color: white;
}

.load-more-btn:active {
    transform: scale(0.98);
}

.loading-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.no-more-data {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 16px;
}

/* ========================================
   底部导航
   ======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1080px;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 999;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    width: 25%;
    height: 100%;
    transition: color var(--transition-fast);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: var(--theme-color);
}

.nav-item svg {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    fill: currentColor;
}

/* ========================================
   Footer
   ======================================== */
.site-footer {
    background: var(--bg-card);
    padding: 16px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid #e5e7eb;
    max-width: 100%;
    overflow: hidden;
}

.site-footer p {
    margin: 4px 0;
    word-break: break-word;
}

/* ========================================
   空状态 & 加载状态
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

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

.loading-indicator {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--theme-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   灯箱
   ======================================== */
.lightbox {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 95%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 4px;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    color: white;
    font-size: 32px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

/* ========================================
   Toast 提示
   ======================================== */
.toast {
    visibility: hidden;
    min-width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    position: fixed;
    z-index: 5000;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    visibility: visible;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        bottom: 60px;
        opacity: 0;
    }
    to {
        bottom: 80px;
        opacity: 1;
    }
}

/* ========================================
   响应式适配
   ======================================== */
@media (max-width: 767px) {
    :root {
        --header-height: 52px;
    }
    
    body {
        padding-left: 0;
        padding-right: 0;
    }
    
    .container {
        padding-left: 12px;
        padding-right: 12px;
        max-width: 100%;
    }
    
    .site-header {
        padding-left: 0;
        padding-right: 0;
    }
    
    .header-inner {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .header-logo-text {
        display: none !important;
    }
    
    .promo-cards-container {
        gap: 10px;
        margin: 20px 12px;
        max-width: calc(100% - 24px);
    }
    
    .game-list {
        padding-left: 0;
        padding-right: 0;
    }
    
    .game-item {
        padding: 10px;
        margin-left: 0;
        margin-right: 0;
    }
    
    .game-item-link {
        padding-left: 0;
        padding-right: 0;
    }
    
    .game-icon-box {
        width: 65px;
        height: 65px;
    }
    
    .game-title {
        font-size: 14px;
    }
    
    .game-desc {
        font-size: 11px;
    }
    
    .download-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    .section-header {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (min-width: 768px) {
    .header-logo img {
        height: 43px;
    }
    
    .header-logo-text {
        display: inline;
    }
    
    .hero-title {
        font-size: 26px;
    }
    
    .section-title {
        font-size: 20px;
    }
}

/* ========================================
   辅助工具类
   ======================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }

.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* 桌面端底部导航居中 */
@media (min-width: 1080px) {
    .bottom-nav {
        left: 50%;
        transform: translateX(-50%);
        max-width: 1080px;
    }
}
