:root {
    --primary-color: #0ea5e9;
    --secondary-color: #ef4444;
    --accent-color: #facc15;
    --success-color: #22c55e;
    --bg-color: #0f172a;
    --bg-dark: #020617;
    --text-color: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #3b82f6;
}

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

body {
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-color) 50%, var(--bg-dark) 100%);
    color: var(--text-color);
    font-family: 'Rajdhani', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at top left, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(239, 68, 68, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at center, rgba(250, 204, 21, 0.05) 0%, transparent 70%);
    z-index: -1;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-color) 50%, var(--bg-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader {
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 25px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

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

.loader h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #3b82f6 0%, #0ea5e9 50%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
    margin-bottom: 20px;
}

.loading-text {
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.loading-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 25px;
}

.progress-bar {
    width: 280px;
    height: 6px;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 3px;
    animation: progressAnim 2s ease-in-out infinite;
}

@keyframes progressAnim {
    0% {
        width: 0%;
        margin-left: 0%;
    }
    50% {
        width: 60%;
    }
    100% {
        width: 0%;
        margin-left: 100%;
    }
}

.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 900px;
    width: 100%;
    padding: 25px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%);
    border-radius: 24px;
    box-shadow: 
        0 0 60px rgba(59, 130, 246, 0.25),
        0 0 100px rgba(14, 165, 233, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(59, 130, 246, 0.3);
    animation: fadeIn 0.8s ease-out;
}

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

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.8rem;
    font-weight: 900;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #3b82f6 0%, #0ea5e9 50%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 4px;
    animation: titleFloat 3s ease-in-out infinite;
    position: relative;
}

h1::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-color), var(--accent-color), var(--primary-color), transparent);
    border-radius: 2px;
}

@keyframes titleFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 500;
}

.instructions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px 25px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    animation: slideIn 0.6s ease-out 0.3s both;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.key {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 6px;
    color: var(--accent-color);
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

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

.canvas-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    animation: canvasGlow 4s ease-in-out infinite alternate;
}

#gameCanvas {
    background-color: #050510;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    display: block;
}

@keyframes canvasGlow {
    from {
        box-shadow: 
            0 0 30px rgba(59, 130, 246, 0.4),
            0 0 60px rgba(14, 165, 233, 0.2),
            inset 0 0 30px rgba(14, 165, 233, 0.05);
    }
    to {
        box-shadow: 
            0 0 40px rgba(59, 130, 246, 0.6),
            0 0 80px rgba(14, 165, 233, 0.3),
            inset 0 0 40px rgba(14, 165, 233, 0.1);
    }
}

.canvas-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid transparent;
    border-radius: 16px;
    pointer-events: none;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color), var(--secondary-color), var(--primary-color)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.5;
}

.controls-hint {
    margin-top: 20px;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: color 0.3s;
}

.hint-item:hover {
    color: var(--text-color);
}

.hint-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    color: var(--primary-color);
    font-size: 12px;
}

@media (max-width: 900px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 2.8rem;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
        max-width: 650px;
    }
    
    .instructions {
        gap: 10px;
        padding: 12px 18px;
    }
    
    .instruction-item {
        font-size: 0.85rem;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        border-radius: 16px;
    }
    
    h1 {
        font-size: 2rem;
        letter-spacing: 2px;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    #gameCanvas {
        max-width: 100%;
        border-radius: 12px;
    }
    
    .instructions {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .controls-hint {
        gap: 15px;
    }
}
