body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: #0a2342;
    font-family: 'Arial', sans-serif;
    color: #fff;
    transition: background-color 1s ease;
    overflow: hidden;
    background-color: #0a5d9a;
    touch-action: none; /* Prevent default touch actions */
}

.game-container {
    border-radius: 10px;
    position: relative;
    width: 800px;
    height: 600px;
    border: 8px solid #ffffff;
    box-shadow: 0 0 30px #000;
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Add scanlines effect for retro arcade feel */
.game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 50%,
        rgba(0, 0, 0, 0.05) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 1001;
}

/* Add CRT screen effect */
.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        rgba(0, 0, 0, 0.2) 90%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: 1002;
}

canvas {
    background: linear-gradient(180deg, #0f5e9c 0%, #2a3c90 60%, #1c2951 100%);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#gameCanvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.game-ui {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 20px;
    font-size: 20px;
    text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);
}

.oxygen {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 20px;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    width: 400px;
    box-shadow: 0 0 50px rgba(255, 0, 0, 0.3);
    border: 2px solid rgba(255, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.game-over h2 {
    color: #ff3333;
    font-size: 10rem;
    margin: 0 0 20px 0;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
    animation: gameOverPulse 2s infinite;
}

.game-over p {
    color: #fff;
    font-size: 24px;
    margin: 20px 0;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.game-over button {
    background: linear-gradient(to bottom, #ff4444 0%, #cc0000 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 20px;
    margin: 10px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
}

.game-over button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.5);
}

@keyframes gameOverPulse {
    0% { transform: scale(1); text-shadow: 0 0 10px rgba(255, 0, 0, 0.7); }
    50% { transform: scale(1.1); text-shadow: 0 0 20px rgba(255, 0, 0, 0.9); }
    100% { transform: scale(1); text-shadow: 0 0 10px rgba(255, 0, 0, 0.7); }
}

.hidden {
    display: none;
}

button {
    background: #2ecc71;
    border: none;
    padding: 10px 20px;
    font-size: 18px;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

button:hover {
    background: #27ae60;
}

.instructions {
    margin-top: 20px;
    text-align: center;
    color: #ccc;
}

.instructions strong {
    background: rgba(255, 255, 255, 0.1);
    outline: 1px solid #00ffff;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    color: #00ffff;
    display: inline-block;
    margin-left: 15px;
}

/* Common warning styles */
.warning {
    position: fixed;
    top: 50vh;
    left: 50vw;
    transform: translate(-50%, -50%);
    padding: 1rem 2rem;
    border-radius: 2rem;
    text-align: center;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.2);
    min-width: min(20rem, 80vw);
    pointer-events: none;
}

/* Boss warning specific styles */
.boss-warning {
    color: #fff;
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    text-shadow: 0.2rem 0.2rem 0.3rem rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

/* Torpedo and invincibility warning specific styles */
.torpedo-warning {
    font-size: clamp(1.2rem, 4vw, 2rem);
    color: #ff9933;
    white-space: nowrap;
    padding: 1rem 2rem;
    text-shadow: 0 0 1rem rgba(255, 153, 51, 0.7);
    font-weight: bold;
    animation: blink 0.5s ease-in-out alternate infinite;
}

/* Generic fade-out effect for all warnings */
.warning.fade-out {
    animation: fadeOut 0.2s forwards;
}

@keyframes blink {
    from { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1.1); 
        text-shadow: 0 0 1.5rem rgba(255, 153, 51, 0.9);
        background: rgba(0, 0, 0, 0.8);
    }
    to { 
        opacity: 0.8; 
        transform: translate(-50%, -50%) scale(1); 
        text-shadow: 0 0 0.5rem rgba(255, 153, 51, 0.5);
        background: rgba(0, 0, 0, 0.6);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translate(-50%, -60%) scale(0.9);
    }
}

.oxygen-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 30px;
    border-radius: 10px;
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
    animation: oxygenWarningPulse 1s infinite alternate;
    z-index: 1000;
}

@keyframes oxygenWarningPulse {
    from { 
        transform: translate(-50%, -50%) scale(1);
        text-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
    }
    to { 
        transform: translate(-50%, -50%) scale(1.1);
        text-shadow: 0 0 20px rgba(255, 0, 0, 0.9);
    }
}

/* Remove individual message styles since they're now combined */
@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Add bonus flash animation */
.bonus-flash {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
    pointer-events: none;
    animation: bonusFloat 1s ease-out forwards;
}

@keyframes bonusFloat {
    0% { 
        opacity: 0;
        transform: translate(-50%, 0) scale(0.5);
    }
    20% { 
        opacity: 1;
        transform: translate(-50%, -20px) scale(1.2);
    }
    100% { 
        opacity: 0;
        transform: translate(-50%, -40px) scale(1);
    }
}

.game-options {
    margin-top: 15px;
    display: flex;
    justify-content: center;
}

.warning {
    color: #ff9900;
    animation: warningPulse 1s infinite alternate;
}

.critical {
    color: #ff0000;
    animation: warningPulse 0.5s infinite alternate;
    font-weight: bold;
}

.level-scoreboard {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    width: 400px;
    z-index: 100;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    animation: scoreboardAppear 0.5s ease-out;
}

@keyframes scoreboardAppear {
    from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.level-scoreboard h2 {
    color: #ffd700;
    margin-top: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.level-scoreboard p {
    font-size: 20px;
    margin: 15px 0;
}

.victory-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    width: 500px;
    z-index: 200;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.8);
    animation: victoryAppear 1s ease-out;
}

@keyframes victoryAppear {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.victory-screen h1 {
    color: #ffd700;
    font-size: 36px;
    margin-top: 0;
    text-shadow: 2px 2px 6px rgba(255, 215, 0, 0.5);
}

.victory-screen p {
    font-size: 24px;
    margin: 20px 0;
}

.victory-screen button {
    background: #ffd700;
    color: #000;
    font-size: 22px;
    padding: 15px 30px;
    margin-top: 30px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.victory-screen button:hover {
    background: #ffcc00;
    transform: scale(1.05);
}

/* Score flash effect when coins are collected */
.score-flash {
    animation: scoreFlash 0.5s ease-out;
    color: #ffd700 !important;
    text-shadow: 0 0 15px #ffd700, 0 0 25px #ffd700 !important;
    font-weight: bold !important;
}

/* Oxygen flash effect when oxygen tanks are collected */
.oxygen-flash {
    animation: oxygenFlash 0.8s ease-out;
    color: #3498db !important;
    text-shadow: 0 0 15px #3498db, 0 0 25px #3498db !important;
    font-weight: bold !important;
}

@keyframes oxygenFlash {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    75% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes scoreFlash {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* Start Screen Styles */
.start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #000428 0%, #004e92 100%);
    background-image: url('assets/png/intro_bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    /* justify-content: space-between; */
    align-items: center;
    padding: 30px;
    box-sizing: border-box;
    overflow: hidden;
}

.game-title {
    text-align: center;
}

.game-title h1 {
    font-size: 15rem;
    font-family: 'Impact', 'Arial Black', sans-serif;
    color: #ffd700;
    text-shadow: 
        0 0 10px #ff8800,
        0 0 20px #ff8800,
        0 0 30px #ff8800,
        4px 4px 0 #000;
    margin: 0 0 0 0;
    letter-spacing: 2px;
    transform: perspective(500px) rotateX(10deg);
    animation: titlePulse 3s infinite ease-in-out;
}

@keyframes titlePulse {
    0% {
        color: #ffd700;
        text-shadow: 
            0 0 10px #ff8800,
            0 0 20px #ff8800,
            0 0 30px #ff8800,
            4px 4px 0 #000;
        transform: perspective(500px) rotateX(10deg) scale(1);
    }
    50% {
        color: #fff6a3;
        text-shadow: 
            0 0 15px #ff8800,
            0 0 30px #ff8800,
            0 0 50px #ff8800,
            0 0 70px #ff8800,
            0 0 90px #ff4400,
            4px 4px 0 #000;
        transform: perspective(500px) rotateX(10deg) scale(1.05);
    }
    100% {
        color: #ffd700;
        text-shadow: 
            0 0 10px #ff8800,
            0 0 20px #ff8800,
            0 0 30px #ff8800,
            4px 4px 0 #000;
        transform: perspective(500px) rotateX(10deg) scale(1);
    }
}

@keyframes submarineFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.level-select {
    text-align: center;
    margin: 20px 0;
}

.level-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.level-btn {
    background: linear-gradient(to bottom, #4a4a4a 0%, #2d2d2d 100%);
    color: #fff;
    border: 3px solid #00ffff;
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5), inset 0 0 5px rgba(0, 255, 255, 0.2);
    text-shadow: 0 0 5px #00ffff;
}

.level-btn:hover, .level-btn.selected {
    background: linear-gradient(to bottom, #00ffff 0%, #009999 100%);
    color: #000;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.start-options {
    text-align: center;
    margin-bottom: 30px;
}

.start-btn {
    background: linear-gradient(to bottom, #ff8800 0%, #ff4400 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 15px 40px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(255, 136, 0, 0.7), inset 0 0 10px rgba(255, 255, 255, 0.3);
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.start-btn:hover {
    background: linear-gradient(to bottom, #ffaa00 0%, #ff6600 100%);
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 136, 0, 0.9), inset 0 0 15px rgba(255, 255, 255, 0.5);
}

.high-score {
    font-size: 12px;
    color: #ffd700;
    margin-top: 10px;
    text-shadow: 0 0 10px #ffd700;
    /* font-weight: bold; */
    position: absolute;
    top: 10px;
    right: 20px;
}

.top-left {
    top: 20px;
    left: 20px;
    animation-delay: 0s;
}

.top-right {
    top: 20px;
    right: 20px;
    animation-delay: 0.5s;
}

.bottom-left {
    bottom: 20px;
    left: 20px;
    animation-delay: 1s;
}

.bottom-right {
    bottom: 20px;
    right: 20px;
    animation-delay: 1.5s;
}

@keyframes decorationPulse {
    0% { transform: scale(1); opacity: 0.3; }
    100% { transform: scale(1.5); opacity: 0.5; }
}

.level-indicator {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 20px;
}

/* Make sure the start screen is hidden by default */
#startScreen.hidden {
    display: none !important;
}

/* Level message styles */
.level-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) perspective(500px) rotateX(10deg);
    color: #ffd700;
    font-weight: bold;
    font-family: 'Impact', 'Arial Black', sans-serif;
    letter-spacing: 2px;
    text-align: center;
    animation: levelFlash 2s infinite alternate;
}

.level-message .level-number {
    font-size: 45px;
    margin-bottom: 10px;
}

.level-message .level-description {
    font-size: 30px;
}

@keyframes levelFlash {
    0% { 
        text-shadow: 
            0 0 10px #ff8800,
            0 0 20px #ff8800,
            0 0 30px #ff8800,
            4px 4px 0 #000;
    }
    100% { 
        text-shadow: 
            0 0 15px #ff8800,
            0 0 30px #ff8800,
            0 0 50px #ff8800,
            4px 4px 0 #000;
    }
}

/* Level message fade out animation */
.level-message.fade-out {
    opacity: 0;
    transform: translate(-50%, -50%) perspective(500px) rotateX(10deg) scale(0.8);
    transition: opacity 0.5s, transform 0.5s;
}

/* Mobile Controls */
.mobile-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: none; /* Hidden by default, shown on mobile */
    pointer-events: none; /* Let touch events pass through */
}

.virtual-joystick {
    position: fixed;
    bottom: 40px;
    left: 40px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    pointer-events: auto;
}

.joystick-knob {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.fire-button {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 80px;
    height: 80px;
    background: rgba(255, 0, 0, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 16px;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
}

.fire-button:active {
    background: rgba(255, 0, 0, 0.5);
}

/* Orientation warning */
.orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 1000;
}

@media (orientation: portrait) {
    .orientation-warning {
        display: flex;
    }
}

/* Mobile-specific adjustments for game elements */
@media (max-width: 768px) {
    .warning {
        font-size: 18px;
    }
    
    .oxygen-message {
        font-size: 16px;
    }
    
    .score-popup {
        font-size: 14px;
    }
    
    .level-message {
        font-size: 20px;
    }
    
    #startScreen, #gameOver {
        font-size: 16px;
    }
    
    .level-btn, #startGameBtn {
        padding: 10px 20px;
        font-size: 16px;
    }
}
