/* =========================================================
   RatoLibre — Reversi (estilos propios del juego)
   ========================================================= */

/* ---------- Barra de herramientas ---------- */

.rv-opcion {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  font-weight: 700;
}

/* Las dos etiquetas miden lo mismo para que las listas queden alineadas */
.rv-opcion > span {
  flex: 0 0 auto;
  min-width: 4.8em;
}

.rv-opcion select {
  flex: 1 1 auto;
  min-height: 48px;
  min-width: 0;
  padding: 0 40px 0 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%231f2a37' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M4 7l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.rv-opcion select:hover {
  border-color: var(--accent);
}

/* ---------- Zona de juego ---------- */

.rv-area {
  padding: 16px;
}

.rv-cuerpo {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rv-principal,
.rv-lateral {
  min-width: 0;
}

/* ---------- Marcador (fichas de cada uno) ---------- */

.rv-marcador {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin: 0 0 10px;
}

.rv-jugador {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 6px 12px;
  border: 3px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.rv-jugador.es-turno {
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
}

.rv-muestra {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.rv-muestra .rv-ficha {
  width: 34px;
  height: 34px;
}

.rv-cuenta {
  font-size: 1.5rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.rv-nombre {
  grid-column: 1 / span 2;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--muted);
}

.rv-jugador.es-turno .rv-nombre {
  color: var(--accent-2);
}

/* ---------- Mensaje ---------- */

/* Alto fijo para el mensaje más largo (cuatro renglones en el celular, tres
   desde 600 px y cinco en celulares de menos de 360 px): así el tablero de
   abajo no salta cuando cambia el mensaje. */
.rv-mensaje {
  display: flex;
  align-items: center;
  height: calc(6em + 16px);
  margin: 0 0 12px;
  padding: 8px 12px;
  border-left: 4px solid var(--accent);
  background: var(--bg);
  border-radius: 0 8px 8px 0;
  font-weight: 600;
  overflow: hidden;
}

.rv-mensaje.es-pensando {
  border-left-color: var(--accent-2);
}

/* ---------- Tablero ---------- */

.rv-marco {
  display: flex;
  justify-content: center;
}

.rv-tablero {
  /* Casillas de 56 px en pantallas grandes; en las medianas se achican para
     que el tablero quepa sin desbordar. */
  --casilla: clamp(32px, calc((100vw - 104px) / 8), 56px);
  --etiqueta-ancho: 24px;
  --etiqueta-alto: 26px;
  display: grid;
  grid-template-columns: var(--etiqueta-ancho) repeat(8, var(--casilla));
  grid-template-rows: var(--etiqueta-alto) repeat(8, var(--casilla));
  padding: 0 5px 5px 0;
  border-radius: 12px;
  background: #173d28;
  box-shadow: var(--shadow-lg);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.rv-etiqueta {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: #f3efe6;
}

.rv-casilla {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--casilla);
  height: var(--casilla);
  margin: 0;
  padding: 0;
  border: 1px solid #12321f;
  border-radius: 0;
  background: #2e7d4f;
  font: inherit;
  color: inherit;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.rv-casilla:focus {
  outline: none;
}

.rv-casilla:focus-visible {
  z-index: 2;
  outline: 4px solid #ffffff;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 7px #1f2a37;
}

/* Casilla donde puedes poner */
.rv-casilla.es-posible {
  cursor: pointer;
}

.rv-casilla.es-posible::before {
  content: "";
  width: 36%;
  height: 36%;
  border-radius: 50%;
  background: #ffd54a;
  border: 2px solid #1f2a37;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

@media (hover: hover) {
  .rv-casilla.es-posible:hover {
    background: #3c9663;
  }
}

/* Última ficha que puso la computadora: aro anaranjado */
.rv-casilla.es-ultima::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 4px solid #ff8a3d;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px #1f2a37, 0 0 0 1px #1f2a37;
  pointer-events: none;
}

/* ---------- Fichas ---------- */

.rv-ficha {
  display: block;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  pointer-events: none;
}

.rv-ficha[hidden] {
  display: none;
}

.rv-ficha.es-negra {
  background: radial-gradient(circle at 35% 30%, #6b7480 0%, #262b31 45%, #08090b 100%);
  border: 2px solid #c9c1b2;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45);
}

.rv-ficha.es-blanca {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f4f0e8 50%, #c9c1b2 100%);
  border: 2px solid #1f2a37;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45);
}

.rv-ficha.es-nueva {
  animation: rv-poner 0.22s ease-out;
}

.rv-ficha.es-girando {
  animation: rv-girar 0.36s ease-in-out;
}

/* ---------- Panel lateral ---------- */

.rv-lateral {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}

.rv-lateral .btn {
  flex: 0 1 auto;
  min-width: 160px;
  max-width: 320px;
}

.rv-leyenda {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 16px;
  line-height: 1.4;
  color: var(--muted);
}

.rv-leyenda li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
}

.rv-ley-punto,
.rv-ley-aro {
  flex: 0 0 auto;
  display: inline-block;
  box-sizing: border-box;
}

.rv-ley-punto {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd54a;
  border: 2px solid #1f2a37;
}

.rv-ley-aro {
  width: 20px;
  height: 20px;
  border: 4px solid #ff8a3d;
  border-radius: 5px;
  background: #2e7d4f;
  box-shadow: 0 0 0 1px #1f2a37;
}

/* ---------- Resultados ---------- */

.rv-estado {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 16px 0;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.rv-estado .dato {
  display: flex;
  flex-direction: column;
  min-width: 6ch;
}

.rv-estado .etiqueta {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.rv-estado strong {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Paneles (final y confirmación) ---------- */

.rv-panel {
  margin: 0 0 16px;
  padding: 20px 16px;
  border: 2px solid var(--accent-2);
  border-radius: var(--radius);
  background: var(--accent-2-soft);
  text-align: center;
  animation: rv-entrar 0.35s ease-out;
}

.rv-panel[hidden] {
  display: none;
}

.rv-panel:focus {
  outline: none;
}

.rv-panel .titulo {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--accent-2);
}

.rv-panel.es-derrota,
.rv-confirmar {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.rv-panel.es-derrota .titulo,
.rv-confirmar .titulo {
  color: var(--accent-dark);
}

.rv-panel.es-empate {
  border-color: var(--border);
  background: var(--bg);
}

.rv-panel.es-empate .titulo {
  color: var(--text);
}

.rv-panel p {
  margin: 0 0 0.6rem;
}

.rv-panel .botones {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.rv-panel .botones .btn {
  flex: 1 1 200px;
  max-width: 320px;
}

/* ---------- Animaciones ---------- */

@keyframes rv-entrar {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@keyframes rv-poner {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

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

/* ---------- Pantallas medianas y grandes ---------- */

@media (min-width: 600px) {
  .rv-mensaje {
    height: calc(4.5em + 16px);
  }
}

@media (min-width: 720px) {
  .rv-opcion {
    flex: 0 1 auto;
  }

  .rv-opcion select {
    min-width: 150px;
  }
}

@media (min-width: 980px) {
  .rv-cuerpo {
    flex-direction: row;
    align-items: flex-start;
    gap: 28px;
  }

  .rv-principal {
    flex: 0 0 auto;
    width: calc(8 * 56px + 24px + 5px);
  }

  .rv-lateral {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---------- Celular ---------- */

/* En el celular el tablero ocupa todo el ancho de la pantalla: así cada
   casilla mide 40 px a 375 px. Va al final para ganarle a las reglas de
   arriba. */
@media (max-width: 479px) {
  .rv-area {
    max-width: none;
    margin-left: -16px;
    margin-right: -16px;
    padding: 12px 0 16px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .rv-panel,
  .rv-marcador,
  .rv-mensaje,
  .rv-lateral {
    margin-left: 12px;
    margin-right: 12px;
  }

  .rv-tablero {
    --casilla: clamp(32px, calc((100vw - 52px) / 8), 56px);
    --etiqueta-ancho: 18px;
    --etiqueta-alto: 24px;
    padding: 0 4px 4px 0;
    border-radius: 10px;
  }

  .rv-lateral .btn {
    flex: 1 1 auto;
  }
}

/* En los celulares más angostos el mensaje más largo ocupa cinco renglones. */
@media (max-width: 359px) {
  .rv-mensaje {
    height: calc(7.5em + 16px);
  }
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
  .rv-panel,
  .rv-ficha.es-nueva,
  .rv-ficha.es-girando {
    animation: none;
  }
}
