/* Competición Judo Club Tomodachi
   Pensado para móviles en un pabellón: contraste alto, botones grandes,
   números de tatami enormes (estilo marcador). */

:root {
  color-scheme: light;
  --papel: #f5f7fa;
  --superficie: #ffffff;
  --tinta: #17202a;
  --suave: #5b6775;
  --linea: #d9dee5;
  --azul: #1d4fa3;
  --azul-oscuro: #163d80;
  --azul-claro: #e6edf8;
  --tatami: #3e7d5a;
  --tatami-claro: #e3f0e8;
  --rojo: #c8322b;
  --rojo-claro: #fbe9e7;
  --ambar: #9a6412;
  --ambar-claro: #fdf3dc;
  --oro: #c9a227;
  --plata: #8e98a3;
  --bronce: #a8683a;
  --radio: 10px;
  --radio-grande: 14px;
  --texto: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --marcador: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html, body { margin: 0; }
body { overflow-x: hidden; }
body {
  font-family: var(--texto);
  font-size: 17px;
  line-height: 1.45;
  color: var(--tinta);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
h1 { font-family: var(--marcador); font-weight: 800; font-size: 2rem; letter-spacing: .01em; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0 0 .75em; }
a { color: var(--azul); }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
.oculto { display: none !important; }
.suave { color: var(--suave); }
.pequeno { font-size: .88rem; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Barra superior ---------- */
.barra {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem;
  background: var(--azul); color: #fff;
}
.barra .rol { font-family: var(--marcador); font-weight: 700; font-size: 1.35rem; white-space: nowrap; }
.barra .quien { font-size: .9rem; opacity: .85; margin-left: auto; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra button { flex: none; }
.barra button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); }
.conexion { width: .7rem; height: .7rem; border-radius: 50%; background: #7fd49c; flex: none; }
.conexion.sin { background: #ff8a80; }
.pendientes-sync {
  background: var(--ambar-claro); color: var(--ambar); font-weight: 600;
  padding: .4rem 1rem; font-size: .92rem;
}

.contenedor { max-width: 1180px; margin: 0 auto; padding: 1rem; }
.estrecho { max-width: 560px; }

/* ---------- Pestañas ---------- */
.pestanas {
  display: flex; gap: .25rem; overflow-x: auto; padding: 0 1rem;
  background: var(--superficie); border-bottom: 1px solid var(--linea);
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 3.1rem); z-index: 15;
}
.pestanas button {
  border: 0; background: none; border-radius: 0; padding: .85rem .9rem;
  font-weight: 600; color: var(--suave); border-bottom: 3px solid transparent; white-space: nowrap;
}
.pestanas button[aria-selected="true"] { color: var(--azul); border-bottom-color: var(--azul); }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; margin: .9rem 0 .3rem; }
.ayuda { font-weight: 400; color: var(--suave); font-size: .88rem; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=date],
input[type=datetime-local], input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: 3rem; padding: .6rem .8rem;
  border: 1.5px solid var(--linea); border-radius: var(--radio); background: var(--superficie); color: var(--tinta);
}
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--azul); outline: none; box-shadow: 0 0 0 3px var(--azul-claro); }
.pin { font-family: var(--marcador); font-size: 2.2rem; letter-spacing: .5em; text-align: center; font-weight: 700; }
.check { display: flex; gap: .7rem; align-items: flex-start; font-weight: 500; margin: .8rem 0; }
.check input { width: 1.4rem; height: 1.4rem; margin-top: .1rem; flex: none; accent-color: var(--azul); }
.opciones { display: flex; gap: .5rem; flex-wrap: wrap; }
.opciones label { margin: 0; flex: 1; }
.opciones input { position: absolute; opacity: 0; }
.opciones span {
  display: block; text-align: center; padding: .75rem; border: 1.5px solid var(--linea);
  border-radius: var(--radio); background: var(--superficie); cursor: pointer;
}
.opciones input:checked + span { border-color: var(--azul); background: var(--azul-claro); color: var(--azul-oscuro); }
.opciones input:focus-visible + span { outline: 3px solid var(--azul); }
.fila { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.texto-legal {
  max-height: 11rem; overflow: auto; padding: .75rem; background: var(--papel);
  border: 1px solid var(--linea); border-radius: var(--radio); font-size: .9rem; white-space: pre-wrap;
}

/* ---------- Botones ---------- */
button, .boton {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.75rem; padding: .5rem 1rem; border-radius: var(--radio);
  border: 1.5px solid var(--linea); background: var(--superficie); color: var(--tinta);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.primario:hover:not(:disabled) { background: var(--azul-oscuro); }
.exito { background: var(--tatami); border-color: var(--tatami); color: #fff; }
.peligro { background: var(--superficie); border-color: var(--rojo); color: var(--rojo); }
.peligro.lleno { background: var(--rojo); color: #fff; }
.grande { min-height: 3.5rem; font-size: 1.1rem; width: 100%; }
.enlace { border: 0; background: none; color: var(--azul); padding: .25rem; min-height: auto; text-decoration: underline; }
.botones { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* ---------- Tarjetas y listas ---------- */
.tarjeta {
  background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio-grande);
  padding: 1rem; margin-bottom: .75rem;
}
.tarjeta.marcada { border-left: 6px solid var(--azul); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { padding: .7rem 0; border-bottom: 1px solid var(--linea); }
.lista > li:last-child { border-bottom: 0; }
.persona { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.persona strong { font-weight: 700; }
.clic { cursor: pointer; }
.clic:hover { background: var(--papel); }

.aviso { padding: .7rem .9rem; border-radius: var(--radio); margin: .6rem 0; font-weight: 500; }
.aviso.info { background: var(--azul-claro); color: var(--azul-oscuro); }
.aviso.ok { background: var(--tatami-claro); color: #22553a; }
.aviso.alerta { background: var(--ambar-claro); color: var(--ambar); }
.aviso.error { background: var(--rojo-claro); color: var(--rojo); }

/* Estados */
.chip {
  display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .82rem; font-weight: 600;
  background: var(--papel); border: 1px solid var(--linea); color: var(--suave); white-space: nowrap;
}
.chip.sin_llegar { background: #eef0f3; }
.chip.pesado { background: var(--azul-claro); color: var(--azul-oscuro); border-color: #c6d4ee; }
.chip.esperando, .chip.pendiente { background: var(--ambar-claro); color: var(--ambar); border-color: #f0dcae; }
.chip.compitiendo, .chip.entregada { background: var(--tatami-claro); color: #22553a; border-color: #bcd9c7; }
.chip.competido, .chip.cerrada { background: #e9ebee; color: var(--tinta); }
.chip.reasignacion, .chip.alerta { background: var(--rojo-claro); color: var(--rojo); border-color: #f2c4bf; }
.resaltado { background: var(--rojo-claro) !important; }
.resaltado-suave { background: var(--ambar-claro) !important; }

.medalla { display: inline-flex; width: 1.6rem; height: 1.6rem; border-radius: 50%; align-items: center; justify-content: center;
  font-family: var(--marcador); font-weight: 800; color: #fff; font-size: .95rem; flex: none; }
.medalla.oro { background: var(--oro); }
.medalla.plata { background: var(--plata); }
.medalla.bronce { background: var(--bronce); }
.medalla.participacion { background: #cfd5dc; color: var(--tinta); }

/* ---------- Contadores del panel ---------- */
.contadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.contador { background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio); padding: .6rem .8rem; }
.contador b { display: block; font-family: var(--marcador); font-size: 2.2rem; line-height: 1; font-weight: 800; }
.contador span { color: var(--suave); font-size: .9rem; }

/* ---------- Tatamis: el elemento con más carácter ---------- */
.tatamis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tatami {
  position: relative; background: var(--tatami-claro); border: 3px solid var(--tatami);
  border-radius: var(--radio-grande); padding: .7rem .8rem .8rem; min-height: 9rem;
}
.tatami.fuera { background: repeating-linear-gradient(135deg, #f3f4f6 0 12px, #e8eaee 12px 24px); border-color: var(--rojo); }
.tatami-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.tatami-num {
  font-family: var(--marcador); font-weight: 800; font-size: 4rem; line-height: .85;
  color: var(--tatami); font-variant-numeric: tabular-nums;
}
.tatami.fuera .tatami-num { color: var(--rojo); }
.tatami-meta { text-align: right; font-size: .85rem; color: var(--suave); }
.lig {
  display: grid; grid-template-columns: auto 1fr auto; gap: .1rem .6rem; align-items: center;
  background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: .45rem .6rem; margin-top: .45rem; cursor: pointer; width: 100%; text-align: left; font-weight: 400;
  min-height: auto;
}
.lig.entregada { border-left: 5px solid var(--tatami); }
.lig.pendiente { border-left: 5px solid var(--oro); }
.lig .n { font-family: var(--marcador); font-weight: 800; font-size: 1.6rem; line-height: 1; grid-row: span 2; }
.lig .et { font-weight: 600; font-size: .95rem; }
.lig .pr { font-size: .82rem; color: var(--suave); }
.barra-progreso { height: 5px; background: var(--linea); border-radius: 3px; overflow: hidden; grid-column: 2 / 4; }
.barra-progreso i { display: block; height: 100%; background: var(--tatami); }

/* ---------- Pantalla de tatami ---------- */
.combate {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: .5rem;
  width: 100%; padding: .7rem; margin: .45rem 0; text-align: left; font-weight: 500; min-height: 4rem;
}
.combate .lado { display: flex; flex-direction: column; justify-content: center; }
.combate .lado.azul { text-align: right; }
.combate .vs { align-self: center; font-family: var(--marcador); color: var(--suave); font-weight: 700; }
.combate .ronda { grid-column: 1 / -1; font-size: .8rem; color: var(--suave); font-weight: 600; }
.combate.hecho { background: var(--papel); }
.combate .gana { font-weight: 800; }
.combate .pierde { color: var(--suave); text-decoration: line-through; text-decoration-thickness: 1px; }
.combate.sin-enviar { border-color: var(--ambar); border-style: dashed; }
.descanso { color: var(--ambar); font-size: .82rem; font-weight: 700; }
.lado-judogi { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; border: 1.5px solid var(--tinta); vertical-align: -1px; margin-right: .3rem; }
.lado-judogi.blanco { background: #fff; }
.lado-judogi.azul { background: var(--azul); border-color: var(--azul); }

.elegir-ganador { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.elegir-ganador button { min-height: 6rem; flex-direction: column; font-size: 1.1rem; padding: .7rem; }
.elegir-ganador .blanco[aria-pressed="true"] { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.elegir-ganador .azul { border-color: var(--azul); }
.elegir-ganador .azul[aria-pressed="true"] { background: var(--azul); color: #fff; }
.puntuaciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; }
.puntuaciones button { min-height: 3.5rem; font-size: 1.05rem; }
.puntuaciones button[aria-pressed="true"] { background: var(--tatami); border-color: var(--tatami); color: #fff; }

/* ---------- Tablas ---------- */
.tabla-caja { overflow-x: auto; border: 1px solid var(--linea); border-radius: var(--radio); background: var(--superficie); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--linea); text-align: left; vertical-align: top; }
th { background: var(--papel); font-weight: 700; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }

/* ---------- Modal ---------- */
.fondo-modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(23,32,42,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--superficie); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto;
  border-radius: var(--radio-grande) var(--radio-grande) 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 720px) {
  .fondo-modal { align-items: center; }
  .modal { border-radius: var(--radio-grande); }
}
.modal-cab { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.modal-cab h2 { margin: 0; }

/* ---------- Avisos flotantes ---------- */
#avisos { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: .4rem; width: min(92vw, 480px); }
.toast { background: var(--tinta); color: #fff; padding: .75rem 1rem; border-radius: var(--radio); font-weight: 500; }
.toast.error { background: var(--rojo); }
.toast.ok { background: var(--tatami); }

/* ---------- Portada de roles ---------- */
.roles { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.roles a { display: block; padding: 1rem; border-radius: var(--radio-grande); background: var(--superficie);
  border: 1px solid var(--linea); text-decoration: none; color: var(--tinta); }
.roles a strong { display: block; font-family: var(--marcador); font-size: 1.5rem; }

.numero-grande { font-family: var(--marcador); font-weight: 800; font-size: 4.5rem; line-height: 1; color: var(--azul); }
.grupo-prop { border: 1px solid var(--linea); border-radius: var(--radio); padding: .6rem; margin: .5rem 0; background: var(--superficie); }
.grupo-prop.excede { border-color: var(--rojo); background: var(--rojo-claro); }
.pct { font-family: var(--marcador); font-weight: 700; font-size: 1.2rem; }
.pct.excede { color: var(--rojo); }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: entra .18s ease-out; }
  @keyframes entra { from { transform: translateY(8px); opacity: 0; } }
}

/* ---------- Impresión (PDF de resultados) ---------- */
#impresion { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  #app, #avisos { display: none !important; }
  #impresion { display: block; }
  .inf-portada { border-bottom: 3px solid var(--azul); padding-bottom: 6mm; margin-bottom: 6mm; }
  .inf-portada h1 { font-size: 26pt; color: var(--azul); }
  .inf-bloque { break-inside: avoid; margin-bottom: 6mm; }
  .inf-lig { break-inside: avoid; border: 1px solid #bbb; border-radius: 4px; padding: 3mm; margin-bottom: 4mm; }
  .inf-lig h3 { margin: 0 0 2mm; }
  .inf-salto { break-before: page; }
  table { font-size: 9.5pt; }
  th { position: static; }
  .medalla { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  th, .inf-portada { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- Portada con logo ---------- */
.portada-cab { display: flex; align-items: center; gap: 1rem; margin: .5rem 0 1rem; }
.portada-logo { width: 88px; height: auto; flex: none; }
.portada-cab h1 { margin: 0; }

/* ---------- Nuevo estado y podio ---------- */
.chip.medalla_entregada { background: #f6efd9; color: #7a5c12; border-color: #e6d49c; }
.podio-lista { list-style: none; margin: .5rem 0 0; padding: 0; }
.podio-lista li { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--linea); font-size: 1.05rem; }
.podio-lista li:last-child { border-bottom: 0; }
.podio-lista .medalla { width: 2rem; height: 2rem; font-size: 1.1rem; }

/* ---------- Secciones de configuración ---------- */
.secciones { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.secciones button[aria-pressed="true"] { background: var(--azul); border-color: var(--azul); color: #fff; }

/* ---------- Buscador del panel ---------- */
.buscador-res { margin-top: .5rem; }
.buscador-res li { display: flex; justify-content: space-between; gap: .75rem; align-items: center; flex-wrap: wrap; }
