Examine the indentation of your code. You will find that, starting with the loop() definition, the indentation is not as expected. This indicates that you are missing a brace somewhere above that point.
Once you have fixed the code, do another Auto Format and examine the indentation again to verify that it is as expected.
Try compiling again. If you have a problem the post the FULL error output.
When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).