A meal from Subway. (Seth Wenig/AP)

Last year was a disastrous one for Chipotle, as the burrito behemoth grappled with the fallout from a food contamination scare and problems such as slow moving lines and untidy restaurants. Its sales continued to decline and investors punished its stock.

And yet, the chain was still adding stores at a breakneck pace, opening some 240 locations in the last fiscal year alone. And there is no sign it is pumping the brakes, reporting this week that it had opened 57 more stores in the first three months of this year.

That kind of expansion is an extreme example of a pattern that we’ve seen widely across the restaurant industry. Chains have aggressively added more locations, determined to make the most of a cultural moment when consumers wished to dine out more often.

Since the recession ended, visits to U.S. restaurants had been growing steadily at around 1 percent a year, according to market research firm NPD Group, giving these dining companies ever more opportunities to pull down dollars.

But 2016 was different. Restaurant visits declined slightly, according to NPD.

And there are fresh signs of trouble for established restaurants. Based on sales and guest count data from some 22,000 restaurant locations, BlackBox Intelligence says same-store traffic to these places was down 3.6 percent in the first quarter, adding to a streak of declines that began last year.

These gloomy traffic figures put into focus one of the industry’s key problems: The supply of restaurants appears to outstrip demand.

“The structural headwind is there are a lot of seats out there,” Eugene Lee, the chief executive of Olive Garden’s parent company, told investors last month.

There is some indication that a shakeout is already underway. NPD says the total number of U.S. restaurants decreased by 2 percent from a year ago. The pullback includes some big-name chains: Subway — by far the most prolific of the big chains with around 27,000 locations — closed hundreds of stores in 2016. McDonald’s has trimmed its U.S. restaurant portfolio slightly, reporting 14,155 locations here in 2016, almost 200 fewer than two years earlier.

So what is going on with diners? Experts say a confluence of factors is likely driving their decision-making. For starters, many restaurants have seen high workforce turnover of late and are relying heavily on part-time help, leading to an uneven eating experience, said Bonnie Riggs, a restaurant industry analyst for NPD.

They’ve not paid enough attention to service,” Riggs said. “It makes up such a big part of the value equation.”

Meanwhile, there is an especially wide price chasm between eating out and cooking at home. According to the Agriculture Department, “food-at-home prices” dropped 1.3 percent in 2016 — the first yearly decline recorded since 1967. But restaurant prices swung the other direction, rising 2.6 percent.

It’s possible many consumers are simply reacting to the fact that it makes more financial sense to fire up the frying pan and chop their own vegetables.

Plus, grocery stores have been making a concerted effort to snare the dollars that you might once have spent at restaurants. Kroger, SuperValu and Whole Foods Market are among the chains that have been angling to get you to buy their prepared foods on the nights you would otherwise have gone to a carryout spot.

These factors may have played a role in some of the weakness we’ve seen this week as several major restaurant chains reported financial results. Visits to non-franchised Chili’s sank 6.2 percent in the quarter. McDonald’s and Starbucks both saw healthy increases in total sales at U.S. restaurants, but still saw a dip in traffic. Maggiano’s, Outback Steakhouse and Carrabba’s Italian Grill each saw guest counts sink.

The reality for many restaurant chains right now is they are fighting for a share of a pie that is not growing. And they’re doing so against a plethora of new competitors. A couple of Washington-area insurgents demonstrate this dynamic well: Cava Group, the parent of Cava Grill, recently announced it nabbed $30 million in new venture capital funding to build more Mediterranean-themed restaurants. Another, &Pizza, obtained $25 million in funding last fall and said it planned to expand to markets such as New York.

And it matters that much of the expansion in the industry is taking place in the fast-casual category. On average, an individual Panera Bread restaurant raked in $2.5 million in 2015, according to trade publication QSR. But an individual Burger King pulled down an average of $1.4 million, and a Subway grabbed $424,000. When so much growth in the industry is happening in a particular niche, it only makes the fight for each of your visits more fierce.

To be sure, some growing chains seem to be navigating the change just fine. Domino’s Pizza, for example, delivered a blockbuster 10.2 percent increase in same-store sales this quarter.

It’s going to continue to be a battle for market share,” Riggs said. “And the ones that are going to win are the ones that are best meeting consumers’ needs.”

Save