* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #fafafa;
    --bg-secondary: #fff;
    --bg-tertiary: #f5f5f5;
    --text-primary: #222;
    --text-secondary: #444;
    --text-tertiary: #666;
    --text-muted: #999;
    --border-color: #e0e0e0;
    --border-secondary: #f0f0f0;
    --accent: #000;
    --accent-hover: #333;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #c0c0c0;
    --text-tertiary: #a0a0a0;
    --text-muted: #707070;
    --border-color: #3a3a3a;
    --border-secondary: #2f2f2f;
    --accent: #fff;
    --accent-hover: #e0e0e0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    font-size: 0.95rem;
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link i {
    width: 24px;
    margin-right: 0.75rem;
    font-size: 1rem;
}

.main {
    padding: 3rem;
    padding-top: 5rem;
    width: 100%;
    position: relative;
}

.language-switcher {
    position: absolute;
    top: 2rem;
    right: 6rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    letter-spacing: -0.5px;
}

.language-switcher:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

.theme-toggle {
    position: absolute;
    top: 2rem;
    right: 3rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

.mobile-controls {
    display: none;
    gap: 0.5rem;
    align-items: center;
}

.sidebar .language-switcher-mobile,
.sidebar .theme-toggle-mobile {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    letter-spacing: -0.5px;
}

.sidebar .theme-toggle-mobile {
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0;
}

.sidebar .language-switcher-mobile:hover,
.sidebar .theme-toggle-mobile:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
    margin-top: 0;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-tertiary);
    font-size: 1.125rem;
    margin-bottom: 3rem;
}

.section {
    margin-bottom: 4rem;
}

.section-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--text-tertiary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.total-players-card .stat-icon {
    background: var(--accent);
    color: var(--bg-secondary);
}

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.versions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.version-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-secondary);
}

.version-title {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.version-total {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.regions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.region-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.region-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.region-flag {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.region-row:nth-child(1) .region-flag { background: #3b82f6; }
.region-row:nth-child(2) .region-flag { background: #ef4444; }
.region-row:nth-child(3) .region-flag { background: #f59e0b; }
.region-row:nth-child(4) .region-flag { background: #8b5cf6; }

.region-name {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.region-count {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.region-bar {
    margin-top: 0.5rem;
    height: 4px;
    background: var(--border-secondary);
    border-radius: 2px;
    overflow: hidden;
}

.region-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.downloads-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.download-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 2rem;
    text-decoration: none;
    color: #222;
    transition: all 0.2s;
    text-align: center;
}

.download-item:hover {
    border-color: #000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.download-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.download-item.google .download-icon { color: #34a853; }
.download-item.apple .download-icon { color: #000; }
.download-item.itch .download-icon { color: #fa5c5c; }

.download-name {
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.download-platform {
    font-size: 0.875rem;
    color: #666;
}

.api-banner {
    background: #000;
    color: #fff;
    border-radius: 8px;
    padding: 3rem;
    text-decoration: none;
    display: block;
    transition: transform 0.2s;
}

.api-banner:hover {
    transform: translateY(-2px);
}

.api-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.api-desc {
    color: #ccc;
    font-size: 1rem;
}

.community-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.community-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
    text-decoration: none;
    color: #222;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.community-item:hover {
    border-color: #000;
}

.community-item i {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
}

.community-item:nth-child(1) i { color: #3b82f6; }
.community-item:nth-child(2) i { color: #22c55e; }
.community-item:nth-child(3) i { color: #ef4444; }
.community-item:nth-child(4) i { color: #0077ff; }
.community-item:nth-child(5) i { color: #ff0000; }
.community-item:nth-child(6) i { color: #5865f2; }

.community-text {
    flex: 1;
}

.community-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.community-meta {
    font-size: 0.8rem;
    color: #999;
}

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1.5rem 2rem;
        overflow: visible;
    }

    .logo {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
    }

    .mobile-controls {
        display: flex;
    }

    .language-switcher,
    .theme-toggle {
        display: none;
    }

    .main {
        padding: 3rem 1.5rem;
        padding-top: 3rem;
    }

    .page-title,
    .page-subtitle {
        display: none;
    }

    .downloads-grid {
        grid-template-columns: 1fr;
    }

    .community-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-overview {
        grid-template-columns: 1fr;
    }

    .versions-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 1.5rem;
        padding-top: 3rem;
    }

    .page-title {
        font-size: 2rem;
    }

    .stat-number {
        font-size: 2rem;
    }

    .version-total {
        font-size: 1.25rem;
    }
    
    .stats-overview {
        grid-template-columns: 1fr;
    }
}