:root {
  --bg: #0f1a12;
  --fg: #ffffff;
  --muted: #c9d6cc;
  --panel: #1d2e22;
  --panel-a: rgba(20, 32, 24, .92);
  --blue: #1a73e8;
  --blue-fg: #ffffff;
  --obj: #ffc233;        /* objects: warm yellow */
  --obj-dim: #c9a55a;    /* not loaded yet */
  --match: #ff5a5f;      /* search match */
  --error: #ff8a80;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; }
.error { color: var(--error); }

.view { position: fixed; inset: 0; }

/* Splash */
#splash, #blocked { display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(#2d4a35, var(--bg)); }
.splash-body { max-width: 30rem; text-align: center; }
.splash-body h1 { font-size: 2.4rem; margin: 0 0 16px; letter-spacing: .02em; }
.welcome, #blocked-msg { font-size: 1.1rem; line-height: 1.5; color: var(--muted); }
.big-blue {
  margin-top: 24px; min-width: 200px; min-height: 64px; padding: 0 32px;
  border: 0; border-radius: 999px; background: var(--blue); color: var(--blue-fg);
  font-size: 1.4rem; font-weight: 700; box-shadow: 0 4px 16px rgba(26,115,232,.45);
}
.big-blue:disabled { opacity: .6; }
#splash-msg { min-height: 1.4em; color: var(--muted); margin-top: 16px; }
#splash-msg.error { color: var(--error); }
#admin-badge { color: var(--match); font-weight: 600; margin: 12px 0 0; }

.icon-btn {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 10px;
  background: var(--panel-a); color: var(--fg); font-size: 1.3rem;
}
.icon-btn.round { border-radius: 50%; }
#menu-btn { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; }

.sheet { background: var(--panel-a); color: var(--fg); border-radius: 14px; padding: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); }
#menu { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 52px); right: 12px; z-index: 20;
  display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
#menu > button { min-height: 44px; border: 0; border-radius: 10px; background: var(--panel); color: var(--fg); }
#menu fieldset { border: 1px solid #3a5242; border-radius: 10px; margin: 0; }
#menu label { display: block; padding: 6px 0; }

dialog { border: 0; border-radius: 14px; background: var(--panel); color: var(--fg); width: min(92vw, 360px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; }
dialog label { display: block; margin: 10px 0; }
dialog input { display: block; width: 100%; margin-top: 4px; min-height: 40px; font: inherit;
  border-radius: 8px; border: 1px solid #3a5242; background: #0f1a12; color: var(--fg); padding: 0 10px; }
dialog .row { justify-content: flex-end; margin-top: 12px; }
dialog button, .sheet button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px;
  background: #33493b; color: var(--fg); }
button.primary { background: var(--blue); color: var(--blue-fg); font-weight: 700; }

/* Map */
#map { position: absolute; inset: 0; }
#search-bar { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 64px; z-index: 5;
  display: flex; gap: 6px; }
#search { flex: 1; min-height: 44px; font: inherit; font-size: 1rem; padding: 0 14px;
  border: 0; border-radius: 10px; background: var(--panel-a); color: var(--fg); }
#search::placeholder { color: var(--muted); }
#search::-webkit-search-cancel-button { display: none; }
#search-results { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 50px); left: 10px; right: 64px;
  z-index: 5; margin: 0; padding: 4px; list-style: none; max-height: 45vh; overflow-y: auto;
  background: var(--panel-a); border-radius: 10px; }
#search-results li button { width: 100%; text-align: left; min-height: 44px; padding: 6px 10px; border: 0;
  background: none; color: var(--fg); display: flex; justify-content: space-between; gap: 8px; border-radius: 8px; }
#search-results li button.available { background: rgba(255,194,51,.28); }
#search-results li small { color: var(--muted); white-space: nowrap; }
#search-results li.empty { padding: 10px; color: var(--muted); }
#locate-btn { position: absolute; right: 10px; bottom: calc(44px + env(safe-area-inset-bottom)); z-index: 5;
  width: 52px; height: 52px; font-size: 1.6rem; }
#map-status { position: absolute; left: 10px; bottom: calc(44px + env(safe-area-inset-bottom)); z-index: 4;
  max-width: calc(100% - 90px); padding: 6px 10px; border-radius: 8px; background: var(--panel-a);
  color: var(--muted); font-size: .9rem; }
#map-status:empty { display: none; }
#toast { position: absolute; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 10; max-width: 90vw; padding: 12px 18px; border-radius: 12px; background: rgba(0,0,0,.85);
  color: #fff; font-size: 1rem; text-align: center; }
.maplibregl-ctrl-top-right { top: max(10px, env(safe-area-inset-top)); }
.maplibregl-ctrl-group { background: var(--panel-a); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

/* User marker: always above object markers */
.user-marker { pointer-events: none; z-index: 3; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.user-marker.no-heading .user-arrow { display: none; }
.obj-marker { z-index: 1; }

/* Object markers */
.obj-marker { display: flex; flex-direction: column; align-items: center; pointer-events: auto; }
.obj-marker .dot { position: relative; width: 22px; height: 22px; border-radius: 50%;
  background: var(--obj-dim); border: 3px solid #fff8e1; box-shadow: 0 1px 6px rgba(0,0,0,.6); opacity: .85; }
.obj-marker .label { margin-top: 4px; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.75);
  color: #fff; font-size: .85rem; font-weight: 600; white-space: nowrap; display: none; }
.obj-marker .arrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; display: none;
  margin-left: -6px; margin-top: -20px;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 20px solid #3e2723;
  transform-origin: 50% 100%; }
.obj-marker.loaded .dot { background: var(--obj); opacity: 1; }
.obj-marker.available .dot { background: var(--obj); opacity: 1; width: 30px; height: 30px;
  box-shadow: 0 0 0 4px rgba(255,194,51,.45), 0 1px 6px rgba(0,0,0,.6); }
.obj-marker.available .label { display: block; background: var(--obj); color: #2b1d00; }
.obj-marker.match .dot { background: var(--match); opacity: 1; }
.obj-marker.match .label { display: block; background: var(--match); color: #fff; }
.obj-marker.match.available .dot { background: var(--obj); box-shadow: 0 0 0 4px var(--match); }
.admin .obj-marker .label { display: block; }
.admin .obj-marker .arrow { display: block; }
.obj-marker.draft .dot { background: #fff; opacity: 1; }

/* Admin panel */
#admin-panel { position: absolute; left: 10px; right: 10px; bottom: calc(34px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; flex-direction: column; gap: 8px; }
#admin-panel select { flex: 1; min-height: 44px; font: inherit; border-radius: 8px; border: 0;
  background: var(--panel); color: var(--fg); padding: 0 8px; }
#admin-hint { margin: 0; color: var(--muted); font-size: .95rem; }
.field { display: block; margin: 4px 0; }
.field input[type=range] { width: 100%; }
.field input[type=number] { width: 100px; min-height: 36px; font: inherit; margin-left: 8px;
  border-radius: 8px; border: 1px solid #3a5242; background: #0f1a12; color: var(--fg); padding: 0 8px; }
#admin-edit .row { justify-content: flex-end; }
.admin #locate-btn, .admin #map-status { bottom: calc(200px + env(safe-area-inset-bottom)); }
.maplibregl-popup-content { background: var(--panel); color: var(--fg); border-radius: 10px; }
.maplibregl-popup-tip { border-top-color: var(--panel) !important; border-bottom-color: var(--panel) !important; }
.popup-del { margin-top: 8px; min-height: 36px; border: 0; border-radius: 8px; background: #c62828; color: #fff; padding: 0 14px; }

/* AR overlay */
#ar-overlay { position: fixed; inset: 0; z-index: 50; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between; }
#ar-overlay > * { pointer-events: auto; }
#ar-top { display: flex; gap: 10px; align-items: flex-start; padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top)); }
#ar-status { flex: 1; margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(0,0,0,.65);
  color: #fff; font-size: 1.05rem; font-weight: 600; }
#ar-status:empty { visibility: hidden; }
#ar-exit { min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--blue);
  color: #fff; font-weight: 700; }
#sound-player { margin: 12px; margin-bottom: calc(16px + env(safe-area-inset-bottom)); padding: 12px;
  border-radius: 14px; background: rgba(0,0,0,.72); color: #fff; }
#sound-name { margin: 0 0 6px; font-size: .8rem; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sound-name::before { content: '♪ '; }
#sound-player button { min-width: 48px; min-height: 48px; border: 0; border-radius: 999px;
  background: var(--blue); color: #fff; font-size: 1.2rem; padding: 0 14px; }
#sound-lang { margin-bottom: 8px; flex-wrap: wrap; }
#sound-player #sound-lang button { font-size: 1rem; min-height: 40px; background: #33493b; }
#sound-player #sound-lang button.selected { background: var(--blue); }
#sound-seek { flex: 1; min-width: 0; height: 32px; }
#sound-time { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }

/* During AR only the overlay is composited over the camera. The map stays laid out (no display:none),
   so its WebGL canvas isn't resized to zero and rebuilt when AR ends. */
body.in-ar { background: transparent; }
body.in-ar #menu { display: none !important; }
