/* Polla Mundialista La Huella — identidad visual real de la marca:
   teal + verde lima + crema, ondas orgánicas, huellitas, títulos redondeados
   extra-bold con acento script (referencia: diseño Canva DAGq0vPbMu8). */

:root {
  --bg: #f7f0e1;            /* crema de marca */
  --surface: #ffffff;
  --surface-2: #f1e8d2;
  --ink: #1e3a3c;
  --ink-soft: #4a6365;
  --ink-faint: #71878a;
  --line: #e6ddc5;
  --teal: #28a8b0;          /* turquesa de marca */
  --teal-deep: #1d8d95;
  --teal-soft: #ddf0f1;
  --lima: #9ab148;          /* verde lima de marca */
  --lima-deep: #66792c;
  --lima-soft: #eef0d6;
  --on-color: #ffffff;
  --crema: #f7f0e1;
  --danger: #c0392b;
  --danger-soft: #f6ddd8;
  --amarillo: #fcd116;
  --azul: #003893;
  --rojo: #ce1126;
  --fuente-titulo: "Fredoka", -apple-system, system-ui, sans-serif;
  --fuente-script: "Pacifico", cursive;
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganar siempre, incluso sobre display:flex de las tarjetas. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
}

.tricolor {
  height: 8px;
  background: linear-gradient(to right, var(--amarillo) 0 50%, var(--azul) 50% 75%, var(--rojo) 75% 100%);
}

.contenedor {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

/* ---------- Hero de marca ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--teal) 0%, var(--teal-deep) 100%);
  color: var(--on-color);
  text-align: center;
  padding: 30px 20px 58px;
}

.hero-inner { position: relative; max-width: 640px; margin: 0 auto; z-index: 2; }

.blob {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}
.blob-lima {
  width: 250px;
  height: 230px;
  right: -70px;
  top: -50px;
  background: var(--lima);
  border-radius: 58% 42% 60% 40% / 50% 56% 44% 50%;
  transform: rotate(-14deg);
}
.blob-crema {
  width: 140px;
  height: 120px;
  left: -50px;
  bottom: 18px;
  background: var(--crema);
  opacity: 0.18;
  border-radius: 45% 55% 60% 40% / 55% 45% 55% 45%;
}

.paw {
  position: absolute;
  z-index: 1;
  opacity: 0.3;
  pointer-events: none;
}
.paw-1 { top: 14px; left: 8%; font-size: 1.5rem; transform: rotate(-20deg); }
.paw-2 { bottom: 56px; right: 6%; font-size: 1.25rem; transform: rotate(18deg); }
.paw-3 { top: 48%; left: 2%; font-size: 1rem; transform: rotate(10deg); }

.hero .marca {
  margin: 0 0 2px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--crema);
}

.hero .script {
  margin: 10px 0 0;
  font-family: var(--fuente-script);
  font-size: 1.625rem;
  line-height: 1;
  color: var(--crema);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.06);
}

.hero h1 {
  margin: 6px 0 0;
  font-family: var(--fuente-titulo);
  font-weight: 700;
  font-size: 2.125rem;
  line-height: 1.04;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.hero .sub {
  margin: 12px auto 0;
  max-width: 32rem;
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.92);
}

.onda {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  width: 100%;
  height: 38px;
  display: block;
  z-index: 2;
}

/* ---------- Tarjetas ---------- */

.tarjeta {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  margin: 0 0 16px;
}

.tarjeta h2 {
  margin: 0 0 8px;
  font-family: var(--fuente-titulo);
  font-weight: 600;
  font-size: 1.1875rem;
  color: var(--ink);
}

.premios {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--lima);
  border-color: var(--lima);
  color: var(--on-color);
}
.premios .trofeo { font-size: 2rem; }
.premios p { margin: 0; font-weight: 700; font-size: 0.9375rem; line-height: 1.4; }

.reglas ol { margin: 0; padding-left: 20px; color: var(--ink-soft); font-size: 0.9375rem; }
.reglas li { margin: 6px 0; }
.reglas strong { color: var(--teal-deep); }

/* ---------- Partidos ---------- */

.partido { padding: 16px; }
.partido .fase {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
}

.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.equipo { text-align: center; }
.equipo .bandera { display: block; font-size: 2rem; line-height: 1.1; }
.equipo .nombre { display: block; font-weight: 600; font-size: 0.9375rem; margin-top: 2px; }

.marcador { display: flex; align-items: center; gap: 8px; }
.marcador input {
  width: 58px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--fuente-titulo);
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--teal-soft);
  border-radius: 14px;
}
.marcador input:focus { outline: 2px solid var(--teal); outline-offset: 2px; }
.marcador input:disabled { background: var(--surface-2); color: var(--ink-faint); border-color: var(--line); }
.marcador .dos-puntos { font-size: 1.25rem; font-weight: 700; color: var(--ink-faint); }

.marcador-final {
  text-align: center;
  font-family: var(--fuente-titulo);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.partido .cuando { margin: 10px 0 0; text-align: center; color: var(--ink-soft); font-size: 0.9375rem; }
.partido .estado { margin: 8px 0 0; text-align: center; font-size: 0.8125rem; font-weight: 700; }
.estado.abierto { color: var(--teal-deep); }
.estado.cerrado { color: var(--ink-faint); }

.mi-resultado {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
  font-size: 0.9375rem;
}
.mi-resultado.exacto { background: var(--lima-soft); color: var(--lima-deep); font-weight: 700; }
.mi-resultado.tendencia { background: var(--teal-soft); color: var(--teal-deep); }

/* ---------- Formulario ---------- */

.identidad .campo { margin: 12px 0 0; }
.campo label { display: block; font-size: 0.9375rem; font-weight: 600; margin-bottom: 4px; }
.campo input, .campo textarea, .campo select {
  font-family: inherit;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.campo textarea { height: auto; padding: 10px 14px; resize: vertical; }
.campo input:focus, .campo textarea:focus, .campo select:focus {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.ayuda { margin: 0 0 4px; color: var(--ink-soft); font-size: 0.875rem; }

.sesion { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sesion p { margin: 0; }
.suave { color: var(--ink-faint); font-size: 0.875rem; }

.enlace {
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--teal-deep);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* Acción primaria fija abajo: pastilla de marca */
.accion {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 10;
}
.accion .primario { max-width: 608px; margin: 0 auto; display: block; }

.primario {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: 999px;
  background: var(--teal);
  color: var(--on-color);
  font-family: var(--fuente-titulo);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(40, 168, 176, 0.35);
}
.primario:active { background: var(--teal-deep); }
.primario:disabled { opacity: 0.6; }

/* ---------- Ranking ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--line); }
th { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
tbody tr:last-child td { border-bottom: none; }
.izq { text-align: left; }
td.puntos { font-weight: 700; color: var(--teal-deep); }
tr.yo td { background: var(--lima-soft); }
tr.yo td:first-child { border-radius: 12px 0 0 12px; }
tr.yo td:last-child { border-radius: 0 12px 12px 0; }

/* ---------- Pie y toast ---------- */

.pie { text-align: center; color: var(--ink-faint); font-size: 0.8125rem; padding: 16px 0 8px; }
.pie p { margin: 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  max-width: min(90vw, 480px);
  padding: 12px 18px;
  background: var(--ink);
  color: var(--crema);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  z-index: 20;
  animation: subir 0.2s ease-out;
}
#toast.error { background: var(--danger); color: white; }

@keyframes subir {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Admin ---------- */

.admin-barra { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-barra h1 { margin: 0; font-family: var(--fuente-titulo); font-size: 1.375rem; }
.fila-botones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.secundario {
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--teal-deep);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}
.secundario:active { background: var(--surface-2); }
.secundario.peligro { color: var(--danger); border-color: var(--danger-soft); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

.login-caja { max-width: 360px; margin: 48px auto; text-align: center; }
.login-caja h1 { font-family: var(--fuente-titulo); font-size: 1.625rem; }
.login-caja input {
  width: 100%;
  height: 56px;
  text-align: center;
  font-size: 1.75rem;
  letter-spacing: 0.4em;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
}
.login-caja input:focus { outline: 2px solid var(--teal); outline-offset: 2px; }
.login-caja .primario { margin-top: 12px; }

.tabla-scroll { overflow-x: auto; }
.tabla-scroll table { min-width: 560px; }
.chip-resultado {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 0.8125rem;
  font-weight: 600;
}
details.editar { margin-top: 12px; }
details.editar summary { cursor: pointer; font-size: 0.9375rem; font-weight: 600; color: var(--teal-deep); }
details.editar .campo { margin-top: 10px; }
