/* Reversi — board, discs, flip wave, score pills (prefix rv-) */
.rv-wrap { --rv-felt: #1f8f5f; --rv-felt-2: #1a7d53; --rv-line: #136142; --rv-rim: #10563a;
  width: min(100%, 560px, max(290px, calc(100vh - 344px))); gap: 0; }
:root[data-theme="dark"] .rv-wrap { --rv-felt: #1a7651; --rv-felt-2: #166848; --rv-line: #0e4630; --rv-rim: #0b3a28; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rv-wrap { --rv-felt: #1a7651; --rv-felt-2: #166848; --rv-line: #0e4630; --rv-rim: #0b3a28; } }

/* score */
.rv-score { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.rv-pill { display: flex; align-items: center; gap: 8px; min-width: 108px; justify-content: center; padding: 6px 14px; border-radius: 14px;
  background: var(--surface-2); border: 2px solid transparent; box-shadow: 0 3px 0 var(--line); transition: border-color .25s, background .25s, transform .25s; }
.rv-pill b { font-size: 22px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); min-width: 2ch; text-align: center; }
.rv-pill small { font-size: 11px; font-weight: 600; color: var(--ink-3); }
.rv-pill small:empty { display: none; }
.rv-pill.rv-on.rv-pa { border-color: var(--brand); background: var(--brand-soft); transform: translateY(-1px); }
.rv-pill.rv-on.rv-pb { border-color: var(--blue); background: var(--blue-soft); transform: translateY(-1px); }
.rv-vs { color: var(--ink-3); font-weight: 700; }
.rv-mini { width: 20px; height: 20px; border-radius: 50%; flex: none; }
.rv-note .rv-mini { width: 14px; height: 14px; }
.rv-note span:last-child { overflow: hidden; text-overflow: ellipsis; }

.rv-score { margin-bottom: 4px; }
/* fixed-height slot between the score strip and the board: holds the pass chip without moving or covering anything */
.rv-slot { height: 30px; width: 100%; display: flex; align-items: center; justify-content: center; min-width: 0; }
.rv-note { max-width: calc(100% - 8px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 700; line-height: 1.2; color: var(--ink); background: var(--surface); border: 2px solid var(--line-2);
  border-radius: 999px; padding: 1px 12px; text-align: center; box-shadow: 0 2px 0 var(--line-2); animation: rvnote .35s var(--spring) both; }
@keyframes rvnote { from { transform: scale(.85); opacity: 0; } }

/* board */
.rv-frame { position: relative; width: 100%; padding: 8px; border-radius: 16px; background: var(--rv-rim); box-shadow: 0 6px 0 rgba(0, 0, 0, .25), var(--shadow); }
.rv-board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; gap: 3px; padding: 3px;
  border-radius: 10px; background: var(--rv-line); }
.rv-cell { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; border-radius: 5px; perspective: 500px;
  background: linear-gradient(145deg, var(--rv-felt), var(--rv-felt-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
.rv-cell > * { grid-area: 1 / 1; }

/* discs */
.rv-disc { width: 82%; height: 82%; border-radius: 50%; position: relative; pointer-events: none; }
.rv-a { background: radial-gradient(circle at 34% 28%, #ffb29f 0, #ff6b4a 42%, #e2502f 100%); box-shadow: 0 3px 0 #a93a20, 0 5px 8px rgba(0, 0, 0, .3); }
.rv-b { background: radial-gradient(circle at 34% 28%, #a8c5ff 0, #3d7bf7 42%, #2a5bc4 100%); box-shadow: 0 3px 0 #1d4396, 0 5px 8px rgba(0, 0, 0, .3); }
.rv-disc::before { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .28); }
.rv-mini.rv-a, .rv-mini.rv-b { box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }

/* placed disc */
.rv-drop { animation: rvdrop .38s var(--spring) both; }
@keyframes rvdrop { from { transform: translateY(-30%) scale(1.45); opacity: 0; } 55% { opacity: 1; } to { transform: none; opacity: 1; } }

/* flip: two faces, the back face shows the old colour until the disc turns */
.rv-flip { width: 82%; height: 82%; position: relative; transform-style: preserve-3d; animation: rvflip .42s cubic-bezier(.35, .1, .3, 1) both; pointer-events: none; }
.rv-face { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.rv-back { transform: rotateY(180deg); }
@keyframes rvflip {
  from { transform: rotateY(180deg); }
  50% { transform: rotateY(90deg) translateZ(14px) scale(1.12); }
  to { transform: rotateY(0deg); }
}

/* last move */
.rv-last::after { content: ""; grid-area: 1 / 1; position: relative; z-index: 2; width: 16%; height: 16%; border-radius: 50%; background: rgba(255, 255, 255, .92);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .18); pointer-events: none; }

/* legal-move hints */
.rv-hint { cursor: pointer; }
.rv-dot { width: 26%; height: 26%; border-radius: 50%; background: rgba(255, 255, 255, .5); box-shadow: 0 0 0 3px rgba(255, 255, 255, .14); animation: rvdot 1.6s ease-in-out infinite alternate; pointer-events: none; }
.rv-me-a .rv-dot { background: rgba(255, 140, 112, .9); }
.rv-me-b .rv-dot { background: rgba(140, 180, 255, .9); }
@keyframes rvdot { from { transform: scale(.85); } to { transform: scale(1.08); } }
.rv-ghost { opacity: 0; transform: scale(.9); transition: opacity .15s, transform .15s; }
@media (hover: hover) {
  .rv-hint:hover { background: linear-gradient(145deg, #27a36e, #20905f); }
  .rv-hint:hover .rv-ghost { opacity: .75; transform: none; }
  .rv-hint:hover .rv-dot { opacity: 0; }
}
.rv-hint:focus { outline: none; }
.rv-hint:focus-visible { box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px var(--rv-line); z-index: 1; }
.rv-hint:focus-visible .rv-ghost { opacity: .75; transform: none; }
.rv-hint:focus-visible .rv-dot { opacity: 0; }
.rv-hint:active .rv-ghost { opacity: .8; transform: scale(.95); }
/* discs that the hovered move would flip */
.rv-pv .rv-disc { box-shadow: 0 0 0 3px #fff, 0 0 14px 3px rgba(255, 255, 255, .55); transform: scale(.94); transition: transform .12s; }


@media (max-width: 520px) {
  .rv-frame { padding: 5px; border-radius: 12px; }
  .rv-board { gap: 2px; padding: 2px; }
  .rv-pill { min-width: 92px; padding: 5px 10px; }
  .rv-pill b { font-size: 19px; }
  .rv-note { font-size: 12px; }
  .rv-slot { height: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .rv-drop, .rv-flip, .rv-dot, .rv-note { animation: none; }
}
