
:root {
    --font-display: 'Orbitron', sans-serif;
    --font-main: 'Inter', system-ui, sans-serif;
    --color-red: #ff3b30;
    --color-red-glow: #ff6b6b;
    --color-blue: #00d4ff;
    --color-blue-glow: #64d8ff;
    --color-accent: #00ff88;
    --glass-bg: rgba(10, 15, 25, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shine: rgba(255, 255, 255, 0.05);
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: var(--font-main);
    touch-action: none;
}

/* ==================== PRELOADER ==================== */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a12 0%, #1a1a2e 50%, #0f0f1a 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.8s ease, visibility 0.8s;
}

#preloader.loaded {
    opacity: 0;
    visibility: hidden;
}

.preloader-logo {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 8px;
    background: linear-gradient(90deg, var(--color-red), var(--color-blue), var(--color-accent), var(--color-blue), var(--color-red));
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite, logoFloat 2s ease-in-out infinite;
    text-shadow: 0 0 60px rgba(255,107,107,0.5);
    margin-bottom: 60px;
}

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

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

.preloader-ring {
    width: 120px;
    height: 120px;
    position: relative;
}

.preloader-ring::before,
.preloader-ring::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.preloader-ring::before {
    inset: 0;
    border: 3px solid transparent;
    border-top-color: var(--color-red);
    border-right-color: var(--color-red);
    animation: spinRing 1.5s linear infinite;
}

.preloader-ring::after {
    inset: 15px;
    border: 3px solid transparent;
    border-bottom-color: var(--color-blue);
    border-left-color: var(--color-blue);
    animation: spinRing 1s linear infinite reverse;
}

@keyframes spinRing {
    to { transform: rotate(360deg); }
}

.preloader-disk {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--color-red-glow), var(--color-blue-glow));
    border-radius: 50%;
    animation: pulseDisk 1s ease-in-out infinite;
    box-shadow: 0 0 30px var(--color-accent);
}

@keyframes pulseDisk {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.7; }
}

.preloader-text {
    font-family: var(--font-display);
    font-size: 0.9rem;
    letter-spacing: 4px;
    color: rgba(255,255,255,0.6);
    margin-top: 40px;
    animation: textPulse 1.5s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Preloader particles */
.preloader-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

/* ==================== GAME CONTAINER ==================== */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: linear-gradient(180deg, #0a0a12 0%, #141428 100%);
    box-shadow: 0 0 80px rgba(0, 212, 255, 0.15), 0 0 120px rgba(255, 59, 48, 0.1);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ==================== AMBIENT BACKGROUND PARTICLES ==================== */
.ambient-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.3;
}

/* ==================== GLASSMORPHISM OVERLAYS ==================== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: opacity 0.5s ease, visibility 0.5s;
}

.overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(255, 59, 48, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 212, 255, 0.15) 0%, transparent 50%);
    pointer-events: none;
}

.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.panel {
    position: relative;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 32px;
    padding: 50px 40px;
    text-align: center;
    box-shadow:
        0 30px 60px rgba(0,0,0,0.5),
        0 0 1px rgba(255,255,255,0.1) inset,
        0 0 80px rgba(0, 212, 255, 0.1);
    width: 90%;
    max-width: 420px;
    transform: translateY(0) scale(1);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s;
    overflow: hidden;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    animation: panelShine 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes panelShine {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

.hidden .panel {
    transform: translateY(40px) scale(0.95);
    opacity: 0;
}

.menu-badge {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--color-accent);
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 20px;
    text-transform: uppercase;
}

h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    margin-bottom: 8px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 6px;
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 50%, #fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    position: relative;
}

h1.game-over-title {
    background: linear-gradient(135deg, var(--color-red) 0%, #ff8a80 50%, var(--color-red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: glitchText 3s ease infinite;
}

@keyframes glitchText {
    0%, 90%, 100% { transform: translate(0); filter: none; }
    92% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
    94% { transform: translate(2px, -1px); filter: hue-rotate(-90deg); }
    96% { transform: translate(-1px, 2px); }
}

.subtitle {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 35px;
    line-height: 1.7;
    font-weight: 400;
}

.score-display {
    margin-bottom: 30px;
}

.score-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.score-value {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fff, var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 40px rgba(0, 255, 136, 0.3);
}

.high-score-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.high-score-row span {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.4);
}

.high-score-row .value {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--color-accent);
}

/* ==================== BUTTONS ==================== */
.btn {
    position: relative;
    display: block;
    width: 100%;
    padding: 18px 32px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 15px;
}

.btn-play {
    background: linear-gradient(135deg, var(--color-red) 0%, #ff6b6b 50%, var(--color-blue) 100%);
    background-size: 200% 200%;
    color: white;
    
    box-shadow: 0 10px 30px rgba(255, 59, 48, 0.3), 0 5px 0 #ff6b6b;

    animation: gradientShift 4s ease infinite;
}

.btn-play::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;
}

.btn-play:hover {
    transform: translateY(-3px);
    box-shadow:
        0 20px 45px rgba(255, 59, 48, 0.4),
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

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

.btn-play:active {
    transform: translate(0, 0) scale(0.98);
}

.btn-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    opacity: 0.8;
}

/* ==================== INSTRUCTIONS ==================== */
.instructions {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 25px 0 35px;
}

.instruction-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.instruction-icon {
    width: 50px;
    height: 50px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    transition: transform 0.3s;
    
}

.instruction-item:hover .instruction-icon {
    transform: scale(1.1) rotate(-5deg);
}

.instruction-icon.red {
    background: linear-gradient(135deg, var(--color-red), #ff6b6b);
    box-shadow: 0 8px 20px rgba(255, 59, 48, 0.3);
}

.instruction-icon.blue {
    background: linear-gradient(135deg, var(--color-blue), #64d8ff);
    box-shadow: 0 8px 20px rgba(0, 212, 255, 0.3);
}

.instruction-text {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==================== DANGER OVERLAY ==================== */
#danger-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 150px rgba(255, 0, 0, 0);
    pointer-events: none;
    z-index: 5;
    transition: box-shadow 0.2s;
}

/* ==================== TOP HUD BAR (modern 3D) ==================== */
#top-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 18px 20px 0;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 8;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s;
}

#top-hud.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.hud-back-btn {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #6fb3e8 0%, #3d84c9 55%, #2a6bab 100%);
    box-shadow:
        0 6px 0 #1f5286,
        0 8px 16px rgba(0,0,0,0.35),
        inset 0 2px 2px rgba(255,255,255,0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hud-back-btn:active {
    transform: translateY(4px);
    box-shadow:
        0 2px 0 #1f5286,
        0 4px 10px rgba(0,0,0,0.3),
        inset 0 2px 2px rgba(255,255,255,0.4);
}

.hud-back-btn svg {
    width: 20px;
    height: 20px;
    stroke: #fff;
    stroke-width: 3;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25));
}

.hud-energy {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    /* max-width: 300px; */
}

.hud-bolt {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-bolt svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.35));
}

.hud-bar-track {
    flex: 1 1 auto;
    height: 18px;
    border-radius: 10px;
    background: linear-gradient(180deg, #eef2f4 0%, #d7dde1 100%);
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.25),
        0 2px 0 rgba(255,255,255,0.4);
    overflow: hidden;
    position: relative;
}

.hud-bar-fill {
    height: 100%;
    border-radius: 10px 4px 4px 10px;
    background: linear-gradient(180deg, #ffe17a 0%, #ffb300 60%, #ff9500 100%);
    box-shadow: inset 0 2px 3px rgba(255,255,255,0.6), inset 0 -3px 4px rgba(180,90,0,0.3);
    transition: width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
    width: 100%;
}

.hud-bar-fill.low {
    background: linear-gradient(180deg, #ff9a8a 0%, #ff5f4d 60%, #e8422f 100%);
}

.hud-score-badge {
    flex: 0 0 auto;
    min-width: 40px;
    padding: 4px 12px;
    border-radius: 14px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(160deg, #3a4250 0%, #20242e 100%);
    box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 1px 1px rgba(255,255,255,0.15);
    text-shadow: 0 2px 2px rgba(0,0,0,0.4);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    h1 { font-size: 2.2rem; letter-spacing: 4px; }
    .panel { padding: 40px 30px; }
    .score-value { font-size: 3.5rem; }
    .preloader-logo { font-size: 2.5rem; letter-spacing: 5px; }
    .hud-energy { max-width: none; }
}
