html {
    height: 100%;
    background: var(--sea-deep) !important;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--sea-deep) !important;
    overflow: hidden;
    touch-action: none;
}

:root {
    --sea-deep: #0b2f3f;
    --sea-mid: #0f6b7a;
    --sea-glow: rgba(0, 180, 200, 0.35);
    --shadow-soft: 0 8px 14px rgba(0, 0, 0, 0.35);
    --shadow-hard: 0 14px 26px rgba(0, 0, 0, 0.45);
}

#seaboard {
    background: var(--sea-deep);

    background-position: center;
    background-repeat: no-repeat;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    transform-style: preserve-3d;
}

#seaboard::before {
    content: "";
    position: absolute;
    inset: -20%;
    background-image:
        repeating-linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.04),
            rgba(255, 255, 255, 0.04) 6px,
            rgba(255, 255, 255, 0.02) 6px,
            rgba(255, 255, 255, 0.02) 14px
        );
    mix-blend-mode: soft-light;
    opacity: 0.35;
    animation: drift 18s linear infinite;
    pointer-events: none;
    z-index: 1;
}

#seaboard::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.4));
    pointer-events: none;
    z-index: 2;
}

.scoreboard {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    letter-spacing: 0.3px;
    z-index: 6;
    pointer-events: none;
}

#player-warship {
    background-image: url("../images/player.png");
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    position: absolute;
  
  

    z-index: 3;
    

}

#opponents-warship{
    background-color: transparent;
    position: absolute;
}

.opponent-warship {
    background-color: transparent;
    background-image: url("../images/enemy.png");
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    filter: drop-shadow(var(--shadow-hard)) saturate(1.08) contrast(1.05);

    z-index: 3;
}

#bullets{
    background-color: black;
    position: absolute;
}

.bullet {
    position: absolute;
    z-index: 4;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.bullet-player {
    background-image: url("../images/playerBullet.png");
}

.bullet-enemy {
    background-image: url("../images/enemyBullet.png");
}

.life-bar {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 6px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    overflow: hidden;
    pointer-events: none;
}

.life-fill {
    height: 100%;
    width: 100%;
    transition: width 120ms linear;
}

.life-bar-player {
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.life-fill-player {
    background: #7dff9d;
}

.life-bar-enemy {
    border: 1px solid rgba(255, 140, 0, 0.7);
}

.life-fill-enemy {
    background: #ff8a00;
}

.hit-flash {
    animation: hitFlash 200ms ease-in-out;
}

.explosion {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 230, 140, 0.9) 0%, rgba(255, 120, 0, 0.8) 45%, rgba(255, 0, 0, 0) 70%);
    box-shadow: 0 0 18px rgba(255, 120, 0, 0.8);
    pointer-events: none;
    z-index: 5;
    animation: explode 500ms ease-out forwards;
}

.scoreboard {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 10px 16px;
    font-size: 16px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: #00ffd5;
    background: rgba(0, 20, 30, 0.7);
    border: 2px solid rgba(0, 255, 213, 0.5);
    box-shadow: 0 0 10px rgba(0, 255, 213, 0.3), inset 0 0 10px rgba(0, 255, 213, 0.2);
    border-radius: 6px;
    letter-spacing: 1px;
    text-shadow: 0 0 5px #00ffd5;
    z-index: 6;
    pointer-events: none;
    line-height: 1.5;
}

.scoreboard.ammo-low {
    color: #ffd24a;
    border-color: rgba(255, 210, 74, 0.75);
    box-shadow: 0 0 10px rgba(255, 210, 74, 0.25), inset 0 0 10px rgba(255, 210, 74, 0.15);
}

.scoreboard.ammo-empty {
    color: #ff6666;
    border-color: rgba(255, 102, 102, 0.9);
    box-shadow: 0 0 12px rgba(255, 102, 102, 0.35), inset 0 0 10px rgba(255, 102, 102, 0.18);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: linear-gradient(135deg, #0b2f3f, #05141c);
    border: 3px solid #00ffd5;
    box-shadow: 0 0 25px rgba(0, 255, 213, 0.4), inset 0 0 15px rgba(0, 255, 213, 0.2);
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    color: white;
    font-family: 'Orbitron', Arial, sans-serif;
    max-width: 90%;
    backdrop-filter: blur(5px);
}

.modal-content h2 {
    margin-top: 0;
    font-size: 36px;
    font-family: 'Black Ops One', cursive;
    color: #ffa600;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(255, 166, 0, 0.8), 2px 2px 0px rgba(255, 60, 0, 0.8);
    text-transform: uppercase;
}

/* Result / End screen styles (Win / Defeat) */
.result-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.03), rgba(0,0,0,0) 20%), transparent;
}

.result-card {
    text-align: center;
    background: linear-gradient(180deg, rgba(6,22,30,0.85), rgba(2,10,15,0.9));
    padding: 36px 48px;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65), 0 0 30px rgba(0, 255, 213, 0.06) inset;
    max-width: 560px;
    width: calc(100% - 48px);
    transform: translateY(0);
    animation: popIn 420ms cubic-bezier(.2,.9,.2,1);
}

.result-title {
    font-family: 'Black Ops One', 'Orbitron', sans-serif;
    font-size: 56px;
    margin: 0 0 8px 0;
    color: #ffd07a;
    text-shadow: 0 6px 18px rgba(255,140,0,0.16), 0 2px 0 rgba(0,0,0,0.45);
}

.result-subtext {
    font-family: 'Orbitron', sans-serif;
    color: #cfeeea;
    margin: 0 0 18px 0;
    font-size: 16px;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin-top: 8px;
}

.result-btn {
    font-family: 'Orbitron', sans-serif;
    background: linear-gradient(180deg, #00ffd5, #00c8a8);
    color: #052126;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 800;
    text-decoration: none;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 200, 170, 0.12), 0 2px 0 rgba(255,255,255,0.02) inset;
}

.result-btn.secondary {
    background: transparent;
    color: #e6fdfa;
    border: 1px solid rgba(255,255,255,0.08);
}

.result-btn:hover {
    transform: translateY(-2px);
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    margin: 25px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    padding: 12px 25px;
    font-size: 18px;
    font-family: 'Black Ops One', cursive;
    letter-spacing: 2px;
    cursor: pointer;
    background: transparent;
    color: #00ffd5;
    border: 2px solid #00ffd5;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(0, 255, 213, 0.2);
    transition: all 0.2s ease-in-out;
}

.diff-btn:hover {
    background: #00ffd5;
    color: #05141c;
    box-shadow: 0 0 20px rgba(0, 255, 213, 0.6);
    transform: scale(1.05) translateY(-2px);
}

.diff-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 5px rgba(0, 255, 213, 0.6);
}

#diff-desc, #next-level-desc {
    font-size: 16px;
    color: #a0d8e0;
    margin-bottom: 20px;
    text-shadow: 0 0 5px rgba(0, 180, 200, 0.5);
    line-height: 1.5;
}

@keyframes drift {
    0% {
        transform: translate3d(-2%, -2%, 0);
    }
    50% {
        transform: translate3d(2%, 1%, 0);
    }
    100% {
        transform: translate3d(-2%, -2%, 0);
    }
}

@keyframes hitFlash {
    0% {
        filter: brightness(1.4) saturate(1.3);
    }
    100% {
        filter: brightness(1) saturate(1);
    }
}

@keyframes explode {
    0% {
        transform: scale(0.6);
        opacity: 0.95;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Mobile Controls */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    padding: 0 30px;
    box-sizing: border-box;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 10;
    pointer-events: none;
}

@media (max-width: 1024px), (pointer: coarse), (hover: none) {
    #mobile-controls {
        display: flex;
    }
}

@media (min-width: 769px) and (max-width: 1366px) {
    #mobile-controls {
        bottom: 16px;
        padding: 0 20px calc(16px + env(safe-area-inset-bottom));
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-end;
        gap: 16px;
    }

    #dpad,
    #action-buttons {
        pointer-events: auto;
    }

    #dpad {
        flex-shrink: 0;
    }

    #action-buttons {
        display: flex;
        justify-content: flex-end;
        flex-shrink: 0;
    }

    .control-btn {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .action-btn {
        width: 76px;
        height: 76px;
        font-size: 16px;
    }

    .dpad-middle {
        gap: 28px;
    }
}

@media (max-width: 768px) {
    #mobile-controls {
        flex-direction: column;
        justify-content: flex-end;
        align-items: center;
        gap: 14px;
        padding: 0 16px calc(12px + env(safe-area-inset-bottom));
    }

    #action-buttons {
        display: flex;
        justify-content: center;
    }

    #dpad {
        gap: 10px;
    }
}

.control-btn {
    pointer-events: auto;
    background: rgba(0, 40, 50, 0.4);
    border: 2px solid rgba(0, 255, 213, 0.4);
    color: #00ffd5;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: manipulation;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 213, 0.2);
    font-family: 'Orbitron', sans-serif;
}

.control-btn:active {
    background: rgba(0, 255, 213, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 213, 0.5);
}

#dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.dpad-middle {
    display: flex;
    gap: 60px;
}

.action-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 18px;
    font-family: 'Black Ops One', cursive;
    letter-spacing: 1px;
    background: rgba(255, 60, 60, 0.2);
    border-color: rgba(255, 60, 60, 0.8);
    color: #ff6b6b;
    box-shadow: 0 0 15px rgba(255, 60, 60, 0.3);
    text-shadow: 0 0 5px #ff6b6b;
}

.action-btn:active {
    background: rgba(255, 60, 60, 0.5);
    box-shadow: 0 0 25px rgba(255, 60, 60, 0.6);
    color: white;
}
