html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(76, 129, 255, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(93, 184, 168, 0.18), transparent 24%),
    #eaf2fb;
  color: #1f2f41;
}

.map-shell {
  position: relative;
  height: 100dvh;
  min-height: 420px;
  overflow: hidden;
}

.map {
  height: 100%;
  width: 100%;
}

.map-topbar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.map-badge,
.status-pill,
.custom-map-control-button {
  pointer-events: auto;
}

.map-badge {
  max-width: min(520px, calc(100% - 140px));
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(133, 163, 196, 0.18);
  box-shadow: 0 16px 36px rgba(29, 63, 100, 0.14);
  backdrop-filter: blur(10px);
}

.map-badge strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.map-badge span {
  display: block;
  font-size: 0.92rem;
  color: #536478;
}

.status-pill {
  flex-shrink: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(133, 163, 196, 0.18);
  box-shadow: 0 10px 26px rgba(29, 63, 100, 0.12);
  font-size: 0.9rem;
  font-weight: 600;
}

.status-pill.loading {
  color: #245c9d;
}

.map-actions {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 5;
  transform: translateX(-50%);
}

.custom-map-control-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #3478c9, #5db8a8);
  color: #fff;
  box-shadow: 0 16px 34px rgba(52, 120, 201, 0.26);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.custom-map-control-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 20px 36px rgba(52, 120, 201, 0.3);
}

.custom-map-control-button:focus-visible {
  outline: 3px solid rgba(52, 120, 201, 0.25);
  outline-offset: 2px;
}

.infobox {
  min-width: min(300px, 76vw);
  max-width: min(340px, 80vw);
  padding: 16px;
  font-family: Inter, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.infobox h3 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.35;
}

.infobox p {
  margin: 0 0 8px;
  color: #4d6176;
}

.infobox a {
  color: #245c9d;
  text-decoration: none;
}

.infobox a:hover {
  text-decoration: underline;
}

.infobox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.infobox-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef5ff;
  color: #245c9d;
  font-weight: 600;
}

.gm-style .gm-style-iw-c {
  border-radius: 20px !important;
  padding: 0 !important;
  box-shadow: 0 20px 40px rgba(29, 63, 100, 0.18) !important;
}

.gm-style .gm-style-iw-d {
  overflow: auto !important;
}

@media (max-width: 760px) {
  .map-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .map-badge {
    max-width: none;
  }

  .status-pill {
    width: fit-content;
    max-width: 100%;
  }

  .map-actions {
    left: 14px;
    right: 14px;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: none;
  }

  .custom-map-control-button {
    width: 100%;
  }

  .infobox {
    min-width: 0;
    max-width: min(300px, 78vw);
    padding: 14px;
  }
}


/* Visual polish */
.map::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(234,242,251,0.12) 0%, rgba(234,242,251,0) 18%, rgba(15,23,42,0.08) 100%);
}

.map-badge {
  border: 1px solid rgba(133, 163, 196, 0.22);
  box-shadow: 0 18px 46px rgba(29, 63, 100, 0.16);
}

.status-pill {
  color: #234b72;
}

.status-pill.loading {
  background: rgba(255, 255, 255, 0.96);
}

.custom-map-control-button {
  backdrop-filter: blur(10px);
}


.map-topbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.legend-menu {
  position: relative;
  pointer-events: auto;
}

.legend-menu summary {
  list-style: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(133, 163, 196, 0.18);
  box-shadow: 0 10px 26px rgba(29, 63, 100, 0.12);
  font-size: 20px;
  font-weight: 800;
  color: #234b72;
  cursor: pointer;
  user-select: none;
}

.legend-menu summary::-webkit-details-marker {
  display: none;
}

.legend-panel {
  position: absolute;
  top: 52px;
  right: 0;
  min-width: 230px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(133, 163, 196, 0.18);
  box-shadow: 0 18px 40px rgba(29, 63, 100, 0.16);
  backdrop-filter: blur(10px);
}

.legend-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #1f2f41;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: #425468;
  margin-top: 8px;
}

.legend-marker {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.16);
}

.legend-baari { background: linear-gradient(135deg, #ef476f, #ff7f50); }
.legend-tilapainen { background: linear-gradient(135deg, #f59e0b, #f97316); }
.legend-alko { background: linear-gradient(135deg, #6366f1, #3b82f6); }
.legend-kauppa { background: linear-gradient(135deg, #22c55e, #16a34a); }
.legend-panimo { background: linear-gradient(135deg, #10b981, #14b8a6); }
.legend-viini { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.legend-muut { background: linear-gradient(135deg, #64748b, #475569); }

@media (max-width: 760px) {
  .map-topbar-actions {
    justify-content: space-between;
  }

  .legend-panel {
    right: 0;
    left: auto;
    max-width: min(280px, calc(100vw - 28px));
  }
}
