How can I fix Z-fight?

Chamfer edges. Something like this:

So edge of grid (size) is where they intersect.
Then add about 1uu chamfer.

Since both meshes overlap and go 45 deg immediately, you will not have Z fight or that tiny lines between meshes.