:root {
  --bg: #0d0a12;
  --panel: #17111f;
  --panel-2: #221a2d;
  --line: #33283f;
  --text: #f4eee6;
  --muted: #a397ad;
  --orange: #ff7a18;
  --orange-2: #ffb347;
  --purple: #9b6dff;
  --slime: #7cf26a;
  --blood: #e0354b;
  --grey: #5b5363;
  --sheet-peek: 42vh;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Nunito, system-ui, sans-serif; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--orange-2); }

#map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font-family: inherit; }
.leaflet-control-attribution { display: none; }
.tiles-dark { filter: invert(1) hue-rotate(200deg) brightness(1.05) contrast(.9) saturate(.5); }
[hidden] { display: none !important; }
.leaflet-control-zoom { display: none; }

/* ---------- Top ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  padding: calc(10px + env(safe-area-inset-top)) 16px 28px;
  background: linear-gradient(to bottom, rgba(13,10,18,.96) 55%, rgba(13,10,18,0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
h1 {
  margin: 0; font-family: Creepster, cursive; font-weight: 400; letter-spacing: 1px;
  font-size: clamp(30px, 8vw, 42px); line-height: 1; color: var(--orange);
  text-shadow: 0 0 18px rgba(255,122,24,.55), 0 2px 0 #4a1d00;
}
h1 span { color: var(--text); text-shadow: 0 0 14px rgba(155,109,255,.6); }
.chips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.chip {
  font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: rgba(34,26,45,.9); border: 1px solid var(--line); white-space: nowrap;
}
.chip-open { border-color: rgba(255,122,24,.6); color: var(--orange-2); }
.nearest {
  margin-top: 8px; display: block; width: 100%; max-width: 420px; text-align: left;
  padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(124,242,106,.45);
  background: rgba(20,40,20,.85); font-size: 14px; font-weight: 700;
}
.nearest b { color: var(--slime); }

.bats { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bat { position: absolute; width: 34px; fill: #000; opacity: .85; filter: drop-shadow(0 0 4px rgba(155,109,255,.7)); }
.b1 { top: 18px; animation: fly 14s linear infinite; }
.b2 { top: 44px; width: 22px; animation: fly 19s linear 4s infinite; }
.b3 { top: 8px; width: 26px; animation: fly 23s linear 9s infinite reverse; }
@keyframes fly {
  0% { transform: translateX(-60px) translateY(0) scaleY(1); }
  25% { transform: translateX(25vw) translateY(10px) scaleY(.6); }
  50% { transform: translateX(50vw) translateY(-4px) scaleY(1); }
  75% { transform: translateX(75vw) translateY(8px) scaleY(.6); }
  100% { transform: translateX(110vw) translateY(0) scaleY(1); }
}

/* ---------- Floating buttons ---------- */
.fabs {
  position: fixed; right: 16px; z-index: 600; display: flex; flex-direction: column; gap: 10px;
  bottom: calc(var(--sheet-peek) + 14px); transition: bottom .3s ease;
}
body.expanded .fabs { opacity: 0; pointer-events: none; }
.fab {
  width: 48px; height: 48px; border-radius: 50%; font-size: 22px;
  background: var(--panel-2); border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0,0,0,.6), 0 0 0 0 rgba(255,122,24,.0);
}
.fab.on { border-color: var(--slime); box-shadow: 0 0 14px rgba(124,242,106,.5); }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 700;
  height: var(--sheet-peek);
  transition: height .3s ease;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.7);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
body.expanded .sheet { height: 88vh; }
.handle { background: none; border: 0; padding: 10px 0 6px; width: 100%; }
.handle span { display: block; width: 44px; height: 5px; border-radius: 3px; margin: 0 auto; background: var(--grey); }

.filters { display: flex; gap: 6px; padding: 0 16px 10px; overflow-x: auto; align-items: center; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.pill {
  flex: none; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line);
}
.pill.active { background: var(--orange); border-color: var(--orange); color: #1a0b00; }
.toggle { flex: none; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--muted); padding-left: 4px; }
.toggle input { accent-color: var(--orange); width: 18px; height: 18px; }

.list { list-style: none; margin: 0; padding: 0 12px 12px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.card {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 10px; margin-bottom: 8px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.card.selected { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange) inset; }
.card.visited { opacity: .55; }
.card .num {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #1a0b00; background: var(--orange);
}
.card .body { min-width: 0; cursor: pointer; }
.card .name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.card .note { font-size: 13px; color: var(--orange-2); margin-top: 2px; }
.card .when { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 13px; line-height: 1.3; white-space: nowrap; }
.card .when .range { color: var(--muted); font-variant-numeric: tabular-nums; }
.card .go {
  padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 800; text-decoration: none;
  background: transparent; border: 1px solid var(--line); color: var(--text);
}
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
.foot { margin: 0; padding: 6px 16px 10px; font-size: 11px; color: var(--muted); text-align: center; }

/* Status */
.st { font-weight: 800; }
.st-open { color: var(--slime); }
.st-closing { color: var(--orange-2); }
.st-soon, .st-later { color: var(--purple); }
.st-closed { color: var(--grey); }
.num.s-soon, .num.s-later, .pin.s-soon, .pin.s-later { background: var(--purple); color: #fff; }
.num.s-closed, .pin.s-closed { background: var(--grey); color: #ddd; }
.num.s-visited, .pin.s-visited { background: var(--slime); color: #0c2108; }

/* ---------- Map pins ---------- */
.pin-wrap { background: none; border: 0; }
.pin {
  position: relative; width: 34px; height: 30px; border-radius: 48% 48% 44% 44%;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #1a0b00;
  background: radial-gradient(circle at 35% 30%, var(--orange-2), var(--orange) 60%, #c24e00);
  box-shadow: 0 0 14px rgba(255,122,24,.75), inset 0 -3px 0 rgba(0,0,0,.25);
  border: 2px solid #1a0b00;
}
.pin::before {
  content: ""; position: absolute; top: -7px; left: 50%; width: 5px; height: 8px; margin-left: -2px;
  background: #3f7a2a; border-radius: 2px 2px 0 0;
}
.pin.s-open { animation: glow 2.2s ease-in-out infinite; }
.pin.s-closing { box-shadow: 0 0 14px rgba(255,179,71,.9); }
.pin.s-closed { box-shadow: none; opacity: .8; }
.pin.s-soon, .pin.s-later { box-shadow: 0 0 12px rgba(155,109,255,.7); }
.pin.sel { transform: scale(1.3); z-index: 1000; outline: 3px solid #fff; outline-offset: 2px; }
@keyframes glow { 50% { box-shadow: 0 0 24px rgba(255,122,24,1), inset 0 -3px 0 rgba(0,0,0,.25); } }

.me-dot {
  width: 18px; height: 18px; border-radius: 50%; background: #4aa3ff; border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(74,163,255,.6); animation: ping 2s infinite;
}
@keyframes ping { 70% { box-shadow: 0 0 0 16px rgba(74,163,255,0); } 100% { box-shadow: 0 0 0 0 rgba(74,163,255,0); } }

/* Popup */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.4; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.pop h3 { margin: 0 0 2px; font-size: 17px; }
.pop .addr { color: var(--muted); font-size: 13px; }
.pop .row { margin-top: 6px; }
.pop .note { color: var(--orange-2); margin-top: 4px; }
.pop .approx { color: var(--muted); font-size: 12px; margin-top: 4px; }
.pop .actions { display: flex; gap: 8px; margin-top: 10px; }
.btn {
  flex: 1; padding: 9px 12px; border-radius: 10px; border: 0; font-weight: 800; font-size: 14px; text-align: center;
  background: var(--orange); color: #1a0b00 !important; text-decoration: none;
}
.btn.ghost { background: var(--panel-2); color: var(--text) !important; border: 1px solid var(--line); }
.btn.done { background: var(--slime); color: #0c2108 !important; }

/* Info dialog */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: 85vh; overflow: auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 20px;
}
dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 10px; font-family: Creepster, cursive; font-weight: 400; color: var(--orange); font-size: 30px; letter-spacing: 1px; }
dialog h3 { margin: 16px 0 4px; font-size: 16px; }
dialog ul { padding-left: 0; list-style: none; margin: 0; }
dialog li { margin: 6px 0; }
dialog p { margin: 4px 0; color: var(--muted); }
dialog .btn { display: block; width: 100%; margin-top: 18px; padding: 12px; font-size: 16px; }
dialog .install-link { margin-top: 12px; }

/* Talebobbel ved 💀-knappen indtil info er læst */
.fab-wrap { position: relative; }
.hint {
  position: absolute; right: calc(100% + 14px); top: 50%; transform: translateY(-50%);
  width: max-content; max-width: 190px; padding: 9px 13px; border-radius: 14px;
  background: var(--orange); color: #1a0b00; border: 0; text-align: left;
  font-size: 14px; font-weight: 700; line-height: 1.25;
  box-shadow: 0 6px 22px rgba(0,0,0,.55), 0 0 22px rgba(255,122,24,.5);
  animation: hint-in .4s ease-out, nudge 1.8s ease-in-out .4s infinite;
}
.hint::after {
  content: ""; position: absolute; left: 100%; top: 50%; margin-top: -8px;
  border: 8px solid transparent; border-left-color: var(--orange); border-right: 0;
}
.fab.attn { border-color: var(--orange); animation: ring 1.8s ease-out infinite; }
@keyframes hint-in { from { opacity: 0; transform: translate(10px, -50%); } }
@keyframes nudge { 50% { transform: translate(-6px, -50%); } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255,122,24,.7); } 100% { box-shadow: 0 0 0 16px rgba(255,122,24,0); } }

/* Installationsdialog */
dialog.install {
  width: min(400px, calc(100vw - 32px)); text-align: center; padding: 28px 22px 22px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255,122,24,.22), transparent 60%),
    radial-gradient(80% 50% at 50% 100%, rgba(155,109,255,.18), transparent 70%),
    var(--panel);
  border-color: rgba(255,122,24,.35);
  box-shadow: 0 0 60px rgba(255,122,24,.25);
}
dialog.install[open] { animation: rise .35s ease-out; }
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }
.install-hero img {
  width: 96px; height: 96px; border-radius: 22px;
  box-shadow: 0 0 0 1px var(--line), 0 0 34px rgba(255,122,24,.55);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
dialog.install h2 { margin: 16px 0 6px; font-size: 32px; line-height: 1.05; }
dialog.install .lead { color: var(--text); font-size: 15px; }
dialog.install .perks { text-align: left; margin: 16px auto 0; max-width: 300px; font-size: 14px; color: var(--muted); }
dialog.install .ios-steps { display: none; text-align: left; margin: 16px auto 0; padding-left: 22px; max-width: 300px; font-size: 15px; }
dialog.install .ios-steps li { margin: 8px 0; }
.share-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; }
.install-actions { margin-top: 6px; }
.install-actions .btn { margin-top: 10px; }
.install-actions .ios-only { display: none; }
dialog.install.ios .perks, dialog.install.ios .std-only { display: none; }
dialog.install.ios .ios-steps { display: block; }
dialog.install.ios .ios-only { display: block; }

/* ---------- Desktop: liste som sidepanel ---------- */
@media (min-width: 900px) {
  .sheet {
    top: 0; right: auto; width: 400px; height: auto !important;
    border-radius: 0; border-top: 0; border-right: 1px solid var(--line);
    padding-top: 150px;
  }
  .handle { display: none; }
  .topbar { z-index: 800; width: 400px; right: auto; background: var(--panel); padding-bottom: 12px; border-right: 1px solid var(--line); }
  #map { left: 400px; }
  .fabs { bottom: 24px !important; }
  body.expanded .fabs { opacity: 1; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .bat, .pin.s-open, .me-dot, .install-hero img, dialog.install[open], .hint, .fab.attn { animation: none; }
  .bat { display: none; }
}
