* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Verdana', sans-serif;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(45deg, #1e3c72, #2a5298, #1e3c72);
            background-size: 400% 400%;
            animation: gradientShift 15s ease infinite;
            overflow-x: hidden;
        }

        @keyframes gradientShift {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .bg-night {
            background: linear-gradient(45deg, #0f0f1e, #1a1a2e, #16213e);
            background-size: 400% 400%;
            animation: gradientShift 20s ease infinite;
        }

        .bg-speed {
            background: linear-gradient(45deg, #ff416c, #ff4b2b, #ff416c);
            background-size: 400% 400%;
            animation: gradientShift 8s ease infinite;
        }

        .bg-segmented {
            background: linear-gradient(45deg, #11998e, #38ef7d, #11998e);
            background-size: 400% 400%;
            animation: gradientShift 12s ease infinite;
        }

        /* Preloader */
        #preloader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 9999;
            transition: opacity 0.5s ease;
        }

        #preloader.fade-out {
            opacity: 0;
            pointer-events: none;
        }

        .snake-loader {
            display: flex;
            gap: 10px;
            margin-bottom: 30px;
        }

        .snake-segment {
            width: 20px;
            height: 20px;
            background: white;
            border-radius: 4px;
            animation: snakeMove 1.5s ease-in-out infinite;
        }

        .snake-segment:nth-child(1) { animation-delay: 0s; }
        .snake-segment:nth-child(2) { animation-delay: 0.1s; }
        .snake-segment:nth-child(3) { animation-delay: 0.2s; }
        .snake-segment:nth-child(4) { animation-delay: 0.3s; }
        .snake-segment:nth-child(5) { animation-delay: 0.4s; }

        @keyframes snakeMove {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-20px); }
        }

        .loader-text {
            color: white;
            font-size: 1.5rem;
            font-weight: bold;
            animation: pulse 2s ease infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        /* Animated Background Shapes */
        .bg-shapes {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 1;
            overflow: hidden;
        }

        .shape {
            position: absolute;
            opacity: 0.1;
        }

        .shape-circle {
            border-radius: 50%;
            background: white;
        }

        .shape-square {
            background: white;
        }

        .shape1 {
            width: 100px;
            height: 100px;
            top: 10%;
            left: 10%;
            animation: float1 15s ease-in-out infinite;
        }

        .shape2 {
            width: 150px;
            height: 150px;
            top: 60%;
            right: 10%;
            animation: float2 20s ease-in-out infinite;
        }

        .shape3 {
            width: 80px;
            height: 80px;
            bottom: 20%;
            left: 15%;
            animation: float3 18s ease-in-out infinite;
        }

        .shape4 {
            width: 120px;
            height: 120px;
            top: 30%;
            right: 20%;
            animation: float1 22s ease-in-out infinite reverse;
        }

        .shape5 {
            width: 90px;
            height: 90px;
            bottom: 10%;
            right: 30%;
            animation: float2 16s ease-in-out infinite reverse;
        }

        @keyframes float1 {
            0%, 100% { transform: translate(0, 0) rotate(0deg); }
            25% { transform: translate(30px, 50px) rotate(90deg); }
            50% { transform: translate(0, 100px) rotate(180deg); }
            75% { transform: translate(-30px, 50px) rotate(270deg); }
        }

        @keyframes float2 {
            0%, 100% { transform: translate(0, 0) scale(1); }
            33% { transform: translate(-50px, 30px) scale(1.2); }
            66% { transform: translate(50px, -30px) scale(0.8); }
        }

        @keyframes float3 {
            0%, 100% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-80px) rotate(180deg); }
        }

        .particles {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 1;
        }

        .particle {
            position: absolute;
            background: rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            animation: floatParticle 20s infinite;
        }

        @keyframes floatParticle {
            0%, 100% { transform: translateY(0) translateX(0); opacity: 0; }
            10% { opacity: 1; }
            90% { opacity: 1; }
            100% { transform: translateY(-100vh) translateX(50px); opacity: 0; }
        }

        .container {
            position: relative;
            z-index: 10;
            text-align: center;
            padding: 20px;
            max-width: 90vw;
        }

        h1 {
            color: white;
            margin-bottom: 20px;
            font-size: clamp(1.5rem, 5vw, 2.5rem);
            text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
        }

        #menuScreen, #gameScreen {
            background: rgba(0, 0, 0, 0.7);
            border-radius: 20px;
            padding: 30px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            backdrop-filter: blur(10px);
        }

        .menu-buttons {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .mode-card {
            padding: 25px;
            border-radius: 15px;
            cursor: pointer;
            transition: all 0.3s;
            color: white;
            text-align: left;
            border: 3px solid transparent;
        }

        .mode-card:hover {
            transform: translateY(-8px) scale(1.02);
            box-shadow: 0 15px 35px rgba(0,0,0,0.4);
            border-color: rgba(255,255,255,0.5);
        }

        .mode-card h3 {
            font-size: 1.4rem;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .mode-card p {
            font-size: 0.9rem;
            line-height: 1.5;
            opacity: 0.9;
        }

        .classic-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .speed-card {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        }

        .night-card {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }

        .segmented-card {
            background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
        }

        canvas {
            box-shadow: 0 10px 50px rgba(0,0,0,0.8);
            border-radius: 10px;
            max-width: 100%;
            height: auto;
            display: block;
            margin: 20px auto;
        }

        .game-info {
            display: flex;
            justify-content: space-around;
            margin-top: 20px;
            flex-wrap: wrap;
            gap: 10px;
        }

        .info-item {
            background: rgba(255,255,255,0.2);
            padding: 10px 20px;
            border-radius: 10px;
            color: white;
            font-weight: bold;
        }

        .button-group {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
            margin-top: 20px;
        }

        .game-btn {
            padding: 12px 30px;
            font-size: 1rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s;
        }

        .game-btn:hover {
            transform: scale(1.05);
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        }

        .replay-btn {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        }

        .hidden {
            display: none;
        }

        @media (max-width: 768px) {
            .menu-buttons {
                grid-template-columns: 1fr;
            }
            
            canvas {
                width: 90vw !important;
                height: 90vw !important;
            }

            .mode-card h3 {
                font-size: 1.2rem;
            }

            .mode-card p {
                font-size: 0.85rem;
            }
        }

        .touch-controls {
            display: none;
            margin-top: 20px;
            gap: 10px;
        }

        @media (max-width: 768px) {
            .touch-controls {
                display: grid;
                grid-template-columns: repeat(3, 1fr);
                max-width: 300px;
                margin: 20px auto;
            }
        }

        .control-btn {
            padding: 20px;
            background: rgba(255,255,255,0.3);
            border: 2px solid white;
            border-radius: 10px;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            user-select: none;
            transition: all 0.2s;
        }

        .control-btn:active {
            background: rgba(255,255,255,0.5);
            transform: scale(0.95);
        }

        .control-btn.empty {
            visibility: hidden;
        }

        .game-over-overlay {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(0,0,0,0.9);
            padding: 30px;
            border-radius: 20px;
            text-align: center;
            display: none;
            z-index: 100;
        }

        .game-over-overlay.show {
            display: block;
        }

        .game-over-overlay h2 {
            color: white;
            font-size: 2rem;
            margin-bottom: 20px;
        }

        .game-over-overlay p {
            color: white;
            font-size: 1.2rem;
            margin-bottom: 20px;
        }