/* CSS Custom Properties */
:root {
    --primary-color: #FF6B35;
    --secondary-color: #4ECDC4;
    --bg-light: #FFF9F5;
    --text-main: #333333;
    --text-light: #999999;
    --white: #FFFFFF;
    --shadow-light: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 16px rgba(0,0,0,0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-main);
    background-color: var(--bg-light);
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: var(--transition);
}

.navbar.scrolled {
    background: rgba(255, 255, 255, 1);
    box-shadow: var(--shadow-light);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.nav-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category-btn {
    padding: 8px 7px;
    border-radius: 6px;
    background: #f5f5f5;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.category-btn:hover {
    background: var(--primary-color);
    color: var(--white);
}

.category-btn.active {
    background: var(--primary-color);
    color: var(--white);
}

.nav-search {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 200px;
    padding: 10px 40px 10px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-btn {
    position: absolute;
    right: 8px;
    padding: 6px;
    color: var(--text-light);
    transition: var(--transition);
}

.search-btn:hover {
    color: var(--primary-color);
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    /* Ensure adequate touch target size for mobile */
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-main);
    transition: var(--transition);
    display: block;
}

/* Add active state styling for better visual feedback */
.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Ensure the button has proper focus state for accessibility */
.mobile-menu-toggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 游戏网格区域样式 */
.games-grid-section {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    
    .games-grid-section {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* 移除广告相关样式后，恢复footer默认边距 */
    .footer {
        margin-bottom: 0; /* 移除广告后恢复默认边距 */
    }
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 20px;
    transform: translateY(-100%);
    transition: var(--transition);
    z-index: 999;
}

.mobile-menu.active {
    transform: translateY(0);
}

.mobile-search {
    margin-bottom: 20px;
}

.mobile-search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

.mobile-categories {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-category-btn {
    padding: 12px 16px;
    border-radius: 6px;
    background: #f5f5f5;
    color: var(--text-main);
    font-size: 16px;
    text-align: left;
    transition: var(--transition);
}

.mobile-category-btn:hover,
.mobile-category-btn.active {
    background: var(--primary-color);
    color: var(--white);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 120px 0 80px;
    text-align: center;
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('../assets/hero-bg.jpg') center/cover;
    opacity: 0.1;
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
}

.hero h2 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero p {
    font-size: 18px;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    padding: 60px 0;
    min-height: calc(100vh - 200px);
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-header h3 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-main);
}

.results-count {
    font-size: 14px;
    color: var(--text-light);
    background: var(--white);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: var(--shadow-light);
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-spinner p {
    color: var(--text-light);
    font-size: 16px;
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 60px;
}

/* Game Card */
.game-card {
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
}

.game-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
}

.game-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f0f0f0;
}

.game-card-content {
    padding: 20px;
}

.game-card-category {
    display: inline-block;
    background: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.game-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.3;
}

.game-card-description {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 80px 20px;
}

.no-results-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 24px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.no-results p {
    color: var(--text-light);
    font-size: 16px;
}

.game-detail-content {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-light);
}

.game-header {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.game-thumbnail img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.game-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.game-category {
    display: inline-block;
    background: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    align-self: flex-start;
}

.game-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
    line-height: 1.2;
}

.game-description-short {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 24px;
    line-height: 1.5;
}

.btn-play {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-color);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition);
    align-self: flex-start;
}

.btn-play:hover {
    background: #e55a2b;
    transform: translateY(-2px);
}

.game-description-section {
    border-top: 1px solid #e0e0e0;
    padding-top: 40px;
}

.game-description-section h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 16px;
}

.divider {
    width: 80px;
    height: 2px;
    background: var(--primary-color);
    margin-bottom: 24px;
}

.game-description-full {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-main);
}

/* Related Games */
.related-games {
    margin-top: 60px;
}

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

.related-game-card {
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
}

.related-game-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.related-game-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.related-game-card-content {
    padding: 12px;
}

.related-game-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
}

/* Game Not Found */
.game-not-found {
    text-align: center;
    padding: 80px 20px;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.not-found-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.game-not-found h2 {
    font-size: 32px;
    color: var(--text-main);
    margin-bottom: 16px;
}

.game-not-found p {
    color: var(--text-light);
    font-size: 18px;
    margin-bottom: 24px;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary:hover {
    background: #e55a2b;
    transform: translateY(-2px);
}

/* Footer */
.footer {
    background: var(--white);
    border-top: 1px solid #e0e0e0;
    padding: 40px 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.footer-links a {
    color: var(--text-light);
    font-size: 14px;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-copyright p {
    color: var(--text-light);
    font-size: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-categories {
        display: none;
    }
    
    .search-input {
        display: none;
    }
    
    .search-btn {
        display: none;
    }
    
    .mobile-search {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .hero h2 {
        font-size: 32px;
    }
    
    .hero p {
        font-size: 16px;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin: 0 -15px;
    }
    
    .game-card {
        margin: 0 15px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .section-header h3 {
        font-size: 24px;
    }
    
    .game-header {
        grid-template-columns: 1fr;
        gap: 24px;
        text-align: center;
    }
    
    .game-title {
        font-size: 24px;
    }
    
    .game-category {
        align-self: center;
    }
    
    .btn-play {
        align-self: center;
    }
    
    .game-detail-content {
        padding: 24px;
    }
    
    .related-games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .nav-container {
        padding: 0 15px;
    }
    
    .hero {
        padding: 100px 0 60px;
    }
    
    .hero h2 {
        font-size: 28px;
    }
    
    .main-content {
        padding: 40px 0;
    }
    
    .related-games-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1199px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .nav-categories {
        gap: 6px;
    }
    
    .category-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .search-input {
        width: 160px;
    }
}

@media (min-width: 1200px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 游戏详情弹窗样式 */
.game-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

.game-detail-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.game-detail-modal .modal-content {
    position: relative;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

.game-detail-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.game-detail-modal .modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.game-detail-modal .modal-close {
    padding: 8px;
    border-radius: 8px;
    color: var(--text-light);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-detail-modal .modal-close:hover {
    background: #f5f5f5;
    color: var(--text-main);
}

.game-detail-modal .modal-body {
    padding: 24px 32px 32px;
}

.game-detail-modal .modal-game-info {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 32px;
    align-items: start;
}

.game-detail-modal .modal-game-image {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

.game-detail-modal .modal-game-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.game-detail-modal .modal-game-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.game-detail-modal .game-category {
    background: var(--primary-color);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: inline-block;
    align-self: flex-start;
}

.game-detail-modal .game-description {
    color: var(--text-main);
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
}

.game-detail-modal .modal-play-btn {
    background: var(--primary-color);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
}

.game-detail-modal .modal-play-btn:hover {
    background: #e55a2b;
    transform: translateY(-2px);
}

/* 弹窗动画 */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 响应式弹窗样式 */
@media (max-width: 768px) {
    .game-detail-modal .modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .game-detail-modal .modal-game-info {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .game-detail-modal .modal-game-image {
        max-width: 300px;
        margin: 0 auto;
    }
    
    .game-detail-modal .modal-header {
        padding: 20px 24px 12px;
    }
    
    .game-detail-modal .modal-header h2 {
        font-size: 20px;
    }
    
    .game-detail-modal .modal-body {
        padding: 20px 24px 24px;
    }
}

@media (max-width: 480px) {
    .game-detail-modal .modal-content {
        width: 98%;
        max-height: 80vh;
    }
    
    .game-detail-modal .modal-header {
        padding: 16px 20px 8px;
    }
    
    .game-detail-modal .modal-body {
        padding: 16px 20px 20px;
    }
}