Rathnayake, Liyanage half-centuries in vain as Sri Lanka unravel in pursuit of 306