:root {
  --ink: #0f172a;
  --muted: #64748b;
  --border: rgba(148, 163, 184, 0.28);
  --surface: rgba(255, 255, 255, 0.9);
  --soon: #f43f5e;
  --next: #7c3aed;
  --later: #0ea5e9;
  --past: #94a3b8;
  --header-h: 58px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: #eef1ed;
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; }

.app-header {
  position: relative;
  z-index: 1000;
  height: var(--header-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  text-decoration: none;
}
.brand-badge {
  height: 30px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.brand-name {
  white-space: nowrap;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.025em;
}
.header-nav { display: flex; align-items: center; gap: 5px; }
.header-link,
.login-link {
  padding: 7px 11px;
  border-radius: 7px;
  color: #64748b;
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}
.header-link:hover { color: var(--ink); background: #f8fafc; }
.header-link.is-current { color: var(--ink); background: #f1f5f9; font-weight: 650; }
.login-link { margin-left: 4px; border: 1px solid #e5e7eb; color: #334155; background: #fff; }
.login-link:hover { border-color: #cbd5e1; background: #f8fafc; }

.map-page { position: relative; height: calc(100dvh - var(--header-h)); min-height: 430px; }
.event-map { width: 100%; height: 100%; background: #e9eeea; }
.leaflet-container { font-family: inherit; }
.leaflet-tile-pane { filter: saturate(0.78) contrast(0.96) brightness(1.02); }
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right { display: none; }
.leaflet-control-attribution {
  padding: 2px 7px !important;
  border-radius: 7px 0 0 0;
  background: rgba(255, 255, 255, 0.76) !important;
  color: #64748b !important;
  font-size: 9px !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-attribution a { color: #475569 !important; }
.leaflet-bottom.leaflet-right { right: 16px; bottom: 16px; }
.leaflet-control-zoom {
  margin: 0 !important;
  overflow: hidden;
  border: 1px solid var(--border) !important;
  border-radius: 11px !important;
  box-shadow: 0 9px 28px rgba(15, 23, 42, 0.12) !important;
}
.leaflet-control-zoom a {
  width: 38px !important;
  height: 38px !important;
  line-height: 36px !important;
  border-color: #eef2f7 !important;
  color: var(--ink) !important;
  background: rgba(255, 255, 255, 0.92) !important;
  font-size: 19px !important;
  backdrop-filter: blur(12px);
}
.leaflet-control-zoom a:hover { background: #fff !important; }

.glass-panel {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(18px) saturate(1.2);
}
.map-intro {
  position: absolute;
  z-index: 600;
  top: 22px;
  left: 24px;
  width: min(330px, calc(100vw - 48px));
  padding: 20px 21px 18px;
  border-radius: 16px;
  pointer-events: none;
}
.intro-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  color: #64748b;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--soon);
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.11);
}
.map-intro h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.03;
  letter-spacing: -0.045em;
}
.map-intro p {
  margin: 9px 0 15px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.map-stats { display: flex; align-items: center; gap: 11px; color: #64748b; font-size: 11px; }
.map-stats strong { color: var(--ink); font-size: 15px; font-weight: 750; }
.stats-divider { width: 1px; height: 16px; background: #dbe2ea; }

.map-legend {
  position: absolute;
  z-index: 600;
  left: 24px;
  bottom: 24px;
  width: 225px;
  overflow: hidden;
  border-radius: 14px;
}
.legend-toggle {
  width: 100%;
  padding: 13px 14px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: transparent;
  color: #334155;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: default;
}
.legend-chevron { display: none; font-size: 14px; transition: transform 160ms ease; }
.legend-body { padding: 2px 14px 14px; }
.legend-row { display: flex; align-items: center; gap: 9px; min-height: 24px; color: #475569; font-size: 10px; }
.legend-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.04); }
.legend-dot.is-soon { background: var(--soon); }
.legend-dot.is-next { background: var(--next); opacity: 0.82; }
.legend-dot.is-later { background: var(--later); opacity: 0.6; }
.legend-dot.is-past { background: var(--past); opacity: 0.48; }
.legend-scale {
  min-height: 34px;
  margin-top: 8px;
  padding-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}
.scale-circle { display: inline-block; border: 1px solid #334155; border-radius: 50%; background: rgba(15, 23, 42, 0.08); }
.scale-circle.is-small { width: 7px; height: 7px; }
.scale-circle.is-medium { width: 11px; height: 11px; }
.scale-circle.is-large { width: 16px; height: 16px; }
.scale-caption { margin-left: 3px; color: #64748b; font-size: 9px; line-height: 1.2; }

.map-actions {
  position: absolute;
  z-index: 600;
  top: 22px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.map-action {
  width: 40px;
  height: 40px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.92);
  color: #334155;
  box-shadow: 0 9px 28px rgba(15, 23, 42, 0.11);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}
.map-action:hover { transform: translateY(-1px); background: #fff; }
.map-action:focus-visible { outline: 3px solid rgba(14, 165, 233, 0.3); outline-offset: 2px; }
.map-action svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.map-action.is-active { color: var(--soon); }

.explore-hint {
  position: absolute;
  z-index: 590;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.82);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
  font-size: 9px;
  font-weight: 550;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease;
}
.explore-hint.is-hidden { opacity: 0; transform: translate(-50%, 7px); }
.mobile-hint { display: none; }

.map-status {
  position: absolute;
  z-index: 700;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  min-height: 38px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 99px;
  color: #475569;
  font-size: 10px;
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
}
.map-status.is-hidden { opacity: 0; transform: translate(-50%, -7px); pointer-events: none; }
.map-status.is-error { color: #b91c1c; border-color: rgba(248, 113, 113, 0.34); }
.status-spinner {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid #dbe2ea;
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.map-status.is-error .status-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.map-marker,
.city-hub-marker { background: transparent; border: 0; }
.city-marker,
.event-marker { position: relative; display: flex; align-items: center; justify-content: center; }
.city-marker { width: var(--size); height: var(--size); }
.city-core {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  background: var(--marker-color);
  color: #fff;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.1);
  font-size: var(--number-size);
  font-weight: 800;
  letter-spacing: -0.04em;
  opacity: var(--marker-opacity);
  transition: transform 160ms ease, opacity 160ms ease;
}
.city-marker:hover .city-core { transform: scale(1.08); opacity: 1; }
.city-marker.is-soon .city-core::before {
  content: '';
  position: absolute;
  inset: -7px;
  border: 1px solid rgba(244, 63, 94, 0.45);
  border-radius: 50%;
  animation: marker-pulse 2.3s ease-out infinite;
}
@keyframes marker-pulse {
  0% { opacity: 0.75; transform: scale(0.88); }
  72%, 100% { opacity: 0; transform: scale(1.26); }
}
.city-label {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.86);
  color: #1e293b;
  box-shadow: 0 3px 11px rgba(15, 23, 42, 0.08);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.event-marker { width: var(--size); height: var(--size); }
.event-core {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 50% 50% 50% 18%;
  background: var(--marker-color);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.24), 0 0 0 1px rgba(15, 23, 42, 0.08);
  opacity: var(--marker-opacity);
  transform: rotate(-45deg);
  transition: transform 160ms ease, opacity 160ms ease;
}
.event-marker:hover .event-core { opacity: 1; transform: rotate(-45deg) scale(1.1); }
.event-core::after {
  content: '';
  position: absolute;
  width: 22%;
  height: 22%;
  top: 39%;
  left: 39%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
}
.event-marker.is-past .event-core { filter: grayscale(0.35); }
.event-marker-label {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  max-width: 150px;
  transform: translateX(-50%);
  overflow: hidden;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #1e293b;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.08);
  font-size: 9px;
  font-weight: 650;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(7px);
}

.city-hub {
  position: relative;
  width: 300px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(16px) saturate(1.15);
}
.city-hub-heading {
  padding: 12px 13px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.city-hub-place { min-width: 0; display: grid; gap: 2px; }
.city-hub-place strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 780;
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.city-hub-place span { color: #94a3b8; font-size: 8px; line-height: 1.2; }
.city-hub-total {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 99px;
  background: #f1f5f9;
  color: #475569;
  font-size: 8px;
  font-weight: 700;
  white-space: nowrap;
}
.city-hub-breakdown {
  padding: 0 13px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #64748b;
  font-size: 8px;
}
.city-hub-breakdown span { display: inline-flex; align-items: center; gap: 5px; }
.city-hub-breakdown i { width: 6px; height: 6px; border-radius: 50%; }
.city-hub-breakdown i.is-upcoming { background: var(--soon); }
.city-hub-breakdown i.is-past { background: var(--past); }
.city-hub-footer {
  min-height: 39px;
  padding: 6px 7px 6px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #edf1f5;
  background: rgba(248, 250, 252, 0.84);
}
.city-hub-range { color: #64748b; font-size: 8px; white-space: nowrap; }
.city-hub-navigation { display: flex; align-items: center; gap: 4px; }
.city-hub-navigation button {
  height: 27px;
  min-width: 27px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid #dfe5ec;
  border-radius: 7px;
  background: #fff;
  color: #334155;
  font-size: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.city-hub-navigation button:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; color: var(--ink); }
.city-hub-navigation button:focus-visible { outline: 2px solid rgba(14, 165, 233, 0.35); outline-offset: 1px; }
.city-hub-navigation button:disabled { color: #b4bfcc; cursor: default; }
.city-hub-navigation .city-hub-next { min-width: 73px; }

.leaflet-tooltip.city-tooltip,
.leaflet-tooltip.event-tooltip {
  padding: 7px 9px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.13);
  font-size: 10px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}
.leaflet-tooltip-top.city-tooltip::before,
.leaflet-tooltip-top.event-tooltip::before { border-top-color: rgba(255, 255, 255, 0.94); }
.leaflet-popup-content-wrapper {
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 15px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
}
.leaflet-popup-content { width: 285px !important; margin: 0; }
.leaflet-popup-tip { box-shadow: 3px 3px 8px rgba(15, 23, 42, 0.08); }
.leaflet-popup-close-button {
  top: 10px !important;
  right: 10px !important;
  width: 27px !important;
  height: 27px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88) !important;
  color: #64748b !important;
  font: 19px/1 Arial, sans-serif !important;
}
.event-popup { color: var(--ink); }
.popup-accent { height: 4px; background: var(--popup-color); opacity: var(--popup-opacity); }
.popup-body { padding: 16px 17px 17px; }
.popup-kicker { margin: 0 32px 7px 0; color: var(--popup-color); font-size: 8px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.popup-title { margin: 0 28px 11px 0; color: var(--ink); font-size: 15px; font-weight: 750; line-height: 1.28; letter-spacing: -0.025em; }
.popup-meta { display: grid; gap: 6px; margin-bottom: 13px; color: #64748b; font-size: 10px; }
.popup-meta-row { display: flex; align-items: flex-start; gap: 7px; }
.popup-meta-icon { width: 13px; flex: 0 0 13px; color: #94a3b8; text-align: center; }
.popup-format { display: inline-flex; align-items: center; gap: 5px; }
.popup-format::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #22c55e; }
.popup-locked {
  margin-bottom: 13px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #e8edf2;
  border-radius: 9px;
  background: #f8fafc;
}
.locked-label { color: #64748b; font-size: 9px; line-height: 1.35; }
.locked-value { display: flex; align-items: center; gap: 5px; color: #334155; font-size: 9px; font-weight: 750; white-space: nowrap; }
.participants-blur {
  display: inline-block;
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
  color: #6b7280;
  border-radius: 3px;
}
.popup-more { margin: -3px 0 12px; color: #64748b; font-size: 9px; line-height: 1.4; }
.popup-actions { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.popup-button {
  min-height: 35px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff !important;
  font-size: 10px;
  font-weight: 650;
  text-decoration: none !important;
}
.popup-button.is-secondary { border: 1px solid #e2e8f0; background: #fff; color: #475569 !important; }

@media (max-width: 720px) {
  :root { --header-h: 54px; }
  .app-header { padding: 0 14px; gap: 10px; }
  .brand-name { display: none; }
  .header-nav { gap: 2px; }
  .header-link { padding: 7px 8px; }
  .header-link:first-child { display: none; }
  .login-link { padding: 7px 10px; }
  .map-intro { top: 12px; left: 12px; width: calc(100vw - 76px); padding: 15px 16px 14px; border-radius: 14px; }
  .map-intro h1 { font-size: 23px; }
  .map-intro p { margin: 6px 0 10px; font-size: 10px; }
  .map-stats { gap: 8px; font-size: 9px; }
  .map-stats strong { font-size: 13px; }
  .map-actions { top: 12px; right: 12px; }
  .map-action { width: 38px; height: 38px; }
  .map-legend { left: 12px; bottom: 12px; width: 196px; }
  .legend-toggle { padding: 11px 12px; cursor: pointer; }
  .legend-chevron { display: inline; }
  .map-legend.is-collapsed .legend-chevron { transform: rotate(180deg); }
  .map-legend.is-collapsed .legend-body { display: none; }
  .legend-body { padding: 0 12px 12px; }
  .explore-hint { bottom: 64px; font-size: 8px; }
  .desktop-hint { display: none; }
  .mobile-hint { display: inline; }
  .map-status { top: auto; bottom: 64px; }
  .leaflet-bottom.leaflet-right { right: 10px; bottom: 10px; }
  .leaflet-control-zoom a { width: 36px !important; height: 36px !important; line-height: 34px !important; }
  .leaflet-control-attribution { max-width: 48vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .event-marker-label { display: none; }
  .city-hub { width: 260px; margin-left: 20px; }
  .city-hub-heading { padding: 11px 11px 7px; }
  .city-hub-breakdown { padding: 0 11px 9px; gap: 9px; }
  .city-hub-footer { padding-left: 11px; }
}

@media (max-width: 390px) {
  .header-link.is-current { max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .map-intro { width: calc(100vw - 70px); }
  .map-intro p { display: none; }
  .map-stats { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
