:root {
  --pink:        #FF2E88;   /* rosa corporatiu principal */
  --pink-deep:   #C2185B;   /* rosa fosc per a vores/accents */
  --pink-dark:   #7A0E3C;   /* rosa molt fosc (superfícies fosques) */
  --pink-soft:   #FFE3F1;   /* rosa clar de fons */
  --ink:         #3A0A22;   /* text fosc sobre fons clar */
  --white:       #FFFFFF;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--pink-soft);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#map { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }

#tracking-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--pink);
  color: var(--white);
  padding: calc(9px + env(safe-area-inset-top)) 16px 9px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  z-index: 900;
  letter-spacing: 0.3px;
}
#tracking-banner.hidden { display: none; }

#fab-container {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 800;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
/* Quan el calaix d'estadístiques és obert, apartem els FAB perquè no se solapin */
body.stats-open #fab-container {
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
}
#fab-container button {
  min-height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: 24px;
  background: var(--pink);
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(122,14,60,0.45);
  white-space: nowrap;
}
#fab-container button:active { opacity: 0.8; }
#btn-center,
#btn-stats,
#btn-delete-track { width: 48px; padding: 0; font-size: 20px; }

#admin-panel {
  position: fixed;
  top: 60px; right: 12px;
  width: 280px;
  max-width: calc(100vw - 24px);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--pink);
  border-radius: 12px;
  padding: 12px;
  z-index: 1000;
}
#admin-panel.hidden { display: none; }
#admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
#admin-header span { font-weight: 700; color: var(--pink-deep); }
#btn-close-admin {
  background: none;
  border: none;
  color: var(--pink-deep);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.admin-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--pink-soft);
}
.admin-user-row:last-child { border-bottom: none; }
.admin-ban-btn {
  background: var(--pink-deep);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
}

#stats-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  color: var(--ink);
  border-radius: 16px 16px 0 0;
  border-top: 3px solid var(--pink);
  box-shadow: 0 -6px 24px rgba(122,14,60,0.25);
  z-index: 700;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(calc(100% - 48px));
  transition: transform 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
#stats-drawer.open { transform: translateY(0); }
#stats-handle {
  height: 48px;
  line-height: 48px;
  text-align: center;
  font-weight: 700;
  color: var(--pink-deep);
  cursor: pointer;
  font-size: 15px;
  user-select: none;
}
#stats-content { padding: 8px 16px 32px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--pink-soft);
  font-size: 15px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:last-child { font-weight: 700; color: var(--pink-deep); }
#stats-ranking { margin-top: 14px; }
.ranking-title { font-weight: 700; color: var(--pink-deep); margin-bottom: 8px; font-size: 15px; }
.ranking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
}
.ranking-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ranking-km { margin-left: auto; font-weight: 700; }

#banned-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--pink), var(--pink-dark));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#banned-screen.hidden { display: none; }
#banned-card { text-align: center; padding: 32px; }
#banned-card h2 { font-size: 28px; margin-bottom: 12px; }
#banned-card p { color: rgba(255,255,255,0.85); font-size: 16px; }

.user-chip {
  background: var(--chip-color, var(--pink));
  color: var(--white);
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 6px rgba(122,14,60,0.5);
  pointer-events: none;
}

/* Etiqueta central de cada zona de cerca */
.zone-label {
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  font-size: 15px;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
}


/* ===== Pla 2: panell soci ===== */

/* Bottom-sheets */
#sheet-root { position: fixed; inset: 0; z-index: 1200; }
#sheet-root.hidden { display: none !important; }
#sheet-backdrop { position: absolute; inset: 0; background: rgba(61,0,28,.25); }
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 80vh;
  background: var(--surface); color: var(--text);
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transform: translateY(0); transition: transform .25s ease;
  padding-bottom: var(--safe-bottom);
}
#sheet-root.closing #sheet { transform: translateY(100%); }
#sheet-header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid #f0dce5; }
#sheet-title { margin: 0; font-size: 18px; flex: 1; }
#sheet-actions { display: flex; gap: 8px; }
#sheet-close, #sheet-actions button { background: none; border: none; color: var(--accent); padding: 6px; line-height: 0; }
#sheet-body { overflow-y: auto; padding: 12px 16px; }

/* Menú inferior */
#bottom-menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  display: flex; background: var(--surface); box-shadow: 0 -4px 16px rgba(61,0,28,.12);
  padding-bottom: var(--safe-bottom);
}
#bottom-menu.hidden { display: none !important; }
.menu-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--accent);
  padding: 8px 2px; font-size: 11px; font-weight: 600;
}
.menu-btn svg { display: block; }
.menu-btn.active { background: #fde6f0; }

/* Banner de recorregut */
#tracking-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1150;
  background: var(--accent); color: #fff; text-align: center; padding: 8px; font-size: 13px; font-weight: 600;
}
#tracking-banner.hidden { display: none !important; }

/* POIs */
.poi-marker {
  width: 16px; height: 16px; border-radius: 50%; cursor: pointer;
  background: var(--poi-color, #888); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.poi-marker.checked { background: #2e7d32; }
.poi-popup strong { font-size: 14px; }
.poi-popup p { margin: 6px 0 0; font-size: 13px; }
.poi-check {
  margin-top: 10px; width: 100%; padding: 8px; border: none; border-radius: 8px;
  background: #eee; color: var(--text); font-weight: 600; display: flex; gap: 6px; align-items: center; justify-content: center;
}
.poi-check.on { background: #2e7d32; color: #fff; }

/* Socis en viu */
.member-chip {
  background: var(--chip-color, #888); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.4);
  transform: translateY(-6px);
}

/* Llistes dins sheets */
.list-row { display: flex; align-items: center; gap: 8px; padding: 10px 4px; border-bottom: 1px solid #f0dce5; }
.list-title { flex: 1; font-size: 14px; }
.list-actions { display: flex; gap: 6px; }
.list-actions button { background: none; border: none; color: var(--accent); padding: 4px; line-height: 0; }

/* Estadístiques */
.stat-row { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px solid #f0dce5; font-size: 15px; }
.ranking-title { font-weight: 700; margin: 14px 0 6px; }
.ranking-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 14px; }
.ranking-dot { width: 12px; height: 12px; border-radius: 50%; }
.ranking-name { flex: 1; }
.ranking-km { font-weight: 700; }

/* Llegenda */
.legend-row { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid #f0dce5; font-size: 15px; }

/* ===== Pla 3: panell admin ===== */
.list-title small { color: #8a6b78; font-weight: 600; }
#poi-flag {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -100%) rotate(45deg); z-index: 1180;
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; background: var(--accent);
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
#poi-flag.hidden { display: none !important; }
#poi-form {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); z-index: 1190;
  background: var(--surface); color: var(--text); border-radius: 14px; box-shadow: var(--shadow); padding: 14px;
}
#poi-form.hidden { display: none !important; }
#poi-form input, #poi-form textarea {
  width: 100%; padding: 10px; margin-bottom: 8px; border: 1px solid #e3c9d5; border-radius: 8px;
  font-size: 15px; color: var(--text); font-family: inherit;
}
.poi-form-actions { display: flex; gap: 8px; }
.poi-form-actions .cta { margin: 0; }
.cta-ghost { background: #eee; color: var(--text); }
