/* 基础重置与移动端适配 (保持不变) */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    color: #333;
}

.app-header {
    background-color: #4A90E2;
    color: white;
    padding: 15px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 搜索和切换控件容器 */
.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: white;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
}

/* 搜索框样式 */
.search-box {
    /* 调整 flex-grow，确保搜索框有足够的空间 */
    flex-grow: 1; 
    /* 保持搜索框的最小宽度，防止在极端窄屏被过度压缩 */
    min-width: 150px; 
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 5px 10px;
    background-color: #fff;
    margin-right: 10px;
}

.search-box i {
    color: #999;
    margin-right: 8px;
}

#searchInput {
    border: none;
    outline: none;
    flex-grow: 1;
    font-size: 16px;
    padding: 0;
}

/* 视图切换按钮样式 - 保持不变 */
.view-toggle {
    /* 确保按钮组不会被压缩，避免换行 */
    flex-shrink: 0; 
}

.view-toggle button {
    background: none;
    border: 1px solid #ccc;
    color: #4A90E2;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 5px;
    transition: background-color 0.2s, color 0.2s;
}

.view-toggle button.active {
    background-color: #4A90E2;
    color: white;
}

/* 游戏列表/宫格容器 */
#gameListContainer {
    padding: 0 10px;
    display: grid;
    gap: 10px;
}

/* 列表视图 (默认) */
.list-view {
    grid-template-columns: 1fr;
}

.list-view .game-item {
    display: flex;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
}

/* 解决问题 1：图片底部的空白 */
.list-view .game-cover {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    overflow: hidden;
}

.list-view .game-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 关键改动：将图片设置为 block 级元素，消除基线对齐导致的底部空白 */
    display: block; 
}

.list-view .game-info {
    padding: 10px;
    flex-grow: 1;
    min-width: 0;
}

.list-view .game-title {
    font-size: 18px;
    margin: 0 0 5px 0;
    color: #4A90E2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-view .game-intro {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.list-view .game-time {
    font-size: 12px;
    color: #999;
    /* 关键改动：移除或设置为零，以消除 p 标签默认的底部空白 */
    margin-bottom: 0; 
    /* 确保顶部也没有多余的边距，如果需要可以调整为 small value */
    margin-top: 5px;
}

/* 宫格视图 (保持不变) */
.grid-view {
    grid-template-columns: repeat(2, 1fr); 
    padding: 10px;
}

.grid-view .game-item {
    display: block;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
    padding-bottom: 10px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
}

.grid-view .game-cover {
    width: 100%;
    height: 150px;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
}

.grid-view .game-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block; /* 同样将图片设为 block */
}

.grid-view .game-info {
    padding: 5px 10px 0;
}

.grid-view .game-title {
    font-size: 16px;
    margin: 5px 0 3px 0;
    color: #4A90E2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-view .game-intro, .grid-view .game-time {
    display: none;
}

/* 媒体查询：平板及桌面端 (保持不变) */
@media (min-width: 600px) {
    .controls-container {
        max-width: 800px;
        margin: 10px auto;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        border: none;
    }
    
    #gameListContainer {
        max-width: 800px;
        margin: 0 auto;
        padding: 0;
    }

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