* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 20px;
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #024237, #076311);
    color: white;
    text-align: center;
    overflow-x: hidden;
    touch-action: manipulation;
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 10px;
}

h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }
}

.score {
    font-size: 1.5em;
    margin-bottom: 10px;
    font-weight: bold;
}

.lives {
    font-size: 1.3em;
    margin-bottom: 20px;
    font-weight: bold;
    color: #ff6b6b;
}

.game-area {
    width: 600px;
    height: 400px;
    background: rgba(0, 0, 50, 0.3);
    border: 3px solid #fff;
    border-radius: 10px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

/* Tablet support (iPad, etc.) */
@media (max-width: 1024px) and (min-width: 769px) {
    .game-area {
        width: 100%;
        max-width: 600px;
        height: calc(100vh - 200px);
        max-height: 60vh;
        min-height: 350px;
    }
}

/* iPad landscape and other wide touch devices */
@media (min-width: 1025px) and (pointer: coarse) {
    .game-area {
        width: 100%;
        max-width: 700px;
        height: calc(100vh - 200px);
        max-height: 65vh;
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .game-area {
        width: 100%;
        max-width: 500px;
        height: calc(100vh - 280px);
        max-height: 60vh;
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .game-area {
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 300px);
        max-height: 50vh;
        min-height: 280px;
    }
}

.player {
    position: absolute;
    bottom: 10px;
    left: 275px;
    font-size: 2em;
    transition: left 0.1s ease;
}

.obstacle {
    position: absolute;
    font-size: 2em;
    animation: fall 2.5s linear;
}

.obstacle.hit {
    animation: explode 0.5s ease-out;
}

.alien {
    position: absolute;
    font-size: 1.8em;
    animation: fall 3s linear;
}

.alien.shot {
    animation: explode 0.3s ease-out;
}

.bullet {
    position: absolute;
    font-size: 1em;
    color: #ffff00;
    animation: shoot 1s linear;
}

@keyframes explode {
    0% { 
        transform: scale(1); 
        opacity: 1; 
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.5); 
        opacity: 0.8; 
        filter: brightness(2);
    }
    100% { 
        transform: scale(2.5); 
        opacity: 0;
        filter: brightness(0);
    }
}

@keyframes shoot {
    from {
        bottom: 50px;
    }
    to {
        bottom: 400px;
    }
}

@keyframes fall {
    from {
        top: -30px;
    }
    to {
        top: 400px;
    }
}

.controls {
    margin-top: 20px;
}

.controls p {
    font-size: 1.2em;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .controls p {
        font-size: 1em;
    }
}

.mobile-instructions {
    display: none;
}

.mobile-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 1000;
    gap: 15px;
    align-items: center;
    justify-content: center;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.shoot-btn {
    width: 65px;
    height: 65px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #ff4444;
    border: 3px solid #fff;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.1s;
}

.shoot-btn:active {
    background: #cc0000;
    transform: scale(0.95);
}

.slider-control {
    position: relative;
    flex: 1;
    max-width: 280px;
    height: 55px;
    background: rgba(76, 175, 80, 0.6);
    border: 4px solid #fff;
    border-radius: 30px;
    cursor: pointer;
    overflow: visible;
    touch-action: none;
    box-shadow: 0 6px 12px rgba(0,0,0,0.5), inset 0 2px 4px rgba(0,0,0,0.3);
}

.slider-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #2E7D32 0%, #4CAF50 50%, #66BB6A 100%);
    opacity: 0.9;
    border-radius: 26px;
}

.slider-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 54px;
    height: 54px;
    background: radial-gradient(circle, #FFD700 0%, #FFA500 100%);
    border: 5px solid #fff;
    border-radius: 50%;
    box-shadow: 0 8px 16px rgba(0,0,0,0.6), 0 0 20px rgba(255, 215, 0, 0.8);
    pointer-events: none;
    transition: transform 0.1s;
}

.slider-control:active .slider-thumb {
    transform: translate(-50%, -50%) scale(1.1);
}

/* Touch device support - detects touch capability regardless of screen size */
@media (pointer: coarse) {
    .desktop-instructions {
        display: none;
    }
    
    .mobile-instructions {
        display: block;
    }
    
    .mobile-controls {
        display: flex;
    }
    
    body {
        padding-bottom: 100px;
    }
}

/* Tablet support (iPad, etc.) - show mobile controls */
@media (max-width: 1024px) and (min-width: 769px) {
    .desktop-instructions {
        display: none;
    }
    
    .mobile-instructions {
        display: block;
    }
    
    .mobile-controls {
        display: flex;
    }
    
    body {
        padding-bottom: 100px;
    }
    
    .game-area {
        height: calc(100vh - 200px);
        max-height: 60vh;
    }
}

@media (max-width: 768px) {
    .desktop-instructions {
        display: none;
    }
    
    .mobile-instructions {
        display: block;
    }
    
    .mobile-controls {
        display: flex;
    }
    
    body {
        padding: 10px;
        padding-bottom: 100px;
    }
    
    .controls {
        margin-top: 15px;
        margin-bottom: 10px;
    }
    
    .game-container {
        padding: 0 5px;
    }
}

@media (max-width: 480px) {
    .shoot-btn {
        width: 60px;
        height: 60px;
        font-size: 1.6em;
    }
    
    .slider-control {
        height: 50px;
        max-width: 220px;
    }
    
    .slider-thumb {
        width: 48px;
        height: 48px;
    }
}

button {
    font-size: 1.2em;
    padding: 10px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    touch-action: manipulation;
}

button:hover {
    background: #45a049;
}

button:active {
    background: #3d8b40;
}

button:disabled {
    background: #666;
    cursor: not-allowed;
}

.scoreboard-link {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 25px;
    font-size: 1.1em;
    color: #FFD700;
    text-decoration: none;
    border: 2px solid #FFD700;
    border-radius: 8px;
    transition: all 0.3s;
}

.scoreboard-link:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    button {
        font-size: 1em;
        padding: 12px 24px;
    }
    
    .scoreboard-link {
        font-size: 1em;
        padding: 8px 20px;
    }
}