*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    padding: 4px;
}

#loadingScreen {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
    transition: opacity 0.6s ease;
}
#loadingScreen.hidden { opacity: 0; pointer-events: none; }
.loader-content { text-align: center; }
.loader-ship { margin-bottom: 28px; animation: loaderFloat 1s ease-in-out infinite; }
.loader-ship svg { filter: drop-shadow(0 0 15px #4ecdc4); }
@keyframes loaderFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}
.loader-bar {
    width: 200px; height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px; overflow: hidden;
    margin: 0 auto 16px;
}
.loader-fill {
    width: 0%; height: 100%;
    background: linear-gradient(90deg, #4ecdc4, #1dd1a1);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.loader-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
    letter-spacing: 4px;
}

.container {
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    border: 2px solid #4ecdc4;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-header {
    text-align: center;
    padding: 4px 4px;
    border-bottom: 1px solid rgba(78,205,196,0.3);
    flex-shrink: 0;
}
.game-header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 900;
    margin-bottom: 4px;
    background: linear-gradient(45deg, #4ecdc4, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}
.game-header h1 i { margin-right: 6px; color: #ff6b6b; font-size: 1rem; }

.mode-bar {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}
.mode-btn {
    padding: 3px 16px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.5);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}
.mode-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.mode-btn.active {
    background: rgba(78,205,196,0.15);
    border-color: #4ecdc4;
    color: #4ecdc4;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.score-board { display: flex; gap: 12px; }
.score {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2px 12px;
    border-radius: 8px;
    min-width: 60px;
}
.player-score {
    background: linear-gradient(135deg, rgba(78,205,196,0.2), rgba(29,209,161,0.1));
    border: 1px solid #4ecdc4;
}
.bot-score {
    background: linear-gradient(135deg, rgba(255,107,107,0.2), rgba(255,71,87,0.1));
    border: 1px solid #ff6b6b;
}
.score-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
}
.score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    text-shadow: 0 0 10px currentColor;
    line-height: 1.2;
}
.player-score .score-value { color: #4ecdc4; }
.bot-score .score-value { color: #ff6b6b; }

.health-bars { flex: 1; max-width: 250px; }
.health-bar {
    height: 14px;
    background: rgba(255,255,255,0.06);
    border-radius: 7px;
    margin-bottom: 3px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
}
.health-bar:last-child { margin-bottom: 0; }
.health-fill {
    height: 100%; width: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
}
.player-health .health-fill {
    background: linear-gradient(90deg, #4ecdc4, #1dd1a1);
    box-shadow: 0 0 6px rgba(78,205,196,0.4);
}
.bot-health .health-fill {
    background: linear-gradient(90deg, #ff6b6b, #ff4757);
    box-shadow: 0 0 6px rgba(255,107,107,0.4);
}
.health-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.game-layout {
    flex: 1;
    display: flex;
    gap: 6px;
    padding: 4px;
    min-height: 0;
}

.side-panel {
    width: 180px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.panel-section {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.key-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
}
.key-hint kbd {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
    padding: 0 5px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    color: #fff;
    min-width: 22px;
    text-align: center;
    line-height: 1.6;
}

.actions .btn {
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.15s ease;
}
.btn i { font-size: 0.7rem; }
.btn-primary {
    background: linear-gradient(135deg, #4ecdc4, #1dd1a1);
    color: #fff;
    box-shadow: 0 3px 8px rgba(78,205,196,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(78,205,196,0.4); }
.btn-secondary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    box-shadow: 0 3px 8px rgba(102,126,234,0.3);
}
.btn-secondary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,0.4); }
.btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #ff4757);
    color: #fff;
    box-shadow: 0 3px 8px rgba(255,107,107,0.3);
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255,107,107,0.4); }

.tools {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.btn-icon:hover { background: rgba(255,255,255,0.18); }
.btn-icon i { margin: 0; font-size: 0.85rem; }

.difficulty-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.difficulty-group span {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.5rem;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    letter-spacing: 1px;
}
.difficulty-group select {
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(78,205,196,0.4);
    border-radius: 4px;
    padding: 3px 5px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    cursor: pointer;
    outline: none;
}
.difficulty-group select:focus {
    border-color: #4ecdc4;
    box-shadow: 0 0 0 2px rgba(78,205,196,0.2);
}

.powerup-indicator { }
.pu-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    letter-spacing: 2px;
    margin-bottom: 4px;
}
.pu-slots {
    display: flex;
    gap: 4px;
}
.pu-slot {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.02);
    transition: all 0.3s ease;
    opacity: 0.3;
}
.pu-slot.active { opacity: 1; }
.pu-slot.active.pu-shield { border-color: #4ecdc4; background: rgba(78,205,196,0.1); }
.pu-slot.active.pu-rapid { border-color: #ffa502; background: rgba(255,165,2,0.1); }
.pu-slot.active.pu-spread { border-color: #a29bfe; background: rgba(162,155,254,0.1); }
.pu-icon {
    font-size: 1rem;
    line-height: 1;
}
.pu-slot.active.pu-shield .pu-icon { color: #4ecdc4; }
.pu-slot.active.pu-rapid .pu-icon { color: #ffa502; }
.pu-slot.active.pu-spread .pu-icon { color: #a29bfe; }
.pu-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.45rem;
    color: rgba(255,255,255,0.5);
}

.play-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.game-area {
    position: relative;
    flex: 1;
    min-height: 200px;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}

#particleCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}
.stars1 { box-shadow: 1420px 98px #fff, 373px 636px #fff, 258px 12px #fff, 906px 418px #fff, 542px 98px #fff, 770px 204px #fff, 125px 375px #fff, 1100px 133px #fff, 95px 850px #fff, 300px 532px #fff, 667px 90px #fff, 843px 700px #fff, 480px 45px #fff, 935px 256px #fff, 200px 460px #fff, 550px 800px #fff; animation: twinkle 4s infinite; }
.stars2 { box-shadow: 1030px 550px rgba(255,255,255,0.6), 450px 780px rgba(255,255,255,0.6), 700px 200px rgba(255,255,255,0.6), 220px 120px rgba(255,255,255,0.6), 880px 600px rgba(255,255,255,0.6), 150px 400px rgba(255,255,255,0.6), 960px 80px rgba(255,255,255,0.6), 340px 500px rgba(255,255,255,0.6), 520px 150px rgba(255,255,255,0.6), 800px 350px rgba(255,255,255,0.6), 120px 650px rgba(255,255,255,0.6), 650px 450px rgba(255,255,255,0.6), 780px 25px rgba(255,255,255,0.6); animation: twinkle 5s infinite 1s; }
.stars3 { box-shadow: 100px 100px rgba(255,255,255,0.4), 400px 300px rgba(255,255,255,0.4), 700px 500px rgba(255,255,255,0.4), 1000px 200px rgba(255,255,255,0.4), 200px 600px rgba(255,255,255,0.4), 500px 400px rgba(255,255,255,0.4), 800px 100px rgba(255,255,255,0.4), 1100px 300px rgba(255,255,255,0.4), 50px 700px rgba(255,255,255,0.4), 300px 800px rgba(255,255,255,0.4), 600px 600px rgba(255,255,255,0.4), 900px 700px rgba(255,255,255,0.4), 150px 900px rgba(255,255,255,0.4), 350px 150px rgba(255,255,255,0.4); animation: twinkle 3s infinite 2s; }
@keyframes twinkle {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

.character {
    position: absolute;
    z-index: 3;
    width: 76px;
    height: 76px;
}
.character-svg { width: 100%; height: 100%; filter: drop-shadow(0 0 6px currentColor); }
#player .character-svg { color: #4ecdc4; }
#bot .character-svg, .enemy-ship .character-svg { color: #ff6b6b; }

.enemy-hp-bar {
    position: absolute;
    z-index: 4;
    width: 50px;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    pointer-events: none;
}
.enemy-hp-fill {
    height: 100%;
    width: 100%;
    background: #ff6b6b;
    border-radius: 2px;
    transition: width 0.15s ease;
}

.bullet-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.bullet {
    position: absolute;
    width: 7px;
    height: 14px;
    border-radius: 50%;
}
.player-bullet {
    background: linear-gradient(to bottom, #4ecdc4, #1dd1a1);
    box-shadow: 0 0 6px #4ecdc4;
}
.bot-bullet {
    background: linear-gradient(to bottom, #ff6b6b, #ff4757);
    box-shadow: 0 0 6px #ff6b6b;
}

/* Falling power-ups */
.powerup {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid;
    background: rgba(0,0,0,0.6);
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 0 10px currentColor;
    animation: puPulse 1s ease-in-out infinite;
}
@keyframes puPulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 1; }
}
.pu-fall-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.touch-controls { display: none; }

.game-over {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.game-over-content {
    background: linear-gradient(135deg, #0f0c29, #302b63);
    padding: 32px;
    border-radius: 12px;
    text-align: center;
    border: 2px solid #4ecdc4;
    max-width: 360px;
    width: 90%;
    animation: popIn 0.35s ease-out;
}
@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.game-over-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 8px;
    background: linear-gradient(45deg, #4ecdc4, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.game-over-content p { font-size: 0.95rem; margin-bottom: 12px; color: #fff; }
.high-score-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem !important;
    color: #ffa502 !important;
    letter-spacing: 1px;
}
.high-score-text span { color: #4ecdc4; font-weight: 900; }

@media (pointer: coarse) {
    .side-panel { display: none; }
    .touch-controls {
        display: flex;
        justify-content: center;
        gap: 16px;
        flex-shrink: 0;
        padding: 6px 0;
    }
    .control-btn {
        width: 52px; height: 52px;
        border-radius: 50%;
        border: none;
        font-family: 'Orbitron', sans-serif;
        font-size: 0.75rem;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
    }
    .control-btn i { font-size: 1.1rem; }
    .control-btn:active { transform: scale(0.92); }
    .move-left {
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: #fff;
        box-shadow: 0 3px 8px rgba(102,126,234,0.4);
    }
    .move-right {
        background: linear-gradient(135deg, #f093fb, #f5576c);
        color: #fff;
        box-shadow: 0 3px 8px rgba(240,147,251,0.4);
    }
    .move-up {
        background: linear-gradient(135deg, #1dd1a1, #10ac84);
        color: #fff;
        box-shadow: 0 3px 8px rgba(29,209,161,0.4);
    }
    .move-down {
        background: linear-gradient(135deg, #feca57, #ff9f43);
        color: #fff;
        box-shadow: 0 3px 8px rgba(254,202,87,0.4);
    }
    .shoot {
        width: 60px; height: 60px;
        background: linear-gradient(135deg, #4ecdc4, #44a08d);
        color: #fff;
        box-shadow: 0 4px 12px rgba(78,205,196,0.4);
        font-size: 0.7rem;
    }
}

@media (max-width: 820px) {
    body { padding: 2px; }
    .container { border-width: 1px; }
    .game-header { padding: 4px 8px; }
    .game-header h1 { font-size: 0.95rem; }
    .game-header h1 i { font-size: 0.85rem; }
    .score { min-width: 45px; padding: 2px 8px; }
    .score-value { font-size: 1.2rem; }
    .score-label { font-size: 0.55rem; }
    .health-bar { height: 12px; }
    .health-text { font-size: 0.45rem; }

    .game-layout { flex-direction: column; padding: 4px; gap: 4px; }
    .side-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }
    .panel-section {
        flex: 1;
        min-width: 120px;
        padding: 6px 8px;
    }
    .key-hint { font-size: 0.6rem; }
    .key-hint kbd { font-size: 0.45rem; min-width: 16px; line-height: 1.4; }
    .actions .btn { font-size: 0.55rem; padding: 4px 6px; }
    .tools { flex-wrap: wrap; }
    .difficulty-group span { font-size: 0.45rem; }
    .difficulty-group select { font-size: 0.5rem; padding: 2px 4px; }

    .play-area {  }
    .game-area { min-height: 150px; }
    .character { width: 50px; height: 50px; }
}
