/**
 * ============================================
 * BRAIN DASH - PREMIUM GAME PAGE STYLES
 * ============================================
 * 
 * Shared styles for all game pages.
 * Designed for a polished, premium gaming experience.
 */

/* ============================================
   1. CSS VARIABLES - Premium Theme
   ============================================ */
:root {
    /* Core Colors */
    --color-bg: #fafafa;
    --color-bg-warm: #fef7ed;
    --color-bg-gradient: linear-gradient(135deg, #fafafa 0%, #fef7ed 50%, #fafafa 100%);
    --color-surface: #ffffff;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;

    /* Brand Colors */
    --color-primary: #10b981;
    --color-primary-light: #d1fae5;
    --color-primary-dark: #059669;
    --color-accent: #8b5cf6;
    --color-accent-light: #ede9fe;

    /* State Colors */
    --color-success: #22c55e;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    --color-cell: #f3f4f6;

    /* Typography */
    --font-main: 'Nunito', system-ui, -apple-system, sans-serif;

    /* Shadows - Enhanced depth */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 50px -10px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 40px rgba(16, 185, 129, 0.15);
    --shadow-canvas: 0 20px 60px -15px rgba(0, 0, 0, 0.12), 0 8px 25px -5px rgba(0, 0, 0, 0.08);

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    --stats-height: 80px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   2. BASE RESET + PREMIUM ANTI-ALIASING
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);

    /* Crisp text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;

    /* Solid background for proper compositing */
    background-color: var(--color-bg);

    /* GPU acceleration hints */
    transform: translateZ(0);
    will-change: opacity;
    font-display: swap;
}

body {
    background: var(--color-bg-gradient);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Subtle animated background pattern */
body::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   3. GAME CONTAINER - Premium Layout
   ============================================ */
.game-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    min-height: 0;
    position: relative;
    z-index: 1;
}

/* ============================================
   4. CANVAS STYLING - Premium Appearance
   ============================================ */
canvas,
#gameCanvas {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-canvas);
    max-width: 100%;
    max-height: 100%;
    border: 1px solid rgba(0, 0, 0, 0.04);

    /* Crisp rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;

    /* GPU layer for smooth animations */
    transform: translateZ(0);
    will-change: transform;
    background-color: #ffffff;

    /* Subtle glow effect */
    transition: box-shadow var(--transition-smooth);
}

canvas:hover,
#gameCanvas:hover {
    box-shadow: var(--shadow-canvas), var(--shadow-glow);
}

/* ============================================
   5. BOTTOM STATS BAR - Premium Design
   ============================================ */
.stats-bar {
    height: var(--stats-height);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 10;
}

/* Decorative top border gradient */
.stats-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg,
            transparent,
            var(--color-primary) 30%,
            var(--color-accent) 70%,
            transparent);
    opacity: 0.5;
}

/* Stat Chips - Enhanced */
.stat-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.25rem;
    background: linear-gradient(135deg, var(--color-bg) 0%, #f5f5f5 100%);
    border-radius: var(--radius-full);
    font-size: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.stat-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    color: var(--color-text);
    font-weight: 800;
    font-size: 1.1rem;
}

/* Special styling for lives */
.stat-item:has(.stat-value:empty),
.stat-item .stat-value:has(❤️) {
    font-size: 1rem;
}

/* ============================================
   6. BACK BUTTON - Premium Style
   ============================================ */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-full);
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-back::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-back:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-back:hover::before {
    opacity: 1;
}

.btn-back:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

/* ============================================
   7. SOUND TOGGLE BUTTON - Premium Style
   ============================================ */
.btn-sound {
    background: linear-gradient(135deg, var(--color-bg) 0%, #f0f0f0 100%);
    border: none;
    font-size: 1.1rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    line-height: 1;
    box-shadow: var(--shadow-sm);
}

.btn-sound:hover {
    background: var(--color-surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-sound:active {
    transform: scale(0.95);
}

/* ============================================
   7B. LANGUAGE SELECTOR - Premium Style
   ============================================ */
.lang-selector {
    position: relative;
}

.btn-lang {
    background: linear-gradient(135deg, var(--color-bg) 0%, #f0f0f0 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 1.1rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    line-height: 1;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-lang:hover {
    background: var(--color-surface);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.lang-dropdown {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 0.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: none;
    z-index: 100;
    min-width: 140px;
}

.lang-dropdown.show {
    display: block;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.lang-option:hover {
    background: var(--color-cell);
}

.lang-option.active {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.lang-flag {
    font-size: 1.2rem;
}

/* ============================================
   8. RESPONSIVE - Mobile Optimized
   ============================================ */
@media (max-width: 768px) {
    .game-container {
        padding: 1rem;
    }

    canvas,
    #gameCanvas {
        border-radius: var(--radius-lg);
    }
}

@media (max-width: 600px) {
    :root {
        --stats-height: 70px;
    }

    .stats-bar {
        gap: 0.5rem;
        padding: 0 0.75rem;
    }

    .stat-item {
        padding: 0.5rem 0.9rem;
        font-size: 0.85rem;
        gap: 0.4rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    .btn-back {
        padding: 0.55rem 1rem;
        font-size: 0.85rem;
    }

    .btn-sound {
        font-size: 1.1rem;
        padding: 0.4rem 0.6rem;
    }
}

@media (max-width: 400px) {
    .stats-bar {
        gap: 0.35rem;
        padding: 0 0.5rem;
    }

    .stat-item {
        padding: 0.4rem 0.7rem;
    }

    .stat-label {
        display: none;
    }

    .btn-back span:last-child {
        display: none;
    }
}

/* ============================================
   9. UTILITIES
   ============================================ */
.hidden {
    display: none !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;
}

/* ============================================
   10. LOADING STATE
   ============================================ */
.game-container.loading canvas {
    opacity: 0.7;
}

.game-container.loading::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(16, 185, 129, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   11. FOCUS STATES - Accessibility
   ============================================ */
.btn-back:focus-visible,
.btn-sound:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ============================================
   12. PRINT STYLES
   ============================================ */
@media print {
    .stats-bar {
        display: none;
    }
}

/* ============================================
   13. LANDSCAPE MOBILE - Optimized Layout
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
    .game-container {
        padding: 0.5rem;
    }

    .stats-bar {
        height: 50px;
        gap: 0.4rem;
        padding: 0 0.5rem;
    }

    .stats-bar::before {
        display: none;
    }

    .stat-item {
        padding: 0.35rem 0.7rem;
        font-size: 0.8rem;
    }

    .stat-label {
        display: none;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .btn-back {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .btn-sound {
        padding: 0.35rem 0.5rem;
        font-size: 0.95rem;
    }

    canvas,
    #gameCanvas {
        border-radius: var(--radius-md);
    }
}