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

body {
    background: #000;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Экран загрузки */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0a0a 50%, #0a0a0a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease-out;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-container {
    text-align: center;
    padding: 40px;
}

.loader-logo {
    font-size: 48px;
    font-weight: bold;
    color: #ff6600;
    text-shadow: 0 0 20px #ff6600, 0 0 40px #ff6600;
    margin-bottom: 30px;
    animation: glow 2s ease-in-out infinite;
}

.loader-bar-container {
    width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff6600, #ffaa00, #ff6600);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 10px #ff6600;
}

.loader-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 2px;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 20px #ff6600, 0 0 40px #ff6600; }
    50% { text-shadow: 0 0 30px #ff6600, 0 0 60px #ff6600, 0 0 80px #ff6600; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.link-wrapper {
    display: block; /* или inline-block */
    text-decoration: none;
    color: inherit;
}

/* Класс для сетки (grid pattern) с анимацией пульсации */
.bg-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 255, 0.03) 2px,
            rgba(0, 255, 255, 0.03) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 255, 0.03) 2px,
            rgba(0, 255, 255, 0.03) 4px
        );
    background-size: 40px 40px, 40px 40px;
    pointer-events: none;
    z-index: 1;
    animation: gridPulse 4s ease-in-out infinite;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* анимированный фон */
#game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(76, 29, 146, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(14, 165, 233, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 50%);
    background-size: 100% 100%, 100% 100%, 100% 100%;
    pointer-events: none;
    z-index: 1;
    animation: bgPulse 4s ease-in-out infinite;
}

@keyframes bgPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* Анимированный фон для экрана прокачки */
#upgrade-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(76, 29, 146, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(14, 165, 233, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.12) 0%, transparent 50%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 255, 0.04) 2px,
            rgba(0, 255, 255, 0.04) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 255, 0.04) 2px,
            rgba(0, 255, 255, 0.04) 4px
        );
    background-size: 100% 100%, 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    pointer-events: none;
    z-index: 0;
    animation: upgradeBgPulse 4s ease-in-out infinite;
}

@keyframes upgradeBgPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.9; }
}

/* Плавающие частицы на фоне */
#game-container::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(0, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 50px 160px, rgba(255, 0, 255, 0.5), transparent),
        radial-gradient(2px 2px at 90px 40px, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(0, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255, 0, 255, 0.5), transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: floatParticles 20s linear infinite;
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

@keyframes floatParticles {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-50px) rotate(2deg); }
}

/* Экраны */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(10, 10, 46, 0.95) 0%, rgba(26, 26, 78, 0.9) 50%, rgba(10, 10, 46, 0.95) 100%);
    backdrop-filter: blur(10px);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

/* Анимация появления экрана */
.screen.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Анимация исчезновения экрана */
.screen.fade-out {
    animation: fadeOut 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Кинематическое масштабирование при появлении */
.screen.zoom-in {
    animation: zoomIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes zoomOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(1.1);
        opacity: 0;
    }
}

/* Анимация появления HUD */
#hud {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#hud.active {
    opacity: 1;
}

/* HUD на экране прокачки */
#upgrade-hud {
    opacity: 1;
}

/* Анимация появления canvas */
#game-canvas {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

#game-canvas.active {
    opacity: 1;
}

/* Экран паузы - без фона */
#pause-screen {
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-in-out;
}

#pause-screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* Заставка */
.title {
    font-size: 5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #00ffff 0%, #00aaff 50%, #00ffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
    animation: titleGlow 3s ease-in-out infinite alternate, titleFloat 4s ease-in-out infinite;
    margin-bottom: 5px;
    letter-spacing: 8px;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

@keyframes titleGlow {
    from {
        filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.5)) drop-shadow(0 0 40px rgba(0, 255, 255, 0.3));
    }
    to {
        filter: drop-shadow(0 0 30px rgba(0, 255, 255, 0.8)) drop-shadow(0 0 60px rgba(0, 255, 255, 0.5)) drop-shadow(0 0 80px rgba(0, 255, 255, 0.3));
    }
}

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

.subtitle {
    font-size: 1.3rem;
    color: #ff6b6b;
    margin-bottom: 15px;
    letter-spacing: 3px;
    text-transform: uppercase;
    animation: subtitlePulse 2s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

@keyframes subtitlePulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.logo {
    font-size: 2.2rem;
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 50px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    animation: logoGlow 2s ease-in-out infinite;
    position: relative;
}

.logo::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ffd700, transparent);
    animation: lineExpand 2s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5)); }
    50% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8)); }
}

@keyframes lineExpand {
    0%, 100% { width: 50px; opacity: 0.5; }
    50% { width: 150px; opacity: 1; }
}

.btn {
    padding: 18px 50px;
    font-size: 1.4rem;
    background: linear-gradient(45deg, #ff6b6b 0%, #ff8e53 50%, #ff6b6b 100%);
    background-size: 200% 200%;
    border: 2px solid rgba(255, 107, 107, 0.5);
    border-radius: 50px;
    color: white;
    cursor: pointer;
    margin: 12px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 2px;
    box-shadow: 
        0 5px 20px rgba(255, 107, 107, 0.4),
        0 0 40px rgba(255, 107, 107, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    animation: btnGradient 3s ease infinite;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 10px 40px rgba(255, 107, 107, 0.6),
        0 0 60px rgba(255, 107, 107, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 107, 107, 0.8);
}

.btn:active {
    transform: translateY(-1px) scale(1.02);
}

@keyframes btnGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.btn-test {
    background: linear-gradient(45deg, #00cc66 0%, #00ff88 50%, #00cc66 100%);
    background-size: 200% 200%;
    border-color: rgba(0, 255, 136, 0.5);
    box-shadow: 
        0 5px 20px rgba(0, 255, 136, 0.4),
        0 0 40px rgba(0, 255, 136, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    animation: btnGradient 3s ease infinite;
}

.btn-test:hover {
    box-shadow: 
        0 10px 40px rgba(0, 255, 136, 0.6),
        0 0 60px rgba(0, 255, 136, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 255, 136, 0.8);
}

.controls-info {
    margin-top: 50px;
    text-align: center;
    color: #aaa;
    font-size: 1rem;
    line-height: 2;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px 40px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    animation: controlsFadeIn 1s ease-out 0.3s both;
}

@keyframes controlsFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.controls-info p {
    margin: 8px 0;
}

.controls-info span {
    color: #00ffff;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

/* Экраны gameover и victory */
.gameover-title {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ff4444 0%, #ff6b6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(255, 68, 68, 0.5);
    animation: gameoverPulse 2s ease-in-out infinite;
    margin-bottom: 30px;
    letter-spacing: 5px;
}

@keyframes gameoverPulse {
    0%, 100% { 
        filter: drop-shadow(0 0 20px rgba(255, 68, 68, 0.5));
        transform: scale(1);
    }
    50% { 
        filter: drop-shadow(0 0 40px rgba(255, 68, 68, 0.8));
        transform: scale(1.02);
    }
}

.victory-title {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(0, 255, 136, 0.5);
    animation: victoryCelebrate 1.5s ease-in-out infinite;
    margin-bottom: 20px;
    letter-spacing: 5px;
}

@keyframes victoryCelebrate {
    0%, 100% { 
        filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.5));
        transform: scale(1) rotate(-2deg);
    }
    50% { 
        filter: drop-shadow(0 0 40px rgba(0, 255, 136, 0.8));
        transform: scale(1.05) rotate(2deg);
    }
}

.score-display {
    font-size: 2rem;
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 20px 0;
    font-weight: 700;
    animation: scoreGlow 2s ease-in-out infinite;
}

@keyframes scoreGlow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5)); }
    50% { filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8)); }
}

/* Холст */
#game-canvas {
    display: none;
    background: #000011;
    position: absolute;
    top: 0;
    left: 0;
}

#game-canvas.active {
    display: block;
}

/* HUD */
#hud {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 40px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    z-index: 5;
    justify-content: space-between;
    align-items: flex-start;
}

#hud.active {
    display: flex;
}

/* HUD на экране прокачки - скрыт по умолчанию */
#upgrade-hud {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 40px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    z-index: 30;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

#upgrade-hud > * {
    pointer-events: auto;
}

#upgrade-screen.active #upgrade-hud {
    display: flex;
}

#upgrade-health-bar-container {
    display: inline-block;
    width: 250px;
    height: 25px;
    background: #333;
    border: 2px solid #555;
    border-radius: 10px;
    overflow: hidden;
    vertical-align: middle;
    margin-left: 10px;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.2);
    position: relative;
}

#upgrade-health-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff3333 0%, #ff6b6b 50%, #ff3333 100%);
    background-size: 200% 100%;
    animation: healthPulse 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#upgrade-energy-bar-container {
    display: inline-block;
    width: 250px;
    height: 28px;
    background: rgba(30, 30, 50, 0.8);
    border: 2px solid rgba(0, 150, 255, 0.5);
    border-radius: 14px;
    overflow: hidden;
    vertical-align: middle;
    margin-left: 10px;
}

#upgrade-energy-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #0066ff 0%, #00aaff 50%, #0066ff 100%);
    background-size: 200% 100%;
    animation: energyPulse 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700;
}

.level-info {
    font-size: 0.95rem;
    background: linear-gradient(135deg, #00ffff 0%, #00aaff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 5px;
    letter-spacing: 2px;
    font-weight: 600;
}

.hud-item {
    color: #fff;
    font-size: 1.3rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
}

#debug-counter {
    color: #00ff88;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

#health-bar-container {
    display: inline-block;
    width: 250px;
    height: 25px;
    background: #333;
    border: 2px solid #555;
    border-radius: 10px;
    overflow: hidden;
    vertical-align: middle;
    margin-left: 10px;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.2);
    position: relative;
}

#health-bar-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: healthShine 2s ease-in-out infinite;
}

@keyframes healthShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#health-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff3333 0%, #ff6b6b 50%, #ff3333 100%);
    background-size: 200% 100%;
    animation: healthPulse 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes healthPulse {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

#energy-bar-container {
    display: inline-block;
    width: 250px;
    height: 28px;
    background: rgba(30, 30, 50, 0.8);
    border: 2px solid rgba(0, 150, 255, 0.5);
    border-radius: 14px;
    overflow: hidden;
    vertical-align: middle;
    margin-left: 10px;
}

#energy-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #0066ff 0%, #00aaff 50%, #0066ff 100%);
    background-size: 200% 100%;
    animation: energyPulse 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes energyPulse {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

#weapon-type {
    background: linear-gradient(135deg, #00ffff 0%, #00aaff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

#missile-ammo {
    background: linear-gradient(135deg, #ff6600 0%, #ff8800 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    text-shadow: 0 0 15px rgba(255, 102, 0, 0.5);
}

#level {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/* Адаптивность */
@media (max-width: 768px) {
    .title {
        font-size: 3rem;
        letter-spacing: 4px;
    }

    .subtitle {
        font-size: 1rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    .btn {
        padding: 14px 35px;
        font-size: 1.1rem;
    }

    .controls-info {
        font-size: 0.85rem;
        padding: 15px 25px;
    }

    #hud {
        flex-wrap: wrap;
        padding: 10px 20px;
    }

    .hud-item {
        font-size: 0.85rem;
        margin: 3px;
        padding: 6px 10px;
    }

    .hud-center {
        font-size: 2rem;
    }

    #health-bar-container, #energy-bar-container {
        width: 180px;
        height: 22px;
    }
}
