/* ==========================================================================
   LudoMus · estilos
   Idea visual: un naipe de la baraja española sobre el tapete verde, con los
   números de un marcador de torneo. Una sola tipografía (Archivo), estrecha
   y gruesa para cifras y títulos, normal para el texto.
   ========================================================================== */

@font-face {
  font-family: 'Archivo';
  src: url('fuentes/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --tapete: #14503A;          /* el verde de la mesa */
  --tapete-hondo: #0C3526;
  --tapete-claro: #1D6B4E;
  --naipe: #FBF8EE;           /* el marfil de la carta */
  --naipe-raya: #E3DCC6;
  --tinta: #16213F;           /* texto sobre el naipe */
  --tinta-suave: #566080;
  --azul: #1F3F99;            /* la raya azul de la baraja */
  --oro: #F5B700;
  --oro-hondo: #D69B00;
  --copa: #BF241B;            /* derrotas */
  --basto: #1B7442;           /* victorias y "Estoy de acuerdo" */
  --basto-hondo: #155C34;
  --sobre-tapete: #FBF8EE;
  --sobre-tapete-suave: #BAD3C6;

  --letra: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --alto-pestanas: 4.25rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 106.25%;          /* 17px: se lee bien en la mesa del bar */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--letra);
  font-stretch: 100%;
  line-height: 1.45;
  color: var(--sobre-tapete);
  background-color: var(--tapete);
  background-image: radial-gradient(120% 60% at 50% 0%, var(--tapete-claro) 0%, var(--tapete) 62%);
  background-attachment: fixed;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--oro);
  outline-offset: 2px;
}
.papel :focus-visible, dialog :focus-visible {
  outline-color: var(--azul);
}

.estrecha {
  font-stretch: 68%;
  font-weight: 800;
  letter-spacing: 0.005em;
}

.sin-js { padding: 2rem 1rem; text-align: center; }

/* El signo de ordinal (1º): más fino que la cifra, para que no parezca un cero. */
.grado {
  font-stretch: 100%;
  font-weight: 500;
  font-size: 0.82em;
  margin-left: 0.04em;
}

/* Texto solo para lectores de pantalla. */
.oculto {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Estructura ---------------------------------------------------------- */

.marco {
  max-width: 30rem;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 1rem calc(var(--alto-pestanas) + 1.5rem + env(safe-area-inset-bottom, 0px));
}
.marco.sin-pestanas { padding-bottom: 2rem; }

.cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0 0.6rem;
}
.marca {
  font-size: 1.6rem;
  line-height: 1;
  text-decoration: none;
  color: var(--sobre-tapete);
}
.marca b { color: var(--oro); font-weight: inherit; }
.cabecera-usuario {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  font-size: 0.94rem;
}
.cabecera-usuario span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sobre-tapete-suave);
}
.boton-salir {
  background: none;
  border: 1.5px solid rgba(251, 248, 238, 0.45);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  color: var(--sobre-tapete);
  font-weight: 600;
  min-height: 2.25rem;
}
.boton-salir:hover { border-color: var(--sobre-tapete); }

main { flex: 1; display: flex; flex-direction: column; }

.titulo {
  font-size: 2.1rem;
  line-height: 1.05;
  margin: 0.9rem 0 1rem;
}
.titulo:focus { outline: none; }
.entradilla {
  color: var(--sobre-tapete-suave);
  margin: -0.5rem 0 1rem;
}

/* --- Pestañas de abajo --------------------------------------------------- */

.pestanas {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--tapete-hondo);
  border-top: 1px solid rgba(251, 248, 238, 0.14);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 5;
}
.pestanas ul {
  max-width: 30rem;
  margin: 0 auto;
  display: flex;
  height: var(--alto-pestanas);
}
.pestanas li { flex: 1 1 auto; min-width: 0; }
.pestanas a {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0 0.3rem;
  text-decoration: none;
  text-align: center;
  color: var(--sobre-tapete-suave);
  font-size: clamp(0.64rem, 3.05vw, 0.72rem);
  font-stretch: 75%;
  font-weight: 600;
  line-height: 1.1;
}
.pestanas a:focus-visible { outline-offset: -3px; }
.pestanas svg { width: 1.5rem; height: 1.5rem; flex: none; }
.pestanas a[aria-current="page"] { color: var(--oro); }
.pestanas a[aria-current="page"]::before {
  content: '';
  position: absolute;
  top: -1px; left: 18%; right: 18%;
  height: 3px;
  background: var(--oro);
  border-radius: 0 0 3px 3px;
}
.globo {
  position: absolute;
  top: 0.45rem;
  left: calc(50% + 0.35rem);
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--copa);
  color: #fff;
  font-size: 0.72rem;
  font-stretch: 100%;
  font-weight: 700;
  line-height: 1.2rem;
}

/* --- Botones -------------------------------------------------------------- */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.7rem 1.25rem;
  border: 0;
  border-radius: 0.8rem;
  font-weight: 700;
  font-size: 1.06rem;
  text-decoration: none;
  text-align: center;
}
.boton[disabled] { opacity: 0.45; cursor: not-allowed; }

.boton-oro { background: var(--oro); color: var(--tinta); box-shadow: 0 3px 0 var(--oro-hondo); }
.boton-oro:not([disabled]):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--oro-hondo); }

.boton-verde {
  background: var(--basto);
  color: #fff;
  min-height: 4.25rem;
  font-size: 1.3rem;
  box-shadow: 0 3px 0 var(--basto-hondo);
}
.boton-verde:not([disabled]):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--basto-hondo); }

.boton-menor {
  background: none;
  color: var(--tinta);
  border: 1.5px solid var(--tinta-suave);
  min-height: 2.75rem;
  font-size: 0.94rem;
  font-weight: 600;
  width: auto;
  padding: 0.4rem 1.1rem;
}
.boton-claro {
  background: none;
  color: var(--sobre-tapete);
  border: 1.5px solid rgba(251, 248, 238, 0.5);
}

/* --- Papel: paneles claros sobre el tapete -------------------------------- */

.papel {
  background: var(--naipe);
  color: var(--tinta);
  border-radius: 1rem;
  padding: 1.1rem 1.1rem 1.2rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}
.papel + .papel { margin-top: 1rem; }
.papel h2 {
  font-size: 1.06rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}
.suave { color: var(--tinta-suave); }
.sobre-tapete-suave { color: var(--sobre-tapete-suave); }

.mensaje {
  border-radius: 0.7rem;
  padding: 0.7rem 0.9rem;
  margin: 0 0 1rem;
  font-weight: 600;
  background: #FBE4E1;
  color: #8E1710;
  border: 1.5px solid #E7A9A3;
}
.mensaje.bien { background: #DDF1E4; color: #0F4F2B; border-color: #9CCDB0; }
.mensaje[hidden] { display: none; }

.cargando, .vacio {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--sobre-tapete-suave);
}
.vacio strong { display: block; color: var(--sobre-tapete); font-size: 1.15rem; margin-bottom: 0.3rem; }
.fallo { text-align: center; padding: 2rem 0.5rem; }
.fallo p { margin-bottom: 1rem; }

/* --- Entrar / crear cuenta ------------------------------------------------- */

.portada {
  text-align: center;
  padding: 2.2rem 0 1.4rem;
}
.portada .marca { font-size: 3.4rem; }
.portada p { color: var(--sobre-tapete-suave); margin-top: 0.4rem; }

.conmutador {
  display: flex;
  background: #ECE6D3;
  border-radius: 0.75rem;
  padding: 0.25rem;
  margin-bottom: 1.1rem;
}
.conmutador button {
  flex: 1;
  border: 0;
  background: none;
  border-radius: 0.55rem;
  min-height: 2.75rem;
  font-weight: 700;
  color: var(--tinta-suave);
}
.conmutador button[aria-pressed="true"] {
  background: var(--naipe);
  color: var(--tinta);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.campo { margin-bottom: 0.9rem; }
.campo label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.campo input[type="text"], .campo input[type="password"], .campo input[type="search"] {
  width: 100%;
  min-height: 3.1rem;
  padding: 0.5rem 0.8rem;
  border: 1.5px solid #B9B29A;
  border-radius: 0.7rem;
  background: #fff;
  color: var(--tinta);
  font-size: 1.06rem;
}
.campo input:focus-visible { outline-offset: 0; border-color: var(--azul); }
.campo .ayuda { font-size: 0.86rem; color: var(--tinta-suave); margin-top: 0.3rem; }
.casilla {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: -0.2rem 0 1rem;
  font-size: 0.94rem;
}
.casilla input { width: 1.2rem; height: 1.2rem; accent-color: var(--azul); }

.apunta {
  border-left: 5px solid var(--oro);
  background: #FFF3C9;
  border-radius: 0 0.6rem 0.6rem 0;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1.1rem;
  font-weight: 600;
}

/* --- Principal: el naipe ---------------------------------------------------- */

.mesa {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 0.6rem;
}

.naipe {
  position: relative;
  width: min(15.5rem, 72vw);
  aspect-ratio: 62 / 88;
  background: var(--naipe);
  color: var(--tinta);
  border-radius: 1.1rem;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 14px 30px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transform: rotate(-1.5deg);
}
/* La raya azul del borde, con su "pinta" (el corte arriba y abajo). */
.naipe::before {
  content: '';
  position: absolute;
  inset: 0.7rem;
  border: 2px solid var(--azul);
  border-radius: 0.6rem;
  pointer-events: none;
}
.naipe::after {
  content: '';
  position: absolute;
  top: calc(0.7rem - 1px);
  bottom: calc(0.7rem - 1px);
  left: 50%;
  width: 1.5rem;
  margin-left: -0.75rem;
  background: linear-gradient(var(--naipe) 0 4px, transparent 4px calc(100% - 4px), var(--naipe) calc(100% - 4px));
  pointer-events: none;
}
.naipe-indice {
  position: absolute;
  top: 1.15rem;
  left: 1.25rem;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--azul);
}
.naipe-indice.abajo {
  top: auto; left: auto;
  bottom: 1.15rem;
  right: 1.25rem;
  transform: rotate(180deg);
}
.naipe-elo {
  font-size: clamp(4.4rem, 25vw, 5.6rem);
  line-height: 0.9;
  font-stretch: 62%;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.naipe-rotulo {
  margin-top: 0.5rem;
  font-weight: 700;
  color: var(--azul);
}
.naipe-puesto {
  margin-top: 0.15rem;
  font-size: 0.9rem;
  color: var(--tinta-suave);
}

.racha {
  margin-top: 1.7rem;
  display: flex;
  gap: 0.55rem;
}
.ficha {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
  border: 2px solid transparent;
}
.ficha.v { background: var(--oro); color: var(--tinta); }
.ficha.d { border-color: var(--sobre-tapete); color: var(--sobre-tapete); }
.ficha.nada { border: 2px dashed rgba(251, 248, 238, 0.35); color: rgba(251, 248, 238, 0.5); }
.racha-nota {
  margin-top: 0.55rem;
  font-size: 0.86rem;
  color: var(--sobre-tapete-suave);
  text-align: center;
}

.mesa .boton { margin-top: 1.5rem; }
.pendientes {
  width: 100%;
  margin-bottom: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.8rem;
  background: var(--naipe);
  color: var(--tinta);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}
.pendientes .globo { position: static; flex: none; }

/* --- Listas sobre papel ----------------------------------------------------- */

.lista > li {
  padding: 0.8rem 0;
  border-top: 1px solid var(--naipe-raya);
}
.lista > li:first-child { border-top: 0; padding-top: 0.1rem; }
.lista > li:last-child { padding-bottom: 0.1rem; }

/* Ranking */
.fila-ranking {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
}
.fila-ranking .puesto { font-size: 1.5rem; color: var(--azul); line-height: 1; }
.fila-ranking .nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-ranking .elo { font-size: 1.5rem; line-height: 1; font-variant-numeric: tabular-nums; }
.lista > li.yo {
  margin: 0 -1.1rem;
  padding-left: calc(1.1rem - 5px);
  padding-right: 1.1rem;
  border-left: 5px solid var(--oro);
  background: #FFF3C9;
  border-top-color: transparent;
}
.lista > li.yo + li { border-top-color: transparent; }
.etiqueta-yo { font-weight: 400; color: var(--tinta-suave); }
.mi-puesto { margin-top: 1rem; }

/* Histórico */
.fila-historico {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.75rem;
  align-items: start;
}
.fila-historico .resultado { font-weight: 800; font-size: 1.06rem; }
.fila-historico .resultado.v { color: var(--basto); }
.fila-historico .resultado.d { color: var(--copa); }
.fila-historico .detalle { grid-column: 1; font-size: 0.92rem; }
.fila-historico .fecha { grid-column: 1; font-size: 0.84rem; color: var(--tinta-suave); }
.fila-historico .cifras { grid-row: 1 / span 3; grid-column: 2; text-align: right; }
.fila-historico .cambio { font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.fila-historico .cambio.v { color: var(--basto); }
.fila-historico .cambio.d { color: var(--copa); }
.fila-historico .total { font-size: 0.84rem; color: var(--tinta-suave); margin-top: 0.2rem; }
.ver-mas { margin-top: 1rem; text-align: center; }

/* Notificaciones */
.lista-avisos > li { padding: 0; }
.lista-avisos > li:first-child .aviso { padding-top: 0.15rem; }
.lista-avisos > li:last-child .aviso { padding-bottom: 0.15rem; }
.aviso {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.6rem;
  align-items: center;
  padding: 0.85rem 0;
  text-decoration: none;
  color: inherit;
}
.aviso .texto { grid-column: 1; }
.aviso .texto b { font-weight: 800; }
.aviso .cuando { grid-column: 1; font-size: 0.84rem; color: var(--tinta-suave); }
.aviso .flecha { grid-row: 1 / span 2; grid-column: 2; width: 1.3rem; height: 1.3rem; color: var(--tinta-suave); }
.sello {
  display: inline-block;
  margin-right: 0.15rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: 0.08em;
}
.sello.pendiente { background: var(--oro); color: var(--tinta); }
.sello.nuevo { background: var(--azul); color: #fff; }
.lista-avisos > li.atendido .texto { color: var(--tinta-suave); }

/* --- Meter resultado -------------------------------------------------------- */

.pareja { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.hueco {
  min-height: 4rem;
  width: 100%;
  border-radius: 0.75rem;
  padding: 0.5rem 0.7rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.hueco .quien { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.hueco .dato { font-size: 0.84rem; color: var(--tinta-suave); }
.hueco .cambiar { font-size: 0.84rem; font-weight: 700; color: var(--azul); text-decoration: underline; text-underline-offset: 0.15em; }
.hueco.fijo { background: #ECE6D3; border: 1.5px solid transparent; }
.hueco.elegido { background: #fff; border: 1.5px solid var(--azul); }
.hueco.libre {
  background: none;
  border: 2px dashed #A9A28A;
  color: var(--azul);
  font-weight: 700;
  align-items: center;
  text-align: center;
}
.contra {
  text-align: center;
  margin: 0.7rem 0;
  font-size: 1.2rem;
  color: var(--tinta-suave);
}
.ganador { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.ganador label {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 4.2rem;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid #B9B29A;
  border-radius: 0.75rem;
  background: #fff;
  cursor: pointer;
  min-width: 0;
}
.ganador input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ganador .opcion { font-weight: 800; font-size: 1.1rem; }
.ganador .quienes { font-size: 0.84rem; color: var(--tinta-suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ganador label.marcada { border-color: var(--basto); background: #DDF1E4; box-shadow: inset 0 0 0 1.5px var(--basto); }
.ganador label:focus-within { outline: 3px solid var(--azul); outline-offset: 2px; }
.papel .boton-oro { margin-top: 1.1rem; }
.acciones { display: grid; gap: 0.7rem; margin-top: 1.1rem; }
.boton-menor.boton-ancho { width: 100%; }
.falta { margin-top: 0.8rem; font-size: 0.9rem; }

/* Elegir jugador */
dialog.elegir {
  width: min(28rem, calc(100vw - 1.5rem));
  max-height: min(34rem, calc(100dvh - 3rem));
  padding: 0;
  border: 0;
  border-radius: 1rem;
  background: var(--naipe);
  color: var(--tinta);
  overflow: hidden;
}
dialog.elegir[open] { display: flex; flex-direction: column; }
dialog.elegir::backdrop { background: rgba(6, 28, 20, 0.7); }
.elegir-cabeza {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem 0.6rem;
}
.elegir-cabeza h2 { font-size: 1.5rem; line-height: 1.1; }
.elegir-cuerpo { padding: 0 1.1rem; }
.elegir-cuerpo .campo { margin-bottom: 0.5rem; }
.elegir-lista { overflow-y: auto; padding: 0 1.1rem 1rem; }
.elegir-lista button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  min-height: 3.1rem;
  padding: 0.5rem 0.2rem;
  background: none;
  border: 0;
  border-top: 1px solid var(--naipe-raya);
  text-align: left;
  font-weight: 600;
}
.elegir-lista li:first-child button { border-top: 0; }
.elegir-lista button:hover { background: #F1EBD9; }
.elegir-lista .elo { color: var(--tinta-suave); font-weight: 400; font-variant-numeric: tabular-nums; }
.elegir-lista .nada { padding: 1.2rem 0; color: var(--tinta-suave); text-align: center; }

/* --- Partida: confirmar un resultado ---------------------------------------- */

.papel-partida { margin-top: 1rem; }
.veredicto { font-size: 2.6rem; line-height: 1; margin-bottom: 0.3rem; }
.veredicto.v { color: var(--basto); }
.veredicto.d { color: var(--copa); }
.equipos { margin: 1rem 0; display: grid; gap: 0.5rem; }
.equipo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.75rem;
  border: 1.5px solid var(--naipe-raya);
  background: #fff;
  font-weight: 700;
}
.equipo .nombres { min-width: 0; overflow-wrap: anywhere; }
.equipo .marca-equipo { flex: none; font-size: 0.84rem; font-weight: 700; color: var(--tinta-suave); }
.equipo.gana { border-color: var(--basto); }
.equipo.gana .marca-equipo { color: var(--basto); }
.equipos .contra { margin: 0; font-size: 1rem; }
.respuesta { margin-top: 1.2rem; display: grid; gap: 0.8rem; justify-items: center; }
.respuesta .regla { font-size: 0.88rem; color: var(--tinta-suave); text-align: center; }
.estado-partida { margin-top: 1rem; font-weight: 600; }
.volver { margin-top: 1rem; }

@media (min-width: 40rem) {
  .titulo { margin-top: 1.4rem; }
}

/* Pantallas bajas: el naipe se acorta para que quepa el botón. */
@media (max-height: 700px) {
  .naipe { width: min(13rem, 62vw); aspect-ratio: 62 / 72; }
  .naipe-elo { font-size: clamp(3.8rem, 21vw, 4.6rem); }
  .racha { margin-top: 1.3rem; }
  .ficha { width: 2.3rem; height: 2.3rem; font-size: 1.2rem; }
  .mesa .boton { margin-top: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .naipe { transform: none; }
}
