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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
}

.game-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    color: white;
    font-size: 2.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.1);
    padding: 15px 25px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    margin-bottom: 20px;
}

.stats {
    display: flex;
    gap: 30px;
    color: white;
    font-weight: bold;
    font-size: 1.1em;
}

.controls {
    display: flex;
    gap: 15px;
}

button {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

button:active {
    transform: translateY(0);
}

#restart-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
}

main {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.game-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-canvas {
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 15px;
    background: #2c3e50;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    display: block;
}

/* Mobile Controls */
.mobile-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.virtual-joystick {
    pointer-events: auto;
}

.joystick-base {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    position: relative;
    backdrop-filter: blur(10px);
}

.joystick-handle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #3498db;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    cursor: pointer;
}

.touch-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    pointer-events: auto;
}

.touch-row {
    display: flex;
    gap: 5px;
}

.touch-btn {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 20px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.touch-btn:active {
    background: rgba(52, 152, 219, 0.6);
    transform: scale(0.95);
}

.touch-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.instructions {
    background: rgba(255,255,255,0.95);
    padding: 20px;
    border-radius: 15px;
    width: 300px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.instructions h3, .instructions h4 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.instructions h3 {
    font-size: 1.3em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.instructions h4 {
    font-size: 1.1em;
    margin-top: 20px;
    color: #764ba2;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
}

.instructions li:before {
    content: "•";
    color: #667eea;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.instructions strong {
    color: #2c3e50;
}

.game-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.message-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 400px;
}

.message-content h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #2c3e50;
}

.message-content button {
    font-size: 1.2em;
    padding: 15px 30px;
}

/* Responsive design */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    main {
        flex-direction: column;
        align-items: center;
    }
    
    .game-area {
        width: 100%;
        max-width: 100vw;
    }
    
    #game-canvas {
        width: 100%;
        max-width: 400px;
        height: 300px;
    }
    
    .mobile-controls {
        display: flex !important;
        bottom: 20px;
    }
    
    .instructions {
        width: 100%;
        max-width: 400px;
        margin-top: 20px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .instructions h4 {
        margin-top: 15px;
    }
    
    .instructions ul {
        max-height: 200px;
        overflow-y: auto;
        padding-right: 10px;
    }
}

@media (max-width: 480px) {
    .mobile-controls {
        width: 95%;
    }
    
    .joystick-base {
        width: 70px;
        height: 70px;
    }
    
    .joystick-handle {
        width: 25px;
        height: 25px;
    }
    
    .touch-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .instructions ul {
        max-height: 150px;
    }
}

/* Touch device detection */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: flex !important;
    }
}

/* Game-specific visual indicators */
.invincible {
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    0% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* Loading animation */
.loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}