body {
    margin: 0;
    padding: 10px;
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

#gameContainer {
    position: relative;
    background: #000;
    border: 3px solid #fff;
    border-radius: 10px;
    overflow: hidden;
    max-width: 95vw;
    max-height: 80vh;
}

#gameCanvas {
    display: block;
    background: linear-gradient(180deg, #87CEEB 0%, #98FB98 100%);
    width: 100%;
    height: auto;
    max-width: 1200px;
    max-height: 800px;
}

#ui {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#score, #lives {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 18px;
}

.warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 0, 0, 0.9);
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    border: 3px solid #fff;
    animation: pulse 1s infinite;
}

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

.hidden {
    display: none !important;
}

#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    border: 3px solid #fff;
}

#gameOver h2 {
    color: #ff4444;
    margin-top: 0;
}

#gameOver button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    margin: 10px;
}

#gameOver button:hover {
    background: #45a049;
}

.scoreboard-btn {
    background: #FF6B35 !important;
}

.scoreboard-btn:hover {
    background: #e55a2b !important;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

#instructions {
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

#instructions h3 {
    margin-top: 0;
    color: #FFD700;
}

#instructions p {
    margin: 5px 0;
    font-size: 16px;
}

.scoreboard-link {
    margin-top: 15px;
    text-align: center;
}

.scoreboard-link-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #FF6B35;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: all 0.3s;
}

.scoreboard-link-btn:hover {
    background: #e55a2b;
    transform: translateY(-2px);
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    flex-direction: row;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-top: 30px;
    padding: 20px;
}

.control-btn {
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.arrow-btn {
    width: 70px;
    height: 70px;
    background: linear-gradient(145deg, #4a90e2, #357abd);
    color: white;
    font-size: 32px;
}

.arrow-btn:hover {
    background: linear-gradient(145deg, #357abd, #2968a3);
}

.shoot-btn {
    width: 100px;
    height: 70px;
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    color: white;
    font-size: 16px;
    font-weight: bold;
    border-radius: 35px;
}

.shoot-btn:hover {
    background: linear-gradient(145deg, #c0392b, #a93226);
}

/* Show mobile controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }
    
    body {
        padding: 0;
        margin: 0;
        min-height: 100vh;
    }
    
    #gameContainer {
        max-width: 100vw;
        max-height: 85vh;
        width: 100vw;
        height: 85vh;
        border-width: 1px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #gameCanvas {
        width: 100% !important;
        height: 100% !important;
        max-width: none;
        max-height: none;
        object-fit: contain;
    }
    
    #instructions {
        display: none; /* Hide instructions on touch devices to save space */
    }
}

/* Mobile phones - maximize screen usage */
@media (max-width: 768px) {
    .mobile-controls {
        display: flex;
        margin-top: 10px;
        padding: 10px;
        gap: 20px;
    }
    
    body {
        padding: 0;
        margin: 0;
        min-height: 100vh;
        justify-content: flex-start;
    }
    
    #gameContainer {
        max-width: 100vw;
        max-height: 85vh;
        width: 100vw;
        height: 85vh;
        border-width: 1px;
        border-radius: 0;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #gameCanvas {
        width: 100% !important;
        height: 100% !important;
        max-width: none;
        max-height: none;
        object-fit: contain;
    }
    
    #instructions {
        display: none; /* Hide instructions on mobile to maximize game space */
    }
    
    /* Larger mobile controls for better touch experience */
    .arrow-btn {
        width: 80px;
        height: 80px;
        font-size: 36px;
    }
    
    .shoot-btn {
        width: 120px;
        height: 80px;
        font-size: 18px;
        border-radius: 40px;
    }
    
    /* Optimize UI elements for mobile */
    #score, #lives {
        padding: 8px 12px;
        font-size: 16px;
    }
    
    .warning {
        padding: 15px 20px;
        font-size: 20px;
    }
    
    #gameOver {
        padding: 20px;
        max-width: 90vw;
    }
    
    #gameOver button {
        padding: 12px 24px;
        font-size: 16px;
    }
}

/* Tablets in portrait mode */
@media (min-width: 481px) and (max-width: 768px) and (orientation: portrait) {
    #gameContainer {
        max-width: 95vw;
        max-height: 70vh;
    }
    
    .mobile-controls {
        margin-top: 20px;
        padding: 15px;
    }
}

/* Tablets in landscape mode */
@media (min-width: 481px) and (max-width: 1024px) and (orientation: landscape) {
    #gameContainer {
        max-width: 95vw;
        max-height: 80vh;
    }
    
    .mobile-controls {
        margin-top: 10px;
        padding: 10px;
    }
    
    #instructions {
        display: block;
        font-size: 12px;
        padding: 10px;
        margin-top: 5px;
    }
}

/* Small phones - ultra compact */
@media (max-width: 480px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    #gameContainer {
        max-width: 100vw;
        max-height: 88vh;
        width: 100vw;
        height: 88vh;
        border-width: 0;
        border-radius: 0;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #gameCanvas {
        width: 100% !important;
        height: 100% !important;
        max-width: none;
        max-height: none;
        object-fit: contain;
    }
    
    .mobile-controls {
        margin-top: 5px;
        padding: 5px;
        gap: 15px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.8);
        z-index: 30;
    }
    
    .arrow-btn {
        width: 75px;
        height: 75px;
        font-size: 34px;
    }
    
    .shoot-btn {
        width: 110px;
        height: 75px;
        font-size: 16px;
    }
    
    #score, #lives {
        padding: 6px 10px;
        font-size: 14px;
    }
}

/* Large screens - use more space */
@media (min-width: 1400px) {
    #gameContainer {
        max-width: 90vw;
        max-height: 85vh;
    }
}

/* Medium screens */
@media (min-width: 769px) and (max-width: 1399px) {
    #gameContainer {
        max-width: 95vw;
        max-height: 80vh;
    }
}