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

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(118, 75, 35, .18), transparent 24%),
    radial-gradient(circle at 84% 76%, rgba(81, 47, 20, .16), transparent 20%),
    linear-gradient(135deg, #d9bd7f, #a8753b);
  color: #2d2116;
  font-family: Georgia, "Times New Roman", serif;
}

.map-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.map-header {
  position: relative;
  z-index: 900;
  flex: 0 0 auto;
  padding: 16px 18px 10px;
}

.map-note {
  background:
    linear-gradient(rgba(242, 218, 156, .91), rgba(214, 179, 112, .93)),
    url("/static/paper-texture.png");
  border: 1px solid rgba(72, 44, 19, .58);
  box-shadow:
    0 10px 22px rgba(28, 15, 6, .28),
    inset 0 0 24px rgba(89, 52, 20, .14);
  color: #2c1d0f;
}

.map-intro {
  max-width: 680px;
  padding: 13px 16px 14px;
  transform: rotate(-.25deg);
}

h1 {
  margin: 0 0 5px;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: .03em;
  text-shadow: 0 1px 0 rgba(255, 238, 190, .8);
}

p {
  margin: 0;
  max-width: 620px;
  line-height: 1.28;
}

.bot-link {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 12px;
  color: #351f0d;
  text-decoration: none;
  border: 1px solid rgba(78, 46, 18, .62);
  background: rgba(242, 211, 139, .74);
  box-shadow: inset 0 0 12px rgba(96, 57, 22, .12);
}

.bot-link:hover {
  background: rgba(255, 226, 157, .86);
}

.map-shell {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #cfad70;
}

/* Critical Leaflet reset. Keeps tiles positioned even if CDN CSS is delayed or overridden. */
.leaflet-container {
  position: relative;
  overflow: hidden;
  outline: 0;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-container img,
.leaflet-container .leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-tile {
  border: 0;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-map-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: #cfad70;
  font-family: Georgia, "Times New Roman", serif;
}

.leaflet-tile-pane {
  filter: none;
}

.map-texture,
.map-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-texture {
  z-index: 450;
  background:
    url("/static/paper-texture.png"),
    radial-gradient(circle at 24% 20%, rgba(88, 49, 18, .14), transparent 22%),
    repeating-linear-gradient(6deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .035) 1px, transparent 1px, transparent 9px);
  opacity: .32;
  mix-blend-mode: multiply;
}

.map-vignette {
  z-index: 451;
  background:
    radial-gradient(circle, transparent 48%, rgba(38, 21, 8, .34) 100%),
    linear-gradient(90deg, rgba(55, 31, 13, .18), transparent 12%, transparent 88%, rgba(55, 31, 13, .18)),
    linear-gradient(0deg, rgba(55, 31, 13, .2), transparent 16%, transparent 88%, rgba(55, 31, 13, .16));
  mix-blend-mode: multiply;
}

.map-legend {
  position: absolute;
  z-index: 900;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 6px;
  min-width: 145px;
  padding: 11px 13px;
  white-space: nowrap;
  transform: rotate(.25deg);
  font-size: 17px;
  line-height: 1.2;
}

.locate-button {
  position: absolute;
  z-index: 910;
  right: 18px;
  top: 18px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(72, 44, 19, .62);
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(245, 221, 156, .94), rgba(205, 164, 91, .88)),
    url("/static/paper-texture.png");
  box-shadow:
    0 8px 18px rgba(28, 15, 6, .26),
    inset 0 0 14px rgba(89, 52, 20, .16);
  color: #5b3515;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1;
}

.locate-button:hover,
.locate-button:focus {
  background:
    radial-gradient(circle, rgba(255, 232, 170, .98), rgba(218, 176, 98, .92)),
    url("/static/paper-texture.png");
  outline: none;
}

.locate-button.is-loading span {
  animation: locate-spin 1.2s linear infinite;
}

.user-location-marker {
  pointer-events: none;
}

.user-location-dot {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 231, 164, .96);
  border-radius: 999px;
  background: #365f8f;
  box-shadow:
    0 0 0 2px rgba(58, 37, 17, .4),
    0 0 14px rgba(66, 117, 176, .7);
}

.user-location-dot::after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 1px solid rgba(54, 95, 143, .55);
  border-radius: inherit;
  animation: location-pulse 1.8s ease-out infinite;
}

@keyframes locate-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes location-pulse {
  0% {
    transform: scale(.65);
    opacity: .55;
  }

  100% {
    transform: scale(1.45);
    opacity: 0;
  }
}

.legend-cross {
  display: inline-block;
  width: 21px;
  color: #8d1f16;
  font-size: 23px;
  line-height: 17px;
  text-align: center;
  transform: rotate(-9deg);
}

.legend-found {
  display: inline-block;
  width: 21px;
  color: #d1a02d;
  font-size: 20px;
  text-align: center;
  text-shadow: 0 0 8px #f5dc83, 0 1px 0 #5b3814;
}

.secret-marker {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: bold;
  text-align: center;
}

.secret-marker .marker-symbol {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
}

.secret-marker.approx .marker-symbol {
  color: #8b2017;
  font-size: 46px;
  line-height: 34px;
  transform: rotate(-12deg);
  text-shadow:
    0 1px 0 rgba(255, 221, 159, .78),
    0 0 8px rgba(83, 17, 11, .22);
}

.secret-marker.approx .marker-symbol::after {
  content: "";
  position: absolute;
  width: 25px;
  height: 3px;
  background: rgba(126, 30, 21, .26);
  transform: rotate(44deg);
  filter: blur(1px);
}

.secret-marker.found .marker-symbol {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #f4d36d;
  font-size: 27px;
  line-height: 30px;
  background: radial-gradient(circle, rgba(98, 61, 18, .42), rgba(77, 45, 11, .12) 58%, transparent 70%);
  text-shadow:
    0 0 8px #ffe8a0,
    0 0 18px rgba(218, 172, 70, .75),
    0 1px 0 #4b2d0c;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background:
    linear-gradient(rgba(239, 214, 151, .96), rgba(222, 188, 119, .96)),
    url("/static/paper-texture.png");
  color: #2b1d10;
  border: 1px solid #76502b;
  box-shadow:
    0 10px 24px rgba(31, 16, 6, .36),
    inset 0 0 22px rgba(85, 48, 17, .14);
}

.leaflet-popup-content {
  margin: 13px 15px;
  min-width: 210px;
  font-size: 14px;
  line-height: 1.35;
}

.popup-title {
  padding-bottom: 7px;
  margin-bottom: 9px;
  border-bottom: 1px solid rgba(93, 57, 24, .38);
  font-weight: bold;
  font-size: 17px;
  letter-spacing: .02em;
}

.popup-line {
  margin: 5px 0;
}

.popup-block {
  margin-top: 10px;
}

.popup-muted {
  margin-top: 10px;
  color: #624322;
  font-style: italic;
}

.leaflet-control-zoom a,
.leaflet-control-attribution {
  filter: sepia(.65);
}

@media (max-width: 600px) {
  .map-header {
    padding: 10px 10px 7px;
  }

  .map-intro {
    padding: 10px 12px;
  }

  .map-header h1 {
    font-size: 25px;
    line-height: 1.05;
  }

  .map-header p {
    font-size: 15px;
    line-height: 1.22;
  }

  .bot-link {
    margin-top: 8px;
    padding: 6px 10px;
    font-size: 15px;
  }

  .map-legend {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    gap: 5px;
    min-width: 122px;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.15;
  }

  .locate-button {
    right: max(10px, env(safe-area-inset-right));
    top: 10px;
    width: 38px;
    height: 38px;
    font-size: 25px;
  }

  .legend-cross {
    width: 18px;
    font-size: 20px;
  }

  .legend-found {
    width: 18px;
    font-size: 17px;
  }
}
