:root {
    --bg-dark: #050811;
    --panel-bg: rgba(11, 18, 36, 0.92);
    --cyan: #00f3ff;
    --magenta: #ff007f;
    --gold: #ffd700;
    --red: #ff3355;
    --green: #00ff88;
    --text: #e2ecff;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
    background: radial-gradient(circle at center, #0c142c 0%, var(--bg-dark) 100%);
    color: var(--text);
    font-family: 'Segoe UI', Roboto, monospace, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-wrapper {
    width: 100%;
    max-width: 860px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.neon-cyan { color: var(--cyan); text-shadow: 0 0 10px rgba(0, 243, 255, 0.7); }
.neon-magenta { color: var(--magenta); text-shadow: 0 0 10px rgba(255, 0, 127, 0.7); }
.neon-gold { color: var(--gold); text-shadow: 0 0 10px rgba(255, 215, 0, 0.6); }
.neon-red { color: var(--red); text-shadow: 0 0 10px rgba(255, 51, 85, 0.7); }

/* HUD Header */
.hud-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    border: 1px solid rgba(0, 243, 255, 0.35);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.15);
    border-radius: 8px;
    padding: 8px 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.hud-brand { display: flex; flex-direction: column; font-weight: 800; letter-spacing: 1px; }
.hud-brand small { font-size: 10px; color: #7e94c2; }

.hud-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-pill {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 13px;
}

.hud-actions { display: flex; gap: 6px; }

/* Stage & Canvas */
.stage-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 75vh;
    border: 2px solid var(--cyan);
    border-radius: 10px;
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.25);
    overflow: hidden;
    background: #03050a;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.canvas-overlay-top {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    gap: 10px;
}

.hp-box, .boss-box { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: bold; }
.bar-track {
    width: 130px;
    height: 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.boss-track { width: 180px; border-color: var(--red); }
.bar-fill { height: 100%; width: 100%; transition: width 0.15s; }
.hp-color { background: linear-gradient(90deg, #00ff88, #00f3ff); }
.boss-color { background: linear-gradient(90deg, #ff007f, #ff3355); }

.powerup-badges { display: flex; gap: 6px; }
.badge-item {
    background: rgba(0, 243, 255, 0.2);
    border: 1px solid var(--cyan);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

/* Modals */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 6, 15, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 20;
}

.neon-card {
    background: var(--panel-bg);
    border: 1px solid var(--cyan);
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.25);
    border-radius: 12px;
    padding: 22px;
    width: 100%;
    max-width: 440px;
    text-align: center;
    max-height: 92%;
    overflow-y: auto;
}

.wide-card { max-width: 680px; }
.subtitle { font-size: 13px; color: #9ab0dc; margin: 6px 0 16px; }

.form-group { text-align: left; margin-bottom: 14px; }
.form-group label { display: block; font-size: 11px; color: var(--cyan); margin-bottom: 5px; letter-spacing: 1px; }
.form-group input, select {
    width: 100%;
    padding: 10px 12px;
    background: #060b19;
    border: 1px solid var(--cyan);
    color: #fff;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
}
select { width: auto; padding: 5px 10px; font-size: 13px; }

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(90deg, #00c6ff, #0072ff);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 198, 255, 0.5);
    transition: transform 0.1s;
}
.btn-primary:hover { transform: scale(1.02); }

.btn-outline, .btn-icon {
    background: transparent;
    border: 1px solid var(--cyan);
    color: var(--cyan);
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
}
.btn-outline:hover { background: rgba(0, 243, 255, 0.15); }

.controls-hint {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #88a0cc;
}

/* Hangar Upgrades */
.hangar-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.4);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.upg-item {
    background: rgba(6, 12, 28, 0.9);
    border: 1px solid rgba(0, 243, 255, 0.3);
    border-radius: 8px;
    padding: 12px;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
}
.upg-item h4 { font-size: 14px; color: var(--cyan); }
.upg-item p { font-size: 12px; color: #9bb1db; }
.upg-btn {
    padding: 7px;
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}
.upg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Result & Tables */
.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0;
}
.result-stats div {
    background: rgba(0,0,0,0.4);
    padding: 10px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.result-stats span { font-size: 11px; color: #8ea5d1; }
.result-stats strong { font-size: 18px; }

.rank-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    text-align: left;
    margin-bottom: 16px;
}
.rank-columns h4 { font-size: 12px; color: var(--cyan); margin-bottom: 6px; }
.neon-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.neon-table th, .neon-table td {
    padding: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.neon-table th { color: #7e94c2; text-align: left; }

/* Touch Controls */
.touch-controls {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
}
.touch-pad { display: flex; gap: 8px; }
.t-btn {
    width: 52px;
    height: 52px;
    background: rgba(0, 243, 255, 0.15);
    border: 1px solid var(--cyan);
    color: #fff;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
}
.fire-btn {
    width: auto;
    padding: 0 18px;
    border-color: var(--magenta);
    background: rgba(255, 0, 127, 0.2);
}

.error-text { color: var(--red); font-size: 12px; margin-top: 8px; }

@media (max-width: 680px) {
    .upgrade-grid, .rank-columns { grid-template-columns: 1fr; }
    .touch-controls { display: flex; }
}