/* Global reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

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

ul {
    list-style: none;
}

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

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

/* ===== Header Styles ===== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 2rem;
    align-items: center;
}

/* Logo */
.logo h1 {
    font-size: 1.8rem;
    font-weight: bold;
    white-space: nowrap;
}

/* Search box */
.search-box {
    display: flex;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 25px 0 0 25px;
    font-size: 0.9rem;
    outline: none;
    background: white;
}

.search-box input::placeholder {
    color: #999;
}

.search-box button {
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 0 25px 25px 0;
    background: rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 0.9rem;
}

.search-box button:hover {
    background: rgba(255,255,255,0.3);
}

/* Mobile menu toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: white;
    margin: 3px 0;
    transition: 0.3s;
}

/* ===== Main Content Area ===== */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 140px);
}

/* ===== Game Sections (Hot Games + Category Sections) ===== */
.games-section {
    margin-bottom: 4rem;
}

.category-section {
    margin-bottom: 4rem;
}

/* Section header */
.section-header {
    margin-bottom: 2rem;
}

.section-header h2 {
    color: #333;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.game-count {
    color: #666;
    font-size: 0.9rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: inline-block;
}

/* ===== Game Grid Styles ===== */
.game-grid {
    display: grid;
    gap: 1.5rem;
}

/* Responsive grid layout */
/* Desktop (≥1200px): 4 columns */
@media (min-width: 1200px) {
    .game-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablet (768–1199px): 3 columns */
@media (min-width: 768px) and (max-width: 1199px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile (<768px): 2 columns */
@media (max-width: 767px) {
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Game card styles */
.game-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Game thumbnail */
.game-thumbnail {
    width: 100%;
    height: 160px;
    overflow: hidden;
    position: relative;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
}

.game-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.game-card:hover .game-thumbnail img {
    transform: scale(1.05);
}

/* Game info (title only, no description) */
.game-info {
    padding: 1rem;
}

.game-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6rem;
}

/* ===== Game Page Styles ===== */

/* Game page body */
.game-page {
    background-color: #f0f2f5;
}

/* ===== Game Page Header Styles ===== */
.game-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.game-header .container {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 1rem;
    align-items: center;
    max-width: 1200px;
}

/* Header left: site name */
.header-left .site-name {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    transition: opacity 0.3s;
}

.header-left .site-name:hover {
    opacity: 0.8;
}

/* Header center: game title */
.header-center {
    text-align: center;
}

.current-game-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header right: back button */
.header-right {
    text-align: right;
}

.back-home-btn {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.back-home-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: translateX(-3px);
}

/* ===== Game Main Content Area ===== */
.game-main {
    padding: 2rem 0;
    min-height: calc(100vh - 150px);
}

.game-layout {
    display: grid;
    grid-template-columns: 70% 30%;
    gap: 2rem;
    align-items: start;
}

/* ===== Game Section Styles ===== */
.game-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Game container */
.game-container {
    position: relative;
    margin: 1rem 0;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    min-height: 400px;
}

/* ===== Game Preview Styles ===== */
.game-preview {
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.preview-background {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.3s ease;
}

.preview-background:hover {
    transform: scale(1.02);
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.4) 0%,
        rgba(0, 0, 0, 0.2) 50%,
        rgba(0, 0, 0, 0.4) 100%
    );
    backdrop-filter: blur(1px);
}

/* Play Button */
.play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
    min-width: 160px;
}

.play-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.6);
}

.play-button:active {
    transform: translateY(-1px) scale(1.02);
}

.play-icon {
    font-size: 1.2rem;
    margin-left: -0.2rem;
}

/* Game iframe (initially hidden) */
#gameFrame {
    width: 100%;
    height: 400px;
    min-height: 300px;
    border: none;
    border-radius: 8px;
    background: white;
    display: none;
}

/* Retry button */
.retry-button {
    margin-top: 1rem;
    padding: 0.7rem 1.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.retry-button:hover {
    background: #5a67d8;
}

/* Game loading state */
.game-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e3e3e3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Game error state */
.game-error {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    text-align: center;
    color: #666;
    background: white;
    border-radius: 8px;
}

.game-error .error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.game-error h3 {
    color: #f44336;
    margin-bottom: 0.5rem;
}

/* Back home link style */
.back-home-link {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.7rem 1.5rem;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 20px;
    transition: background-color 0.3s;
}

.back-home-link:hover {
    background: #5a67d8;
}

/* ===== Recommendations Section Styles ===== */
.recommendations-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.recommendations-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.recommendations-title {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
}

.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.recommendation-item {
    display: flex;
    gap: 0.8rem;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    align-items: center;
}

.recommendation-item:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

.recommendation-thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #e9ecef;
}

.recommendation-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recommendation-info {
    flex: 1;
    min-width: 0;
}

.recommendation-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.more-games {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.more-games-btn {
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s;
}

.more-games-btn:hover {
    color: #764ba2;
}

.no-recommendations {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem 0;
}

/* ===== Ad Slot Styles ===== */
.ad-slot {
    margin: 1rem 0;
    display: block;
    position: relative;
    overflow: hidden;
}

/* Ad slot positioning */
.ad-slot.ad-homeTop {
    margin: 1.5rem 0;
}

.ad-slot.ad-homeFeed {
    margin: 2rem 0;
}

.ad-slot.ad-categoryTop {
    margin: 1rem 0 2rem;
}

.ad-slot.ad-categoryFeed {
    margin: 2rem 0;
}

.ad-slot.ad-gameTop {
    margin-bottom: 1.5rem;
}

.ad-slot.ad-gameBottom {
    margin-top: 1.5rem;
}

.ad-slot.ad-gameSide {
    margin-bottom: 2rem;
}

/* ===== AdSense 占位符样式 ===== */
.ad-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    min-height: inherit;
}

.ad-placeholder:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: #667eea;
}

.placeholder-content {
    text-align: center;
    padding: 1rem;
}

.placeholder-text {
    display: block;
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.placeholder-info {
    color: #adb5bd;
    font-size: 0.75rem;
    font-style: italic;
}

/* ===== 真实 AdSense 样式 ===== */
.adsbygoogle {
    background: transparent;
    display: block;
}

/* 防止广告导致的布局偏移 */
.ad-slot .adsbygoogle {
    min-height: inherit;
}

/* ===== 响应式广告样式 ===== */
@media (max-width: 768px) {
    .ad-slot {
        margin: 0.8rem 0;
    }
    
    .ad-slot.ad-homeTop,
    .ad-slot.ad-categoryTop {
        margin: 1rem 0 1.5rem;
    }
    
    .ad-slot.ad-gameSide {
        margin: 1rem 0;
    }
    
    .placeholder-text {
        font-size: 0.8rem;
    }
    
    .placeholder-info {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .ad-slot {
        margin: 0.6rem 0;
    }
    
    .placeholder-content {
        padding: 0.8rem;
    }
    
    .placeholder-text {
        font-size: 0.75rem;
    }
}

/* ===== Footer Styles ===== */
.footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
}

.footer p {
    opacity: 0.8;
}

/* ===== Responsive Design ===== */
@media (max-width: 992px) {
    .container {
        padding: 0 15px;
    }
    
    .header .container {
        grid-template-columns: auto 1fr;
        gap: 1rem;
    }
    
    .search-box {
        order: 2;
        grid-column: span 2;
        margin-top: 1rem;
    }
}

@media (max-width: 768px) {
    .header .container {
        grid-template-columns: 1fr auto;
    }
    
    .search-box {
        order: 0;
        grid-column: 1;
        margin: 0;
        max-width: none;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .section-header h2 {
        font-size: 1.4rem;
    }
    
    .games-section,
    .category-section {
        margin-bottom: 3rem;
    }
    
    .game-thumbnail {
        height: 120px;
    }
    
    .game-info {
        padding: 0.8rem;
    }
    
    .game-title {
        font-size: 0.9rem;
        min-height: 2.4rem;
    }
    
    /* Game page responsive */
    .game-header .container {
        grid-template-columns: auto 1fr auto;
        gap: 0.8rem;
    }
    
    .header-left .site-name {
        font-size: 1.2rem;
    }
    
    .current-game-title {
        font-size: 1rem;
    }
    
    .back-home-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Main layout becomes vertical */
    .game-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Game section adjustments */
    .game-section {
        padding: 1rem;
    }
    
    .game-container,
    .game-preview {
        min-height: 300px;
        height: 300px;
    }
    
    #gameFrame {
        min-height: 250px;
        height: 300px;
    }
    
    
    .play-button {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        min-width: 140px;
    }
    
    /* Recommendations adjustments */
    .recommendations-container {
        padding: 1rem;
    }
    
    .recommendations-title {
        font-size: 1.1rem;
    }
    
    .recommendation-item {
        padding: 0.6rem;
    }
    
    .recommendation-thumb {
        width: 50px;
        height: 50px;
    }
    
    .recommendation-title {
        font-size: 0.85rem;
    }
    
    /* Ad slot adjustments */
    .ad-slot.ad-side {
        min-height: 200px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.4rem;
    }
    
    .search-box input,
    .search-box button {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .section-header h2 {
        font-size: 1.2rem;
    }
    
    .game-grid {
        gap: 0.8rem;
    }
    
    .game-thumbnail {
        height: 100px;
    }
    
    .game-info {
        padding: 0.6rem;
    }
    
    .game-title {
        font-size: 0.85rem;
        min-height: 2.2rem;
    }
    
    .games-section,
    .category-section {
        margin-bottom: 2rem;
    }
    
    .main {
        padding: 1.5rem 0;
    }
    
    /* Game page mobile */
    .game-main {
        padding: 1rem 0;
    }
    
    .game-header .container {
        gap: 0.5rem;
    }
    
    .header-left .site-name {
        font-size: 1.1rem;
    }
    
    .current-game-title {
        font-size: 0.9rem;
    }
    
    .back-home-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    
    .game-section {
        padding: 0.8rem;
    }
    
    .game-container,
    .game-preview {
        min-height: 250px;
        height: 250px;
    }
    
    #gameFrame {
        min-height: 200px;
        height: 250px;
    }
    
    
    .play-button {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
        min-width: 120px;
    }
    
    .play-icon {
        font-size: 1rem;
    }
    
    .recommendations-container {
        padding: 0.8rem;
    }
    
    .recommendation-item {
        padding: 0.5rem;
        gap: 0.6rem;
    }
    
    .recommendation-thumb {
        width: 45px;
        height: 45px;
    }
    
    .ad-slot {
        min-height: 80px;
    }
    
    .ad-slot.ad-top {
        min-height: 100px;
    }
    
    .ad-slot.ad-side {
        min-height: 150px;
    }
    
    .ad-content {
        font-size: 0.8rem;
    }
}