/* --- General Body & Font Styling --- */
body {
    font-family: 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
    margin: 0;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Header Styling --- */
header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #333;
    font-size: 24px;
    font-weight: bold;
}

.logo-link img {
    height: 40px;
    margin-right: 12px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.main-nav a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: color 0.2s;
    white-space: nowrap;
}

.main-nav a:hover {
    color: #007bff;
}

/* 搜索框样式 */
.main-nav .search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 20px;
}

.main-nav .search-input {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    width: 250px;
    transition: all 0.3s;
    outline: none;
}

.main-nav .search-input:focus {
    border-color: #007bff;
    width: 300px;
}

.main-nav .search-btn {
    padding: 8px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    white-space: nowrap;
}

.main-nav .search-btn:hover {
    background: #0056b3;
}

.user-auth a {
    margin-left: 15px;
    text-decoration: none;
    color: #007bff;
    font-weight: 500;
}

.user-auth a:last-child {
    background-color: #007bff;
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.user-auth a:last-child:hover {
    background-color: #0056b3;
}

/* --- Main Content Styling --- */
main {
    padding: 40px 0;
}

.featured-games h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.game-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    text-decoration: none;
    color: #333;
    transition: transform 0.2s, box-shadow 0.2s;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.game-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.game-card-content {
    padding: 20px;
}

.game-card-content h3 {
    margin-top: 0;
    font-size: 20px;
}

/* --- Wallpaper Grid Styling --- */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.wallpaper-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    text-decoration: none;
    color: #333;
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
    position: relative;
}

.wallpaper-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* 图片容器基础样式 */
.wallpaper-card .image-container {
    position: relative;
    width: 100%;
    background-color: #f8f8f8;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 16:9横屏比例 - 适合大多数显示器 */
.wallpaper-card .image-container.ratio-16-9 {
    aspect-ratio: 16 / 9;
}

/* 16:10比例 - 适合笔记本电脑 */
.wallpaper-card .image-container.ratio-16-10 {
    aspect-ratio: 16 / 10;
}

/* 21:9超宽屏比例 - 适合超宽显示器 */
.wallpaper-card .image-container.ratio-21-9 {
    aspect-ratio: 21 / 9;
}

/* 9:16竖屏比例 - 适合手机壁纸 */
.wallpaper-card .image-container.ratio-9-16 {
    aspect-ratio: 9 / 16;
}

/* 1:1正方形比例 - 适合头像等 */
.wallpaper-card .image-container.ratio-1-1 {
    aspect-ratio: 1 / 1;
}

/* 4:3传统比例 */
.wallpaper-card .image-container.ratio-4-3 {
    aspect-ratio: 4 / 3;
}

/* 3:2比例 */
.wallpaper-card .image-container.ratio-3-2 {
    aspect-ratio: 3 / 2;
}

/* 默认比例 - 自适应图片原始比例 */
.wallpaper-card .image-container.ratio-default {
    min-height: 150px;
    max-height: 300px;
}

/* 图片样式 - 确保填充容器并保持比例 */
.wallpaper-card .image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 对于默认比例，让图片决定容器高度 */
.wallpaper-card .image-container.ratio-default img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* 针对不同比例的特殊处理 - 使用CSS Grid自适应布局 */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-flow: dense;
    gap: 20px;
}

/* 移除特殊的跨列/跨行规则，让所有图片保持在单个网格单元内 */
/* 这样可以确保图片容器的比例正确显示 */

/* 在中等屏幕上的调整 */
@media (max-width: 1024px) {
    .wallpaper-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* 在小屏幕上的调整 */
@media (max-width: 768px) {
    .wallpaper-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .wallpaper-grid {
        grid-template-columns: 1fr;
    }
}

/* 兼容旧版本的直接img标签 */
.wallpaper-card > img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.wallpaper-card-content {
    padding: 10px;
}

.wallpaper-card-content h3 {
    margin: 0;
    font-size: 14px;
    font-weight: normal;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 宽高比标签 */
.aspect-ratio-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1;
}

/* 为不同比例添加视觉提示 */
.wallpaper-card {
    position: relative;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.wallpaper-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* 优化图片加载时的显示 */
.wallpaper-card .image-container {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.wallpaper-card .image-container img {
    transition: opacity 0.3s ease;
}

/* 添加加载状态 */
.wallpaper-card .image-container img[loading] {
    opacity: 0;
}

.wallpaper-card .image-container img:not([loading]) {
    opacity: 1;
}

/* --- Search Section Styling --- */
.search-section {
    background-color: #f8f9fa;
    padding: 40px 20px;
    border-radius: 10px;
    margin: 40px 0;
}

.search-section h2 {
    color: #333;
    margin-bottom: 20px;
}

.search-form {
    max-width: 600px;
    margin: 0 auto;
}

.search-form > div {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s;
}

.search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-btn {
    padding: 12px 30px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    white-space: nowrap;
}

.search-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2);
}

.search-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

/* --- Footer Styling --- */
footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
}

footer p {
    white-space: pre-wrap;
}

/* --- Auth Page Specific Overlays --- */
body.auth-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3); /* Dark overlay */
    z-index: -1;
}

/* --- 轮播图样式 --- */
.carousel-section {
    margin-bottom: 60px;
}

.carousel-section h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
    color: #333;
}

/* 不同比例的轮播图容器 */
.carousel {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    background: #000;
}

/* 16:9 横屏轮播图 */
.carousel-16-9 {
    aspect-ratio: 16 / 9;
}

/* 16:10 笔记本轮播图 */
.carousel-16-10 {
    aspect-ratio: 16 / 10;
}

/* 21:9 超宽屏轮播图 */
.carousel-21-9 {
    aspect-ratio: 21 / 9;
}

/* 9:16 竖屏轮播图 */
.carousel-9-16 {
    aspect-ratio: 9 / 16;
    max-width: 500px; /* 增加竖屏轮播图的最大宽度 */
    max-height: 80vh; /* 限制最大高度不超过视口80% */
}

/* 1:1 正方形轮播图 */
.carousel-1-1 {
    aspect-ratio: 1 / 1;
    max-width: 600px; /* 限制正方形轮播图的最大宽度 */
}

/* 轮播图内部样式 */
.carousel-inner {
    display: flex;
    transition: transform 0.5s ease-in-out;
    height: 100%;
}

.carousel-item {
    min-width: 100%;
    height: 100%;
    position: relative;
}

.carousel-item a {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 使用contain确保图片完整显示 */
    display: block;
    transition: transform 0.3s ease;
}

.carousel-item a:hover img {
    transform: scale(1.02);
}

/* 轮播图控制按钮 */
.carousel-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.6);
    color: white;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    z-index: 10;
    font-size: 24px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.carousel-control:hover {
    background-color: rgba(0,0,0,0.8);
}

.carousel-control.prev {
    left: 20px;
}

.carousel-control.next {
    right: 20px;
}

/* 轮播图指示器 */
.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: background-color 0.3s;
}

.indicator.active {
    background-color: white;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-nav .search-input {
        width: 200px;
    }
    
    .main-nav .search-input:focus {
        width: 250px;
    }
}

@media (max-width: 768px) {
    header .container {
        flex-wrap: wrap;
    }
    
    .main-nav {
        order: 3;
        width: 100%;
        margin-top: 10px;
        justify-content: center;
    }
    
    .main-nav .search-form {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .main-nav .search-input {
        flex: 1;
    }
    
    .carousel-9-16 {
        max-width: 90vw; /* 在小屏幕上使用视口宽度的90% */
        max-height: 75vh; /* 调整最大高度 */
    }
    
    .carousel-1-1 {
        max-width: 400px;
    }
    
    .carousel-control {
        padding: 10px 15px;
        font-size: 20px;
    }
    
    .carousel-control.prev {
        left: 10px;
    }
    
    .carousel-control.next {
        right: 10px;
    }
}

/* 淡入淡出效果 */
.carousel.fade .carousel-inner {
    display: block;
}

.carousel.fade .carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

.carousel.fade .carousel-item.active {
    opacity: 1;
}

/* 缩放效果 */
.carousel.zoom .carousel-inner {
    display: block;
}

.carousel.zoom .carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    transform: scale(1.1);
    opacity: 0;
    transition: transform 0.6s ease-in-out, opacity 0.6s ease-in-out;
}

.carousel.zoom .carousel-item.active {
    transform: scale(1);
    opacity: 1;
}

/* --- 图片水印样式 --- */
.watermark-container {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.watermark-container .image-watermark {
    position: absolute;
    top: 10px;
    left: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 1;
    font-family: Arial, sans-serif;
    letter-spacing: 1px;
}

/* 针对不同大小的图片调整水印 */
@media (max-width: 480px) {
    .watermark-container .image-watermark {
        font-size: 12px;
        top: 5px;
        left: 5px;
    }
}

/* 确保水印在图片容器内正确显示 */
.wallpaper-card .watermark-container {
    width: 100%;
    height: 100%;
}

.carousel-item .watermark-container {
    width: 100%;
    height: 100%;
}

/* 防止水印影响布局 */
.watermark-container img {
    display: block;
    max-width: 100%;
    height: auto;
}
