You are playing a game with some friends. The game is played on a rectangular chess board where each cell may be either empty or occupied by a rook. You are given a String board representing the layout of the board. Each character of each element of board represents a single cell of the board. A '.' represents an empty cell, while a 'X' represents an occupied cell.
The goal of the game is to take turns placing rooks onto empty spaces of the board so that they are not within the line of sight of any other rook. The line of sight extends directly up, down, left, and right.
Your strategy is to place your next rook on the board so that the number of "safe" squares remaining on the board (those that are not within the line of sight of any existing rook) is minimized, while also making sure that your piece is not within the line of sight of any rook already on the board. Return the number of safe squares remaining after you make the best possible move. If it is impossible for you to make a move on a safe square, return -1.