:root {
    --bg-dark: #0a0c10;
    --neon-blue: #00f2ff;
    --neon-pink: #ff00ea;
    --neon-cyan: #00f2ff;
    --glass-bg: rgba(13, 17, 23, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Outfit', sans-serif;
    color: #ffffff;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #141923 0%, #080a0f 100%);
}

/* HUD Overlay */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
}

.score-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    min-width: 120px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #8f9cae;
    margin-bottom: 4px;
}

#score, #level {
    font-size: 24px;
    font-weight: 800;
    font-family: monospace;
    color: var(--neon-blue);
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}

.battery-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.health-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 4px;
}

#health-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--neon-blue) 0%, #00ff88 100%);
    border-radius: 5px;
    box-shadow: 0 0 10px var(--neon-blue);
    transition: width 0.1s ease-out, background 0.3s ease;
}

/* Repel Indicator */
.hud-bottom {
    display: flex;
    justify-content: center;
    width: 100%;
}

.ability-indicator {
    position: relative;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.indicator-ring {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid var(--neon-pink);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--neon-pink);
    clip-path: polygon(50% 50%, -50% -50%, 150% -50%); /* Will clip dynamically in code */
}

.key-hint {
    font-size: 9px;
    font-weight: 800;
    color: #8f9cae;
}

.ability-name {
    font-size: 12px;
    font-weight: 800;
    color: #ffffff;
    margin-top: 2px;
    letter-spacing: 1px;
}

/* Overlays & Panels */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 100;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 2rem;
    text-align: center;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

h1 {
    font-size: 3.2rem;
    font-weight: 800;
    letter-spacing: -0.05rem;
    margin-bottom: 1rem;
    background: linear-gradient(to bottom, #ffffff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p {
    color: #8f9cae;
    margin-bottom: 2rem;
    line-height: 1.6;
    font-size: 0.95rem;
}

.controls-guide {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 1rem;
}

.control-item {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.9rem;
}

.control-item span:first-child {
    color: #8f9cae;
}

.control-item span:last-child {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
}

.primary-btn {
    background: white;
    color: black;
    border: none;
    padding: 1rem 2.5rem;
    font-family: inherit;
    font-weight: 800;
    font-size: 1rem;
    border-radius: 100px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: auto;
    display: inline-block;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(255, 255, 255, 0.2);
}

.primary-btn:active {
    transform: translateY(0);
}

.final-stats {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 16px;
    border-radius: 8px;
    width: 100%;
}

.stat span:last-child {
    font-family: monospace;
    font-size: 1.6rem;
    font-weight: 700;
}

.stat #final-score {
    color: #00f2ff;
    text-shadow: 0 0 8px rgba(0, 242, 255, 0.5);
}

.stat #high-score {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

/* ── Mute Button ── */
#mute-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    font-size: 1.4rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    line-height: 1;
}

#mute-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 242, 255, 0.25);
}

#mute-btn:active {
    transform: scale(0.95);
}

#mute-btn.muted {
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.4);
}

/* ── Flux Level Progression Bar (Full Width Top) ── */
#level-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 10px; /* Thicker, premium presence */
    background: rgba(10, 15, 25, 0.95);
    border-bottom: 1px solid rgba(0, 242, 255, 0.25);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 150;
    pointer-events: none;
    overflow: hidden;
}

/* Sci-fi calibration ticks overlay */
#level-bar-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(90deg, 
        transparent, 
        transparent 39px, 
        rgba(0, 0, 0, 0.65) 39px, 
        rgba(0, 0, 0, 0.65) 40px
    );
    z-index: 2;
    pointer-events: none;
}

#level-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, 
        var(--neon-cyan) 0%, 
        #00ff88 33%, 
        var(--neon-cyan) 66%, 
        #0088ff 100%
    );
    background-size: 300% 100%;
    animation: progress-shimmer 5s linear infinite;
    box-shadow: 0 0 12px var(--neon-cyan), 0 0 20px rgba(0, 242, 255, 0.4);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

@keyframes progress-shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* ── Level Up Card Overlay Selector ── */
#overlay-levelup .glass-panel {
    max-width: 520px;
    text-align: left;
}

#upgrade-options {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1.5rem;
    width: 100%;
}

.upgrade-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.upgrade-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 16px rgba(0, 210, 255, 0.25);
    transform: translateY(-2px);
}

.upgrade-card:active {
    transform: translateY(0);
}

.upgrade-card .type-badge {
    align-self: flex-start;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 0.15rem;
}

.upgrade-card .type-badge.levelable {
    background: rgba(0, 210, 255, 0.12);
    color: var(--neon-cyan);
    border: 1px solid rgba(0, 210, 255, 0.25);
}

.upgrade-card .type-badge.single {
    background: rgba(0, 255, 136, 0.12);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.25);
}

.upgrade-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.upgrade-card p {
    font-size: 0.82rem;
    color: #8f9cae;
    margin: 0;
    line-height: 1.45;
}


