:root {
    /* Colors - Dark/Neon Theme */
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --primary: #6366f1;
    /* Indigo */
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary: #ec4899;
    /* Pink */
    --accent: #22d3ee;
    /* Cyan */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --danger: #ef4444;

    /* Spacing & sizing */
    --header-height: 70px;
    --footer-height: 60px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
}

body.light-theme {
    /* Light Theme Overrides */
    --bg-dark: #f0f9ff;
    --bg-darker: #e0f2fe;
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);

    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.3);
    --secondary: #db2777;
    --accent: #0ea5e9;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 20%);
    background-attachment: fixed;
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass-header,
.glass-footer,
.glass-panel,
.glass-modal,
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Header */
.glass-header {
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.logo .highlight {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buttons & Inputs */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
}

.glass-select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
    cursor: pointer;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.glass-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
}

.glass-btn.primary:hover {
    background: #4f46e5;
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
}

.hero-section h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    font-weight: 800;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

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

/* Category Tabs */
.category-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.5rem 1.5rem;
    border-radius: 100px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover,
.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Game Grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.game-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition-medium);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.game-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.game-card .game-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 1rem;
    transition: var(--transition-medium);
}

.game-card:hover .game-icon {
    transform: scale(1.1) rotate(5deg);
    color: var(--primary);
}

.game-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.game-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.game-card .difficulty-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

/* Game View */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.icon-btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    transition: var(--transition-fast);
}

.icon-btn-text:hover {
    color: var(--text-main);
}

.game-wrapper {
    width: 100%;
    min-height: 500px;
}

.game-container {
    width: 100%;
    min-height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-lg);
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.game-stats-display {
    display: flex;
    gap: 1.5rem;
    font-weight: 600;
    color: var(--accent);
}

.game-controls-bottom {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

/* Footer */
.glass-footer {
    padding: 1.5rem 2rem;
    margin-top: auto;
    border-top: 1px solid var(--glass-border);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

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

.author-name {
    color: var(--secondary);
    font-weight: 600;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: var(--transition-fast);
}

.social-links a:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.glass-modal {
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: scaleIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        padding-bottom: var(--footer-height);
        /* Ensure footer doesn't overlap content */
    }

    .hero-section {
        padding: 1rem;
        margin-bottom: 2rem;
    }

    .hero-section h1 {
        font-size: 2rem;
    }

    .glass-header {
        padding: 0 1rem;
        height: 60px;
    }

    .logo span {
        font-size: 1.2rem;
    }

    /* Stack footer content */
    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }

    /* Grid: 1 column on mobile */
    .game-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }

    .game-card {
        padding: 1rem;
        /* Smaller padding */
    }

    /* Game View Fixes */
    main {
        padding: 1rem;
        /* Reduce main padding */
    }

    .game-container {
        min-height: 400px;
        /* Reduce height requirement */
        padding: 10px;
        /* Prevent edge collision */
        overflow: hidden;
        /* Prevent inner game overflow */
    }

    /* Ensure games fit (max-width for games like 2048) */
    .game-area,
    .c4-board-wrapper,
    .sudoku-grid {
        transform: scale(0.85);
        /* Slight shrink for complex games */
        transform-origin: center center;
    }
}

@media (max-width: 400px) {

    /* Even smaller screens */
    .game-area,
    .c4-board-wrapper,
    .sudoku-grid {
        transform: scale(0.75);
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.jumping-dots {
    display: flex;
    gap: 12px;
}

.dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    animation: jump 0.6s ease-in-out infinite alternate;
}

.dot:nth-child(1) {
    animation-delay: 0s;
    background: var(--accent);
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
    background: var(--secondary);
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
    background: var(--success);
}

@keyframes jump {
    0% {
        transform: translateY(0) scale(1);
    }

    100% {
        transform: translateY(-25px) scale(1.2);
    }
}

.loader-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}