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

[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#map { position: fixed; inset: 0; }

/* top bar */
#topbar {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  z-index: 20;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.pill {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.95);
  color: #1a1145;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pill.action {
  background: #6c3ce9;
  color: #fff;
  cursor: pointer;
}
#btn-park { margin-right: auto; font-size: 20px; padding: 8px 14px; cursor: pointer; }
#party-pill { letter-spacing: 1px; cursor: pointer; }
#party-count { font-weight: 400; opacity: 0.7; letter-spacing: 0; }

/* category chips */
#chips {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 4px 10px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  z-index: 19;
}
#chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.7);
  color: #555;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.chip.active { background: #fff; color: #1a1145; }

/* locate button */
#btn-locate {
  position: fixed;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  font-size: 26px;
  background: #fff;
  color: #2a6ef5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 20;
  cursor: pointer;
}
#btn-locate.following { background: #2a6ef5; color: #fff; }

/* geolocation tap target */
#geo-banner {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 100px);
  left: 50%;
  transform: translateX(-50%);
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 16px;
  font-weight: 700;
  background: #2a6ef5;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  z-index: 21;
  cursor: pointer;
  white-space: nowrap;
}

/* party dock */
#dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 20;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.35));
}
#dock::-webkit-scrollbar { display: none; }
.member {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  width: 64px;
}
.member .avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.member .label {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member.stale .avatar { opacity: 0.45; }

/* modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 40, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-card {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 26px 22px 22px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.modal-card h2 { color: #1a1145; margin-bottom: 16px; font-size: 20px; }
.modal-close {
  position: absolute;
  top: 8px;
  right: 14px;
  border: none;
  background: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
}
#qr { display: flex; justify-content: center; margin-bottom: 12px; }
#qr img, #qr canvas { border-radius: 8px; }
.code-row { font-size: 17px; margin-bottom: 16px; color: #333; letter-spacing: 1px; }
.big-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  background: #6c3ce9;
  color: #fff;
  cursor: pointer;
  margin-bottom: 10px;
}
.big-btn.secondary { background: #eee7fd; color: #6c3ce9; }
.big-btn.danger { background: #fdecef; color: #d32f2f; margin-top: 4px; }
.modal-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  margin-bottom: 4px;
}
.modal-card input {
  width: 100%;
  border: 2px solid #ddd;
  border-radius: 12px;
  padding: 12px;
  font-size: 17px;
  margin-bottom: 14px;
  text-align: center;
}
.modal-card input:focus { outline: none; border-color: #6c3ce9; }
#code-input { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }
.or { color: #999; font-size: 13px; margin: 6px 0 14px; }

/* park picker home screen */
#park-picker {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: linear-gradient(160deg, #2b1a6e, #5b2d9e 55%, #a04ac2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.picker-inner { width: 100%; max-width: 340px; text-align: center; }
#picker-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 18px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 26px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
}
.picker-logo { width: 96px; height: 96px; margin-bottom: 14px; border-radius: 22px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
#park-picker h1 { color: #fff; font-size: 26px; margin-bottom: 4px; }
#park-picker p { color: rgba(255,255,255,0.75); margin-bottom: 24px; font-size: 15px; }
.park-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: none;
  border-radius: 16px;
  background: rgba(255,255,255,0.96);
  padding: 16px 18px;
  margin-bottom: 14px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  text-align: left;
}
.park-card:active { transform: scale(0.98); }
.park-emoji { font-size: 34px; }
.park-text { display: flex; flex-direction: column; }
.park-text strong { font-size: 18px; color: #1a1145; }
.park-text small { font-size: 13px; color: #888; }

/* toast */
#toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 110px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 12, 60, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}

/* heading arrows */
.dot-wrap, .me-wrap { position: relative; }
.me-wrap { width: 18px; height: 18px; }
.arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-bottom: 9px solid #2a6ef5;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
  pointer-events: none;
  display: none;
}

/* saved parties */
.saved-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.saved-join {
  flex: 1;
  border: 2px solid #eee7fd;
  border-radius: 12px;
  background: #faf8ff;
  padding: 11px;
  font-size: 16px;
  letter-spacing: 2px;
  color: #1a1145;
  cursor: pointer;
}
.saved-del {
  border: none;
  background: none;
  font-size: 24px;
  color: #bbb;
  cursor: pointer;
  padding: 0 6px;
}

/* own-location marker */
.me-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2a6ef5;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(42, 110, 245, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
}
.peer-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.peer-marker .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
}
.peer-marker .tag {
  font-size: 11px;
  font-weight: 700;
  color: #1a1145;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  padding: 1px 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.maplibregl-popup-content {
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #1a1145;
}
.maplibregl-popup-content .kind { font-size: 12px; font-weight: 400; color: #888; display: block; }
