shader_type canvas_item;

// The color you want to replace (e.g., your #325512 background)
uniform vec4 key_color : source_color = vec4(0.196, 0.333, 0.071, 1.0);
// How close the color needs to be to match (0.01 to 0.1 is usually best)
uniform float sensitivity : hint_range(0.0, 1.0) = 0.05;
// Read the screen behind this shader
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;

void fragment() {
    // 1. Get the original color of the screen at this position
    vec4 screen_color = texture(screen_texture, SCREEN_UV);
    
    // 2. Calculate the difference between the screen pixel and our target color
    // We use the distance formula in 3D space: 
    // d = sqrt((r1-r2)^2 + (g1-g2)^2 + (b1-b2)^2)
    float diff = distance(screen_color.rgb, key_color.rgb);

    if (diff <= sensitivity) {
        // --- START YOUR EFFECT HERE ---
        // Example: Making it pulse red
        vec3 effect = screen_color.rgb + vec3(sin(TIME) * 0.5, 0.0, 0.0);
        
        COLOR = vec4(effect, screen_color.a);
        // --- END YOUR EFFECT HERE ---
    } else {
        // If it's NOT the target color, draw the screen exactly as it is
        COLOR = screen_color;
    }
}