
:root{
  --ocean-a:#a8d0df;
  --ocean-b:#cbe5ed;
  --ink:#3f3130;
  --muted:#7b6561;
  --paper:#f3e3c7;
  --paper-2:#e4c98f;
  --coast:#fbefca;
  --ring:#d5ecf0;
  --panel:rgba(250,239,216,.88);
}

*{box-sizing:border-box}
html,body,#app,#map{height:100%;width:100%;margin:0}
body{
  overflow:hidden;
  color:var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:var(--ocean-a);
}

#map{
  position:absolute;
  inset:0;
  z-index:1;
  background:
    radial-gradient(circle at 20% 18%, rgba(255,255,255,.28), transparent 22%),
    radial-gradient(circle at 78% 78%, rgba(255,255,255,.18), transparent 24%),
    linear-gradient(135deg,var(--ocean-b),var(--ocean-a) 48%,#8ec3d6);
}
#map::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:450;
  opacity:.18;
  background-image:
    radial-gradient(rgba(80,120,130,.22) .6px, transparent .8px),
    linear-gradient(transparent 95%, rgba(255,255,255,.25));
  background-size:5px 5px, 100% 100%;
  mix-blend-mode:multiply;
}

.leaflet-pane{z-index:300}
.leaflet-overlay-pane{z-index:390}
.leaflet-tooltip-pane{z-index:440}
.leaflet-control-container{display:none}

.title-card{
  position:absolute;
  top:24px;
  left:28px;
  max-width:min(520px,calc(100vw - 56px));
  z-index:800;
  padding:18px 22px 20px;
  background:linear-gradient(180deg,rgba(248,236,212,.92),rgba(238,220,184,.78));
  border:1px solid rgba(95,74,60,.25);
  box-shadow:0 18px 50px rgba(55,76,83,.22);
  backdrop-filter:blur(6px);
}
.eyebrow{
  margin:0 0 4px;
  text-transform:uppercase;
  letter-spacing:.18em;
  font-size:11px;
  color:var(--muted);
}
h1{
  margin:0;
  font-size:clamp(31px,5vw,58px);
  line-height:.88;
  font-weight:500;
}
.subtitle{
  margin:10px 0 0;
  font-size:15px;
  max-width:39em;
}

.counter-card{
  position:absolute;
  right:24px;
  top:24px;
  z-index:810;
  min-width:150px;
  text-align:right;
  padding:14px 16px;
  background:rgba(244,227,193,.78);
  border:1px solid rgba(92,72,56,.22);
  box-shadow:0 12px 34px rgba(54,76,84,.18);
  backdrop-filter:blur(6px);
}
.counter-card span{
  display:block;
  font-size:32px;
  line-height:1;
}
.counter-card small{
  text-transform:uppercase;
  letter-spacing:.12em;
  color:var(--muted);
  font-size:10px;
}

.legend{
  position:absolute;
  left:28px;
  bottom:26px;
  z-index:805;
  width:270px;
  background:var(--panel);
  border:1px solid rgba(92,72,56,.22);
  box-shadow:0 14px 38px rgba(45,65,72,.2);
  backdrop-filter:blur(6px);
}
.legend button{
  position:absolute;
  right:8px;
  top:7px;
  border:0;
  background:rgba(98,77,59,.14);
  color:var(--ink);
  width:24px;
  height:24px;
  border-radius:50%;
  cursor:pointer;
}
.legend-content{padding:16px 18px 18px}
.legend h2{font-size:17px;margin:0 0 8px}
.legend p,.legend li{font-size:13px;line-height:1.35}
.legend ol{padding-left:19px;margin:9px 0 0}
.legend.minimized{width:48px;height:42px;overflow:hidden}
.legend.minimized .legend-content{display:none}

.map-menu{
  position:absolute;
  right:24px;
  bottom:24px;
  z-index:820;
  display:flex;
  gap:8px;
}
.map-menu button{
  border:1px solid rgba(66,52,46,.28);
  background:rgba(247,235,211,.82);
  color:var(--ink);
  padding:9px 12px;
  font-family:Georgia,"Times New Roman",serif;
  cursor:pointer;
  box-shadow:0 8px 24px rgba(45,65,72,.16);
}
.map-menu button:hover{background:rgba(255,246,225,.95)}

.loader{
  position:absolute;
  z-index:900;
  left:50%;
  bottom:34px;
  transform:translateX(-50%);
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  background:rgba(246,235,214,.92);
  border:1px solid rgba(92,72,56,.2);
  box-shadow:0 10px 30px rgba(45,65,72,.18);
}
.loader[hidden]{display:none}
.spinner{
  width:16px;height:16px;border-radius:50%;
  border:2px solid rgba(80,64,52,.25);
  border-top-color:rgba(80,64,52,.85);
  animation:spin 900ms linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

.modal-backdrop{
  position:absolute;
  inset:0;
  z-index:1000;
  background:rgba(23,35,39,.24);
  display:grid;
  place-items:center;
}
.modal-backdrop[hidden]{display:none !important}
.modal{
  width:min(560px,calc(100vw - 36px));
  max-height:calc(100vh - 48px);
  overflow:auto;
  background:#f5e8cf;
  border:1px solid rgba(75,55,41,.3);
  box-shadow:0 24px 80px rgba(20,30,35,.36);
  padding:24px 26px;
  position:relative;
}
.close{
  position:absolute;
  right:12px;top:10px;
  border:0;background:transparent;
  font-size:30px;line-height:1;cursor:pointer;color:var(--ink);
}
.modal h2{margin-top:0}
.modal p{font-size:15px;line-height:1.45}
.credit{font-size:13px;color:var(--muted)}

.lake-label{
  background:transparent;
  border:0;
  box-shadow:none;
  color:#5b4542;
  font-family:Georgia,"Times New Roman",serif;
  font-size:12px;
  text-shadow:
    0 1px 0 rgba(245,235,210,.85),
    1px 0 0 rgba(245,235,210,.85),
    0 -1px 0 rgba(245,235,210,.85),
    -1px 0 0 rgba(245,235,210,.85);
}

@media (max-width:720px){
  .title-card{top:14px;left:14px;padding:14px 16px}
  .counter-card{top:auto;right:14px;bottom:75px}
  .legend{left:14px;bottom:14px;width:245px}
  .map-menu{right:14px;bottom:14px}
}


/* --- Final touch-up pass: hierarchy, alignment, polished panels, mobile-first controls --- */
.leaflet-popup-pane{z-index:1250 !important}
.leaflet-tooltip-pane{z-index:1180 !important}
.leaflet-popup-content-wrapper{
  background:linear-gradient(180deg,rgba(255,248,232,.98),rgba(242,226,194,.96));
  color:var(--ink);
  border:1px solid rgba(77,58,44,.26);
  border-radius:18px;
  box-shadow:0 18px 48px rgba(34,52,58,.30);
  padding:0;
  overflow:hidden;
}
.leaflet-popup-content{
  margin:0;
  width:260px !important;
}
.leaflet-popup-tip{
  background:rgba(242,226,194,.96);
  box-shadow:0 10px 20px rgba(34,52,58,.16);
}
.leaflet-container a.leaflet-popup-close-button{
  top:10px;
  right:12px;
  width:26px;
  height:26px;
  border-radius:999px;
  display:grid;
  place-items:center;
  color:#6a5146;
  background:rgba(80,60,44,.09);
  font:700 18px/1 Georgia,"Times New Roman",serif;
}
.leaflet-container a.leaflet-popup-close-button:hover{
  background:rgba(80,60,44,.16);
  color:#2f2421;
}
.popup{padding:16px 18px 17px}
.popup h3{
  margin:0 30px 5px 0;
  font-size:20px;
  line-height:1.05;
  font-weight:700;
  letter-spacing:.01em;
}
.popup p{
  margin:0 0 12px;
  color:#735e54;
  font-size:13px;
  line-height:1.35;
}
.popup dl{
  display:grid;
  grid-template-columns:auto 1fr;
  gap:7px 12px;
  margin:0;
  padding-top:12px;
  border-top:1px solid rgba(90,70,54,.18);
  font-size:13px;
}
.popup dt{
  color:#7f675d;
  font-weight:700;
  letter-spacing:.02em;
}
.popup dd{
  margin:0;
  text-align:right;
  color:#3f3130;
  font-variant-numeric:tabular-nums;
}

.title-card,
.counter-card,
.legend,
.map-menu button,
.loader,
.modal{
  border-radius:18px;
}
.map-menu button,
.legend button,
.close,
.counter-card{
  transition:background-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.map-menu button:hover,
.legend button:hover,
.close:hover{
  transform:translateY(-1px);
}
.map-menu button:focus-visible,
.legend button:focus-visible,
.close:focus-visible,
.counter-card:focus-visible{
  outline:3px solid rgba(60,120,145,.35);
  outline-offset:2px;
}

.legend{
  overflow:hidden;
}
.legend button{
  display:grid;
  place-items:center;
  font-weight:700;
}
.legend:not(.minimized) #legendToggle{
  background:rgba(98,77,59,.12);
}
.legend:not(.minimized) #legendToggle::after{
  content:"";
}
.legend.minimized #legendToggle{
  right:50%;
  top:50%;
  transform:translate(50%,-50%);
}

.modal{
  border-radius:24px;
}
.modal h2{
  font-size:25px;
  line-height:1.05;
  margin:0 38px 14px 0;
}
.modal p{
  margin:0 0 13px;
}
.modal .credit{
  padding-top:10px;
  border-top:1px solid rgba(90,70,54,.16);
}
.modal .credit + .credit{
  border-top:0;
  padding-top:0;
}

/* Mobile composition: keep the map open, put details in bottom-sheet style, use compact icon controls. */
@media (max-width:720px){
  .title-card{
    top:calc(8px + env(safe-area-inset-top));
    left:8px;
    right:8px;
    max-width:none;
    padding:10px 14px 11px;
    border-radius:15px;
    box-shadow:0 10px 28px rgba(40,60,66,.18);
  }
  .title-card .eyebrow,
  .title-card .subtitle{
    display:none;
  }
  h1{
    font-size:22px;
    line-height:1.05;
    text-align:center;
  }

  .map-menu{
    top:calc(62px + env(safe-area-inset-top));
    right:10px;
    bottom:auto;
    gap:8px;
    z-index:940;
  }
  .map-menu button{
    width:42px;
    height:42px;
    padding:0;
    border-radius:999px;
    display:grid;
    place-items:center;
    font-size:0;
    background:rgba(248,238,218,.92);
  }
  .map-menu button span{display:none}
  .map-menu button::before{
    content:attr(data-mobile-label);
    font-size:18px;
    font-weight:700;
    line-height:1;
  }

  .counter-card{
    top:calc(62px + env(safe-area-inset-top));
    left:10px;
    right:auto;
    bottom:auto;
    min-width:0;
    width:auto;
    max-width:46vw;
    padding:8px 10px;
    border-radius:999px;
    display:flex;
    align-items:baseline;
    gap:5px;
    text-align:left;
    z-index:935;
    cursor:pointer;
  }
  .counter-card span{
    font-size:18px;
    font-weight:700;
  }
  .counter-card small{
    font-size:0;
    letter-spacing:0;
  }
  .counter-card small::after{
    content:"islands";
    font-size:10px;
    letter-spacing:.08em;
    text-transform:uppercase;
  }
  .counter-card:not(.expanded) small::after{
    content:"";
  }
  .counter-card:not(.expanded)::after{
    content:"Islands";
    font-size:10px;
    letter-spacing:.08em;
    text-transform:uppercase;
    color:var(--muted);
  }

  .legend{
    left:10px;
    bottom:calc(10px + env(safe-area-inset-bottom));
    width:44px;
    height:44px;
    border-radius:999px;
    z-index:940;
  }
  .legend .legend-content{display:none}
  .legend #legendToggle{
    right:0;
    top:0;
    width:44px;
    height:44px;
    border-radius:999px;
    background:rgba(248,238,218,.94);
    font-size:18px;
  }
  .legend.mobile-open{
    width:min(310px,calc(100vw - 20px));
    height:auto;
    border-radius:20px;
  }
  .legend.mobile-open .legend-content{
    display:block;
    padding:16px 18px 18px;
  }
  .legend.mobile-open #legendToggle{
    right:8px;
    top:8px;
    width:28px;
    height:28px;
    font-size:17px;
  }

  .loader{
    bottom:calc(12px + env(safe-area-inset-bottom));
    max-width:calc(100vw - 78px);
    left:calc(50% + 24px);
    padding:9px 11px;
    border-radius:999px;
    font-size:13px;
    z-index:930;
  }

  .leaflet-popup{
    position:fixed !important;
    left:12px !important;
    right:12px !important;
    bottom:calc(12px + env(safe-area-inset-bottom)) !important;
    top:auto !important;
    transform:none !important;
    margin:0 !important;
    width:auto !important;
    z-index:1300 !important;
  }
  .leaflet-popup-content-wrapper{
    border-radius:22px;
    box-shadow:0 18px 60px rgba(20,32,38,.35);
  }
  .leaflet-popup-content{
    width:auto !important;
    max-width:none !important;
  }
  .leaflet-popup-tip-container{display:none}
  .popup{padding:17px 18px 18px}
  .popup h3{
    font-size:21px;
    margin-right:38px;
  }

  .modal-backdrop{
    align-items:end;
    place-items:end center;
    padding:0 10px calc(10px + env(safe-area-inset-bottom));
  }
  .modal{
    width:100%;
    max-height:min(76vh,620px);
    border-radius:24px 24px 20px 20px;
    padding:22px 20px;
  }
}

@media (min-width:721px){
  .legend.minimized #legendToggle{
    font-size:17px;
  }
}
