The angles are not limited, you can keep pan/ roll between -180 and 180 and still describe the whole sphere (see spherical coordinates on Wikipedia)/ all angles.
Try something as follows:
// in the player function after c_move:
c_trace(my.x,vector(my.x,my.y,my.z-2000),IGNORE_PASSABLE | IGNORE_ME);
if(trace_hit)
{
vec_rotate(normal,vector(-my.pan,0,0));
my_shadow.tilt = -asin(normal.x);
my_shadow.roll = -asin(normal.y);
}