Karunaratne on brink of century as Sri Lanka fight back