:root {
  --verde: #167746;
  --verde-oscuro: #0c4f2d;
  --fondo: #f3f6f4;
  --blanco: #ffffff;
  --texto: #202621;
  --gris: #69736d;
  --borde: #dfe6e1;
  --dorado: #d99c16;
  --rojo: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: Arial, Helvetica, sans-serif;
}

header {
  padding: 24px 16px 20px;
  background: linear-gradient(
    135deg,
    var(--verde-oscuro),
    var(--verde)
  );
  color: white;
}

.encabezado-contenido {
  width: min(1100px, 100%);
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.encabezado-contenido > div {
  text-align: center;
}

.logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 50%;
  background: white;
  padding: 6px;
}

header h1 {
  margin: 0;
  font-size: 26px;
}

header p {
  margin: 6px 0 0;
  opacity: .9;
}

nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  background: white;
  border-bottom: 1px solid var(--borde);
}

nav button {
  padding: 15px 8px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: white;
  color: var(--gris);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: .2s;
}

nav button:hover {
  color: var(--verde);
}

nav button.activo {
  color: var(--verde);
  border-bottom-color: var(--verde);
}

main {
  width: min(1100px,100%);
  margin: auto;
  padding: 18px 12px 40px;
}

.titulo-seccion {
  margin: 4px 2px 16px;
  font-size: 22px;
}

.tarjeta {
  overflow: hidden;
  background: white;
  border-radius: 14px;
  border: 1px solid var(--borde);
  box-shadow: 0 4px 16px rgba(0,0,0,.05);
}

.tabla-contenedor {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--borde);
  text-align: left;
  white-space: nowrap;
}

th {
  background:#edf5ef;
  color:#0f5c34;
  font-size:12px;
  letter-spacing:.5px;
  font-weight:700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.numero {
  text-align: right;
  font-weight: bold;
}

.posicion {
  width: 80px;
  text-align: center;
  font-weight: bold;
}

.positivo {
  color: var(--verde);
}

.negativo {
  color: var(--rojo);
}

.estado {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e8f3ec;
  color: var(--verde-oscuro);
  font-size: 12px;
  font-weight: bold;
}

.filtros-categoria {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--borde);
}

.filtro-categoria{
    transition:.2s;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--borde);
  background: white;
  cursor: pointer;
  font-weight: bold;
}

.filtro-categoria:hover{
    background:#f4f8f5;
}

.filtro-categoria.activo {
  background: var(--verde);
  color: white;
  border-color: var(--verde);
}

.cargando,
.vacio,
.error {
  padding: 35px;
  text-align: center;
}

.error {
  color: var(--rojo);
}

@media (max-width:600px){

  .encabezado-contenido{
    flex-direction:column;
    text-align:center;
  }

  .logo{
    width:60px;
    height:60px;
  }

  header h1{
    font-size:22px;
  }

  nav button{
    font-size:12px;
    padding:13px 4px;
  }

  main{
    padding:14px 8px 30px;
  }

  .titulo-seccion{
    font-size:19px;
  }
}

/* =====================================================
   FASE 1 - RANKING PREMIUM
===================================================== */

.ranking-herramientas{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:16px;
    margin:22px 0;
    flex-wrap:wrap;
}

.campo-busqueda{
    min-width:330px;
    display:flex;
    align-items:center;
    gap:10px;
    background:#fff;
    border:1px solid var(--borde);
    border-radius:999px;
    padding:10px 16px;
}

.campo-busqueda input{
    border:none;
    outline:none;
    font-size:15px;
    background:transparent;
    width:220px;
}

.campo-orden{
    display:flex;
    align-items:center;
    gap:10px;
    font-weight:bold;
}

.campo-orden select{
    padding:9px 14px;
    border-radius:10px;
    border:1px solid var(--borde);
    background:white;
}

.lider-ranking{
    display:flex;
    align-items:center;
    gap:18px;
    padding:18px 24px;
    margin-bottom:18px;
    background:linear-gradient(135deg,#0f5c34,#198754);
    color:white;
    border-radius:16px;
    box-shadow:0 6px 18px rgba(0,0,0,.12);
}

.lider-icono{
    font-size:44px;
}

.lider-etiqueta{
    display:block;
    font-size:14px;
    opacity:.85;
    margin-bottom:2px;
}

.lider-nombre{
    display:block;
    font-size:22px;
    font-weight:700;
    margin-bottom:4px;
}

.lider-detalle{
    font-size:15px;
    opacity:.95;
}

.ranking-tabla table tbody tr{
    transition:.18s;
}

.ranking-tabla tbody tr{
    transition:.15s;
}

.ranking-tabla tbody tr:hover{
    background:#eef8f1;
}

.podio-1{
    background:#fff8db;
}

.podio-2{
    background:#f6f6f6;
}

.podio-3{
    background:#fff2e7;
}

.medalla-ranking{
    font-size:22px;
}

.numero-posicion{
    font-weight:bold;
    color:#666;
}

.insignia-lider{
    display:inline-block;
    margin-left:8px;
    padding:2px 8px;
    border-radius:999px;
    background:#198754;
    color:white;
    font-size:10px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.4px;
}

.puntos-ranking{
    font-size:18px;
    font-weight:700;
    color:#0f5c34;
}

.sin-resultados{
    padding:40px;
    text-align:center;
    color:#777;
}

@media(max-width:700px){

    .ranking-herramientas{
        flex-direction:column;
        align-items:stretch;
    }

    .campo-busqueda{
        width:100%;
    }

    .campo-busqueda input{
        width:100%;
    }

    .campo-orden{
        justify-content:space-between;
    }

    .lider-ranking{
        padding:18px;
    }

    .lider-icono{
        font-size:40px;
    }

    .lider-nombre{
        font-size:22px;
    }

}

/* =====================================================
   PARTIDOS
===================================================== */

.partidos-contenedor {
  display: grid;
  gap: 28px;
}

.grupo-partidos {
  display: grid;
  gap: 14px;
}

.grupo-partidos-encabezado {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.grupo-partidos-encabezado h3 {
  margin: 0;
  font-size: 20px;
}

.cantidad-partidos {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f3ec;
  color: var(--verde-oscuro);
  font-size: 13px;
  font-weight: bold;
}

.lista-partidos {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
}

.tarjeta-partido {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--borde);
  border-radius: 16px;
  background: white;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .06);
}

.tarjeta-partido::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 5px;
}

.tarjeta-partido.programado::before {
  background: #1976d2;
}

.tarjeta-partido.finalizado::before {
  background: var(--verde);
}

.tarjeta-partido.anulado::before {
  background: var(--rojo);
}

.partido-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--borde);
}

.partido-fecha {
  display: block;
  font-size: 16px;
  font-weight: bold;
}

.partido-tipo {
  display: inline-block;
  margin-top: 5px;
  color: var(--gris);
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}

.estado-partido {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: bold;
}

.estado-programado {
  background: #e8f1fb;
  color: #125b9e;
}

.estado-finalizado {
  background: #e8f3ec;
  color: var(--verde-oscuro);
}

.estado-anulado {
  background: #fbe9e7;
  color: var(--rojo);
}

.partido-competencia {
  display: grid;
  gap: 6px;
  padding: 14px 20px;
  background: #f7faf8;
  color: var(--gris);
  font-size: 13px;
}

.partido-competencia strong {
  color: var(--texto);
}

.enfrentamiento {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 22px 20px;
}

.jugador-partido {
  min-width: 0;
  text-align: center;
}

.jugador-partido strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.jugador-etiqueta {
  display: block;
  margin-bottom: 5px;
  color: var(--gris);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.versus {
  width: 42px;
  height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background: var(--verde);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.ganador-partido {
  display: inline-block;
  margin-top: 7px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff5d6;
  color: #876000;
  font-size: 11px;
  font-weight: bold;
}

.resultado-partido {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 20px;
  border-top: 1px solid var(--borde);
  background: #fbfcfb;
}

.resultado-partido > div {
  display: grid;
  gap: 4px;
}

.resultado-etiqueta {
  color: var(--gris);
  font-size: 11px;
  text-transform: uppercase;
}

.resultado-marcador {
  color: var(--verde-oscuro);
  font-size: 18px;
}

.mensaje-partido-anulado {
  padding: 14px 20px;
  border-top: 1px solid var(--borde);
  background: #fff6f5;
  color: var(--rojo);
  text-align: center;
  font-size: 13px;
  font-weight: bold;
}

@media (max-width: 600px) {
  .lista-partidos {
    grid-template-columns: 1fr;
  }

  .partido-cabecera {
    padding: 16px;
  }

  .partido-competencia {
    padding: 13px 16px;
  }

  .enfrentamiento {
    grid-template-columns: 1fr;
    padding: 18px 16px;
  }

  .versus {
    width: 36px;
    height: 36px;
    margin: auto;
  }

  .resultado-partido {
    flex-direction: column;
    padding: 14px 16px;
  }
}

/* =====================================================
   MOVIMIENTOS DEL RANKING
===================================================== */

.movimientos-tabla {
    width: 95%;
    margin: 0 auto;
}

.movimientos-tabla table {
    width: 100%;
    min-width: 1450px;
}

/* Anchos de columnas */
.movimientos-tabla th:nth-child(1),
.movimientos-tabla td:nth-child(1) {
    width: 110px;   /* Fecha */
}

.movimientos-tabla th:nth-child(2),
.movimientos-tabla td:nth-child(2) {
    width: 180px;   /* Tenista */
}

.movimientos-tabla th:nth-child(3),
.movimientos-tabla td:nth-child(3) {
    width: 190px;   /* Tipo */
}

.movimientos-tabla th:nth-child(4),
.movimientos-tabla td:nth-child(4) {
    width: 110px;   /* Puntos */
}

.movimientos-tabla th:nth-child(5),
.movimientos-tabla td:nth-child(5) {
    width: 260px;   /* Torneo */
}

/* Descripción ocupa todo el espacio restante */
.movimientos-tabla th:nth-child(6),
.movimientos-tabla td:nth-child(6) {
    min-width: 600px;
}

.movimientos-tabla td {
    vertical-align: middle;
}

/* Hace los puntos más grandes */
.puntos-movimiento {
    font-size: 16px;
    font-weight: 800;
}

/* Mantiene fijo el encabezado */
.movimientos-tabla thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef8f2; /* mismo color del encabezado */
}

.tipo-movimiento {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  white-space: nowrap;
}

.tipo-movimiento-icono {
  font-size: 16px;
}

.tipo-torneo {
  color: #1976d2;
}

.tipo-desafio {
  color: #008f83;
}

.tipo-anulado {
  color: #d97706;
}

.tipo-otro {
  color: var(--gris);
}

.puntos-movimiento {
  font-weight: 800;
  white-space: nowrap;
}

.descripcion-movimiento{
    min-width:550px;
    max-width:700px;
    line-height:1.45;
}