/* Reversi. The board is a container, so discs and coordinates scale with it
   (cqw), as in Checkers. A disc sizes itself in em from its own font-size,
   which is one square wide. */
.rv { width: min(30rem, 100%); }

.rv-board {
  container-type: inline-size;
  display: grid; grid-template-columns: repeat(8, 1fr);
  border: 3px solid var(--felt-dark); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); user-select: none; -webkit-user-select: none;
  background: var(--felt);
}

.rv-sq {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; box-sizing: border-box; min-width: 0;
  margin: 0; padding: 0; border: 0; font: inherit; color: inherit; line-height: 1;
  background-color: var(--felt);
  /* Grid lines between squares. */
  box-shadow: inset 0 0 0 0.25cqw var(--felt-dark);
  background-image: var(--ov-dot, none);
}

/* Edge coordinates come from data-rank and data-file (empty off the edge),
   so the squares hold no text. */
.rv-sq::before, .rv-sq::after {
  position: absolute; font-size: 2.2cqw; font-weight: 700; line-height: 1; opacity: 0.75;
  color: var(--paper); pointer-events: none;
}
.rv-sq::before { content: attr(data-rank); top: 0.5cqw; left: 0.7cqw; }
.rv-sq::after { content: attr(data-file); bottom: 0.8cqw; right: 0.8cqw; }

/* The square just played on: a ring. The discs it flipped get a lighter one
   below, so the move reads as "this disc, and these turned". */
.rv-sq.last { box-shadow: inset 0 0 0 0.25cqw var(--felt-dark), inset 0 0 0 0.9cqw var(--accent); }
.rv-sq.flipped { box-shadow: inset 0 0 0 0.25cqw var(--felt-dark), inset 0 0 0 0.6cqw rgb(224 117 45 / 0.85); }

.rv-disc {
  font-size: 12.5cqw; width: 0.7em; height: 0.7em; border-radius: 50%; box-sizing: border-box;
  position: relative; box-shadow: 0 0.06em 0.1em rgb(0 0 0 / 0.35);
}
.rv-disc.black {
  background: radial-gradient(circle at 35% 30%, #5a5148, #2b2620 60%);
  border: 0.05em solid #14110e;
}
.rv-disc.white {
  background: radial-gradient(circle at 35% 30%, #fffdf8, #e6dcc6 70%);
  border: 0.05em solid #7a6e5a;
}

/* A turned disc flips over once per move. Every push redraws the board, so
   the board is marked `gn-fresh` only by the PlayOnce script, which also sets
   --played (how long ago this move was first seen) so that a redraw after the
   flip shows nothing instead of flipping again. Skipped for anyone who asked
   for less motion; the ring still marks it. */
@media (prefers-reduced-motion: no-preference) {
  .rv-board.gn-fresh .rv-sq.flipped .rv-disc { animation: rv-flip 0.45s ease-out calc(0s - var(--played, 0s)); }
}
@keyframes rv-flip {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(0.05); }
  100% { transform: scaleX(1); }
}

/* Squares you can act on: a faint dot says "a disc may go here". */
.rv-sq.legal {
  --ov-dot: radial-gradient(circle, rgb(255 255 255 / 0.28) 0 2.2cqw, transparent calc(2.2cqw + 0.5px));
}
button.rv-sq { cursor: pointer; }
button.rv-sq:hover { box-shadow: inset 0 0 0 0.25cqw var(--felt-dark), inset 0 0 0 0.6cqw var(--accent); }
button.rv-sq:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

/* Both disc counts, always on show. */
.rv-score { display: flex; gap: 1.5rem; margin: 0 0 0.6rem; font-size: 1.1rem; }
.rv-count { display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.5rem; border-radius: var(--radius); }
.rv-count.turn { background: var(--paper-2); outline: 2px solid var(--accent); }
.rv-count .rv-disc { font-size: 1.4rem; }

/* Move list: one line per pair of plies, numbered by the list. The box
   opens at the newest moves and stays there (`GameKit.MoveList`):
   a column-reverse scroller whose one child, the list, sits at its end. */
.rv-moves {
  display: flex; flex-direction: column-reverse; margin: 0.8rem 0 0; max-height: 9rem; overflow-y: auto;
  font-family: var(--mono); font-size: 0.9rem; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.rv-moves ol {
  flex: none; margin: 0; padding: 0.5rem 0.5rem 0.5rem 2.2rem;
  display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; list-style-position: inside;
}
.rv-moves li { min-width: 10rem; padding: 0; }
.rv-moves li::marker { color: var(--ink-soft); }
.rv-ply { display: inline-block; min-width: 4.6rem; margin-right: 0.3rem; }
