:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0a9c0;
    --text-muted: #6b7280;
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-primary: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --surface: rgba(0, 0, 0, 0.02);
    --surface-hover: rgba(0, 0, 0, 0.05);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.2);
}

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

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
                radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    z-index: -1;
    animation: backgroundShift 20s ease-in-out infinite alternate;
}

@keyframes backgroundShift {
    0% { transform: translateX(-10px) translateY(-10px); }
    100% { transform: translateX(10px) translateY(10px); }
}

/* Navigation */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(26, 26, 46, 0.9);
    backdrop-filter: blur(20px);
    z-index: 1000;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

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

.control-btn {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.control-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* Main layout */
.main-container {
    margin-top: 80px;
    min-height: calc(100vh - 80px);
    display: flex;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* Sidebar */
.sidebar {
    width: 280px;
    padding: 2rem;
    background: var(--bg-secondary);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.sidebar-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.game-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.game-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.game-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0.1;
    transition: var(--transition);
    z-index: -1;
}

.game-btn:hover::before {
    left: 0;
}

.game-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.game-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.game-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Stats panel */
.stats-panel {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-value {
    font-weight: 600;
    color: var(--accent-primary);
}

/* Content area */
.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.game-section {
    display: none;
    animation: fadeInUp 0.6s ease-out;
}

.game-section.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-header {
    text-align: center;
    margin-bottom: 3rem;
}

.game-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.game-description {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Game cards */
.game-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
}

/* Buttons */
.btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.875rem 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: var(--transition);
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-success {
    background: var(--gradient-success);
}

/* Input fields */
.input-field {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
    width: 100%;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Number guessing game */
.guess-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.guess-input-group {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
}

.attempts-display {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
}

.hint {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1rem 0;
    padding: 1rem;
    border-radius: var(--border-radius);
}

.hint.too-high {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.hint.too-low {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.hint.correct {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Memory game */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    max-width: 500px;
    margin: 2rem auto;
    perspective: 1000px;
}

.memory-card {
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s, box-shadow 0.3s;
}

.memory-card:hover {
    box-shadow: var(--shadow-lg);
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
}

.card-back {
    background: var(--gradient-primary);
    color: white;
}

.card-front {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-primary);
    transform: rotateY(180deg);
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.memory-card.matched {
    transform: rotateY(180deg) scale(0.9);
    opacity: 0.6;
    cursor: default;
}

.memory-card.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Game stats */
.game-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Random number generator */
.rng-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.rng-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 2rem 0;
}

.rng-result {
    font-size: 4rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 2rem 0;
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 100px;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--accent-success);
    box-shadow: var(--shadow-xl);
    color: var(--text-primary);
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
}

.toast.error {
    border-left-color: var(--accent-danger);
}

.toast.warning {
    border-left-color: var(--accent-warning);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive design */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .game-menu {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.5rem;
    }

    .nav-container {
        padding: 0 1rem;
    }

    .content {
        padding: 1rem;
    }

    .memory-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .rng-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .guess-input-group {
        flex-direction: column;
    }

    .memory-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .game-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Loading animations */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
}

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

/* Achievement badge */
.achievement {
    background: var(--gradient-success);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    animation: achievementPop 0.6s ease-out;
}

@keyframes achievementPop {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 50px 50px;
    animation: move 2s linear infinite;
}

@keyframes move {
    0% { background-position: 0 0; }
    100% { background-position: 50px 50px; }
}

/* Dark/Light theme toggle */
[data-theme="light"] {
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* Sound wave animation */
.sound-wave {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.sound-bar {
    width: 3px;
    background: var(--accent-primary);
    border-radius: 2px;
    animation: soundWave 1.2s ease-in-out infinite;
}

.sound-bar:nth-child(1) { height: 10px; animation-delay: 0s; }
.sound-bar:nth-child(2) { height: 15px; animation-delay: 0.1s; }
.sound-bar:nth-child(3) { height: 8px; animation-delay: 0.2s; }
.sound-bar:nth-child(4) { height: 12px; animation-delay: 0.3s; }

@keyframes soundWave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.3); }
}