/* Tic tac toe: the board, its squares and the two marks. */

.mark-x::before, .mark-x::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 5px; border-radius: 3px; background: var(--p1);
  transform: translate(-50%, -50%) rotate(45deg);
}
.mark-x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.mark-o::before { content: ""; position: absolute; inset: 1px; border: 5px solid var(--p2); border-radius: 50%; }

/* A square board that fills the room its stage has (see shell.css). Every size is worked out
   from --board: the squares never take their size from the page's flow or from what is drawn in
   them, so placing a mark cannot change any square. */
.board {
  --board: min(100cqw, 100cqh, 600px);
  --cell: calc((var(--board) - 2 * var(--gap)) / 3);
  display: grid;
  grid-template-columns: repeat(3, var(--cell));
  grid-template-rows: repeat(3, var(--cell));
  gap: var(--gap);
  width: var(--board);
  height: var(--board);
}
.cell {
  appearance: none;
  display: block;
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  color: inherit;
  padding: 0;
  margin: 0;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.cell:hover:not([aria-disabled="true"]) { background: #1f2540; }
.cell[aria-disabled="true"] { cursor: default; }
.cell svg { position: absolute; left: calc(var(--cell) * .18); top: calc(var(--cell) * .18); width: calc(var(--cell) * .64); height: calc(var(--cell) * .64); display: block; overflow: visible; }
.cell .stroke { fill: none; stroke-width: 12; stroke-linecap: round; }
.cell[data-mark="X"] .stroke { stroke: var(--p1); }
.cell[data-mark="O"] .stroke { stroke: var(--p2); }
.cell.is-win { background: #263055; outline: 3px solid var(--ink); outline-offset: -3px; }
.board.is-over .cell:not(.is-win) svg { opacity: .45; }

/* the mark draws itself once when placed */
@media (prefers-reduced-motion: no-preference) {
  .cell.just-placed .stroke { stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw .22s ease-out forwards; }
  .cell.just-placed .stroke + .stroke { animation-delay: .1s; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}
