You celebrated your 40th birthday with a cake, cards, and a niggling worry in the back of your mind that you should start planning for retirement.

You began reading about retirement planning and were dismayed when every article gave the same advice: Start saving for retirement early in life. Oops -- too late.

You didn't put away a dime for retirement throughout your 20s and 30s. What can you do?

Fortunately, there's still time to recover. Here are some tips to help you prepare for retirement, even if you got a late start.

No. 1: Find out how much money you'll need
How much money will you need during retirement?

As a rule of thumb, you'll want to replace 80% to 85% of your pre-retirement income. So if you earn $100,000 per year, you'll want to generate $80,000 $85,000 annually during retirement. If you earn $50,000 per year, you'll want $40,000 to $42,500 per year when you retire.

This guideline is sometimes criticized for basing its projections on your current income, rather than your expenses, with the implicit assumption that you spend most of your paycheck. If you save 60% of your earnings, you probably don't need to replace 85% of your pre-retirement income. You can project your retirement goals based on your current spending habits.

If you generally spend most of your paycheck, on the other hand, try using the 80%-85% rule of thumb as a handy guideline.

No. 2: Discover how much you're on track to receive
Most people derive their retirement income from three sources: Social Security, pensions, and their investment portfolios.

Your Social Security income will be based on a 35-year average of your "covered wages," which is your annual employee or self-employment income. It doesn't count any income over the "wage base" of $113,700.

Sound confusing? Don't worry. That's just a fancy way of saying that your Social Security payout will be based on your income. We can't tell you precisely how much you'll collect, because the amount varies from person to person. However, the Social Security website features a calculator that helps you estimate your payout.

For the sake of example, let's assume you're on track to collect $1,500 per month ($18,000 per year) from Social Security, and you're not eligible for any pensions. Now let's do some quick math. Let's assume that you earn $70,000 per year and you want to replace 80% of your pre-retirement income. That means you'll need to generate $56,000 each year in retirement, which is $4,667 per month.

If Social Security pays $18,000 per year, your investment portfolio needs to generate the difference.

No. 3: Run a retirement planning calculator
At this point, we realize things may sound bleak. How can your investments generate the $38,000 annual difference between the amount that you're on track to earn and the amount that you need?

Take a deep breath. Don't panic. You're in better shape than you think.

First, let's multiply the amount that you need by 25. If your investments need to generate $38,000 per year, you'll need an investment portfolio of $950,000. Let's round this up to $1 million, just to be on the safe side.

Now, how can you create $1 million?

From 1990 to 2010, the S&P 500 yielded a long-term annualized average of 9.1% annually. In other words, if you invested in an index fund that tracked the S&P 500, you'd earn roughly a 9% annual return after fees and expenses. (Remember, the time frame from 1990 to 2010 includes two major market crashes.)

Because you'll be diversified into fixed-income investments like bonds, let's assume that your overall portfolio earns a long-term annualized return of 7%. Now let's plug these assumptions into a retirement planning calculator.

Let's imagine that every year, you contribute $17,500 to a tax-deferred retirement account, such as your 401(k) or 403(b). You also contribute another $5,500 into an IRA.

At that rate, you'll grow an inflation-adjusted $1 million nest egg in less than 26 years. If you're 40 now, that means you can have a $1 million portfolio before you turn 66 -- even if you currently have $0 saved for retirement.

What does a $1 million portfolio translate into? Well, a handy rule of thumb known as the "4% withdrawal rule" says you can safely withdraw 4% from your retirement portfolio during your first year of retirement. You can continue withdrawing the same amount (adjusted for inflation) every subsequent year.

Your $1 million portfolio, in other words, allows you to safely withdraw $40,000 during your first year of retirement and $40,000 adjusted for inflation every year thereafter. That means you'll more than meet your retirement goal of generating $38,000 annually through your investments.

Couple that with your $18,000 expected Social Security payout, and voila -- you now have enough money for retirement despite your late start.

No. 4: Take care of your total financial future
As a final note, if you're saving for retirement with a late start, be wary of other factors that may drag on your finances. Pay down all your debt immediately, especially high-interest debt such as credit card balances.

Also, prioritize retirement savings over your children's college fund. Your children have the rest of their financial lives ahead of them, which means they have plenty of time to earn, invest, and enjoy the power of compounding interest. You have a shorter time frame, and you must prioritize your own needs.

Find ways to boost your income through freelance or consulting work and trim your savings. Direct every spare penny toward your retirement account. Take care of your health so that you'll have the freedom and flexibility to work longer into your 60s or early 70s, if required.

If you've started saving for retirement late in the game, don't despair. You still have time to build a firm retirement foundation. But you'll need to start now.