:root {
  --fondo: #ffffff;
  --papel: #f5f6f8;
  --texto: #14171c;
  --suave: #626a77;
  --linea: #e4e7ec;
  --azul: #002d62;
  --rojo: #ce1126;
  --barra: #002d62;
  --pista: #eceef2;
  --error: #b42318;
  --radio: 14px;
  --ojo: #002d62;
  --em: #ce1126;
  --sobre-barra: #fff;
  --boton: #002d62;
  --sobre-boton: #fff;
  color-scheme: light;
}
/* Noche: se activa con el botón (data-theme="dark") o, si nadie eligió, con el modo del teléfono */
:root[data-theme="dark"] {
  --fondo: #0f1115; --papel: #181b21; --texto: #eef0f3; --suave: #9aa3b0; --linea: #272b33;
  --barra: #4f8dff; --pista: #1f232b; --error: #ff7b72;
  --ojo: #8fb4ff; --em: #ff6b78; --sobre-barra: #0b1020; --boton: #4f8dff; --sobre-boton: #0b1020;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #0f1115; --papel: #181b21; --texto: #eef0f3; --suave: #9aa3b0; --linea: #272b33;
    --barra: #4f8dff; --pista: #1f232b; --error: #ff7b72;
    --ojo: #8fb4ff; --em: #ff6b78; --sobre-barra: #0b1020; --boton: #4f8dff; --sobre-boton: #0b1020;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.solo-lector { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }

/* ---------- Cabeza ---------- */
.cabeza, main, .pie { width: min(100%, 560px); margin-inline: auto; padding-inline: 16px; }
.cabeza { padding-top: 20px; }
.marca { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.logo { flex: none; width: 48px; height: 48px; border-radius: 14px; background: #fff; border: 1px solid var(--linea); display: grid; place-items: center; }
.logo img { display: block; width: 36px; height: 36px; }
.marca-texto { display: grid; line-height: 1.15; min-width: 0; }
.acciones { margin-left: auto; flex: none; display: flex; gap: 8px; }
.redondo {
  flex: none; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; padding: 0;
  display: grid; place-items: center; background: var(--papel); border: 1px solid var(--linea); color: var(--texto);
  -webkit-tap-highlight-color: transparent; transition: background .2s;
}
.redondo:focus-visible { outline: 2px solid var(--barra); outline-offset: 2px; }
.redondo svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Compartir */
.secundario {
  width: 100%; min-height: 48px; border-radius: var(--radio); background: transparent; color: var(--texto);
  border: 1px solid var(--linea); font-weight: 600; cursor: pointer; margin-top: 10px;
}
.secundario:focus-visible, .texto-boton:focus-visible, .red:focus-visible { outline: 2px solid var(--barra); outline-offset: 2px; }
.texto-boton { width: 100%; min-height: 44px; margin-top: 6px; background: none; border: 0; color: var(--suave); cursor: pointer; text-decoration: underline; }
.listo-invita { margin: 0 0 18px; text-align: center; font-size: .92rem; color: var(--suave); }
.listo-invita strong { color: var(--texto); }
.invita { margin-top: 16px; padding: 14px; border: 1px solid var(--linea); border-radius: var(--radio); background: var(--papel); }
.invita p { margin: 0; font-size: .9rem; color: var(--suave); }
.invita p strong { color: var(--texto); }
.invita .secundario { margin-top: 10px; background: var(--fondo); }
.promesa-suave { margin: 0 0 16px !important; color: var(--suave); }
.redes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.red {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: var(--radio);
  border: 1px solid var(--linea); background: var(--papel); color: var(--texto); font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; text-align: left;
}
/* Íconos de línea (PNG negro con transparencia) pintados con el color del texto: sirven de día y de noche */
.ico { width: 22px; height: 22px; flex: none; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.ico-whatsapp { --ico: url(/iconos/whatsapp.png); }
.ico-facebook { --ico: url(/iconos/facebook.png); }
.ico-x { --ico: url(/iconos/x.png); }
.ico-telegram { --ico: url(/iconos/telegram.png); }
.ico-correo { --ico: url(/iconos/correo.png); }
.ico-enlace { --ico: url(/iconos/enlace.png); }
.enlace { width: 100%; min-height: 44px; margin-top: 12px; padding: 0 12px; font-size: 16px; color: var(--suave); background: var(--fondo); border: 1px dashed var(--linea); border-radius: 12px; }
.texto #compartirNativo { margin-top: 0; }
.tema .sol { display: none; }
/* Se muestra el ícono del modo al que se pasa: de día la luna, de noche el sol */
:root[data-theme="dark"] .tema .sol { display: block; }
:root[data-theme="dark"] .tema .luna { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tema .sol { display: block; }
  :root:not([data-theme="light"]) .tema .luna { display: none; }
}
.marca-texto strong { font-size: 1.05rem; letter-spacing: -.01em; }
.marca-texto small { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--suave); margin-top: 3px; }
.ojo { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ojo); }
.ojo i { width: 8px; height: 8px; border-radius: 50%; background: var(--rojo); flex: none; }
h1 { font-size: 2rem; line-height: 1.08; margin: 0 0 10px; letter-spacing: -.03em; }
h1 em { font-style: italic; font-weight: 600; color: var(--em); }
.sub { margin: 0; color: var(--suave); }
.resumen { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 6px; }
.resumen strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.resumen span { color: var(--suave); }
.filtro select {
  min-height: 44px; max-width: 58vw; padding: 0 12px; border: 1px solid var(--linea); border-radius: 999px;
  background: var(--papel); appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--suave) 50%), linear-gradient(135deg, var(--suave) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 34px; text-overflow: ellipsis;
}

/* ---------- Lista ---------- */
main { padding-bottom: 8px; }
.lista { list-style: none; margin: 0; padding: 0; }
.cand { border-bottom: 1px solid var(--linea); position: relative; }
.cand:last-child { border-bottom: 0; }
.fila {
  display: grid; grid-template-columns: 22px 48px 1fr auto; align-items: center; gap: 10px;
  width: 100%; min-height: 72px; padding: 12px 0; background: none; border: 0; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fila:focus-visible { outline: 2px solid var(--barra); outline-offset: 2px; border-radius: 10px; }
.pos { color: var(--suave); font-size: .85rem; font-variant-numeric: tabular-nums; text-align: center; }
.foto {
  position: relative; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; background: var(--c, var(--suave)); color: #fff; font-weight: 700; font-size: 1rem;
  transition: width .5s ease, height .5s ease;
}
.foto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; }
.creditos { list-style: none; margin: 0; padding: 0; font-size: .85rem; color: var(--suave); display: grid; gap: 10px; }
.creditos b { color: var(--texto); font-weight: 600; }
.info { min-width: 0; display: grid; gap: 7px; }
.nombre { font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.partido { font-style: normal; font-weight: 600; font-size: .7rem; letter-spacing: .04em; margin-left: 6px; color: var(--c); white-space: nowrap; }
.barra { height: 22px; border-radius: 11px; background: var(--pista); overflow: hidden; }
.relleno {
  height: 100%; min-width: 34px; border-radius: 11px; background: var(--barra); color: var(--sobre-barra);
  display: flex; align-items: center; justify-content: flex-end; padding-right: 9px;
  font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums;
  transition: width .8s cubic-bezier(.2, .8, .2, 1);
}
.pct { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.4em; text-align: right; }

/* El que va ganando: sube y su imagen crece */
.cand.lider .foto { width: 64px; height: 64px; font-size: 1.25rem; box-shadow: 0 0 0 3px var(--fondo), 0 0 0 5px #e0a800; }
.cand.lider .fila { grid-template-columns: 22px 64px 1fr auto; }
.cand.lider .nombre { font-size: 1.08rem; }
.corona { position: absolute; top: 0; left: 75px; transform: translateX(-50%); font-size: 1.1rem; line-height: 1; z-index: 1; display: none; }
.cand.lider .corona { display: block; }
.cand.mio .nombre::after { content: "Tu voto"; display: inline-block; white-space: nowrap; margin-left: 8px; font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--pista); color: var(--suave); vertical-align: 1px; }

/* Detalle al tocar */
.detalle { display: none; padding: 0 0 16px 32px; }
.cand.abierto .detalle { display: block; }
.regiones { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; font-size: .9rem; color: var(--suave); }
.regiones li { display: flex; justify-content: space-between; gap: 12px; }
.regiones b { color: var(--texto); font-variant-numeric: tabular-nums; }
.regiones .titulo { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }

.principal {
  width: 100%; min-height: 48px; border: 0; border-radius: var(--radio); background: var(--boton); color: var(--sobre-boton);
  font-weight: 700; cursor: pointer;
}
.principal:disabled { opacity: .4; cursor: not-allowed; }
.principal:focus-visible { outline: 2px solid var(--rojo); outline-offset: 2px; }

.aviso { color: var(--suave); text-align: center; padding: 24px 0; }
.pie { padding-block: 22px 40px; color: var(--suave); font-size: .82rem; }
.pie p { margin: 0 0 8px; }

/* ---------- Hojas (formulario y términos) ---------- */
.hoja {
  border: 0; padding: 0; background: var(--fondo); color: var(--texto);
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0; border-radius: 20px 20px 0 0;
  overflow: auto; overscroll-behavior: contain;
}
.hoja::backdrop { background: rgb(0 0 0 / .5); }
.hoja[open] { animation: sube .28s ease; }
@keyframes sube { from { transform: translateY(24px); opacity: 0; } }
.hoja form, .hoja .texto { padding: 0 18px calc(22px + env(safe-area-inset-bottom)); }
.hoja-cab { position: sticky; top: 0; background: var(--fondo); display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; z-index: 2; }
.hoja form .hoja-cab { margin-inline: -18px; }
.hoja h2 { margin: 0; font-size: 1.2rem; }
.cerrar { width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; font-size: 1.8rem; line-height: 1; color: var(--suave); cursor: pointer; }
.por { margin: 0 0 14px; color: var(--suave); }
.por strong { color: var(--texto); }
.campo { display: block; margin-bottom: 12px; font-size: .85rem; color: var(--suave); }
.campo input, .campo select {
  display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 0 14px; font-size: 16px; /* 16px: iOS no hace zoom */
  background: var(--papel); border: 1px solid var(--linea); border-radius: 12px; color: var(--texto);
}
.campo input:focus, .campo select:focus { outline: 2px solid var(--barra); outline-offset: 0; border-color: transparent; }
.campo.mal input, .campo.mal select { border-color: var(--error); }
.err { display: block; color: var(--error); min-height: 0; font-size: .82rem; margin-top: 4px; }
.err:empty { display: none; }
.check { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0 8px; font-size: .9rem; }
.check input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--azul); }
.nota { font-size: .8rem; color: var(--suave); margin: 12px 0 0; text-align: center; }
#enviar { margin-top: 12px; }

.listo-marca { width: 64px; height: 64px; margin: 18px auto 12px; border-radius: 50%; background: #1a9a52; color: #fff; display: grid; place-items: center; font-size: 2rem; }
.listo { text-align: center; margin: 0 0 20px; font-size: 1.05rem; }

.texto h3 { margin: 18px 0 4px; font-size: .95rem; }
.texto p { margin: 0; color: var(--suave); font-size: .92rem; }
.texto .promesa { color: var(--texto); font-weight: 600; background: var(--papel); border-left: 4px solid var(--rojo); padding: 12px 14px; border-radius: 8px; margin-top: 4px; }
.texto .principal { margin-top: 22px; }

/* ---------- Pantallas grandes ---------- */
@media (min-width: 640px) {
  .cabeza { padding-top: 40px; }
  h1 { font-size: 2.6rem; }
  .hoja { margin: auto; border-radius: 20px; }
  .filtro select { max-width: 280px; }
}
@media (prefers-reduced-motion: reduce) {
  .relleno, .foto, .hoja[open] { transition: none; animation: none; }
}
