:root {
    --bg-color: #050505;
    --accent-neon: #00ff41;
    --accent-dash: #00e5ff;
    --enemy-color: #ff0055;
    --hp-color: #ff3333;
    --text-color: #ffffff;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
    user-select: none;
    touch-action: none;
    /* Mobile-first: Ensure full screen usage */
    position: fixed;
    top: 0;
    left: 0;
}

canvas {
    display: block;
    transition: filter 0.1s ease;
}

#glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.1),
            rgba(0, 0, 0, 0.1) 1px,
            transparent 1px,
            transparent 2px);
    pointer-events: none;
    z-index: 500;
    opacity: 0.3;
}

.shake {
    animation: shake-anim 0.2s double;
}

@keyframes shake-anim {
    0% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-5px, 5px);
    }

    40% {
        transform: translate(5px, -5px);
    }

    60% {
        transform: translate(-5px, -5px);
    }

    80% {
        transform: translate(5px, 5px);
    }

    100% {
        transform: translate(0, 0);
    }
}

#ui-layer {
    position: absolute;
    top: 20px;
    padding-top: env(safe-area-inset-top);
    /* iPhone Notch Protection */
    left: 20px;
    padding-left: env(safe-area-inset-left);
    pointer-events: none;
    width: calc(100% - 40px);
    z-index: 100;
}

.stats {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 0 10px var(--accent-neon);
    margin-bottom: 5px;
}

.hp-bar-container {
    width: 200px;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 10px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

#hp-fill {
    width: 100%;
    height: 100%;
    background: var(--hp-color);
    box-shadow: 0 0 10px var(--hp-color);
    transition: width 0.3s ease;
}

.hp-text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 900;
    line-height: 12px;
    color: #fff;
    pointer-events: none;
    text-shadow: 1px 1px 2px #000;
}


/* Attack Speed Indicator (Hidden) */
.stamina-container {
    display: none;
    width: 150px;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    margin-top: 5px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 0, 0.2);
    /* Yellow for attack */
}

#attack-fill {
    width: 100%;
    height: 100%;
    background: #ffff00;
    box-shadow: 0 0 10px #ffff00;
    transition: width 0.05s linear;
}

/* Skill Selection Modal (Mobile Optimized) */
#skill-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
    /* Prevent scrollbars */
}

#skill-modal h2 {
    color: var(--accent-neon);
    font-size: 2rem;
    /* Smaller for mobile */
    margin-bottom: 20px;
    text-shadow: 0 0 20px var(--accent-neon);
    text-align: center;
}

.skill-container {
    display: flex;
    flex-direction: column;
    /* Stack skills vertically on mobile */
    gap: 15px;
    width: 100%;
    max-width: 400px;
    /* Max width for larger screens */
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    max-height: 70vh;
    box-sizing: border-box;
    /* Important for padding */
    padding: 5px;
    /* Inner spacing */
}

.skill-card {
    flex: none;
    /* Don't stretch */
    background: rgba(255, 255, 255, 0.08);
    /* Slightly lighter */
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    /* Compact padding */
    border-radius: 12px;
    text-align: left;
    /* Align text left for list view */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: row;
    /* Horizontal layout for icon + text */
    align-items: center;
    gap: 15px;
    min-height: 80px;
    /* Ensure touch target size */
}

.skill-icon {
    font-size: 2.5rem;
    /* Slightly smaller */
    width: 60px;
    text-align: center;
}

.skill-info {
    /* Wrapper for title/desc */
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.skill-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
}

.skill-desc {
    font-size: 0.85rem;
    color: #ccc;
    line-height: 1.3;
}

/* Settings/Pause Button */
#settings-btn {
    position: absolute;
    top: 80px;
    /* Moved down to avoid overlap with EXP HUD */
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: all;
    z-index: 1000;
    font-size: 1.5rem;
    transition: all 0.2s;
}

#settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(45deg);
}

/* Pause Overlay */
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

/* Blood Flash on Hit */
#blood-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 40%, rgba(255, 0, 0, 0.4) 100%);
    pointer-events: none;
    display: none;
    z-index: 900;
}

.skill-card:hover {
    background: rgba(0, 255, 65, 0.1);
    border-color: var(--accent-neon);
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 255, 65, 0.2);
}

/* Floating Text Engine */
.damage-text {
    position: absolute;
    pointer-events: none;
    font-weight: 900;
    color: #fff;
    font-size: 1.2rem;
    text-shadow: 0 0 5px #000;
    animation: float-up 0.6s ease-out forwards;
    z-index: 1000;
}

@keyframes float-up {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.5);
        opacity: 0;
    }
}

.skill-icon {
    font-size: 3rem;
}

.skill-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
}

.skill-desc {
    font-size: 0.9rem;
    color: #aaa;
    line-height: 1.4;
}

.xp-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
}

#xp-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-dash);
    box-shadow: 0 0 15px var(--accent-dash);
    transition: width 0.3s ease;
}

#xp-text {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 1rem;
    color: var(--accent-dash);
    font-weight: 800;
    text-shadow: 0 0 10px var(--accent-dash);
    pointer-events: none;
}

.hint {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    opacity: 0.6;
    font-size: 0.9rem;
    letter-spacing: 2px;
    pointer-events: none;
}

.level-up-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 900;
    color: var(--accent-neon);
    opacity: 0;
    pointer-events: none;
}

@keyframes flash {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

.active-flash {
    animation: flash 0.8s ease-out forwards;
}

/* Joystick (Mobile Control) */
#joystick-zone {
    position: absolute;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.08);
    /* Faint background */
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    pointer-events: none;
    /* Let touches pass through the zone to js */
    display: none;
    /* Hidden until touched */
    z-index: 2000;
    backdrop-filter: blur(4px);
    transition: opacity 0.2s;
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    background: var(--accent-dash);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px var(--accent-dash);
    transition: transform 0.05s linear;
    /* Smooth knob movement */
}