```python
import bpy
import bmesh
import math
import random

# ==============================================================================
# 0. CLEANUP & INITIAL SETUP
# ==============================================================================
# Safe clean up of default startup elements
for obj_name in ["Cube", "Light", "Camera"]:
    if obj_name in bpy.data.objects:
        bpy.data.objects.remove(bpy.data.objects[obj_name], do_unlink=True)

scene = bpy.context.scene
scene.render.engine = 'CYCLES'
scene.view_settings.view_transform = 'AgX'
scene.view_settings.look = 'High Contrast'

# Target setup for camera tracking
target = bpy.data.objects.new("Target", None)
target.location = (0.0, -0.4, -0.2)
bpy.context.collection.objects.link(target)

# ==============================================================================
# 1. PROCEDURAL GOLDFISH GEOMETRY
# ==============================================================================

# --- A. Plump Body with 3D S-Shape Curve ---
bpy.ops.mesh.primitive_uv_sphere_add(segments=64, ring_count=32, radius=1.0)
body = bpy.context.active_object
body.name = "Goldfish_Body"

# Shape sphere into an elegant goldfish body using mathematical displacement
bm = bmesh.new()
bm.from_mesh(body.data)

for v in bm.verts:
    y = v.co.y  # -1.0 to 1.0
    y_scaled = y * 1.5

    # Elegant goldfish silhouette tapering
    if y > 0.2:
        factor = math.sqrt(max(0.0, 1.0 - ((y - 0.2) / 0.8)**2))
    else:
        t_val = (y - 0.2) / -1.2  # 0 at mid-forward, 1 at tail
        factor = 0.15 + 0.85 * (1.0 - t_val**2.0)

    v.co.x *= factor * 0.76   # Slightly compressed laterally
    v.co.z *= factor * 1.22   # Plump height
    v.co.y = y_scaled

    # Applying the beautiful "mid-swim S-curve"
    dx = 0.32 * math.sin(y_scaled * 2.1 - 0.5)
    dz = 0.12 * math.sin(y_scaled * 1.4)
    v.co.x += dx
    v.co.z += dz

bm.to_mesh(body.data)
bm.free()

# --- B. Massive Flowing Veil-Tail Fin ---
fin_mesh = bpy.data.meshes.new("Tail_Fin")
fin_obj = bpy.data.objects.new("Tail_Fin", fin_mesh)
bpy.context.collection.objects.link(fin_obj)

verts, faces = [], []
rows, cols = 35, 35

for r in range(rows):
    t_y = r / (rows - 1)
    y = -1.35 - t_y * 1.95  # Flows backward from tail base

    # Sync visual flow with body's S-curve at start of tail
    body_dx = 0.32 * math.sin(y * 2.1 - 0.5)

    # Large classic flowing veil-tail shape
    z_span = 0.15 + 1.95 * (t_y**1.1)

    for c in range(cols):
        t_z = (c / (cols - 1)) * 2.0 - 1.0 # Normalized height range
        z = t_z * z_span

        # Elegant ripples and secondary sweep
        fold = 0.22 * math.sin(t_z * 5.5) * (t_y**1.1) * math.cos(y * 3.5)
        x = body_dx + fold
        x += 0.35 * math.sin(y * 2.2)  # Lagging wave sweep

        # Delicate downward droop of a heavy veil-tail
        z_droop = -0.15 * (t_y**1.5)

        verts.append((x, y, z + z_droop))

for r in range(rows - 1):
    for c in range(cols - 1):
        p1 = r * cols + c
        p2 = r * cols + (c + 1)
        p3 = (r + 1) * cols + (c + 1)
        p4 = (r + 1) * cols + c
        faces.append((p1, p2, p3, p4))

fin_mesh.from_pydata(verts, [], faces)
fin_mesh.update()

# --- C. Wavy Dorsal Fin ---
dorsal_mesh = bpy.data.meshes.new("Dorsal_Fin")
dorsal_obj = bpy.data.objects.new("Dorsal_Fin", dorsal_mesh)
bpy.context.collection.objects.link(dorsal_obj)

d_verts, d_faces = [], []
d_rows, d_cols = 20, 15

for r in range(d_rows):
    t_y = r / (d_rows - 1)
    y = 0.15 - t_y * 1.15
    body_dx = 0.32 * math.sin(y * 2.1 - 0.5)

    # Stand-out sail-like height
    z_start = 0.35
    height = 1.25 * (math.sin(t_y * math.pi)**0.65)

    for c in range(d_cols):
        t_z = c / (d_cols - 1)
        z = z_start + t_z * height

        # Subtle horizontal folds
        fold = 0.06 * math.sin(t_z * 4.5) * math.cos(y * 4.0) * (t_y**0.5)
        x = body_dx + fold

        # Backward sweep
        y_sweep = -0.22 * (t_z**1.3)

        d_verts.append((x, y + y_sweep, z))

for r in range(d_rows - 1):
    for c in range(d_cols - 1):
        p1 = r * d_cols + c
        p2 = r * d_cols + (c + 1)
        p3 = (r + 1) * d_cols + (c + 1)
        p4 = (r + 1) * d_cols + c
        d_faces.append((p1, p2, p3, p4))

dorsal_mesh.from_pydata(d_verts, [], d_faces)
dorsal_mesh.update()

# --- D. Left and Right Pectoral/Side Fins ---
def create_side_fin(name, side_sign):
    m = bpy.data.meshes.new(name)
    obj = bpy.data.objects.new(name, m)
    bpy.context.collection.objects.link(obj)

    s_verts, s_faces = [], []
    s_rows, s_cols = 15, 12

    # Anchored beautifully at base of gills (y ≈ 0.45, z ≈ -0.2)
    base_y = 0.45
    body_dx = 0.32 * math.sin(base_y * 2.1 - 0.5)
    base_x = (0.32 + body_dx) * side_sign
    base_z = -0.2

    for r in range(s_rows):
        t_r = r / (s_rows - 1)
        dist = t_r * 0.95

        for c in range(s_cols):
            t_c = (c / (s_cols - 1)) * 2.0 - 1.0

            x = base_x + dist * 0.95 * side_sign
            y = base_y - dist * 0.85 + t_c * 0.22 * (t_r**0.5)
            z = base_z - dist * 0.28 + t_c * 0.12 * (t_r**0.8)

            # Wavy folds on side fins
            fold = 0.045 * math.sin(t_c * 3.5) * (t_r**1.1)
            z += fold

            s_verts.append((x, y, z))

    for r in range(s_rows - 1):
        for c in range(s_cols - 1):
            p1 = r * s_cols + c
            p2 = r * s_cols + (c + 1)
            p3 = (r + 1) * s_cols + (c + 1)
            p4 = (r + 1) * s_cols + c
            s_faces.append((p1, p2, p3, p4))

    m.from_pydata(s_verts, [], s_faces)
    m.update()
    return obj

left_fin = create_side_fin("Pectoral_Fin_L", 1)
right_fin = create_side_fin("Pectoral_Fin_R", -1)

# --- E. Classic Bulgy Goldfish Eyes ---
def create_eye(name, x, y, z, rot_y):
    bpy.ops.mesh.primitive_uv_sphere_add(segments=32, ring_count=16, radius=0.21)
    eye = bpy.context.active_object
    eye.name = name
    eye.location = (x, y, z)
    eye.rotation_euler = (0, rot_y, 0)
    return eye

# Positioned symmetrically at the sides of the head area
eye_l = create_eye("Eye_L", 0.42, 0.78, 0.14, math.radians(45))
eye_r = create_eye("Eye_R", -0.42, 0.78, 0.14, math.radians(-45))

# --- F. Modifier Stack & Smooth Shading ---
# Clean solidify and subdivisions across organic elements
fishes = [body, fin_obj, dorsal_obj, left_fin, right_fin, eye_l, eye_r]
for obj_item in fishes:
    for poly in obj_item.data.polygons:
        poly.use_smooth = True

    # Solidify fins for realistic glass transmission/depth
    if obj_item in [fin_obj, dorsal_obj, left_fin, right_fin]:
        sol = obj_item.modifiers.new(name="Solidify", type='SOLIDIFY')
        sol.thickness = 0.016
        sol.offset = 0.0

    sub = obj_item.modifiers.new(name="Subdivision", type='SUBSURF')
    sub.levels = 2
    sub.render_levels = 3

# ==============================================================================
# 2. KIDS' RECOGNIZABLE STAR FLOOR
# ==============================================================================
star_mesh = bpy.data.meshes.new("Star_Floor")
star_obj = bpy.data.objects.new("Star_Floor", star_mesh)
bpy.context.collection.objects.link(star_obj)

star_verts, star_faces = [], []
num_points = 5
outer_radius = 6.5
inner_radius = 2.6
z_bot, z_top = -4.5, -4.0

# Bottom & Top center anchors
star_verts.append((0.0, 0.0, z_bot))
star_verts.append((0.0, 0.0, z_top))

# Generate Star outline rings
for idx in range(num_points * 2):
    angle = idx * math.pi / num_points
    r = outer_radius if (idx % 2 == 0) else inner_radius
    x = r * math.sin(angle)
    y = r * math.cos(angle)
    star_verts.append((x, y, z_bot)) # Bottom ring
    star_verts.append((x, y, z_top)) # Top ring

for idx in range(num_points * 2):
    next_idx = (idx + 1) % (num_points * 2)
    p1 = 3 + idx * 2
    p2 = 3 + next_idx * 2
    star_faces.append((1, p1, p2)) # Top triangles with center

for idx in range(num_points * 2):
    next_idx = (idx + 1) % (num_points * 2)
    p1 = 2 + idx * 2
    p2 = 2 + next_idx * 2
    star_faces.append((0, p2, p1)) # Bottom triangles with center (reversed winding)

for idx in range(num_points * 2):
    next_idx = (idx + 1) % (num_points * 2)
    b1, t1 = 2 + idx * 2, 3 + idx * 2
    b2, t2 = 2 + next_idx * 2, 3 + next_idx * 2
    star_faces.append((b1, b2, t2, t1)) # Extruded side walls

star_mesh.from_pydata(star_verts, [], star_faces)
star_mesh.update()

for poly in star_mesh.polygons:
    poly.use_smooth = True

star_bevel = star_obj.modifiers.new(name="Bevel", type='BEVEL')
star_bevel.width = 0.16
star_bevel.segments = 3

star_smooth = star_obj.modifiers.new(name="SmoothByAngle", type='SMOOTH_BY_ANGLE')

# ==============================================================================
# 3. CURVED WATERY CYCLORAMA L-BACKDROP
# ==============================================================================
back_mesh = bpy.data.meshes.new("Backdrop")
back_obj = bpy.data.objects.new("Backdrop", back_mesh)
bpy.context.collection.objects.link(back_obj)

b_verts, b_faces = [], []
steps_w, steps_h = 24, 30
width = 28.0
y_start, y_end = 5.0, -11.0
floor_z, top_z = -4.8, 17.0

for i in range(steps_w):
    x = -width/2 + (i / (steps_w - 1)) * width
    for j in range(steps_h):
        t = j / (steps_h - 1)
        # Smooth bezier sweep from ground forward to high back wall
        y = y_start + (y_end - y_start) * (t**1.75)
        z = floor_z + (top_z - floor_z) * (t**2.15)
        b_verts.append((x, y, z))

for i in range(steps_w - 1):
    for j in range(steps_h - 1):
        p1 = i * steps_h + j
        p2 = (i + 1) * steps_h + j
        p3 = (i + 1) * steps_h + (j + 1)
        p4 = i * steps_h + (j + 1)
        b_faces.append((p1, p2, p3, p4))

back_mesh.from_pydata(b_verts, [], b_faces)
back_mesh.update()

for poly in back_mesh.polygons:
    poly.use_smooth = True

back_sub = back_obj.modifiers.new(name="Subdivision", type='SUBSURF')
back_sub.levels = 1

# ==============================================================================
# 4. MATTERS & SHADERS (PROSTHETIC SCALES, LIGHT TRANSMISSION)
# ==============================================================================

# --- A. Shiny Scaled Goldfish Body Material ---
body_mat = bpy.data.materials.new(name="Goldfish_Body_Mat")
body_mat.use_nodes = True
nodes = body_mat.node_tree.nodes
links = body_mat.node_tree.links
nodes.clear()

node_output = nodes.new(type='ShaderNodeOutputMaterial')
node_bsdf = nodes.new(type='ShaderNodeBsdfPrincipled')
links.new(node_bsdf.outputs['BSDF'], node_output.inputs['Surface'])

# Base settings for glossy warm goldfish skin
node_bsdf.inputs['Roughness'].default_value = 0.1
node_bsdf.inputs['Subsurface Weight'].default_value = 0.35
node_bsdf.inputs['Subsurface Radius'].default_value = (0.5, 0.18, 0.08)
node_bsdf.inputs['Subsurface Color'].default_value = (1.0, 0.12, 0.0, 1.0)
if 'Coat Weight' in node_bsdf.inputs:
    node_bsdf.inputs['Coat Weight'].default_value = 0.85
    node_bsdf.inputs['Coat Roughness'].default_value = 0.03

# Procedural Scale Bump Map
node_tex_coord = nodes.new(type='ShaderNodeTexCoord')
node_mapping = nodes.new(type='ShaderNodeMapping')
node_mapping.inputs['Scale'].default_value = (8.5, 16.0, 8.5)
links.new(node_tex_coord.outputs['Generated'], node_mapping.inputs['Vector'])

node_voronoi = nodes.new(type='ShaderNodeTexVoronoi')
node_voronoi.distance = 'EUCLIDEAN'
node_voronoi.inputs['Scale'].default_value = 2.45
links.new(node_mapping.outputs['Vector'], node_voronoi.inputs['Vector'])

node_bump = nodes.new(type='ShaderNodeBump')
node_bump.inputs['Strength'].default_value = 0.12
node_bump.inputs['Distance'].default_value = 0.04
links.new(node_voronoi.outputs['Distance'], node_bump.inputs['Height'])
links.new(node_bump.outputs['Normal'], node_bsdf.inputs['Normal'])

# Goldfish orange coloring gradient with scales pattern
node_mix_color = nodes.new(type='ShaderNodeMix')
node_mix_color.data_type = 'RGBA'
node_mix_color.blend_type = 'MIX'
node_mix_color.inputs['Factor'].default_value = 0.4
links.new(node_voronoi.outputs['Distance'], node_mix_color.inputs['Factor'])
node_mix_color.inputs['A'].default_value = (1.0, 0.15, 0.0, 1.0)  # Classic orange
node_mix_color.inputs['B'].default_value = (1.0, 0.48, 0.04, 1.0) # Sparkling golden highlight
links.new(node_mix_color.outputs['Result'], node_bsdf.inputs['Base Color'])

body.data.materials.append(body_mat)

# --- B. Translucent Veil Fin Material (Glowy Edge Gradient) ---
fin_mat = bpy.data.materials.new(name="Goldfish_Fin_Mat")
fin_mat.use_nodes = True
fnodes = fin_mat.node_tree.nodes
flinks = fin_mat.node_tree.links
fnodes.clear()

f_output = fnodes.new(type='ShaderNodeOutputMaterial')
f_bsdf = fnodes.new(type='ShaderNodeBsdfPrincipled')
flinks.new(f_bsdf.outputs['BSDF'], f_output.inputs['Surface'])

# Glossy transparent finish
f_bsdf.inputs['Base Color'].default_value = (1.0, 0.28, 0.02, 1.0)
f_bsdf.inputs['Transmission Weight'].default_value = 0.88
f_bsdf.inputs['Roughness'].default_value = 0.18
f_bsdf.inputs['IOR'].default_value = 1.333 # Water-like refraction

f_tex_coord = fnodes.new(type='ShaderNodeTexCoord')
f_sep = fnodes.new(type='ShaderNodeSeparateXYZ')
flinks.new(f_tex_coord.outputs['Generated'], f_sep.inputs['Vector'])

# Transition transparency to beautiful thin edges
f_map = fnodes.new(type='ShaderNodeMapRange')
f_map.inputs['From Min'].default_value = 0.0
f_map.inputs['From Max'].default_value = 1.0
f_map.inputs['To Min'].default_value = 0.4
f_map.inputs['To Max'].default_value = 0.96
flinks.new(f_sep.outputs['Y'], f_map.inputs['Value'])
flinks.new(f_map.outputs['Result'], f_bsdf.inputs['Transmission Weight'])

# Delicate structural rib lines on fins
f_wave = fnodes.new(type='ShaderNodeTexWave')
f_wave.wave_type = 'BANDS'
f_wave.direction = 'Z'
f_wave.inputs['Scale'].default_value = 24.0
flinks.new(f_tex_coord.outputs['Generated'], f_wave.inputs['Vector'])

f_bump = fnodes.new(type='ShaderNodeBump')
f_bump.inputs['Strength'].default_value = 0.13
flinks.new(f_wave.outputs['Color'], f_bump.inputs['Height'])
flinks.new(f_bump.outputs['Normal'], f_bsdf.inputs['Normal'])

for fin in [fin_obj, dorsal_obj, left_fin, right_fin]:
    fin.data.materials.append(fin_mat)

# --- C. Bulgy Black & Gold Eyes ---
eye_mat = bpy.data.materials.new(name="Goldfish_Eye_Mat")
eye_mat.use_nodes = True
enodes = eye_mat.node_tree.nodes
elinks = eye_mat.node_tree.links
enodes.clear()

e_output = enodes.new(type='ShaderNodeOutputMaterial')
e_bsdf = enodes.new(type='ShaderNodeBsdfPrincipled')
elinks.new(e_bsdf.outputs['BSDF'], e_output.inputs['Surface'])

e_tex = enodes.new(type='ShaderNodeTexCoord')
e_vmath = enodes.new(type='ShaderNodeVectorMath')
e_vmath.operation = 'DISTANCE'
e_vmath.inputs[1].default_value = (0.5, 0.5, 0.82) # Shifted outwards for pupil location
elinks.new(e_tex.outputs['Generated'], e_vmath.inputs[0])

e_ramp = enodes.new(type='ShaderNodeValToColor')
e_ramp.color_ramp.interpolation = 'CONSTANT'
e_ramp.color_ramp.elements[0].position = 0.22
e_ramp.color_ramp.elements[0].color = (0.005, 0.005, 0.005, 1.0) # Pupil
e_ramp.color_ramp.elements[1].position = 0.36
e_ramp.color_ramp.elements[1].color = (0.91, 0.48, 0.02, 1.0)  # Gold Iris
e_elem = e_ramp.color_ramp.elements.new(0.42)
e_elem.color = (1.0, 0.16, 0.01, 1.0) # Outer blend with body skin

elinks.new(e_vmath.outputs['Value'], e_ramp.inputs['Fac'])
elinks.new(e_ramp.outputs['Color'], e_bsdf.inputs['Base Color'])

e_bsdf.inputs['Roughness'].default_value = 0.04
if 'Coat Weight' in e_bsdf.inputs:
    e_bsdf.inputs['Coat Weight'].default_value = 1.0
    e_bsdf.inputs['Coat Roughness'].default_value = 0.01

eye_l.data.materials.append(eye_mat)
eye_r.data.materials.append(eye_mat)

# --- D. Warm Soft Playful Star Floor Material ---
star_mat = bpy.data.materials.new(name="Star_Floor_Mat")
star_mat.use_nodes = True
snodes = star_mat.node_tree.nodes
slinks = star_mat.node_tree.links
snodes.clear()

s_output = snodes.new(type='ShaderNodeOutputMaterial')
s_bsdf = snodes.new(type='ShaderNodeBsdfPrincipled')
slinks.new(s_bsdf.outputs['BSDF'], s_output.inputs['Surface'])

# Soft pastel cream sand color
s_bsdf.inputs['Base Color'].default_value = (0.96, 0.82, 0.56, 1.0)
s_bsdf.inputs['Roughness'].default_value = 0.55
s_bsdf.inputs['Subsurface Weight'].default_value = 0.28
s_bsdf.inputs['Subsurface Color'].default_value = (0.95, 0.68, 0.38, 1.0)

s_noise = snodes.new(type='ShaderNodeTexNoise')
s_noise.inputs['Scale'].default_value = 85.0
s_noise.inputs['Detail'].default_value = 4.0

s_bump = snodes.new(type='ShaderNodeBump')
s_bump.inputs['Strength'].default_value = 0.045
slinks.new(s_noise.outputs['Fac'], s_bump.inputs['Height'])
slinks.new(s_bump.outputs['Normal'], s_bsdf.inputs['Normal'])

star_obj.data.materials.append(star_mat)

# --- E. Deep Water Vignette Backdrop Material ---
water_mat = bpy.data.materials.new(name="Water_Backdrop_Mat")
water_mat.use_nodes = True
wnodes = water_mat.node_tree.nodes
wlinks = water_mat.node_tree.links
wnodes.clear()

w_output = wnodes.new(type='ShaderNodeOutputMaterial')
w_bsdf = wnodes.new(type='ShaderNodeBsdfPrincipled')
wlinks.new(w_bsdf.outputs['BSDF'], w_output.inputs['Surface'])

w_bsdf.inputs['Roughness'].default_value = 0.78
w_bsdf.inputs['Specular IOR Level'].default_value = 0.22

# Soft radial aquatic spotlight glow to pop the orange tones
w_tex = wnodes.new(type='ShaderNodeTexCoord')
w_dist = wnodes.new(type='ShaderNodeVectorMath')
w_dist.operation = 'DISTANCE'
w_dist.inputs[1].default_value = (0.5, 0.38, 0.28) # Glow epicenter location
wlinks.new(w_tex.outputs['Generated'], w_dist.inputs[0])

w_ramp = wnodes.new(type='ShaderNodeValToColor')
w_ramp.color_ramp.elements[0].position = 0.0
w_ramp.color_ramp.elements[0].color = (0.04, 0.30, 0.54, 1.0) # Magical aqua backdrop light
w_ramp.color_ramp.elements[1].position = 0.85
w_ramp.color_ramp.elements[1].color = (0.005, 0.038, 0.11, 1.0) # Deep endless water tone

wlinks.new(w_dist.outputs['Value'], w_ramp.inputs['Fac'])
wlinks.new(w_ramp.outputs['Color'], w_bsdf.inputs['Base Color'])

back_obj.data.materials.append(water_mat)

# ==============================================================================
# 5. WATER BUBBLES FIELD (GLB & CYCLES COMPATIBLE)
# ==============================================================================
random.seed(101)

bubble_mat = bpy.data.materials.new(name="Bubble_Mat")
bubble_mat.use_nodes = True
bnodes = bubble_mat.node_tree.nodes
blinks = bubble_mat.node_tree.links
bnodes.clear()

b_out = bnodes.new(type='ShaderNodeOutputMaterial')
b_bsdf = bnodes.new(type='ShaderNodeBsdfPrincipled')
blinks.new(b_bsdf.outputs['BSDF'], b_out.inputs['Surface'])

b_bsdf.inputs['Base Color'].default_value = (0.85, 0.96, 1.0, 1.0)
b_bsdf.inputs['Roughness'].default_value = 0.01
b_bsdf.inputs['Transmission Weight'].default_value = 0.95
b_bsdf.inputs['IOR'].default_value = 1.15

# Spawn distinct shining glassy bubbles
for b_idx in range(30):
    rad = random.uniform(0.04, 0.13)
    bx = random.uniform(-4.0, 4.0)
    by = random.uniform(-2.5, 2.0)
    bz = random.uniform(-4.2, 4.5)

    # Avoid spawning bubbles clipping through the main goldfish body
    if math.sqrt(bx**2 + (by - 0.2)**2 + bz**2) < 1.35:
        bx += math.copysign(1.1, bx)
        by += math.copysign(0.6, by)

    bpy.ops.mesh.primitive_uv_sphere_add(segments=16, ring_count=10, radius=rad)
    bubble = bpy.context.active_object
    bubble.name = f"Bubble_{b_idx}"
    bubble.location = (bx, by, bz)
    bubble.data.materials.append(bubble_mat)

    for poly in bubble.data.polygons:
        poly.use_smooth = True

# ==============================================================================
# 6. CAMERA & STUNNING LIGHTING ARCHITECTURE
# ==============================================================================

# --- A. Camera setup to view star, S-curve body and flow ---
cam_data = bpy.data.cameras.new("Hero_Camera")
cam_obj = bpy.data.objects.new("Hero_Camera", cam_data)
bpy.context.collection.objects.link(cam_obj)
bpy.context.scene.camera = cam_obj

# High-fidelity portrait angle
cam_obj.location = (5.85, 6.15, 2.3)
cam_data.lens = 54.0

track_const = cam_obj.constraints.new(type='TRACK_TO')
track_const.target = target
track_const.track_axis = 'TRACK_NEGATIVE_Z'
track_const.up_axis = 'UP_Y'

# --- B. Lighting Architecture ---

# 1. Cool Sun Sunlight - Directing caustics feel downwards
sun_data = bpy.data.lights.new(name="Water_Sun", type='SUN')
sun_data.energy = 5.0
sun_data.color = (0.78, 0.95, 1.0) # Light blueish white
sun_obj = bpy.data.objects.new(name="Water_Sun", object_data=sun_data)
bpy.context.collection.objects.link(sun_obj)
sun_obj.location = (3.0, 3.5, 9.0)
sun_obj.rotation_euler = (math.radians(24), math.radians(-16), 0)

# 2. Key Area Light - Warm fill on the volumetric goldfish sides
key_data = bpy.data.lights.new(name="Goldfish_Key", type='AREA')
key_data.energy = 320.0
key_data.color = (1.0, 0.62, 0.35) # Pops the orange
key_data.size = 2.8
key_obj = bpy.data.objects.new(name="Goldfish_Key", object_data=key_data)
bpy.context.collection.objects.link(key_obj)
key_obj.location = (4.8, 4.5, 1.2)

track_key = key_obj.constraints.new(type='TRACK_TO')
track_key.target = target
track_key.track_axis = 'TRACK_NEGATIVE_Z'
track_key.up_axis = 'UP_Y'

# 3. Dynamic Rim Spotlight - Catching edges of the translucent fins for back-lit sheen
rim_data = bpy.data.lights.new(name="Fin_Rim", type='SPOT')
rim_data.energy = 650.0
rim_data.color = (0.36, 0.86, 1.0) # Intense aquatic cyan rim glow
rim_data.spot_size = math.radians(65)
rim_data.spot_blend = 0.45
rim_obj = bpy.data.objects.new(name="Fin_Rim", object_data=rim_data)
bpy.context.collection.objects.link(rim_obj)
rim_obj.location = (-4.0, -5.0, -0.6)

track_rim = rim_obj.constraints.new(type='TRACK_TO')
track_rim.target = target
track_rim.track_axis = 'TRACK_NEGATIVE_Z'
track_rim.up_axis = 'UP_Y'
```