It can move any number of unoccupied squares diagonally , vertically , and horizontally . The queen can be moved any number of unoccupied squares in a straight line vertically , horizontally , or diagonally , thus combining the moves of the rook and bishop .