:root {
  --bg: #0f1720;
  --panel: #172230;
  --panel-2: #1f2d3d;
  --line: #2b3a4d;
  --text: #e8eef5;
  --muted: #93a4b7;
  --accent: #3ec46d;
  --accent-ink: #06231a;
  --danger: #e0564f;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
#map { position: absolute; inset: 0; }

/* ── Top bar ─────────────────────────────── */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(15,23,32,0.9), rgba(15,23,32,0));
  pointer-events: none;
}
.brand {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 700; font-size: 18px; letter-spacing: 0.2px;
  pointer-events: auto; color: var(--text); text-decoration: none;
}
.brand b { color: var(--accent); font-weight: 800; }
.brand-logo { display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.score-chip {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-weight: 700; font-size: 15px; cursor: pointer;
  box-shadow: var(--shadow);
}
.score-icon { color: #f7d154; }
.avatar-btn {
  pointer-events: auto; flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 50%; padding: 0;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-size: 18px; font-weight: 800; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.avatar-btn:active { transform: scale(0.95); }
.top-right { display: inline-flex; align-items: center; gap: 8px; pointer-events: auto; }
.lang-wrap { position: relative; display: inline-flex; align-items: center; }
.lang-globe { position: absolute; left: 10px; font-size: 13px; pointer-events: none; z-index: 1; }
.lang-select {
  appearance: none; -webkit-appearance: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 24px 7px 30px; font-size: 13px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow); max-width: 150px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23e8eef5' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.lang-select:focus { outline: none; border-color: var(--accent); }
/* RTL: flip the fixed-corner UI */
[dir="rtl"] .fab { right: auto; left: 18px; }
[dir="rtl"] .filter-btn { left: auto; right: 12px; }
[dir="rtl"] .filters { direction: rtl; left: 12px; right: 66px; }

/* ── Filters ─────────────────────────────── */
.filter-btn {
  position: absolute; top: 60px; left: 12px; z-index: 6;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow);
}
.filter-btn:active { transform: scale(0.95); }
.filter-dot {
  position: absolute; top: 6px; right: 6px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--panel);
}
.filters {
  position: absolute; top: 64px; left: 66px; right: 12px; z-index: 5;
  display: flex; gap: 8px; padding: 6px 2px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  white-space: nowrap; opacity: 0.55; transition: opacity .15s, border-color .15s;
}
.pill.active { opacity: 1; border-color: var(--accent); }

/* ── FAB ─────────────────────────────────── */
.fab {
  position: absolute; right: 18px; bottom: 26px; z-index: 6;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  border: none; font-size: 32px; line-height: 1; font-weight: 700;
  box-shadow: var(--shadow); cursor: pointer;
}
.fab:active { transform: scale(0.96); }

/* ── Bottom sheets ───────────────────────── */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--panel); border-top-left-radius: 20px; border-top-right-radius: 20px;
  box-shadow: var(--shadow); padding: 8px 16px 20px;
  max-height: 86vh; overflow-y: auto;
  transform: translateY(0); transition: transform .25s ease;
}
.sheet.hidden { transform: translateY(105%); pointer-events: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 18px; margin: 0; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.sheet-body { display: flex; flex-direction: column; }

.field-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 14px 0 8px; }

/* Type picker */
.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.type-opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--panel-2); border: 2px solid transparent; border-radius: 12px;
  padding: 12px 6px; cursor: pointer; font-size: 12px; color: var(--text);
}
.type-opt .emoji { font-size: 24px; }
.type-opt.active { border-color: var(--accent); }

/* Photo drop */
.photo-drop {
  display: flex; align-items: center; justify-content: center;
  min-height: 150px; border: 2px dashed var(--line); border-radius: 14px;
  background: var(--panel-2); cursor: pointer; overflow: hidden; position: relative;
}
.photo-hint { color: var(--muted); font-size: 14px; }
.photo-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; }

/* Type chip + manual-picker toggle (photo-first flow) */
.type-toggle { margin-top: 14px; width: 100%; }
.type-chip {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px;
}
.type-chip .tc-icon { font-size: 22px; }
.type-chip .tc-label { flex: 1; font-weight: 700; font-size: 15px; }
.type-chip .tc-change {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.type-chip .tc-change:hover { border-color: var(--accent); color: var(--text); }

/* AI recognition box */
.ai-box { margin-top: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.ai-box.scanning { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.ai-spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ai-label { font-size: 15px; font-weight: 700; }
.ai-label .em { margin-right: 6px; }
.rarity-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.ai-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.rarity-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.rarity-opt { font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.rarity-opt.active { color: var(--text); }

/* Location row */
.loc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.loc-text { font-size: 14px; color: var(--text); }
.loc-help { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* Buttons */
.primary-btn {
  margin-top: 20px; width: 100%; padding: 15px; border: none; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 700; cursor: pointer;
}
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}

/* ── Detail sheet content ────────────────── */
.detail-photo { width: 100%; border-radius: 12px; margin-bottom: 12px; }
.detail-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-select { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ── Profile / account ───────────────────── */
.pf-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 12px; }
.pf-id { min-width: 0; }
.pf-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 22px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
}
.pf-avatar.empty { background: var(--panel-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); font-size: 26px; }
.pf-name { font-size: 19px; font-weight: 800; }
.pf-name.prompt { color: var(--accent); font-size: 16px; }
.pf-points { color: var(--muted); font-size: 14px; }
.pf-points b { color: var(--text); }
.pf-email { color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.pf-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 0 10px; }

/* Nickname claim card (surfaced at the top for signed-in users) */
.pf-claim { margin: 0 0 4px; }
.pf-claim.empty { background: rgba(62,196,109,0.08); border: 1px solid var(--accent); border-radius: 12px; padding: 12px; margin-bottom: 8px; }

/* Nickname + email rows */
.pf-form { display: flex; gap: 8px; }
.pf-input {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 14px;
}
.pf-input:focus { outline: none; border-color: var(--accent); }
.pf-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* Impact */
.impact-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.impact-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.impact-row:last-child { border-bottom: none; }
.ir-label { font-weight: 700; }
.ir-val { color: var(--muted); font-size: 14px; }
.ir-val b { color: var(--text); }
.ref-stats { margin-top: 10px; font-size: 14px; color: var(--muted); }
.ref-stats b { color: var(--text); }

/* Achievements grid */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.ach {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 8px; text-align: center;
}
.ach.locked { opacity: 0.4; filter: grayscale(0.7); }
.ach .ach-ico { font-size: 26px; }
.ach .ach-t { font-size: 12px; font-weight: 700; margin-top: 6px; }
.ach .ach-d { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.3; }

/* Leaderboard */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }
.lb-name { flex: 1; font-weight: 700; }
.lb-row.me { color: var(--accent); }
.lb-pts { font-weight: 800; }
.lb-pts .s { color: var(--gold, #f7d154); }

/* My finds archive */
.pf-section-flex { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pf-share-btn {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.pf-share-btn:hover { border-color: var(--accent); color: var(--text); }
.find-list { display: flex; flex-direction: column; gap: 8px; }
.find-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
}
.find-thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; }
.find-thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.find-meta { flex: 1; min-width: 0; }
.find-top { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.find-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.rarity-badge.sm { padding: 2px 7px; font-size: 11px; font-weight: 800; border-radius: 999px; }
.find-share {
  background: none; border: none; color: var(--muted); font-size: 18px;
  cursor: pointer; flex: 0 0 auto; padding: 4px 6px; line-height: 1;
}
.find-share:hover { color: var(--accent); }

/* ── Markers ─────────────────────────────── */
.marker {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 3px 8px rgba(0,0,0,0.4); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.marker span { transform: rotate(45deg); font-size: 15px; }
.marker.resolved { opacity: 0.55; }
/* Declutter: hide report pins when zoomed out (draft pin stays). */
.markers-hidden .report-marker { display: none; }

/* ── Flyover ad-banner (blimp) ───────────── */
.flyover-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.flyover {
  position: absolute; top: 15%; left: 0;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  will-change: transform; animation: flyR 20s linear forwards;
}
.flyover.rev { flex-direction: row-reverse; animation: flyL 20s linear forwards; }
.blimp { width: 78px; pointer-events: auto; cursor: pointer; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); }
.blimp svg { display: block; width: 100%; height: auto; }
.blimp:active { transform: scale(0.94); }
.fly-banner {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(0,0,0,.3); transform-origin: right center;
  animation: sway 2.6s ease-in-out infinite;
}
.flyover.rev .fly-banner { transform-origin: left center; border-top-color: var(--accent); }
.fly-banner.sponsor { border-top-color: var(--gold, #f7d154); color: #ffe9a8; }
@keyframes flyR { from { transform: translateX(-48vw); } to { transform: translateX(110vw); } }
@keyframes flyL { from { transform: translateX(110vw); } to { transform: translateX(-48vw); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes sway { 0%,100% { transform: rotate(-1.2deg); } 50% { transform: rotate(1.6deg); } }
/* Reduced motion: fade a static banner in the corner instead of flying it */
body.reduce-fly .flyover { left: auto; right: 14px; top: 76px; animation: flyFade 6s ease forwards; }
body.reduce-fly .flyover.rev { flex-direction: row; }
body.reduce-fly .blimp { animation: none; }
body.reduce-fly .fly-banner { animation: none; }
@keyframes flyFade { 0%,100% { opacity: 0; } 15%,85% { opacity: 1; } }

/* ── Banner + toast ──────────────────────── */
.banner {
  position: absolute; left: 12px; right: 12px; bottom: 100px; z-index: 8;
  background: #3a2a12; border: 1px solid #6b4d1e; color: #ffdca3;
  padding: 12px 14px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow);
}
.banner code { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.toast {
  position: absolute; left: 50%; bottom: 110px; z-index: 20; transform: translateX(-50%);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}
.toast.err { border-color: var(--danger); color: #ffb4af; }

.hidden { display: none !important; }
