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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #e2e8f0;
    background: #0f172a;
    min-height: 100vh;
}

/* ===== CSS Variables (Design Tokens) ===== */
:root {
    /* Colors - CrazyGames inspired dark theme */
    --primary-color: #ff6b35;
    --secondary-color: #f7931e;
    --accent-color: #00d4ff;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-card-hover: #2d3b52;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    /* Typography */
    --font-primary: 'Nunito', sans-serif;
    --font-display: 'Fredoka One', cursive;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ===== Container & Layout ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ===== Header & Navigation ===== */
header {
    background: var(--bg-primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--primary-color);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-container {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.logo-image {
    max-width: 150px;
    height: auto;
}

.header-ad-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-left: auto;
}

.header-ad-left img {
    display: block;
}

.header-ad {
    display: flex;
    align-items: center;
}

.site-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: var(--spacing-xs) 0;
    line-height: 1.2;
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.logo {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

/* ===== Main Content ===== */
main {
    padding: var(--spacing-xl) 0;
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: var(--spacing-xl);
    color: var(--text-primary);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

h2 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    margin: var(--spacing-2xl) 0 var(--spacing-lg) 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ===== Filter Controls ===== */
.filters {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filter-group label {
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===== Game Grid ===== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

/* ===== Game Cards ===== */
.game-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 107, 53, 0.1);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transform: scaleX(0);
    transition: transform 0.3s ease;
    z-index: 1;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(255, 107, 53, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    border-color: var(--primary-color);
    background: var(--bg-card-hover);
}

.game-card:hover::before {
    transform: scaleX(1);
}

.game-thumbnail {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

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

.game-content {
    padding: var(--spacing-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.game-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.game-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    line-height: 1.6;
    flex: 1;
}

.game-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

.game-tag {
    background: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(255, 107, 53, 0.2);
}

.play-button {
    width: 100%;
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(255, 107, 53, 0.3);
}

.play-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(255, 107, 53, 0.4);
}

.game-card h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.game-card p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
}

/* ===== Search & Filter Section ===== */
.search-filter-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 107, 53, 0.2);
}

.search-container {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.search-input {
    flex: 1;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
}

.search-button {
    padding: var(--spacing-md) var(--spacing-xl);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(255, 107, 53, 0.4);
}

.filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filter-group label {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
}

.filter-select {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
}

.clear-filters-button {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border: 2px solid var(--error-color);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-filters-button:hover {
    background: var(--error-color);
    color: white;
}

/* ===== Content Tabs ===== */
.content-tabs {
    margin-bottom: var(--spacing-xl);
}

.tab-buttons {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.tab-button {
    padding: var(--spacing-md) var(--spacing-xl);
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-button:hover {
    background: rgba(255, 107, 53, 0.1);
    color: var(--primary-color);
}

.tab-button.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(255, 107, 53, 0.4);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.section-title {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xl);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ===== Enhanced Game Cards ===== */
.game-card.new-game::after {
    content: 'NEW';
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--accent-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 2;
}

.game-card.recommended-game {
    box-shadow: 0 0 0 3px var(--primary-color), 0 20px 25px -5px rgba(255, 107, 53, 0.3);
}

.game-badge {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.game-badge.new {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.game-badge.recommended {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.game-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-md);
}

.tag {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tag.recommended {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
}

.tag.new {
    background: linear-gradient(135deg, var(--accent-color), #d97706);
    color: white;
}

.tag.popular {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .header-content {
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: var(--spacing-xs) 0;
    }
    
    .logo-image {
        max-width: 100px;
    }
    
    .header-ad-left {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
    
    .header-ad {
        width: 100%;
        justify-content: center;
    }
    
    .header-ad img,
    .header-ad-left img {
        max-width: 100%;
        height: auto;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .search-filter-section {
        padding: var(--spacing-md);
    }
    
    .filter-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        justify-content: space-between;
        width: 100%;
    }
    
    .filter-select {
        flex: 1;
    }
    
    .clear-filters-button {
        width: 100%;
    }
    
    .tab-buttons {
        gap: var(--spacing-xs);
    }
    
    .tab-button {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.875rem;
    }
    
    .game-thumbnail {
        height: 180px;
    }
    
    .game-content {
        padding: var(--spacing-md);
    }
}

@media (max-width: 480px) {
    .logo-image {
        max-width: 80px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .game-card h3 {
        font-size: 1.125rem;
    }
}

/* ===== Utility Classes ===== */
.text-center {
    text-align: center;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }

/* ===== Loading Animation ===== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ===== Accessibility ===== */
/* Accessibility Improvements */
a:focus, button:focus, input:focus, select:focus {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Loading Spinner ===== */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-right-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .game-card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}
