* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #050816;
    color: white;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

#game {
    position: relative;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(circle at 20% 20%, #18245c 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, #35145f 0%, transparent 20%),
        #050816;
    overflow: hidden;
}

/* النجوم */
.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    opacity: .8;
    animation: moveStar linear infinite;
}

@keyframes moveStar {
    from {
        transform: translateY(-20px);
    }
    to {
        transform: translateY(110vh);
    }
}

/* الواجهة */
#hud {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    z-index: 20;
    font-size: 18px;
    gap: 8px;
}

.panel {
    background: rgba(10, 15, 40, .75);
    border: 1px solid rgba(120, 150, 255, .35);
    padding: 10px 15px;
    border-radius: 12px;
    backdrop-filter: blur(8px);
}

/* السفينة */
#ship {
    position: absolute;
    width: 55px;
    height: 70px;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.ship-body {
    position: absolute;
    width: 35px;
    height: 55px;
    background: linear-gradient(#7cf6ff, #3974ff);
    clip-path: polygon(50% 0%, 100% 100%, 50% 78%, 0% 100%);
    left: 10px;
    top: 0;
    box-shadow: 0 0 20px #32e8ff;
}

.flame {
    position: absolute;
    width: 15px;
    height: 25px;
    background: linear-gradient(#fff, #00c8ff, transparent);
    bottom: -8px;
    left: 20px;
    filter: blur(2px);
    animation: flame .12s infinite alternate;
}

@keyframes flame {
    from { height: 18px; }
    to { height: 28px; }
}

/* الطلقات */
.bullet {
    position: absolute;
    width: 5px;
    height: 20px;
    background: #65f6ff;
    border-radius: 10px;
    box-shadow: 0 0 15px #00eaff;
    z-index: 8;
}

/* الأعداء */
.enemy {
    position: absolute;
    width: 45px;
    height: 45px;
    background: radial-gradient(circle, #ff668d, #7d1247);
    border-radius: 50%;
    box-shadow: 0 0 20px #ff176b;
    z-index: 7;
}

.enemy::before,
.enemy::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    top: 12px;
}

.enemy::before {
    left: 9px;
}

.enemy::after {
    right: 9px;
}

/* الانفجار */
.explosion {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, white, #ffb300, #ff1744, transparent);
    animation: explode .35s forwards;
    z-index: 15;
}

@keyframes explode {
    from {
        transform: scale(.3);
        opacity: 1;
    }

    to {
        transform: scale(2);
        opacity: 0;
    }
}

/* شاشات البداية والنهاية */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(3, 5, 20, .88);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    padding: 20px;
}

.overlay h1 {
    font-size: clamp(35px, 8vw, 75px);
    margin-bottom: 10px;
    text-shadow: 0 0 25px #00eaff;
}

.overlay p {
    color: #b8c8ff;
    margin-bottom: 25px;
}

button {
    border: none;
    padding: 15px 35px;
    border-radius: 12px;
    background: linear-gradient(135deg, #00d9ff, #695cff);
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(0, 217, 255, .4);
}

button:active {
    transform: scale(.95);
}

/* =========================
   أزرار الموبايل
   ========================= */

#mobileControls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 30;
    pointer-events: none;
}

#movementControls {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

#fireControls {
    pointer-events: auto;
}

.control {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(50, 100, 255, .28);
    border: 2px solid rgba(120, 180, 255, .55);
    color: white;
    font-size: 27px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

.control:hover {
    background: rgba(50, 120, 255, .45);
}

#fireBtn {
    background: rgba(255, 40, 90, .28);
    border-color: rgba(255, 100, 150, .65);
}

#fireBtn:hover {
    background: rgba(255, 40, 90, .45);
}

/* حقوق اللعبة */
#copyright {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(190, 210, 255, .65);
    font-size: 12px;
    z-index: 40;
    pointer-events: none;
}

#copyright strong {
    color: #7cecff;
}

.hidden {
    display: none !important;
}

/* تحسين الموبايل */
@media (max-width: 600px) {
    #hud {
        font-size: 12px;
        top: 8px;
        left: 8px;
        right: 8px;
    }

    .panel {
        padding: 8px 9px;
    }

    .control {
        width: 60px;
        height: 60px;
        font-size: 23px;
    }

    #mobileControls {
        bottom: 22px;
        left: 15px;
        right: 15px;
    }

    #copyright {
        bottom: 2px;
        font-size: 10px;
    }
}