:root {
  --bg: #f8f8f6;
  --ink: #080808;
  --muted: #6e6e68;
  --red: #c55c5c;
  --blue: #6b8ac2;
  --nav-top: 2rem;
  --nav-height: calc(1.5rem * 1.65);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", Charter, Georgia, serif;
}
#iteration, #controls {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
#iteration {
  /* Centers the 30px "Score" line on the nav's line box. */
  margin-top: calc(var(--nav-top) + (var(--nav-height) - 30px) / 2);
  gap: 6px;
  font-size: 30px;
  line-height: 1;
  white-space: nowrap;
}
#score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: 0.3em;
}
#red-score { text-align: right; color: var(--red); }
#blue-score { text-align: left; color: var(--blue); }
#status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
  white-space: normal;
  max-width: calc(100vw - 24px);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.board-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 760px;
  max-height: 650px;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}
#nav {
  position: absolute;
  /* Matches the nav on about.html. */
  top: var(--nav-top);
  right: clamp(16px, 3vw, 40px);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 1.25em;
  font-size: 17px;
  line-height: 1;
}
#nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms ease;
}
#nav a:hover { color: var(--ink); }
body.playing #controls { visibility: hidden; }
#controls {
  margin-bottom: clamp(14px, 3vh, 36px);
  gap: 10px;
}
#stepping {
  display: flex;
  align-items: center;
  gap: 18px;
}
#stepping button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
#stepping svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}
#pause .play-icon { display: none; }
#pause.paused .pause-icon { display: none; }
#pause.paused .play-icon { display: block; }
button:disabled { opacity: 0.3; cursor: default; }
#speed {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 30px;
  line-height: 1;
}
#speed button {
  padding: 2px 1px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
#speed button.active { border-bottom-color: var(--ink); }
.times { font-size: 0.8em; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.cell { fill: var(--bg); stroke: var(--ink); stroke-width: 1.5; outline: none; transition: fill 120ms ease; }
.cell:focus-visible { stroke-width: 3; }
#board.your-turn .cell:not(.occupied) { cursor: pointer; }
#board.your-turn .cell:not(.occupied):hover { fill: color-mix(in srgb, var(--red) 14%, var(--bg)); }
.edge { stroke-width: 5; stroke-linecap: round; pointer-events: none; }
.edge.red, .winning-edge.red { stroke: var(--red); }
.edge.blue, .winning-edge.blue { stroke: var(--blue); }
.stone { transition: opacity 400ms ease; }
.stone.dimmed { opacity: 0.2; }
.winning-edge {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  pointer-events: none;
}
@media (max-height: 650px) {
  :root { --nav-top: 6px; }
  #controls { margin-bottom: 10px; gap: 6px; }
  #stepping button { height: 34px; }
}
