"Bad faith" is a theory of liability. A liability insurer has a legal obligation to settle a third party claim within policy limits when there is a substantial likelihood of recovery in excess of those limits. Such a duty is implied in law to protect the insured from exposure to liability in excess of coverage as a result of the insurer's gamble, on which only the insured might lose. An insurance company who unreasonably refuses to settle a third-party claim for an amount within policy limits becomes liable to its insured for a judgment in excess of policy limits. The theory is that the insurance company had the opportunity to settle the claim but refused, and any judgment in excess of the policy limits was therefore caused by the insurance company's refusal to settle. In addition to the excess judgment amount the insurance company is potentially liable for punitive damages, attorneys' fees, and costs.