/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #107c10;
    --primary-hover: #0b6b0b;
    --secondary-color: #1a1a1a;
    --text-color: #ffffff;
    --text-muted: #a0a0a0;
    --background-color: #0a0a0a;
    --card-background: #1a1a1a;
    --border-color: #333;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.4);
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ===== 头部样式 ===== */
.header {
    background: linear-gradient(135deg, #107c10 0%, #0b6b0b 100%);
    padding: 10px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: auto;
    flex: 0 0 auto;
}

.title {
    font-size: clamp(1.1rem, 1.7vw, 1.55rem);
    font-weight: 700;
    margin-bottom: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.subtitle {
    display: none; /* 隐藏副标题以节省空间 */
}

.search-container {
    width: min(680px, 100%);
    max-width: 680px;
    margin: 0;
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.search-input {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    outline: none;
    transition: var(--transition);
    height: auto;
    min-height: 20px;
    min-width: 0;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
}

.search-input:focus {
    border-color: var(--text-color);
    background: rgba(255, 255, 255, 0.15);
}

.search-button {
    padding: 6px 12px;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    height: auto;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sort-select {
    padding: 6px 12px;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    min-height: 20px;
}

.sort-select:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--text-color);
}

.sort-select:focus {
    border-color: var(--text-color);
    background: rgba(255, 255, 255, 0.15);
}

.sort-select option {
    background: var(--secondary-color);
    color: var(--text-color);
}

.search-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--text-color);
}

/* ===== 主内容样式 ===== */
.main {
    flex: 1;
    padding: 40px 0;
}

/* ===== 统计栏样式 ===== */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* ===== 加载动画 ===== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading-container p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ===== 错误信息 ===== */
.error-container {
    text-align: center;
    padding: 60px 20px;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.error-container h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-color);
}

.error-container p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.retry-button {
    padding: 12px 30px;
    font-size: 1rem;
    border: none;
    border-radius: 25px;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.retry-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* ===== 游戏网格 ===== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 游戏卡片 ===== */
.game-card {
    background: var(--card-background);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.game-card:focus-visible,
.search-button:focus-visible,
.load-more-button:focus-visible,
.retry-button:focus-visible,
.game-link:focus-visible {
    outline: 3px solid #9bf00b;
    outline-offset: 3px;
}

.game-image {
    width: 100%;
    height: 280px; /* 改为与卡片宽度接近的正方形 */
    object-fit: cover;
    object-position: center;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
}

.game-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.game-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
    line-height: 1.4;
    min-height: 60px;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.game-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #ffd700;
    font-size: 1rem;
}

.rating-number {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.game-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.category-tag {
    background: rgba(16, 124, 16, 0.2);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(16, 124, 16, 0.3);
}

.game-developer {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
    line-height: 1.4;
}

.game-developer small {
    opacity: 0.8;
}

.game-publisher {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
    line-height: 1.4;
}

.game-publisher small {
    opacity: 0.8;
}

.game-price {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    font-size: 0.85rem;
    color: #90ee90;
    font-weight: 600;
}

.game-date {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.game-date::before {
    content: '📅';
}

.game-link {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9rem;
    text-align: center;
    transition: var(--transition);
}

.game-link:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.load-more-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 36px;
}

.load-more-container[hidden] {
    display: none;
}

.load-more-button {
    padding: 12px 30px;
    border: 1px solid var(--primary-color);
    border-radius: 24px;
    background: var(--primary-color);
    color: white;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.load-more-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.results-progress {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== 无结果提示 ===== */
.no-results {
    text-align: center;
    padding: 60px 20px;
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-color);
}

.no-results p {
    color: var(--text-muted);
}

/* ===== 页脚样式 ===== */
.footer {
    background: var(--secondary-color);
    padding: 30px 0;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.footer p {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.footer-note {
    font-size: 0.8rem !important;
    opacity: 0.7;
}

/* ===== 响应式设计 ===== */
@media (max-width: 900px) {
    .header {
        min-height: 0;
        padding: 14px 0;
    }

    .header .container {
        flex-direction: column;
        gap: 10px;
    }

    .header-content {
        justify-content: center;
    }

    .search-container {
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .header {
        height: auto;
        min-height: 0;
    }

    .title {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .search-container {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .search-button {
        width: auto;
    }

    .sort-select {
        grid-column: 1 / -1;
        width: 100%;
    }

    .stats-bar {
        gap: 20px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }

    .game-image {
        height: 180px;
    }

    .game-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 12px 0;
    }

    .title {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.8rem;
    }

    .games-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .game-image {
        height: 200px;
    }

    .game-content {
        padding: 15px;
    }
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ===== 选择文本样式 ===== */
::selection {
    background: var(--primary-color);
    color: white;
}

/* ===== 新游戏标记样式 ===== */
.new-game {
    border: 2px solid #ff4444 !important;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.3) !important;
    animation: new-game-glow 2s ease-in-out infinite alternate;
}

.new-game .game-title {
    position: relative;
}

.new-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ff4444, #cc0000);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: new-badge-pulse 1.5s ease-in-out infinite;
}

@keyframes new-game-glow {
    from {
        box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
    }
    to {
        box-shadow: 0 0 30px rgba(255, 68, 68, 0.6);
    }
}

@keyframes new-badge-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
