:root {
  --cancha: #0E3B2E;
  --cancha-2: #15523F;
  --bola: #D7F34A;
  --bola-tinta: #1D2A05;
  --fondo: #F4F6F2;
  --tarjeta: #FFFFFF;
  --texto: #14201B;
  --suave: #5C6B64;
  --linea: #E2E7E3;
  --sube: #1F8A4C;
  --baja: #C2412D;
  --aviso: #B7791F;
  --radio: 18px;
  --sombra: 0 1px 2px rgba(14, 59, 46, .06), 0 6px 20px rgba(14, 59, 46, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0B1411;
    --tarjeta: #13201B;
    --texto: #E8EFEA;
    --suave: #93A39B;
    --linea: #22332C;
    --sube: #4ADE80;
    --baja: #F87171;
    --sombra: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--fondo); color: var(--texto);
  font-size: 15px; line-height: 1.45;
}
svg { flex: none; }
svg:not([width]) { width: 22px; height: 22px; }
.opcion svg { width: 24px; height: 24px; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select { font: inherit; color: inherit; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); position: relative; }

/* Encabezado */
.top { position: sticky; top: 0; z-index: 5; background: var(--fondo); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px; }
.top h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.02em; }
.marca { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -.03em; flex: 1; }
.marca img { width: 30px; height: 30px; border-radius: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--cancha); color: var(--bola); flex: none; }
.avatar.g { width: 52px; height: 52px; font-size: 18px; }
.avatar.xl { width: 84px; height: 84px; font-size: 30px; }

.pagina { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); border: 1px solid var(--linea); }
.tarjeta h3 { margin: 0 0 10px; font-size: 15px; }
.sec { font-size: 13px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .06em; margin: 6px 2px -4px; display: flex; justify-content: space-between; align-items: center; }
.sec a, .link { color: var(--cancha-2); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 14px; text-decoration: none; }
@media (prefers-color-scheme: dark) { .sec a, .link { color: var(--bola); } }
.suave { color: var(--suave); }
.peq { font-size: 13px; }
.fila { display: flex; align-items: center; gap: 12px; }
.fila .crece { flex: 1; min-width: 0; }
.nom { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Héroe de nivel */
.heroe { background: linear-gradient(150deg, var(--cancha) 0%, var(--cancha-2) 100%); color: #fff; border: 0; position: relative; overflow: hidden; }
.heroe::after { content: ''; position: absolute; right: -50px; top: -50px; width: 180px; height: 180px; border-radius: 50%; border: 2px solid rgba(215, 243, 74, .25); }
.heroe .et { color: rgba(255, 255, 255, .72); font-size: 13px; }
.nivel-big { font-size: 56px; font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--bola); }
.barra { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .18); overflow: hidden; margin-top: 6px; }
.barra > i { display: block; height: 100%; background: var(--bola); border-radius: 6px; }
.barra.clara { background: var(--linea); }
.barra.clara > i { background: var(--sube); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 14px; font-weight: 700; background: var(--bola); color: var(--bola-tinta); }
.btn.sec2 { background: var(--fondo); color: var(--texto); border: 1px solid var(--linea); }
.btn.oscuro { background: var(--cancha); color: var(--bola); }
.btn.ancho { width: 100%; }
.btn.chico { padding: 8px 12px; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.acciones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.accion { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 16px; padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; box-shadow: var(--sombra); }
.accion .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--fondo); }

/* Chips y etiquetas */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--linea); background: var(--tarjeta); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--cancha); color: var(--bola); border-color: var(--cancha); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 650; background: var(--fondo); color: var(--suave); }
.tag.verde { background: rgba(31, 138, 76, .12); color: var(--sube); }
.tag.bola { background: var(--bola); color: var(--bola-tinta); }
.tag.rojo { background: rgba(194, 65, 45, .12); color: var(--baja); }
.niv { font-weight: 800; font-size: 18px; min-width: 44px; text-align: center; padding: 6px 0; border-radius: 12px; background: var(--fondo); }
.sube { color: var(--sube); } .baja { color: var(--baja); }

/* Listas */
.lista > * + * { border-top: 1px solid var(--linea); }
.lista > * { padding: 12px 0; }
.lista > *:first-child { padding-top: 0; } .lista > *:last-child { padding-bottom: 0; }

/* Partidos abiertos */
.cupos { display: flex; gap: 6px; }
.cupo { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--cancha); color: var(--bola); }
.cupo.libre { background: transparent; border: 2px dashed var(--linea); color: var(--suave); }

/* Barra inferior */
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: var(--tarjeta); border-top: 1px solid var(--linea); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--suave); text-decoration: none; padding: 6px 0; border-radius: 12px; }
.nav a.on { color: var(--texto); }
.nav a.on svg { stroke: var(--bola-tinta); }
.nav a.on .pt { background: var(--bola); }
.nav .pt { padding: 3px 16px; border-radius: 999px; }
.nav svg { width: 22px; height: 22px; stroke: var(--suave); }

/* Hoja modal */
.velo { position: fixed; inset: 0; background: rgba(5, 15, 11, .5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.hoja { background: var(--tarjeta); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; animation: sube .22s ease-out; }
.hoja .asa { width: 40px; height: 5px; border-radius: 4px; background: var(--linea); margin: 0 auto 14px; }
.hoja h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
@keyframes sube { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.campo label { font-size: 13px; font-weight: 650; color: var(--suave); }
.campo input, .campo select { padding: 13px 14px; border-radius: 13px; border: 1px solid var(--linea); background: var(--fondo); font-size: 16px; }
.opciones { display: grid; gap: 8px; }
.opcion { text-align: left; padding: 14px; border-radius: 14px; border: 1.5px solid var(--linea); background: var(--tarjeta); font-weight: 600; display: flex; gap: 10px; align-items: center; }
.opcion.on { border-color: var(--cancha); background: rgba(215, 243, 74, .22); }
.opcion small { display: block; font-weight: 500; color: var(--suave); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* Bienvenida */
.bienvenida { min-height: 100vh; padding: calc(24px + env(safe-area-inset-top)) 20px 28px; display: flex; flex-direction: column; }
.pasos { display: flex; gap: 6px; margin-bottom: 26px; }
.pasos i { flex: 1; height: 4px; border-radius: 4px; background: var(--linea); }
.pasos i.on { background: var(--cancha); }
@media (prefers-color-scheme: dark) { .pasos i.on { background: var(--bola); } }
.bienvenida h2 { font-size: 28px; letter-spacing: -.03em; margin: 0 0 6px; line-height: 1.15; }
.portada { background: radial-gradient(circle at 70% 20%, #1d6a50 0%, var(--cancha) 60%); color: #fff; justify-content: space-between; }
.portada .logo { width: 84px; height: 84px; border-radius: 22px; }
.portada h2 { font-size: 40px; color: #fff; }
.portada .lema { color: var(--bola); font-weight: 700; font-size: 18px; }
.beneficios { display: grid; gap: 12px; margin: 26px 0; }
.beneficios div { display: flex; gap: 12px; align-items: center; color: rgba(255, 255, 255, .9); }
.beneficios b { width: 36px; height: 36px; border-radius: 10px; background: rgba(215, 243, 74, .15); display: grid; place-items: center; flex: none; }

/* Datos */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 16px; padding: 12px; box-shadow: var(--sombra); }
.kpi b { display: block; font-size: 22px; letter-spacing: -.02em; }
.kpi span { font-size: 12px; color: var(--suave); }
.grafico svg { width: 100%; height: auto; display: block; }
.barras-h > div { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; padding: 5px 0; }
.reloj { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.reloj div { background: var(--fondo); border-radius: 12px; padding: 10px; }
.reloj b { display: block; font-size: 18px; }
.reloj span { font-size: 11px; color: var(--suave); }

/* Explicación del nivel */
.explica { background: var(--fondo); border-radius: 14px; padding: 14px; font-size: 14px; }
.explica .paso { display: flex; justify-content: space-between; padding: 4px 0; }
.delta-big { font-size: 44px; font-weight: 800; letter-spacing: -.03em; }

/* Cuadro de torneo */
.cuadro { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.ronda { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.duelo { border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; font-size: 13px; background: var(--tarjeta); }
.duelo div { padding: 7px 10px; display: flex; justify-content: space-between; gap: 6px; }
.duelo div + div { border-top: 1px solid var(--linea); }
.duelo .gana { font-weight: 700; background: rgba(215, 243, 74, .25); }
.duelo .res { font-size: 12px; color: var(--suave); background: var(--fondo); padding: 4px 10px; font-variant-numeric: tabular-nums; }
.btn.ico { padding: 8px; border-radius: 11px; }

/* Aviso flotante */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--cancha); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; z-index: 30; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100% - 32px); width: max-content; text-align: center; animation: aparece .2s; }
@keyframes aparece { from { transform: translate(-50%, 16px); opacity: 0; } }

/* Interruptor */
.sw { width: 50px; height: 30px; border-radius: 999px; background: var(--linea); position: relative; flex: none; transition: background .15s; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.sw.on { background: var(--sube); }
.sw.on::after { transform: translateX(20px); }

.vacio { text-align: center; padding: 26px 10px; color: var(--suave); }
.chat { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.burbuja { max-width: 80%; padding: 10px 13px; border-radius: 16px; font-size: 14px; }
.burbuja.el { background: var(--fondo); align-self: flex-start; border-bottom-left-radius: 4px; }
.burbuja.yo { background: var(--cancha); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
