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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #000;
    color: #fff;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    text-align: center;
}

.car-loader {
    width: 60px;
    height: 40px;
    background: #fff;
    border-radius: 5px 5px 0 0;
    position: relative;
    margin: 0 auto 20px;
    animation: drive 2s infinite ease-in-out;
}

.car-loader::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background: #333;
    border-radius: 50%;
    bottom: -7px;
    left: 5px;
    animation: rotate 0.5s infinite linear;
}

.car-loader::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background: #333;
    border-radius: 50%;
    bottom: -7px;
    right: 5px;
    animation: rotate 0.5s infinite linear;
}

@keyframes drive {
    0%, 100% { transform: translateX(-20px); }
    50% { transform: translateX(20px); }
}

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

.loader p {
    font-size: 18px;
    color: #fff;
    font-weight: 600;
}

/* Controls Overlay */
#controls-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 40px;
    border-radius: 20px;
    z-index: 1000;
    max-width: 500px;
    border: 2px solid rgba(102, 126, 234, 0.5);
    box-shadow: 0 10px 50px rgba(102, 126, 234, 0.3);
    transition: opacity 0.3s ease;
}

#controls-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#controls-overlay h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
    font-size: 28px;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.key {
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    min-width: 80px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.desc {
    color: #ccc;
    font-size: 16px;
}

.close-btn {
    width: 100%;
    padding: 15px;
    margin-top: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* Airplane Controls Overlay - Futuristic Theme */
#airplane-controls-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(255, 0, 255, 0.1));
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 20px;
    z-index: 1000;
    max-width: 500px;
    border: 3px solid;
    border-image: linear-gradient(135deg, #00ffff, #ff00ff) 1;
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.5),
        0 0 60px rgba(255, 0, 255, 0.3),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    transition: opacity 0.3s ease;
    animation: neonPulse 2s ease-in-out infinite;
}

@keyframes neonPulse {
    0%, 100% {
        box-shadow: 
            0 0 30px rgba(0, 255, 255, 0.5),
            0 0 60px rgba(255, 0, 255, 0.3),
            inset 0 0 20px rgba(0, 255, 255, 0.1);
    }
    50% {
        box-shadow: 
            0 0 40px rgba(0, 255, 255, 0.7),
            0 0 80px rgba(255, 0, 255, 0.5),
            inset 0 0 30px rgba(0, 255, 255, 0.2);
    }
}

#airplane-controls-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#airplane-controls-overlay h2 {
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #00ffff, #ff00ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 32px;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.key-futuristic {
    background: linear-gradient(135deg, #00ffff, #0088ff);
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 700;
    min-width: 90px;
    text-align: center;
    box-shadow: 
        0 0 15px rgba(0, 255, 255, 0.6),
        0 4px 15px rgba(0, 136, 255, 0.4);
    border: 1px solid rgba(0, 255, 255, 0.5);
    color: #000;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.desc-futuristic {
    color: #00ffff;
    font-size: 16px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    font-weight: 500;
}

.close-btn-futuristic {
    width: 100%;
    padding: 15px;
    margin-top: 20px;
    background: linear-gradient(135deg, #00ffff, #ff00ff);
    border: 2px solid #00ffff;
    border-radius: 12px;
    color: #000;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.close-btn-futuristic:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.8),
        0 6px 20px rgba(255, 0, 255, 0.5);
    border-color: #ff00ff;
}

/* HUD */
#hud {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
}

.hud-item {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    font-size: 16px;
    backdrop-filter: blur(10px);
}

.hud-label {
    color: #667eea;
    font-weight: 700;
    margin-right: 5px;
}

#speed-display {
    color: #4ade80;
    font-weight: 700;
    font-size: 18px;
}

#location-display {
    color: #fbbf24;
    font-weight: 700;
}

/* Mode Switch Buttons - Large hitboxes for mobile */
#mode-switch-container {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mode-switch-btn {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(37, 99, 235, 0.9));
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 18px 25px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.2s ease;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-width: 140px;
    min-height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.mode-switch-btn:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(29, 78, 216, 0.95));
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.6);
}

.mode-switch-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 15px rgba(59, 130, 246, 0.5);
}

/* Control Instructions */
#control-instructions {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    max-width: 90vw;
}

.instruction-box {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 15px 25px;
    border-radius: 12px;
    border: 2px solid rgba(0, 255, 255, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

@media (max-width: 768px) {
    #mode-switch-container {
        top: 80px;
        right: 10px;
        gap: 10px;
    }
    
    .mode-switch-btn {
        padding: 15px 20px;
        font-size: 16px;
        min-width: 120px;
        min-height: 60px;
    }
    
    .instruction-box {
        font-size: 12px;
        padding: 12px 20px;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.98), rgba(20, 20, 40, 0.98));
    padding: 40px;
    border-radius: 20px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    border: 2px solid rgba(102, 126, 234, 0.5);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 59, 48, 0.8);
    transform: rotate(90deg);
}

#modal-title {
    font-size: 32px;
    margin-bottom: 20px;
    color: #667eea;
    text-align: center;
}

#modal-body {
    color: #ddd;
    line-height: 1.8;
    font-size: 16px;
}

#modal-body h3 {
    color: #764ba2;
    margin-top: 20px;
    margin-bottom: 10px;
}

#modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

#modal-body li {
    margin-bottom: 8px;
}

#modal-body a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

#modal-body a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.project-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.project-card h4 {
    color: #fbbf24;
    margin-bottom: 10px;
}

/* Scrollbar Styling */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

/* Responsive */
@media (max-width: 1024px) {
    body {
        -webkit-text-size-adjust: 100%;
        touch-action: none;
    }
    
    #canvas-container {
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1;
    }
    
    #canvas-container canvas {
        width: 100% !important;
        height: 100% !important;
        display: block;
    }
    
    #controls-overlay {
        padding: 20px;
        max-width: 90%;
        font-size: 14px;
    }
    
    .modal-content {
        padding: 20px;
        max-width: 95%;
    }
    
    #modal-title {
        font-size: 24px;
    }
    
    #hud {
        font-size: 14px;
        z-index: 100;
    }
    
    /* Ensure mobile controls are visible */
    .mobile-controls-container {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* ========================================
   MOBILE TOUCH CONTROLS
   ======================================== */
.mobile-controls-container {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 99999;
    display: block;
    pointer-events: auto;
}

.touch-controls {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
}

/* Joystick Layout (Car & Airplane) */
.joystick-container {
    display: grid;
    grid-template-columns: 70px 70px 70px;
    grid-template-rows: 70px 70px 70px;
    gap: 10px;
}

.joystick-btn {
    background: linear-gradient(145deg, #ffffff, #e0e0e0);
    border: 3px solid #000;
    border-radius: 15px;
    color: #000;
    font-size: 28px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.joystick-btn:active {
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: #fff;
    transform: scale(0.95);
    box-shadow: 0 3px 15px rgba(76, 175, 80, 0.6) inset;
}

#car-up, #plane-up { grid-column: 2; grid-row: 1; }
#car-left, #plane-left { grid-column: 1; grid-row: 2; }
#car-center, #plane-center { 
    grid-column: 2; 
    grid-row: 2; 
    background: rgba(200, 200, 200, 0.5);
    border: 3px solid rgba(0, 0, 0, 0.3);
    cursor: default;
    pointer-events: none;
}
#car-right, #plane-right { grid-column: 3; grid-row: 2; }
#car-down, #plane-down { grid-column: 2; grid-row: 3; }

/* D-Pad Layout (Snake) - smaller and centered at bottom */
.dpad-container {
    display: grid;
    grid-template-columns: 50px 50px 50px;
    grid-template-rows: 50px 50px 50px;
    gap: 6px;
}

.dpad-btn {
    background: linear-gradient(145deg, #ffffff, #e0e0e0);
    border: 3px solid #000;
    border-radius: 10px;
    color: #000;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
    background: linear-gradient(145deg, #FF9800, #F57C00);
    color: #fff;
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(255, 152, 0, 0.6) inset;
}

/* Traditional D-pad layout */
#snake-up { grid-column: 2; grid-row: 1; }
#snake-left { grid-column: 1; grid-row: 2; }
.dpad-center { 
    grid-column: 2; 
    grid-row: 2; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    pointer-events: none;
}
#snake-right { grid-column: 3; grid-row: 2; }
#snake-down { grid-column: 2; grid-row: 3; }

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.action-btn {
    background: linear-gradient(145deg, #2196F3, #1976D2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    padding: 10px 18px;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
    transition: all 0.2s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.action-btn:active {
    background: linear-gradient(145deg, #1976D2, #1565C0);
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(33, 150, 243, 0.6) inset;
}

/* Hide airplane and snake controls by default */
#airplane-controls,
#snake-controls {
    display: none;
}

/* Snake controls positioning - centered at bottom, left on landscape */
#snake-controls {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100001; /* Higher than snake game container */
    pointer-events: auto;
}

/* Landscape mode adjustments for snake game */
@media (orientation: landscape) and (max-height: 600px) {
    #snake-controls {
        left: 15px;
        bottom: 50%;
        transform: translateY(50%);
    }
    
    #snake-game-container {
        flex-direction: row !important;
        gap: 15px;
        padding: 15px !important;
        max-height: 90vh !important;
    }
    
    #snake-canvas {
        width: 250px !important;
        height: 250px !important;
        max-width: 40vw !important;
        max-height: 70vh !important;
    }
}

/* ========================================
   VIRTUAL JOYSTICK
   ======================================== */
.virtual-joystick {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 99999;
    width: 150px;
    height: 150px;
}

.joystick-outer {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    border: 3px solid rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.3), inset 0 0 20px rgba(0, 255, 255, 0.1);
    position: relative;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.joystick-inner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 255, 0.8) 0%, rgba(0, 200, 255, 0.5) 100%);
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease-out;
    pointer-events: none;
}

.joystick-outer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.3);
}

/* ========================================
   ALTITUDE SLIDER (Airplane)
   ======================================== */
.altitude-slider-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99999;
    width: 80px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.slider-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.slider-track {
    width: 40px;
    height: 250px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 20px;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.2);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.slider-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to top, rgba(0, 255, 255, 0.3), rgba(0, 255, 255, 0.1));
    border-radius: 20px;
    transition: height 0.1s ease-out;
}

.slider-handle {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 255, 0.9) 0%, rgba(0, 200, 255, 0.6) 100%);
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
    transition: top 0.1s ease-out;
    pointer-events: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .virtual-joystick {
        width: 120px;
        height: 120px;
        bottom: 20px;
        left: 20px;
    }
    
    .joystick-outer {
        width: 120px;
        height: 120px;
    }
    
    .joystick-inner {
        width: 50px;
        height: 50px;
    }
    
    .altitude-slider-container {
        width: 60px;
        height: 250px;
        bottom: 20px;
        right: 20px;
    }
    
    .slider-track {
        width: 35px;
        height: 200px;
    }
    
    .slider-handle {
        width: 45px;
        height: 45px;
    }
}
