:root {
  --verde: #1b5e3a;
  --verde-claro: #2e8b57;
  --amarillo: #ffcc00;
  --fondo: #f4f7f5;
  --texto: #1d2a22;
  --gris: #6b7a70;
  --rojo: #c0392b;
  --radio: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.oculto { display: none !important; }

/* ---------- Login ---------- */
#pantalla-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--verde) 0%, var(--verde-claro) 100%);
}
.login-caja {
  background: #fff;
  border-radius: var(--radio);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.login-logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 12px; }
.login-caja h1 { font-size: 1.4rem; color: var(--verde); margin-bottom: 24px; }

label {
  display: block;
  text-align: left;
  font-size: .9rem;
  color: var(--gris);
  margin-bottom: 16px;
}
input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  font-size: 1rem;           /* 16px evita el zoom automático en iPhone */
  border: 1px solid #cfd8d3;
  border-radius: 10px;
}
input:focus { outline: 2px solid var(--verde-claro); border-color: transparent; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
}
form button[type=submit] {
  width: 100%;
  padding: 14px;
  background: var(--verde);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 10px;
  margin-top: 8px;
}
form button[disabled] { opacity: .6; }
.error { color: var(--rojo); font-size: .9rem; min-height: 1.2em; margin-top: 12px; }

/* ---------- App ---------- */
.barra {
  position: sticky; top: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  background: var(--verde);
  color: #fff;
  font-weight: 600;
}
.btn-texto { background: none; color: inherit; padding: 6px 8px; font-size: .95rem; }

main { padding: 18px; max-width: 640px; margin: 0 auto; }
main h2 { font-size: 1.05rem; color: var(--verde); margin: 18px 0 10px; }

.lista { list-style: none; }
.lista li {
  background: #fff;
  border-radius: var(--radio);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.lista li small { display: block; color: var(--gris); margin-top: 4px; }
.lista .vacio { background: none; box-shadow: none; color: var(--gris); text-align: center; }

.rejilla { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tarjeta {
  background: #fff;
  border-radius: var(--radio);
  padding: 16px 6px;
  font-size: 1.6rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.tarjeta span { font-size: .8rem; color: var(--texto); }

/* ---------- Aviso instalar ---------- */
.aviso {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  background: var(--texto); color: #fff;
  border-radius: var(--radio);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: .9rem;
}
.aviso span { flex: 1; }
#btn-instalar { background: var(--amarillo); color: var(--texto); padding: 8px 12px; border-radius: 8px; font-weight: 600; }

.cargando {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--fondo); color: var(--gris);
}

/* =====================================================================
   v2: Jugadores, Campo, hojas emergentes y avisos
   ===================================================================== */
.titulo-atras { font-size: 1.05rem; font-weight: 600; padding: 0; }
.sub { font-size: .8rem; opacity: .85; font-weight: 400; }
.vacio { color: var(--gris); text-align: center; padding: 20px; }
.nota { font-size: .78rem; color: var(--gris); margin: 10px 4px; }
.buscador { margin: 0 0 12px; }

/* Lista de jugadores */
.item {
  background: #fff; border-radius: var(--radio); padding: 12px 14px; margin-bottom: 9px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.item .info { flex: 1; min-width: 0; }
.item small { display: block; color: var(--gris); font-size: .8rem; margin-top: 2px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.chip { font-size: .7rem; padding: 3px 8px; border-radius: 20px; background: #e3f1e8; color: var(--verde); font-weight: 600; }
.flecha { color: #b5c2ba; font-size: 1.2rem; }

.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 22px);
  width: 58px; height: 58px; border-radius: 50%; background: var(--amarillo); color: var(--texto);
  font-size: 2rem; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

/* Campo */
.segmento { display: flex; background: #e1e8e4; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.segmento div { flex: 1; text-align: center; padding: 9px 4px; border-radius: 8px; font-size: .85rem; color: var(--gris); cursor: pointer; }
.segmento .on { background: #fff; color: var(--verde); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.tabla {
  width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radio);
  overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); font-size: .9rem;
}
.tabla th { background: #e3f1e8; color: var(--verde); font-size: .75rem; text-transform: uppercase; padding: 8px 4px; }
.tabla td { text-align: center; padding: 5px 4px; border-top: 1px solid #eef2ef; }
.tabla tr.total td { background: #f4f7f5; font-weight: 700; padding: 8px 4px; }
.tabla tr.grande td { background: #e3f1e8; color: var(--verde); }
.celda-input {
  width: 62px; margin: 0 auto; padding: 7px 4px; text-align: center; font-size: 1rem;
  -moz-appearance: textfield;
}
.celda-input::-webkit-inner-spin-button, .celda-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font-size: 1rem;
  border: 1px solid #cfd8d3; border-radius: 10px; background: #fff;
}
.boton-grande {
  display: block; width: 100%; padding: 14px; margin-top: 12px; background: var(--verde); color: #fff;
  font-size: 1.05rem; font-weight: 600; border-radius: 10px;
}
.boton-grande[disabled] { opacity: .6; }

/* Hojas emergentes */
.hoja-fondo { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
.hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 90vh; overflow-y: auto;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(env(safe-area-inset-bottom) + 24px);
  max-width: 640px; margin: 0 auto;
}
.hoja .asa { width: 40px; height: 5px; border-radius: 3px; background: #d6dfda; margin: 0 auto 14px; }
.hoja h3 { color: var(--verde); margin-bottom: 12px; }
.check-linea { display: flex; align-items: center; gap: 10px; font-size: .95rem; color: var(--texto); }
.check-linea input { width: 22px; height: 22px; margin: 0; flex: none; }
.boton-peligro {
  width: 100%; padding: 12px; margin-top: 10px; background: none; color: var(--rojo);
  border: 1.5px solid var(--rojo); border-radius: 10px; font-weight: 600;
}

/* Avisos */
.toast {
  position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 12px); z-index: 30;
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 10px;
  color: #fff; font-size: .9rem; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.toast.ok { background: var(--verde); }
.toast.error { background: var(--rojo); }

/* =====================================================================
   v3: Nuevo torneo, ficha del torneo y grupos de salida
   ===================================================================== */
.lista li { cursor: pointer; }
.chip.amarillo { background: #fff4c2; color: #8a6d00; }
.chip.gris { background: #eceff1; color: var(--gris); }
.btn-enlace { background: none; color: var(--verde-claro); font-weight: 600; padding: 2px 4px; text-decoration: underline; }
.btn-icono { background: none; font-size: 1.1rem; padding: 6px; border-radius: 8px; line-height: 1; }
.btn-icono.claro { background: rgba(255,255,255,.15); }
.boton-sec {
  display: block; width: 100%; padding: 11px; margin-top: 8px; background: #fff; color: var(--verde);
  border: 1.5px dashed var(--verde-claro); border-radius: 10px; font-weight: 600; font-size: .9rem; text-align: center;
}
.fila-acciones { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.fila-acciones .nota { margin: 0; }

/* Nuevo torneo: jornadas */
.jornada-fila { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.jornada-fila .jornada-num { font-weight: 800; color: var(--verde); width: 26px; flex: none; }
.jornada-fila input, .jornada-fila select { margin: 0; padding: 10px 8px; font-size: .9rem; min-width: 0; }
.jornada-fila input { flex: 1.1; }
.jornada-fila select { flex: 1; }
.btn-quitar, .btn-quitar-hueco { width: 34px; height: 34px; flex: none; }
.btn-quitar { border-radius: 50%; background: #fbe9e7; color: var(--rojo); font-size: 1.2rem; }

/* Inscritos */
.inscrito { padding: 9px 12px; cursor: default; }
.inscrito.apagado { opacity: .55; }
.check-grande { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--verde); }
.hcp-input { width: 70px; margin: 0; padding: 8px; text-align: center; font-weight: 700; flex: none; }

/* Ficha */
.destacado {
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-claro) 100%);
  color: #fff; border-radius: var(--radio); padding: 16px; margin-bottom: 6px;
}
.destacado small { display: block; opacity: .9; margin-top: 4px; }
.dest-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.dest-titulo { font-size: 1.2rem; }
.tarjeta-jornada { background: #fff; border-radius: var(--radio); padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tj-cab { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.tj-cab strong { color: var(--verde); }
.tj-cab small { display: block; color: var(--gris); font-size: .82rem; margin-top: 2px; }
.grupo-resumen { border-top: 1px solid #eef2ef; padding: 8px 0; }
.grupo-cab { display: flex; justify-content: space-between; font-size: .85rem; }
.grupo-cab span { color: var(--gris); }
.grupo-nombres { font-size: .88rem; margin-top: 2px; }
.tabla-simple { background: #fff; border-radius: var(--radio); box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; }
.fila-simple { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid #eef2ef; }
.fila-simple:first-child { border-top: none; }
.fs-nombre { flex: 1; }
.fs-dato { color: var(--gris); font-size: .85rem; font-weight: 600; }
.avatar.mini { width: 28px; height: 28px; font-size: .65rem; }

/* Editor de grupos */
.barra-herramientas { display: flex; gap: 8px; margin-bottom: 12px; }
.barra-herramientas > * { flex: 1; margin: 0; padding: 10px 4px; font-size: .85rem; }
.grupo-editor { background: #fff; border-radius: var(--radio); padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.grupo-editor.cerrado { border-left: 4px solid var(--amarillo); }
.ge-cab { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ge-cab strong { color: var(--verde); flex: 1; }
.hora-input { width: 110px; margin: 0; padding: 7px 8px; font-size: .9rem; }
.ge-cerrado { font-size: .82rem; color: #8a6d00; background: #fff8dc; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.miembros { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.miembro { background: #f0f4f1; border-radius: 20px; padding: 4px 4px 4px 4px; font-size: .85rem; display: flex; align-items: center; gap: 6px; }
.miembro b { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: .62rem; display: flex; align-items: center; justify-content: center; }
.miembro-quitar { background: none; color: var(--gris); font-size: 1.1rem; width: 24px; height: 24px; line-height: 1; }
.anadir-select { width: auto; margin: 0; padding: 6px 10px; font-size: .85rem; border: 1.5px dashed #c5d1ca; border-radius: 20px; color: var(--verde); background: #fff; }
.libres { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-jugador { background: #fff; border: 1px solid #d6dfda; border-radius: 20px; padding: 5px 12px; font-size: .85rem; }

/* =====================================================================
   v4: Tarjeta del día y "mis partidas"
   ===================================================================== */
.centrado { text-align: center; }
.partida { margin-bottom: 12px; }
.boton-amarillo {
  display: inline-block; margin-top: 12px; background: var(--amarillo); color: var(--texto);
  padding: 10px 16px; border-radius: 9px; font-weight: 700; font-size: .95rem;
}
.selector-hoyo {
  display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: var(--radio);
  padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 12px;
}
.selector-hoyo .num { text-align: center; font-size: 2rem; font-weight: 800; color: var(--verde); line-height: 1; }
.selector-hoyo .num small { display: block; font-size: .75rem; color: var(--gris); font-weight: 500; margin-top: 6px; }
.nav-h {
  width: 46px; height: 46px; border-radius: 50%; background: #e3f1e8; color: var(--verde);
  font-size: 1.5rem; font-weight: 700; line-height: 1;
}
.nav-h:disabled { opacity: .3; }
.bolitas { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.bolitas button {
  width: 18px; height: 18px; border-radius: 50%; background: #cfd8d3; color: #fff;
  font-size: .55rem; font-weight: 700; padding: 0; line-height: 18px;
}
.bolitas button.hecho { background: var(--verde-claro); }
.bolitas button.actual { background: var(--amarillo); color: var(--texto); transform: scale(1.25); }
.aviso-tarjeta { background: #fff8dc; color: #8a6d00; border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin-bottom: 10px; }
.jugador-golpes {
  background: #fff; border-radius: var(--radio); padding: 12px 12px; margin-bottom: 9px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; align-items: center; gap: 10px;
}
.jugador-golpes .info { flex: 1; min-width: 0; }
.jugador-golpes small { display: block; color: var(--gris); font-size: .75rem; margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.stepper .b {
  width: 44px; height: 44px; border-radius: 50%; background: #eef2ef; color: var(--verde);
  font-size: 1.5rem; font-weight: 700; line-height: 1;
}
.stepper .b:active { background: #d4e6da; }
.stepper .v { width: 36px; text-align: center; font-size: 1.6rem; font-weight: 800; }
.stepper .v.vacio-golpe { color: #c5d1ca; }
.birdie { color: #c0392b; }
.bogey { color: #2c5aa0; }
.pts { white-space: nowrap; display: inline-block; font-size: .68rem; background: var(--verde); color: #fff; padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.guardado { text-align: center; font-size: .82rem; color: var(--gris); min-height: 1.2em; margin: 4px 0; }
.guardado.ok { color: var(--verde-claro); }
.guardado.error { color: var(--rojo); }
.tabla td.izq, .tabla th.izq { text-align: left; padding-left: 12px; }
.tabla td { padding: 8px 4px; }

/* =====================================================================
   v5: Clasificación
   ===================================================================== */
.pestañas { overflow-x: auto; }
.pestañas div { min-width: 52px; }
.clasif td small { display: block; color: var(--gris); font-size: .7rem; }
.clasif tr.pulsable { cursor: pointer; }
.clasif tr.pulsable:active td { background: #f0f6f2; }
.clasif tr.apagada td { color: #b5c2ba; }
.clasif sup { font-size: .6rem; color: var(--gris); margin-left: 1px; }
.clasif .cero { color: #b5c2ba; }
.pos { font-weight: 800; width: 28px; }
.oro { color: #c9a400; }
.plata { color: #8e9aa3; }
.bronce { color: #b06b2c; }
.vivo { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--rojo); font-weight: 700; margin-left: 6px; }
.vivo::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--rojo); animation: latido 1.5s infinite; }
@keyframes latido { 50% { opacity: .3; } }
.tabla-scroll { overflow-x: auto; border-radius: var(--radio); }
