SANTA CLARA — Fret not, 49ers fans.

While Thursday night’s high-scoring and highly entertaining 41-39 loss to the Rams might feel deflating — they were so close to actually winning — it was actually the best-case scenario for the franchise.

Simply put, the 49ers won’t gain anything from winning games this year. Outside of registering a win or two to avoid being the worst team in NFL history, there’s no discernible benefit to walking off the field at the end of games with more points on the board.

But Thursday’s loss to the Rams was a victory, of sorts, for the 49ers — it was a moral victory.

And those are the only kind of victories the 49ers should be trying to accrue this season.

Again, the 49ers’ 2017 season won’t be defined by wins and losses — it doesn’t matter if the Niners win six games or one — the 2017 campaign will be defined by how it set the team up for 2018 and beyond.

First-year head coach Kyle Shanahan has a six-year contract, one of the worst rosters in the NFL, and a stopgap quarterback at the helm of his offense. He’s starting his tenure from lower than rock bottom, so 2017 is being treated like a 16-game week evaluation period.

And off this bottom-of-the-barrel roster, Shanahan is trying to find players with NFL-caliber talent, technique, and tenacity that he should keep for next year’s team.

He might have found a few players worthy of keeping on Thursday night.

The game, itself, was a mess. It featured two bad defenses, four ill-timed turnovers, a bevy of critical penalties and a perfect onside kick recovery. It looked more like a late-night college football game than an NFL showcase.

But it was also the most interesting game the 49ers have played in a long time.

And it was interesting not because of the chaos, but because of the relentless effort the Niners brought all game. Like our San Francisco 49ers Facebook page for more 49ers news, commentary and conversation.

If that effort keeps up in the weeks to come, this season won’t be for naught.

“I was proud of the guys, how they fought,” Shanahan said. “We have mentally strong people, I believe we’ll get better from all this stuff… I don’t really care about record right now — I care about how guys are responding to it.”

That’s not cliché coach talk — that quote is telling.

It tells the truth that the team won’t fully cop to: The 49ers’ rebuild really starts next year, when the team will have a ton of money to spend in free agency and likely a load of high draft picks.

It also says that this season will be about not only finding quality players but also establishing a new culture for the franchise.

It might only be Week 3, but you can see that culture forming in Santa Clara.

I can understand how it can be frustrating to 49ers fans for the team to come up short on Thursday. The first two games of this season were painful and laborious and that might have been an upgrade over the last few years’ product.

A win would have felt good — there’s no doubt about that.

But Niners fans should keep their eye on the big picture.

Because as good as a prime-time win would have felt on Thursday, the question remains: would you consider short-term buzz you’d get from a win over the Rams in September worth it in April?

The 49ers know it and so should their fans: Every win that actually shows up in the standings this year hurts San Francisco’s chances to win in the years to come — in seasons where wins and losses actually matter — because it diminishes the 49ers chances of landing the quarterback (or offensive weapon) of their choosing in April’s draft.

Ask yourself, Niners fans: How many games are the Jets going to win this year? The race to the bottom (or top, depending on your goals) is competitive.

And every win also backs up the false notion that this 49ers’ roster, as currently constructed, is good enough for the years to come.

It isn’t.

So as long as the team is trying — so long as a positive, high-effort culture is being built — there’s all the reason in the world to root for 49ers losses. Frankly, the tougher they are to swallow, the better.