(NOTE: This is a follow-up to my previous question, which can be found here: Display Hidden Table Cell on click of another Table Cell in HTML, CSS, and JavaScript))
Since I last posted my previous question, it seems I didn’t do a good enough job of explaining myself. One person mistakenly thought I was trying to create a Minesweeper clone (I am not), and another person wasn’t sure how exactly I wanted to go about revealing the hidden cells in my table. So I’m here to hopefully try and correct that mistake.
So, here’s my problem and the best explanation I can currently give as to what I’m trying to do…
As stated previously, I’m trying to create an “avoid the mines”-style game.
The objective is to reach the end of a given level (represented by a table with cells) by clicking on the cells in the grid (called “tiles”) in a sequential order.
Clicking on a revealed cell should change the background color of that cell to dark gray, and should also reveal its neighboring cells (the ones that are hidden) by changing their visibility status to “visible”, and changing the color of their borders to white.
Again, this needs to be done in sequential order.
For example, let’s say I have a 5 by 5 table of cells, with each cell having id’s ranging from A1 to E5. And let’s assume that cell “A1” (the starting tile) is already revealed and has been clicked on.
When I click on A1’s neighboring cell with the id “A2”, I want A2 to have its background color changed to dark gray, and I want the cells neighboring A2 (in this case, cells “A3” and “B2”) to have their visibility changed to “visible”, and their border colors to change to white (to show that they have been revealed).
This process should be repeated for all cells that are clicked on by the player that have the “.Tile” and “.TileFinish” classes assigned to them.
To try and help y’all visualize what I’m trying to do, here are some screenshots of the table grid in various states…

This is a shot of the sample table with all relevant cells. Only those with their corresponding classes (“.Tile”, “.TileStart”, etc.) and their corresponding id’s (“A2”, “B3”, etc.) are highlighted.

This is a shot of the grid with all other cells hidden except A1 and A2, the latter of which has been highlighted with a white border. This is an example of a cell that I want to be visible and clickable when the game first loads.

This is a shot of what I want to happen when I click on cell A2. A2 gets its background color changed to dark gray, and its neighboring cell, “B2”, gets revealed and highlighted with a white border.
Again, just like last time, I understand that what I’m asking is rather complicated. If I need to use JavaScript to make this work, then I won’t complain.
But if I can do it without JavaScript, then all the better.
Hope that clears up any ambiguity from my previous question. And I look forward to y’all’s answers.
Also, here’s the HTML and CSS code I already have for this project…
body {
background-color: black;
}
table {
border-collapse: collapse;
position: absolute;
}
td {
width: 64px;
height: 64px;
text-align: center;
justify-content: center;
}
.TileStart {
border: 1px solid white;
color: black;
background-color: white;
}
.Tile {
color: white;
background-color: black;
cursor: pointer;
display: none;
}
.TileFinish {
color: black;
background-color: white;
cursor: pointer;
display: none;
}
#A2, #B2 {
display: table-cell;
}
#A2 {
border: 1px solid darkgray;
}
#B2 {
border: 1px solid white;
}
<!DOCTYPE html>
<html>
<head>
<title>Hidden Tiles Advanced Test</title>
<link rel="stylesheet" href="hidden-tiles-advanced-styles.css">
<meta charset="utf-8">
<meta name="description" content="Testing advanced use of hidden cells in tables.">
</head>
<body>
<table>
<tr>
<td class="TileStart" id="A1">Start</td>
<td class="Tile" id="A2" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td id="A3"></td>
<td id="A4"></td>
<td id="A5"></td>
</tr>
<tr>
<td id="B1"></td>
<td class="Tile" id="B2" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td class="Tile" id="B3" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td class="Tile" id="B4" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td id="B5"></td>
</tr>
<tr>
<td id="C1"></td>
<td class="Tile" id="C2" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td id="C3"></td>
<td class="Tile" id="C4" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td id="C5"></td>
</tr>
<tr>
<td id="D1"></td>
<td class="Tile" id="D2" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td class="Tile" id="D3" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td class="Tile" id="D4" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td id="D5"></td>
</tr>
<tr>
<td id="E1"></td>
<td id="E2"></td>
<td id="E3"></td>
<td class="Tile" id="E4" onclick="style='background-color: darkgray; color: border: 1px solid white;'"></td>
<td class="TileFinish" id="E5"></td>
</tr>
</table>
</body>
</html>