:root {
  --cyan: #00f0ff;
  --magenta: #ff2bd6;
  --bg: #04121c;
  --panel-bg: rgba(6, 20, 30, 0.92);
  --panel-border: rgba(0, 240, 255, 0.28);
  --text: #eaf6ff;
  --muted: #9fb2c8;
  --chip-bg: rgba(10, 28, 40, 0.85);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; overflow: hidden; }

#cesiumContainer { position: fixed; inset: 0; }

/* Hide Cesium's default credit clutter but keep it reachable. */
.cesium-widget-credits { font-size: 10px !important; opacity: 0.5; }
.cesium-viewer-bottom { z-index: 5; }

/* ─── Top bar ─────────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(4,18,28,0.94) 0%, rgba(4,18,28,0.72) 70%, transparent 100%);
  backdrop-filter: blur(4px);
  /* Let clicks fall through the transparent gradient area to the map/banner;
     only the interactive children below capture pointer events. */
  pointer-events: none;
}
#topbar .brand, #topbar .search-box, #topbar .filters { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  /* Rendered as a <button> so it's a real, focusable control — reset the
     browser chrome and keep the glowing star look. */
  appearance: none; border: 0; background: none; padding: 0; margin: 0;
  line-height: 1; cursor: pointer;
  font-size: 26px; color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan), 0 0 24px rgba(0,240,255,0.5);
  transition: transform .15s ease, text-shadow .15s ease;
}
.brand-mark:hover { transform: scale(1.12) rotate(8deg); }
.brand-mark:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }
.brand-title { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ─── Search ──────────────────────────────────────────────── */
.search-box { position: relative; flex: 1 1 380px; max-width: 620px; min-width: 240px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; opacity: 0.7; pointer-events: none;
}
#searchInput {
  width: 100%; padding: 11px 14px 11px 36px;
  background: var(--chip-bg); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 10px;
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
#searchInput:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,240,255,0.15), 0 0 18px rgba(0,240,255,0.25);
}
#searchInput::placeholder { color: #6f849a; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; overflow: hidden; display: none; z-index: 30;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); max-height: 60vh; overflow-y: auto;
}
.search-results.open { display: block; }
.search-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.search-row:hover, .search-row.active { background: rgba(0,240,255,0.12); }
.sr-name { font-weight: 600; }
.sr-sub { font-size: 12px; color: var(--muted); text-align: right; }
.search-none { padding: 12px 14px; color: var(--muted); font-size: 13px; }

/* ─── Cluster jump-to list (click a cyan cluster badge) ──────────────── */
.cluster-list {
  position: fixed; z-index: 30; min-width: 190px; max-width: 260px;
  max-height: 260px; overflow-y: auto;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.cluster-list.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.cluster-list-title {
  padding: 8px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--cyan); border-bottom: 1px solid rgba(255,255,255,0.08);
}
.cluster-list-row {
  padding: 9px 12px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cluster-list-row:hover { background: rgba(0,240,255,0.12); }
.cluster-list-row:last-child { border-bottom: none; }

/* ─── Filter chips ────────────────────────────────────────── */
.filters { display: flex; gap: 7px; flex-wrap: wrap; }
.filter-chip {
  --chip: var(--cyan);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
  font-size: 12px; color: var(--text);
  background: var(--chip-bg); border: 1px solid rgba(255,255,255,0.14);
  transition: all .15s; opacity: 0.55;
}
.filter-chip .fc-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--chip);
  box-shadow: 0 0 6px var(--chip);
}
.filter-chip.active { opacity: 1; border-color: var(--chip); }
.filter-chip:hover { opacity: 1; }

/* ─── Legend ──────────────────────────────────────────────── */
.legend {
  position: fixed; left: 18px; bottom: 34px; z-index: 15;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 12px 14px; font-size: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.45); max-width: 210px;
}
.legend-title { font-weight: 700; margin-bottom: 8px; color: var(--cyan); }
.legend-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--muted); }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 7px currentColor; }
.terrain-row {
  display: flex; align-items: center; gap: 5px; margin-top: 10px; padding-top: 9px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.terrain-label { color: var(--muted); margin-right: 2px; }

/* ─── Zoom controls ───────────────────────────────────────── */
/* Discreet by design: quiet at rest, brightens on hover/focus. Sits
   vertically centered on the left edge — clear of the legend (bottom-left)
   and the topbar/brand (top). */
.zoom-controls {
  position: fixed; left: 14px; top: 50%; transform: translateY(-50%); z-index: 16;
  display: flex; flex-direction: column;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 9px; overflow: hidden;
  opacity: 0.55; transition: opacity .2s ease, box-shadow .2s ease;
}
.zoom-controls:hover, .zoom-controls:focus-within {
  opacity: 1; box-shadow: 0 0 16px rgba(0,240,255,0.25);
}
.zoom-btn {
  appearance: none; border: 0; cursor: pointer;
  width: 34px; height: 34px; padding: 0;
  background: transparent; color: var(--text);
  font-size: 18px; line-height: 1; font-weight: 700;
}
.zoom-btn:hover, .zoom-btn:focus-visible { background: rgba(0,240,255,0.14); color: var(--cyan); }
.zoom-btn:first-child { border-bottom: 1px solid var(--panel-border); }
.zoom-btn:focus-visible { outline: none; }
.terrain-btn {
  padding: 3px 8px; border-radius: 6px; cursor: pointer; font-size: 11px;
  background: var(--chip-bg); color: var(--muted);
  border: 1px solid rgba(255,255,255,0.14); transition: all .15s;
}
.terrain-btn:hover { color: var(--text); }
.terrain-btn.active { color: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,240,255,0.25); }

/* ─── Info panel ──────────────────────────────────────────── */
.info-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 380px; max-width: 92vw;
  z-index: 25; background: var(--panel-bg); border-left: 1px solid var(--panel-border);
  box-shadow: -12px 0 40px rgba(0,0,0,0.5); backdrop-filter: blur(6px);
  padding: 22px 22px 40px; overflow-y: auto;
  transform: translateX(105%); transition: transform .32s cubic-bezier(.4,.0,.2,1);
}
.info-panel.open { transform: translateX(0); }
.panel-header { display: flex; align-items: flex-start; gap: 10px; }
.cat-dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 7px; flex: none;
  box-shadow: 0 0 10px currentColor; }
.title-wrap { flex: 1; }
.place-name { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.15; }
.alt-names { font-size: 12px; color: var(--muted); margin-top: 3px; font-style: italic; }
.close-btn {
  background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0 4px; transition: color .15s;
}
.close-btn:hover { color: var(--cyan); }
.panel-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--cyan); color: var(--cyan); text-transform: uppercase; letter-spacing: .5px;
}
.modern { font-size: 13px; color: var(--muted); }
.panel-actions { display: flex; gap: 8px; margin-bottom: 18px; }
.act-btn {
  flex: 1; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--chip-bg); color: var(--text); border: 1px solid var(--panel-border);
  transition: all .15s;
}
.act-btn:hover { border-color: var(--cyan); }
.act-btn.primary { background: rgba(0,240,255,0.16); border-color: var(--cyan); }

.panel-section { margin: 16px 0; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--cyan); margin: 0 0 7px; }
.section-body { margin: 0; font-size: 14px; line-height: 1.55; color: #d6e6f2; }
.panel-section.ruins { padding: 12px 14px; background: rgba(255,43,214,0.08);
  border: 1px solid rgba(255,43,214,0.3); border-radius: 10px; }
.panel-section.ruins .section-title { color: var(--magenta); }
.tell-name { margin-top: 8px; font-size: 12px; color: #f5b8e8; }

.ref-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ref-chip {
  font-size: 12.5px; padding: 5px 10px; border-radius: 7px; text-decoration: none;
  background: rgba(0,240,255,0.1); color: var(--cyan);
  border: 1px solid rgba(0,240,255,0.3); transition: all .15s; white-space: nowrap;
}
.ref-chip:hover { background: rgba(0,240,255,0.22); box-shadow: 0 0 12px rgba(0,240,255,0.3); }
.ref-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }

.sources .source-links { display: flex; gap: 8px; flex-wrap: wrap; }
.source-link {
  font-size: 13px; padding: 8px 12px; border-radius: 8px; text-decoration: none;
  background: var(--chip-bg); color: var(--text); border: 1px solid var(--panel-border);
  transition: all .15s;
}
.source-link:hover { border-color: var(--cyan); color: var(--cyan); }

/* ─── Tours ───────────────────────────────────────────────── */
.tour-bar {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%); z-index: 15;
}
.tour-buttons {
  display: flex; gap: 8px; flex-wrap: nowrap; justify-content: flex-start;
  max-width: min(92vw, 860px); overflow-x: auto; padding: 2px 4px;
  scroll-snap-type: x proximity; scrollbar-width: thin;
}
.tour-buttons::-webkit-scrollbar { height: 5px; }
.tour-buttons::-webkit-scrollbar-thumb { background: rgba(0,240,255,0.3); border-radius: 3px; }
.tour-btn { scroll-snap-align: start; flex: none; }
.tour-btn {
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--panel-bg); color: var(--text); border: 1px solid var(--panel-border);
  transition: all .15s;
}
.tour-btn:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 14px rgba(0,240,255,0.25); }

.tour-hud {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 16; width: 440px; max-width: 92vw; opacity: 0; pointer-events: none;
  background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); transition: all .3s;
}
.tour-hud.open { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.tour-hud-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.tour-hud-name { font-weight: 700; color: var(--cyan); }
.tour-hud-progress { font-size: 12px; color: var(--muted); }
.tour-hud-caption { font-size: 14px; line-height: 1.45; margin-bottom: 12px; color: #d6e6f2; }
.tour-hud-controls { display: flex; gap: 8px; }
.thc-btn {
  flex: 1; padding: 8px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--chip-bg); color: var(--text); border: 1px solid var(--panel-border); transition: all .15s;
}
.thc-btn:hover:not(:disabled) { border-color: var(--cyan); }
.thc-btn:disabled { opacity: 0.4; cursor: default; }
.thc-btn.stop { border-color: rgba(255,80,80,0.5); color: #ff8a8a; }

/* ─── Banners ─────────────────────────────────────────────── */
.token-banner {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  z-index: 22; display: none; align-items: center; gap: 12px;
  background: rgba(255,179,0,0.14); border: 1px solid rgba(255,179,0,0.5);
  color: #ffd98a; padding: 9px 14px; border-radius: 9px; font-size: 12.5px; max-width: 92vw;
}
.token-banner.show { display: flex; }
.token-banner code { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 4px; color: #fff; }
.token-banner button { background: none; border: none; color: inherit; cursor: pointer; font-size: 18px; }

.free-cam-hint {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%) translateY(-8px);
  z-index: 22; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  background: rgba(0,240,255,0.12); border: 1px solid rgba(0,240,255,0.4);
  color: var(--cyan); padding: 9px 14px; border-radius: 9px; font-size: 12.5px; max-width: 92vw;
  box-shadow: 0 0 16px rgba(0,240,255,0.2);
}
.free-cam-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.fatal {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(4,18,28,0.95); z-index: 100; color: #ff8a8a; font-size: 15px; padding: 24px; text-align: center;
}
.fatal.show { display: flex; }

/* ─── Auth modal (opened by the ✦ brand-mark) ─────────────── */
.auth-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(4, 18, 28, 0.92);
  backdrop-filter: blur(6px);
}
.auth-backdrop.open { display: flex; }
.auth-card {
  position: relative; width: 360px; max-width: 92vw;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,0.6);
  padding: 26px 24px 24px;
}
.auth-close {
  position: absolute; top: 10px; right: 12px;
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 22px; line-height: 1;
}
.auth-close:hover { color: var(--text); }
.auth-brand { font-size: 20px; font-weight: 700; letter-spacing: .5px; margin-bottom: 18px; }
.auth-mark { color: var(--cyan); text-shadow: 0 0 12px var(--cyan); }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; appearance: none; cursor: pointer;
  background: var(--chip-bg); border: 1px solid transparent;
  color: var(--muted); padding: 8px 0; border-radius: 8px; font-size: 14px;
}
.auth-tab.active { color: var(--bg); background: var(--cyan); font-weight: 700; }
.auth-input {
  display: block; width: 100%; margin-bottom: 12px;
  background: rgba(2, 12, 20, 0.8); border: 1px solid var(--panel-border);
  color: var(--text); border-radius: 8px; padding: 11px 12px; font-size: 14px;
}
.auth-input:focus { outline: none; border-color: var(--cyan); }
.auth-error { color: #ff8080; font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.auth-btn {
  appearance: none; cursor: pointer; width: 100%;
  border: 0; border-radius: 9px; padding: 12px 0;
  font-size: 15px; font-weight: 700; color: var(--bg);
  background: var(--cyan); box-shadow: 0 0 18px rgba(0,240,255,0.35);
}
.auth-btn:hover { filter: brightness(1.08); }
.auth-btn:disabled { opacity: .6; cursor: default; }
.auth-btn.auth-secondary { background: var(--chip-bg); color: var(--text); box-shadow: none; }
.auth-btn.auth-admin { background: var(--magenta); box-shadow: 0 0 18px rgba(255,43,214,0.4); margin-bottom: 10px; }
.auth-actions { margin-top: 6px; }
.auth-signed { font-size: 15px; margin: 4px 0 16px; }
.auth-note { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ─── God Mode admin overlay ──────────────────────────────── */
/* Deliberately translucent, with transparent menus/submenus. */
.admin-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: none; flex-direction: column; gap: 14px;
  padding: 20px 24px 24px;
  background: rgba(4, 16, 26, 0.82);
  backdrop-filter: blur(10px);
  color: var(--text); overflow: hidden;
}
.admin-overlay.open { display: flex; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-title { font-size: 22px; font-weight: 800; letter-spacing: .5px;
  color: var(--magenta); text-shadow: 0 0 16px rgba(255,43,214,0.5); }
.admin-head-actions { display: flex; align-items: center; gap: 10px; }
.admin-online { color: var(--cyan); font-size: 13px; }
.admin-btn {
  appearance: none; cursor: pointer;
  background: rgba(10, 28, 40, 0.6); border: 1px solid var(--panel-border);
  color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13px;
}
.admin-btn:hover { border-color: var(--cyan); }
.admin-btn.admin-close { border-color: rgba(255,43,214,0.5); }
.admin-tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.admin-tile {
  flex: 1 1 120px; min-width: 110px;
  background: rgba(6, 20, 30, 0.45); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 12px 14px;
}
.admin-tile-num { font-size: 26px; font-weight: 800; color: var(--cyan); }
.admin-tile-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-tab {
  appearance: none; cursor: pointer;
  background: transparent; border: 1px solid var(--panel-border);
  color: var(--muted); border-radius: 8px; padding: 7px 16px; font-size: 14px;
}
.admin-tab.active { color: var(--bg); background: var(--cyan); border-color: var(--cyan); font-weight: 700; }
.admin-table { flex: 1; overflow: auto; border: 1px solid var(--panel-border);
  border-radius: 12px; background: rgba(3, 12, 20, 0.35); }
.admin-data { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-data th, .admin-data td { text-align: left; padding: 8px 12px; white-space: nowrap; }
.admin-data thead th {
  position: sticky; top: 0; background: rgba(6, 20, 30, 0.95);
  color: var(--cyan); font-weight: 700; border-bottom: 1px solid var(--panel-border);
}
.admin-data tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
.admin-data tbody td { border-bottom: 1px solid rgba(255,255,255,0.05); color: var(--text); }
.admin-empty { padding: 22px; color: var(--muted); text-align: center; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 720px) {
  #topbar { gap: 10px; padding: 10px 12px; }
  .brand-title { font-size: 17px; }
  .filters { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .legend { display: none; }
  .info-panel { width: 100%; }
  .tour-bar { bottom: 20px; width: 100%; }
  .tour-buttons { padding: 2px 10px; }
  .admin-overlay { padding: 14px; }
  .admin-title { font-size: 18px; }
}
