:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f5f5;
    --text-color: #333;
    --border-radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: Arial, sans-serif;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1000px;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--secondary-color);
}

header, footer {
    text-align: center;
    padding: 1em 0;
}

header {
    background-color: #333;
    color: white;
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 90px 0; /* 上下间距设置为一个icon的高度 */
    max-width: 1000px;
    margin: 0 auto;
}

#game-container {
    width: 100%;
    max-width: 600px;
    height: 400px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
}

.ad-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
    padding: 1em;
    margin-bottom: 1em;
}

#top-ad {
    width: 100%;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.games-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 10px;
    max-width: 1000px;
    margin: 0 auto;
    justify-content: flex-start; /* 改为居左对齐 */
}

/* 添加容器以保持整体居中但内容左对齐 */
.games-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0;
}

.game-item {
    flex: 0 0 85px; /* 固定宽度 */
    height: 85px;
    text-align: center;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    background: white;
    overflow: hidden; /* 防止内容溢出 */
}

.game-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.game-item img {
    width: 55px;
    height: 55px;
    object-fit: contain;
    margin-bottom: 4px;
}

.game-item h3 {
    margin: 2px 0;
    font-size: 0.75em;
    white-space: nowrap; /* 强制单行显示 */
    overflow: hidden;
    text-overflow: ellipsis; /* 超出显示省略号 */
    width: 77px; /* 固定宽度 = 容器宽度(85px) - 左右padding(4px * 2) */
    padding: 0;
    color: var(--text-color);
    line-height: 1.2;
    height: 1.2em; /* 单行高度 */
}

.game-item a {
    text-decoration: none;
    color: inherit;
    display: block;
    width: 100%;
    height: 100%;
}

footer {
    color: #333; /* 更改为深灰色文字 */
    padding: 1.5em 0;
    background: linear-gradient(to right, #fff, #f8f9fa);
    border-top: 1px solid #eee;
}

.footer-links {
    margin-bottom: 1em;
    white-space: nowrap; /* 防止换行 */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px; /* 使用gap控制链接间距 */
}

.footer-links a {
    color: #666; /* 更改链接颜色为灰色 */
    text-decoration: none;
    margin: 0 0.5em;
    font-size: 14px; /* 设置基础字体大小 */
    padding: 0.5em 1em;
    border-radius: 20px;
    transition: all 0.3s ease;
}

/* 修改分隔符样式 */
.footer-links span {
    color: #666;
    margin: 0;
}

.footer-links a:hover {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

.copyright {
    margin-top: 0.5em;
}

/* Media queries for responsiveness */
@media (max-width: 768px) {
    :root {
        --border-radius: 8px;
    }

    header, footer {
        padding: 0.5em 0;
    }

    main {
        padding: 70px 0; /* 适配平板端icon高度 */
    }

    #game-container {
        height: 300px;
    }

    .games-grid {
        gap: 8px;
        padding: 0 8px;
    }

    .game-item {
        flex: 0 0 70px;
        height: 70px;
        padding: 3px;
        overflow: hidden; /* 防止内容溢出 */
    }

    .game-item img {
        width: 45px;
        height: 45px;
    }

    .game-item h3 {
        font-size: 0.7em;
        padding: 0 2px;
        width: 62px; /* 70px - (4px * 2) */
    }

    .footer-links {
        gap: 6px; /* 减小间距 */
    }

    .footer-links a {
        font-size: 13px; /* 稍微减小字体 */
    }
}

@media (max-width: 480px) {
    :root {
        --border-radius: 6px;
    }

    header h1, footer p {
        font-size: 1.2em;
    }

    main {
        padding: 45px 0; /* 适配移动端icon高度 */
    }

    #game-container {
        height: 200px;
    }

    .games-grid {
        gap: 4px;
        padding: 0 4px;
    }
    
    .footer-links a {
        display: inline;
        margin: 0;
        color: #666; /* 确保移动端也使用相同的链接颜色 */
    }

    .footer-links {
        gap: 4px; /* 进一步减小间距 */
    }

    .footer-links a {
        font-size: 12px; /* 更小的字体 */
    }

    .game-item {
        flex: 0 0 72px; /* 增加宽度以适应文字 */
        height: 72px;
        padding: 3px;
        box-sizing: border-box;
        overflow: hidden; /* 防止内容溢出 */
    }

    .game-item img {
        width: 45px; /* 增加图片尺寸 */
        height: 45px;
        margin-bottom: 2px;
    }

    .game-item h3 {
        font-size: 0.65em;
        margin: 1px 0;
        padding: 0;
        width: 66px; /* 72px - (3px * 2) */
        line-height: 1.2;
        height: 1.2em;
    }

    .ad-container {
        padding: 0;
    }
}

/* 添加平板端优化 */
@media (min-width: 481px) and (max-width: 768px) {
    body {
        padding: 0 15px;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 70px));
        gap: 8px;
        padding: 0 8px;
    }

    .game-item {
        width: 70px;
        height: 70px;
        aspect-ratio: auto; /* 移除这个属性 */
    }
}

/* 移除之前的中等尺寸屏幕断点，现在使用auto-fill自动处理 */

/* 游戏详情页样式 */
.game-detail {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.game-detail-header {
    width: 100%;
    display: flex;
    align-items: flex-start; /* 改为顶部对齐 */
    gap: 20px;
    margin-bottom: 20px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-sizing: border-box;
}

.game-detail-icon {
    flex: 0 0 120px; /* 固定宽度 */
    height: 120px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid #ddd;
    padding: 10px;
    background: white;
}

.game-detail-info {
    flex: 1;
    min-width: 0; /* 防止内容溢出 */
    position: relative; /* 添加相对定位 */
}

.game-detail-info h1 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: var(--text-color);
    word-break: break-word; /* 允许长标题换行 */
    display: flex;
    justify-content: space-between; /* 添加空间分配 */
    align-items: center; /* 垂直居中 */
}

.game-type {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    margin-bottom: 10px;
}

.game-description {
    color: var(--text-color);
    line-height: 1.6;
    margin-bottom: 20px;
    word-break: break-word; /* 允许长文本换行 */
}

.game-container {
    width: 100%;
    height: 600px;
    border: none;
    background: #f0f0f0;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* 分类按钮样式 */
.more-categories {
    margin-top: 20px;
}

.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-button {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s ease;
}

.category-button:hover {
    background: darken(var(--primary-color), 10%);
}

/* 更多游戏样式 */
.more-games {
    margin-top: 40px;
}

.more-games .games-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-detail {
        padding: 15px;
    }

    .game-detail-header {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .game-detail {
        padding: 10px;
    }

    .game-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 10px;
    }

    .game-detail-icon {
        width: 80px;
        height: 80px;
        margin-bottom: 10px;
    }

    .game-detail-info h1 {
        font-size: 20px;
    }

    .game-container {
        height: 300px;
    }
}

/* 添加返回首页链接的样式 */
.back-to-home {
    display: inline-block;
    margin-top: 0; /* 移除顶部外边距 */
    padding: 5px 10px; /* 调整内边距 */
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s ease;
}

.back-to-home:hover {
    background: darken(var(--primary-color), 10%);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
