If anyone knows the importance of waiting for every ballot to be counted, it’s Lan Diep, the San Jose Councilman who made national headlines when he was sworn into his seat with a Captain America shield just four years ago.

Diep — now in the midst of his fourth election — has yet to have an easy path to victory. In his first run during a special election in 2015, he lost by just 13 votes. The next year, Diep won his council seat by a mere 12 votes after triggering a newly-enacted recount rule for close races in Santa Clara County and sparking a legal battle that ultimately was decided in his favor.

“This whole thing right now is very familiar territory for me, so I’m not biting my nails,” he said in an interview. “There are still votes to be counted.

“For me, there’s always hope until there’s none left.”

In his bid for re-election, Diep is trailing his opponent David Cohen by a larger margin this time around — about 500 votes as of Friday. But with the potential for thousands of ballots still to be counted in his race, Diep said he’s staying patient and “waiting for everything to shake out” — a strategy he said he’d advise others in his position to use as well.

Mirroring the presidential race nationally, dozens of races across the Bay Area — from city councils to school boards to city measures — remain too close to call, including some within less than a 1% margin of winning or losing. Those candidates and invested voters could be forced to wait nearly a month to find out the final outcome.

Under California law, ballots postmarked by election day can be processed up until November 20, and county election officials have until December 3 to count every valid ballot and issue final results to the state.

As of Friday, Santa Clara County estimated it had counted about 73% of ballots expected to be cast in the election, with more than 200,000 ballots yet to be tallied. The county had already broken a record for most ballots cast in an election — 827,484 — but voter turnout was still trailing behind the county’s 2008 record — 80% compared to 86%.

“We’re hoping to beat that record,” said Ryan Aralar, spokesperson for the county’s registrar of voters. “We’re still receiving lots of mail-in ballots cast from around the state, such as students that lived here and went off to college and people who move around, so we’ll be getting a lot more in the next few days for sure.”

What makes declaring winners in local elections even more difficult than some national or state contests is that not every ballot will include a local race. And according to elections officials, there’s no clear way of determining how many ballots are still uncounted in certain cities and areas, such as in the San Jose District 4 race between Diep and Cohen.

So far with each update of race results, Cohen’s vote count is holding between a 2-3% margin above Diep’s, leaving Cohen feeling as if he is “in good shape” but still not quite ready to declare victory.

“I’m not taking things for granted until another 10% or so of votes come in,” Cohen said, though he is starting to “put together transition plans just to make sure we’re ready.”

In San Mateo County, about 288,000 ballots had been counted as of Friday, and at least 71,000 remained to be counted — about 65,000 of which are mail-in ballots.

Although only a fraction of those ballots will include votes cast in Redwood City, those uncounted ballots will decide the fate of one of the closest races on the Peninsula with the potential for a big upset. Redwood City council candidate Lissette Espinoza-Garnica, a 24-year-old caregiver and community leader with the Democratic Socialists of America, was leading incumbent Janet Borgens on Saturday by just 26 votes.

Espinoza-Garnica, who launched her campaign just five months before the election, said she is optimistic about her lead given the high percentage of votes that have yet to be counted are mail-in ballots, which she believes could be more favorable to her progressive platform.

“The anticipation is killing me but I’m trying to stay occupied,” she said, though adding that she checks the updated results as soon as they’re available. “I feel content with my campaign win or lose because it means that people are listening and residents were moved by my campaign.”

A San Mateo city measure to extend the city’s current height and density limits was failing by less than 400 votes Saturday. If the tides turn and Measure Y passes, the City Council would not be able to increase the current height and density limits without voter approval for 10 years.

Alameda County, where election officials say they’re on track to set a record for voter turnout, still has about 43% of votes left to count, including mail-in ballots and provisional and conditional voter registration ballots.

“It’s still a significant number of votes out to be counted,” Alameda County Registrar Tim Dupuis said, adding that the county is on pace to finish counting the majority of ballots by “early next week.”

With more than 300,000 ballots yet to be counted, it remains to be seen whether the county’s half-percent sales tax increase — dubbed Measure W — will clear the finish line with a passing grade. The measure, which would be the second half-cent sales tax increase Alameda County voters have approved this year, was passing by less than a two-point margin as of Friday.

In a race for two open seats on the Alameda City Council, the vote between second and third place is razor thin and toggling back and forth. In early returns, former Alameda Mayor Trish Spencer was ahead by less than 30 votes. But as of the latest figures, political newcomer Amos White had narrowly edged ahead of Spencer.

In Contra Costa County, where election officials still have yet to count more than 150,000 ballots, races for seats on the city councils in Antioch, Oakley and San Ramon were all within a 1% margin on Friday.