/* Layout: the map fills the whole screen; a search card floats top-left, map controls bottom-right, readouts bottom-left. */
:root {
  --ocean: #00a8c6;
  --surface: #f6fbfb;
  --surface-2: #e4f0f1;
  --fg: #0d2c3a;
  --muted: #4c6a76;
  --line: #c3d8dc;
  --accent: #d93868;
  --accent-fg: #ffffff;
  --label: #fff3c4;
  --ok: #1d7a4c;
  --warn: #a15c00;
  --shadow: 0 6px 22px rgba(4, 40, 52, .28);
  /* Marker colours per layer; the same in both themes because they sit on the map image, not on the chrome. */
  --c-mission: #6d3fd6;
  --c-money: #b97f00;
  --c-easter_egg: #d9542b;
  --c-trivia: #1f5fd0;
  --c-shop: #33434b;
  --c-collectible: #b0399a;
  --c-other: #5a6b73;
  --font-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Barlow", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #0c2530; --surface-2: #143644; --fg: #e8f4f6; --muted: #9dbac3; --line: #24505f;
    --accent: #ff6b93; --accent-fg: #1a0710; --ok: #5fd39a; --warn: #f0b458; --shadow: 0 6px 22px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --surface: #0c2530; --surface-2: #143644; --fg: #e8f4f6; --muted: #9dbac3; --line: #24505f;
  --accent: #ff6b93; --accent-fg: #1a0710; --ok: #5fd39a; --warn: #f0b458; --shadow: 0 6px 22px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
html, body { height: 100%; margin: 0; }
body { background: var(--ocean); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.4; overflow: hidden; }
[hidden] { display: none !important; }
#app { position: relative; height: 100%; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--ocean); outline: none; }

/* Leaflet 1.9.4 core rules, kept here so the page needs no second stylesheet (and no Leaflet image files). */
.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-container{overflow:hidden;-webkit-tap-highlight-color:transparent;font-family:inherit}
.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;user-select:none;-webkit-user-drag:none}
.leaflet-tile::selection{background:transparent}
.leaflet-container .leaflet-tile{max-width:none!important;max-height:none!important;width:auto;padding:0}
.leaflet-container.leaflet-touch-zoom{touch-action:pan-x pan-y}
.leaflet-container.leaflet-touch-drag{touch-action:pinch-zoom}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{touch-action:none}
.leaflet-tile{filter:inherit;visibility:hidden}
.leaflet-tile-loaded{visibility:inherit}
.leaflet-zoom-box{width:0;height:0;box-sizing:border-box;z-index:800}
.leaflet-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-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}
.leaflet-control{position:relative;z-index:800;pointer-events:auto}
.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}
.leaflet-zoom-animated{transform-origin:0 0}
svg.leaflet-zoom-animated{will-change:transform}
.leaflet-zoom-anim .leaflet-zoom-animated{transition:transform .25s cubic-bezier(0,0,.25,1)}
.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{transition:none}
.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}
.leaflet-interactive{cursor:pointer}
.leaflet-grab{cursor:grab}
.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:grabbing}
.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}
.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive{pointer-events:auto}
.leaflet-container.placing, .leaflet-container.placing .leaflet-grab{cursor:crosshair}

/* Overlay that carries every control; the map behind it stays full-bleed. */
#ui { position: absolute; inset: 0; z-index: 1100; pointer-events: none;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; }
#ui > * { min-width: 0; min-height: 0; }
.panel { pointer-events: auto; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

#top { display: flex; flex-direction: column; gap: 8px; width: min(380px, 100%); max-height: 100%; }
#search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 46px; flex: none; }
#search svg { flex: none; color: var(--muted); }
#q { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 16px; height: 100%; outline: none; }
#q::placeholder { color: var(--muted); }
#search:focus-within { border-color: var(--accent); }
#results { list-style: none; margin: 0; padding: 4px; max-height: min(46vh, 340px); overflow-y: auto; }
#results li { margin: 0; }
#results button { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
#results button:hover, #results button.active { background: var(--surface-2); }
#results .nm { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: .02em; text-transform: uppercase; }
#results .ty { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
#results .none { padding: 10px; color: var(--muted); }

#card { padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
#card h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.05; letter-spacing: .02em; text-transform: uppercase; text-wrap: balance; }
#card .head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
#card p { margin: 0; max-width: 60ch; }
#card .note { color: var(--muted); font-size: 13.5px; }
#card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 14px; }
#card dt { color: var(--muted); }
#card dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
#card a { color: var(--accent); font-weight: 500; }
#card .actions, #card .badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.cat { color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font: inherit; font-weight: 500; padding: 7px 12px; border-radius: 7px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }

#hint { justify-self: center; align-self: start; padding: 9px 14px; font-weight: 500; display: flex; gap: 12px; align-items: center; }
#hint button { border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 2px 4px; }

#bottom { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
#readout { display: flex; flex-direction: column; gap: 6px; align-items: start; flex: 1; min-width: 0; }
#grid { white-space: nowrap; padding: 4px 10px; font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .04em; border-radius: 7px; }
#grid span { color: var(--muted); font-weight: 500; }
#scale { pointer-events: none; color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 40, 55, .8); font-variant-numeric: tabular-nums; }
#scale i { display: block; height: 6px; border: 2px solid #fff; border-top: 0; box-shadow: 0 1px 2px rgba(0, 40, 55, .5); margin-top: 2px; }
#credit { pointer-events: none; color: #fff; font-size: 11px; text-shadow: 0 1px 2px rgba(0, 40, 55, .9); max-width: 46ch; }
#controls { display: flex; flex-direction: column; gap: 8px; align-items: end; position: relative; }
/* Panels float above the buttons so opening one does not squeeze the readouts beside them. */
#layers, #link { position: absolute; right: 0; bottom: calc(100% + 8px); max-height: min(60vh, 420px); overflow-y: auto; }
#controls .stack { display: flex; flex-direction: column; overflow: hidden; }
#controls .stack > button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--fg); cursor: pointer; display: grid; place-items: center; }
#controls .stack > button:hover { background: var(--surface-2); }
#controls .stack > button + button { border-top: 1px solid var(--line); }
#locate.on, #link-btn.on, #layers-btn[aria-expanded="true"], #link-btn[aria-expanded="true"] { color: var(--accent); }
button:focus-visible, #q:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layer list */
#layers { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 230px; max-width: min(300px, calc(100vw - 32px)); }
#layers h3 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .06em; text-transform: uppercase; }
#layers label { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 9px; padding: 5px 2px; cursor: pointer; }
#layers input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
#layers .cnt { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
#layers .sep { border-top: 1px solid var(--line); margin: 4px 0; }
#layers .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 40, 55, .4); box-sizing: border-box; }

/* Link devices */
#link { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; width: min(290px, calc(100vw - 32px)); box-sizing: border-box; }
#link h3 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .06em; text-transform: uppercase; }
#link p { margin: 0; }
#link .note { color: var(--muted); font-size: 13px; }
#link .err { color: var(--warn); font-weight: 500; }
#link .status { font-weight: 600; }
#link .status.ok { color: var(--ok); }
#link .code { font-family: var(--font-display); font-weight: 700; font-size: 38px; line-height: 1; letter-spacing: .14em; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }
#link .actions, #link .join { display: flex; flex-wrap: wrap; gap: 8px; }
#link .join input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--fg);
  font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }

/* Markers */
.me { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0, 40, 55, .35), 0 2px 8px rgba(0, 0, 0, .45); box-sizing: border-box; position: relative; }
.me::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--accent); animation: ping 2.2s ease-out infinite; }
@keyframes ping { from { transform: scale(1); opacity: .9; } to { transform: scale(3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .me::after { animation: none; opacity: 0; } }
.pin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--label); box-shadow: 0 0 0 2px #0d2c3a, inset 0 0 0 2px #0d2c3a; box-sizing: border-box; }
.pt { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 40, 55, .45), 0 2px 6px rgba(0, 0, 0, .4); box-sizing: border-box;
  display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1; }
.pt.sel { box-shadow: 0 0 0 3px var(--label), 0 0 0 5px #0d2c3a; }
.pt.unconfirmed { border-style: dashed; }
.pt.found { opacity: .55; font-size: 16px; }
.pt.found.sel { opacity: 1; }

@media (max-width: 560px) {
  #credit { font-size: 10px; max-width: 38ch; }
  #top { width: 100%; }
}
