.game {
  max-width: 560px;
}

.scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
}

.player,
.draws {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  transition: border-color 120ms ease;
}

.player {
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-areas:
    "badge name"
    "score score";
}

.player.active {
  border-color: var(--accent);
  background: var(--surface);
}

.mark-badge {
  grid-area: badge;
  width: 28px;
  height: 28px;
}

.player-name {
  grid-area: name;
  width: 100%;
  min-width: 0;
  padding: 2px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-weight: 700;
  text-overflow: ellipsis;
}

.player-name:hover {
  background: var(--surface-2);
}

.score {
  grid-area: score;
  font-size: 2.2rem;
  line-height: 1;
}

.draws {
  min-width: 72px;
  text-align: center;
  color: var(--muted);
}

.draws span {
  font-size: 0.85rem;
  font-weight: 700;
}

.draws strong {
  font-size: 1.6rem;
  line-height: 1;
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 2.4em;
  margin: 24px 0 12px;
  font-size: 1.25rem;
  text-align: center;
}

.board {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 0;
  aspect-ratio: 1;
  width: min(100%, 460px);
  margin: 0 auto;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 0;
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 3px solid var(--accent-soft);
  border-bottom: 3px solid var(--accent-soft);
  background: transparent;
}

.board-row .cell:nth-child(3) {
  border-right: 0;
}

.board-row:nth-child(3) .cell {
  border-bottom: 0;
}

.cell:focus-visible {
  outline-offset: -8px;
}

.cell[aria-disabled="true"] {
  cursor: default;
}

.board:not(.over) .cell[data-mark=""]:hover {
  background: var(--surface);
}

.cell svg {
  position: absolute;
  top: 16%;
  left: 16%;
  width: 68%;
  height: 68%;
}

.mark-badge svg {
  width: 100%;
  height: 100%;
}

.cell svg,
.mark-badge svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
}

.cell[data-mark="X"],
.player[data-player="X"] .mark-badge {
  color: var(--text);
}

.cell[data-mark="O"],
.player[data-player="O"] .mark-badge {
  color: var(--accent);
}

.cell path,
.cell circle {
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  animation: draw 220ms ease-out;
}

@keyframes draw {
  from {
    stroke-dashoffset: 100;
  }
}

.board.over .cell:not(.win) svg {
  opacity: 0.25;
}

.cell.win {
  background: var(--surface-2);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
}

.rules {
  margin-top: 20px;
  text-align: center;
}

@media (max-width: 420px) {
  .scoreboard {
    grid-template-columns: 1fr 1fr;
  }

  .draws {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px;
  }

  .draws strong {
    font-size: 1rem;
  }
}
