/* Reversi — own styles, theme variables only. Root class: .rv */

.rv {
  width: 100%;
  max-width: 640px;
}

/* ---------------------------------------------------------------- disc counts */

.rv-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.rv-score {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rv-score.is-turn {
  border-color: var(--gm-accent-line, rgba(192, 57, 43, 0.42));
  box-shadow: inset 0 0 0 1px var(--gm-accent-line, rgba(192, 57, 43, 0.42));
}

.rv-score-lab {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rv-score b {
  margin-left: auto;
  font: 500 1.35rem/1.15 var(--gm-display, "Fraunces", Georgia, serif);
  font-variant-numeric: tabular-nums;
}

.rv-disc {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.rv-disc.d,
.rv-piece.d {
  background: var(--gm-piece-b, #14161c);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2), 0 2px 3px rgba(0, 0, 0, 0.45);
}

.rv-disc.l,
.rv-piece.l {
  background: var(--gm-piece-w, #f7f3ea);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2), 0 2px 3px rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------- board */

.rv-board-wrap {
  width: 100%;
  padding: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.7);
}

.rv-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 2px;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--gm-board-edge, rgba(0, 0, 0, 0.45));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.rv-sq {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--gm-sq-dark, #2f6b4a);
  cursor: default;
  touch-action: manipulation;
}

.rv-sq.is-legal { cursor: pointer; }

.rv-sq.is-legal::after {
  content: "";
  position: absolute;
  inset: 36%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.38);
  transition: inset 0.15s ease;
}

.rv-sq.is-legal:hover::after { inset: 30%; }

.rv-sq:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: -3px;
  z-index: 2;
}

.rv-sq.is-last::before {
  content: "";
  position: absolute;
  top: 6%;
  right: 6%;
  width: 15%;
  height: 15%;
  border-radius: 50%;
  background: var(--gm-accent-bright, #e0584a);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
  z-index: 1;
}

.rv-piece {
  position: absolute;
  inset: 11%;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.rv-piece.is-on {
  opacity: 1;
  transform: scale(1);
}

.rv-piece.is-on::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
}

.rv-piece.l.is-on::after { border-color: rgba(0, 0, 0, 0.12); }

.rv-piece.is-flip { animation: rv-flip 0.4s ease; }
.rv-piece.is-new { animation: rv-pop 0.22s ease-out; }

.rv-sq.is-shake { animation: rv-shake 0.35s ease; }

@keyframes rv-flip {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(0.08); }
  100% { transform: scaleX(1); }
}

@keyframes rv-pop {
  0% { transform: scale(0.6); }
  100% { transform: scale(1); }
}

@keyframes rv-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5%); }
  75% { transform: translateX(5%); }
}

#gm-reversi .gm-status { margin-top: 12px; }

.gm-seg button,
.gm-actions .gm-btn { min-height: 44px; }

@media (max-width: 480px) {
  .rv-bar { gap: 6px; }
  .rv-score { padding: 8px 10px; gap: 8px; }
  .rv-score b { font-size: 1.2rem; }
  .rv-board-wrap { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .rv-piece, .rv-sq.is-legal::after { transition: none; }
  .rv-piece.is-flip, .rv-piece.is-new, .rv-sq.is-shake { animation: none; }
  .gm-status.is-thinking .gm-dot { animation: none; }
}
