/* ===== 简约大气·清新通用版 ===== */
:root {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(59, 130, 246, 0.15);
    --text: #1e293b;
    --text-light: #64748b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    --radius: 20px;
    --radius-sm: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

/* 主容器 */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* 头部导航 */
.main-nav {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--card-border);
    position: relative;
    overflow: hidden;
}

.header-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.nav-brand {
    width: 100%;
}

.nav-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

.nav-subtitle {
    font-size: 0.9rem;
    color: var(--text-light);
    background: #f1f5f9;
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 40px;
    margin-top: 0.5rem;
}

/* 快速导航按钮 */
.quick-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.nav-btn {
    background: white;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 0.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(4px);
}

.nav-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

/* 广告区域 */
.banner-section {
    margin-bottom: 2rem;
}

.banner-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.banner-card {
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    border: 1px solid #eef2ff;
}

.banner-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.banner-link {
    display: block;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #f8fafc;
}

.banner-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.banner-card:hover .banner-image {
    transform: scale(1.02);
}

.banner-content {
    padding: 0.6rem;
    text-align: center;
    background: white;
}

.banner-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 搜索栏 */
.search-section {
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 48px;
    font-size: 0.95rem;
    background: white;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

/* 游戏网格 */
.games-section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.2rem;
}

.section-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.section-subtitle {
    color: var(--text-light);
    font-size: 0.85rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.2rem;
}

/* 游戏卡片 */
.game-card {
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    border: 1px solid #eef2ff;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.game-media {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f1f5f9;
}

.game-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

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

.game-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

.game-info {
    padding: 0.8rem;
}

.game-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.3;
    height: 2.6rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.game-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    font-size: 0.75rem;
}

.game-type {
    background: #eef2ff;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    color: var(--primary);
    font-weight: 500;
}

.game-rating {
    color: var(--accent);
}

.play-button {
    width: 100%;
    background: var(--primary);
    border: none;
    border-radius: 40px;
    padding: 0.6rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.play-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.play-button.loading {
    background: #94a3b8;
    cursor: not-allowed;
}

/* 底部 */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    background: white;
    border-radius: var(--radius);
    margin-top: 2rem;
    border: 1px solid #eef2ff;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* 模态框 */
.game-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.game-modal.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-modal-header {
    width: 95%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 12px 12px 0 0;
    padding: 0.8rem 1.2rem;
}

.game-title-bar {
    font-weight: 600;
    color: var(--primary);
}

.modal-btn {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
}

.modal-btn:hover {
    background: #e2e8f0;
}

.game-modal-content {
    width: 95%;
    max-width: 1200px;
    height: 85vh;
    background: white;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.game-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* 保护提示 */
.protection-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
    text-align: center;
}

/* 响应式 */
@media (max-width: 1024px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
    .quick-nav {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.8rem;
    }
    .banner-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.8rem;
    }
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
    }
    .nav-title {
        font-size: 1.4rem;
    }
}

@media (max-width: 640px) {
    .quick-nav {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
    .nav-btn {
        font-size: 0.7rem;
        padding: 0.6rem 0.2rem;
    }
    .banner-title {
        font-size: 0.7rem;
    }
    .game-title {
        font-size: 0.8rem;
    }
    .play-button {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    .game-info {
        padding: 0.5rem;
    }
}

/* 游戏卡片随机颜色备用（可忽略） */
.color-1, .color-2, .color-3, .color-4, .color-5, .color-6 {
    /* 仅用于渐变背景，保留但无实际影响 */
}

/* ===== Telegram Mini App refinement ===== */
:root {
    --ink: #14213d;
    --muted: #71809a;
    --surface: rgba(255, 255, 255, .88);
    --line: rgba(29, 78, 216, .10);
    --blue: #2764f5;
    --violet: #7c4dff;
    --cyan: #09b9e8;
    --tg-safe-top: 0px;
    --tg-safe-bottom: 0px;
}

html { background: #eff4ff; }

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 0% 0%, rgba(61, 130, 255, .18), transparent 29rem),
        radial-gradient(circle at 100% 10%, rgba(139, 92, 246, .14), transparent 26rem),
        #f5f8ff;
    color: var(--ink);
}

.app-container {
    max-width: 1180px;
    padding: calc(20px + var(--tg-safe-top)) 20px calc(26px + var(--tg-safe-bottom));
}

.neon-bg { display: none; }

.main-nav {
    min-height: 134px;
    padding: 24px 28px;
    margin-bottom: 18px;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 28px;
    background:
        linear-gradient(118deg, rgba(21, 71, 190, .98), rgba(70, 60, 220, .95) 58%, rgba(111, 74, 242, .92));
    box-shadow: 0 18px 38px rgba(46, 63, 166, .22);
    isolation: isolate;
}

.main-nav::before,
.main-nav::after {
    position: absolute;
    content: '';
    z-index: -1;
    border-radius: 999px;
    opacity: .7;
}

.main-nav::before {
    width: 210px;
    height: 210px;
    right: -35px;
    top: -130px;
    background: radial-gradient(circle, rgba(132, 235, 255, .75) 0 2px, transparent 3px 100%), rgba(43, 205, 255, .20);
    background-size: 18px 18px;
    transform: rotate(20deg);
}

.main-nav::after {
    width: 175px;
    height: 175px;
    left: 40%;
    bottom: -125px;
    border: 24px solid rgba(162, 149, 255, .22);
}

.geometric-pattern { display: none; }

.header-wrapper {
    position: relative;
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
    gap: 16px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #2857da;
    font-size: 22px;
    background: linear-gradient(145deg, #fff, #c8f3ff);
    box-shadow: 0 8px 18px rgba(9, 17, 96, .25);
}

.brand-copy { min-width: 0; }

.app-kicker {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    color: rgba(255,255,255,.72);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
}

.app-kicker span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #60f5bb;
    box-shadow: 0 0 0 4px rgba(96,245,187,.14);
}

.nav-title {
    margin: 0;
    color: #fff;
    background: none;
    -webkit-text-fill-color: currentColor;
    font-size: clamp(23px, 4vw, 30px);
    letter-spacing: -.04em;
    line-height: 1.15;
}

.nav-subtitle {
    display: block;
    max-width: 480px;
    padding: 0;
    margin: 6px 0 0;
    border-radius: 0;
    background: transparent;
    color: rgba(255,255,255,.75);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 11px;
    align-self: flex-start;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    color: #fff;
    background: rgba(255,255,255,.12);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    backdrop-filter: blur(8px);
}

.header-status i { color: #ffdf75; }

.quick-nav { margin: 0 0 18px; gap: 10px; }

.nav-btn {
    position: relative;
    overflow: hidden;
    padding: 12px 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: #38517a;
    box-shadow: 0 7px 18px rgba(47, 77, 132, .07);
    font-size: 13px;
}

.nav-btn::before {
    content: '↗';
    display: inline-block;
    margin-right: 5px;
    color: var(--blue);
    font-weight: 800;
}

.nav-btn:hover { color: #fff; background: var(--blue); transform: translateY(-2px); }
.nav-btn:hover::before { color: #fff; }

.banner-section { margin-bottom: 18px; }
.banner-grid { gap: 12px; }
.banner-card { border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 7px 20px rgba(49, 72, 131, .07); }
.banner-content { padding: 9px 10px 10px; }
.banner-title { color: #3a4d6d; font-size: 12px; font-weight: 700; }

.search-section { margin-bottom: 14px; }
.search-box { gap: 8px; }
.search-input {
    min-height: 50px;
    padding-left: 46px;
    border: 1px solid rgba(31, 83, 206, .13);
    border-radius: 17px;
    color: var(--ink);
    background: rgba(255,255,255,.9);
    box-shadow: 0 8px 22px rgba(47, 74, 143, .08);
}
.search-input::placeholder { color: #9ba9c0; }
.search-input:focus { border-color: rgba(39,100,245,.55); box-shadow: 0 0 0 4px rgba(39,100,245,.1), 0 8px 22px rgba(47,74,143,.08); }
.search-icon { left: 17px; color: var(--blue); }
.search-submit {
    height: 50px;
    min-width: 96px;
    margin: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--blue), var(--violet));
    box-shadow: 0 9px 18px rgba(56, 78, 213, .26);
}
.search-submit i { margin-right: 6px; }

.category-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -2px 20px;
    padding: 3px 2px 8px;
    scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab {
    flex: 0 0 auto;
    padding: 8px 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: none;
    color: #667797;
    font-size: 13px;
}
.category-tab:hover { transform: none; background: #eef3ff; color: var(--blue); border-color: rgba(39,100,245,.18); box-shadow: none; }
.category-tab.active { border-color: transparent; background: linear-gradient(135deg, var(--blue), var(--violet)); box-shadow: 0 8px 16px rgba(63,83,214,.22); }

.games-section { margin-bottom: 4px; }
.section-header { margin-bottom: 14px; }
.section-title { position: relative; padding-left: 12px; color: var(--ink); font-size: 20px; letter-spacing: -.03em; }
.section-title::before { position: absolute; content: ''; left: 0; top: 4px; bottom: 4px; width: 4px; border-radius: 6px; background: linear-gradient(var(--cyan), var(--blue)); }
.section-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; }

.games-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.game-card {
    border: 1px solid rgba(30, 77, 169, .10);
    border-radius: 18px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 9px 22px rgba(48, 74, 135, .075);
}
.game-card:hover { border-color: rgba(39,100,245,.35); box-shadow: 0 15px 27px rgba(44,65,138,.16); transform: translateY(-4px); }
.game-media { aspect-ratio: 1.25 / 1; background: linear-gradient(145deg, #e3ebff, #f6f8ff); }
.game-media::after { position: absolute; content: ''; inset: auto 0 0; height: 42%; background: linear-gradient(transparent, rgba(7,18,62,.18)); pointer-events: none; }
.game-poster { position: relative; z-index: 0; }
.game-badge { z-index: 1; top: 9px; right: 9px; padding: 4px 8px; border: 1px solid rgba(255,255,255,.4); border-radius: 9px; background: rgba(18,34,86,.68); box-shadow: 0 3px 10px rgba(0,0,0,.15); backdrop-filter: blur(7px); font-size: 10px; }
.game-info { padding: 11px; }
.game-title { height: auto; min-height: 34px; margin-bottom: 8px; color: #1c2c4a; font-size: 13px; font-weight: 750; line-height: 1.34; }
.game-meta { margin-bottom: 10px; }
.game-type { background: #edf3ff; color: #486bb1; font-size: 10px; font-weight: 750; }
.game-rating { font-size: 11px; color: #ffae28; }
.play-button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px; border-radius: 11px; background: linear-gradient(135deg, #2764f5, #7656ef); box-shadow: 0 7px 13px rgba(58,78,212,.20); font-size: 12px; }
.play-button i { font-size: 9px; }
.play-button:hover { background: linear-gradient(135deg, #174fe0, #6540ed); }
.play-button:active { transform: scale(.97); }

.pagination { gap: 7px; margin: 26px 0 0; }
.pagination a, .pagination span { min-width: 34px; height: 34px; padding: 0 .7rem; border: 1px solid var(--line); box-shadow: none; color: #59709c; font-size: 12px; }
.pagination a:hover, .pagination .active { background: var(--blue); border-color: var(--blue); color: #fff; }
.app-footer { padding: 17px; margin-top: 24px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.58); }

.telegram-webapp[data-telegram-theme="dark"] body { background: #10182c; color: #eaf0ff; }
.telegram-webapp[data-telegram-theme="dark"] .game-card,
.telegram-webapp[data-telegram-theme="dark"] .search-input,
.telegram-webapp[data-telegram-theme="dark"] .nav-btn { background: rgba(29,41,68,.92); border-color: rgba(183,205,255,.12); color: #dce7ff; }
.telegram-webapp[data-telegram-theme="dark"] .game-title,
.telegram-webapp[data-telegram-theme="dark"] .section-title { color: #eff4ff; }
.telegram-webapp[data-telegram-theme="dark"] .game-type { background: rgba(67,104,185,.25); color: #bbd0ff; }
.telegram-webapp[data-telegram-theme="dark"] .app-footer { background: rgba(29,41,68,.66); }

@media (max-width: 768px) {
    .app-container { padding: calc(14px + var(--tg-safe-top)) 12px calc(20px + var(--tg-safe-bottom)); }
    .main-nav { min-height: 114px; padding: 19px 17px; margin-bottom: 14px; border-radius: 22px; }
    .brand-mark { width: 44px; height: 44px; flex-basis: 44px; border-radius: 15px; font-size: 18px; }
    .header-status { display: none; }
    .nav-subtitle { max-width: calc(100vw - 105px); font-size: 11px; }
    .quick-nav { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
    .nav-btn { padding: 10px 7px; font-size: 12px; }
    .banner-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
    .search-submit { min-width: 50px; padding: 0; }
    .search-submit span { display: none; }
    .search-submit i { margin: 0; }
    .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .game-card { border-radius: 16px; }
    .game-info { padding: 10px; }
    .game-title { min-height: 32px; font-size: 12px; }
}

@media (max-width: 370px) {
    .games-grid { gap: 8px; }
    .game-info { padding: 8px; }
    .play-button { padding: 8px 4px; }
    .play-button i { display: none; }
}
