:root {
  --cyan: #00e5ff;
  --magenta: #ff2d95;
  --purple: #7b2dff;
  --green: #00ff88;
  --yellow: #ffe600;
  --bg: #040614;
  --panel: rgba(8, 12, 34, 0.82);
  --line: rgba(0, 229, 255, 0.35);
  --font: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: #cff; font-family: var(--font); }

#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ============ CRT OVERLAY ============ */
#crt { pointer-events: none; position: fixed; inset: 0; z-index: 5; mix-blend-mode: overlay; opacity: 0.55; }
.scanlines { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px); }
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.5) 100%); }

/* ============ BOOT ============ */
#boot { position: fixed; inset: 0; z-index: 100; background: rgba(2, 3, 10, 0.55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; transition: opacity 0.45s; pointer-events: auto; }
.boot-inner { width: min(560px, 86vw); text-align: center; }
.boot-title { font-size: 44px; letter-spacing: 8px; color: var(--cyan); text-shadow: 0 0 18px var(--cyan), 0 0 42px var(--cyan); }
.boot-sub { font-size: 12px; letter-spacing: 5px; color: var(--magenta); margin: 10px 0 34px; text-shadow: 0 0 10px var(--magenta); }
.boot-bar { height: 6px; background: #0a1240; border: 1px solid var(--line); box-shadow: 0 0 12px rgba(0,229,255,0.4) inset; overflow: hidden; }
.boot-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); box-shadow: 0 0 14px var(--cyan); }
.boot-progress { margin-top: 6px; font-size: 11px; letter-spacing: 3px; color: var(--cyan); text-shadow: 0 0 8px var(--cyan); text-align: right; }
.boot-log { text-align: left; font-size: 12px; color: var(--green); margin-top: 14px; opacity: 0; animation: bootFade 0.4s ease forwards; }
.boot-log:nth-of-type(1) { animation-delay: 0.9s }
.boot-log:nth-of-type(2) { animation-delay: 1.3s }
.boot-log:nth-of-type(3) { animation-delay: 1.7s }
@keyframes bootFade { to { opacity: 1 } }
#boot-pass { width: 240px; margin-top: 34px; padding: 12px 16px; background: rgba(6,10,28,0.8); border: 1px solid var(--line); color: var(--cyan); font-family: var(--font); font-size: 16px; letter-spacing: 6px; text-align: center; outline: none; box-shadow: 0 0 12px rgba(0,229,255,0.2); }
#boot-pass:focus { border-color: var(--cyan); box-shadow: 0 0 18px rgba(0,229,255,0.5); }
#boot-pass:disabled { opacity: 0.35; cursor: not-allowed; border-color: rgba(0,229,255,0.25); box-shadow: none; }
#boot-pass-msg { height: 22px; margin-top: 10px; font-size: 12px; letter-spacing: 3px; color: var(--green); text-shadow: 0 0 8px currentColor; }
#boot-enter { margin-top: 8px; background: transparent; color: var(--cyan); border: 1px solid var(--cyan); padding: 14px 40px; font-family: var(--font); font-size: 15px; letter-spacing: 4px; cursor: pointer; box-shadow: 0 0 14px rgba(0,229,255,0.35); text-shadow: 0 0 8px var(--cyan); transition: 0.2s; animation: pulseBtn 1.6s infinite; }
#boot-enter:disabled { opacity: 0.35; cursor: not-allowed; animation: none; box-shadow: none; }
#boot-enter:hover:not(:disabled) { background: var(--cyan); color: #001; box-shadow: 0 0 30px var(--cyan); animation: none; }
@keyframes pulseBtn { 50% { box-shadow: 0 0 30px rgba(0,229,255,0.8) } }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.hud-corner { position: absolute; width: 42px; height: 42px; border: 2px solid var(--cyan); filter: drop-shadow(0 0 6px rgba(0,229,255,0.7)); }
.hud-corner.tl { top: 16px; left: 16px; border-right: none; border-bottom: none; }
.hud-corner.tr { top: 16px; right: 16px; border-left: none; border-bottom: none; }
.hud-corner.bl { bottom: 16px; left: 16px; border-right: none; border-top: none; }
.hud-corner.br { bottom: 16px; right: 16px; border-left: none; border-top: none; }

#hud-title { position: absolute; top: 26px; left: 70px; }
#hud-title span { font-size: 26px; letter-spacing: 6px; font-weight: 700; }
.hud-accent { color: var(--cyan); text-shadow: 0 0 14px var(--cyan); }
.hud-accent2 { color: var(--magenta); text-shadow: 0 0 14px var(--magenta); }
.hud-title-sub { font-size: 10px; letter-spacing: 3px; color: rgba(0,229,255,0.55); margin-top: 4px; }

#coords-readout { position: absolute; left: 70px; bottom: 52px; font-size: 12px; line-height: 1.9; }
.readout-row .lbl { color: var(--magenta); display: inline-block; width: 58px; text-shadow: 0 0 8px var(--magenta); }
.readout-row .val { color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }

/* ---- Developer center button (bottom-right) ---- */
#dev-btn { pointer-events: auto; position: absolute; right: 26px; bottom: 26px; background: transparent; color: var(--magenta); border: 1px solid var(--magenta); padding: 7px 14px; font-family: var(--font); font-size: 11px; letter-spacing: 2px; cursor: pointer; box-shadow: 0 0 12px rgba(255,45,149,0.25); text-shadow: 0 0 8px var(--magenta); transition: 0.2s; }
#dev-btn:hover { background: var(--magenta); color: #001; box-shadow: 0 0 22px var(--magenta); }
#dev-btn.logged { color: var(--green); border-color: var(--green); text-shadow: 0 0 8px var(--green); box-shadow: 0 0 12px rgba(0,255,136,0.25); }
#dev-btn.logged:hover { background: var(--green); color: #001; }

/* ---- Add button (top-right) — hidden until dev login ---- */
#add-btn { display: none; pointer-events: auto; position: absolute; top: 30px; right: 26px; width: 58px; height: 58px; border-radius: 50%; border: 2px solid var(--cyan); background: radial-gradient(circle at 30% 30%, #0a1a3a, #060a24); color: var(--cyan); font-size: 30px; line-height: 1; cursor: pointer; box-shadow: 0 0 22px rgba(0,229,255,0.35), inset 0 0 20px rgba(0,229,255,0.15); transition: 0.2s; text-shadow: 0 0 12px var(--cyan); }
#hud.dev #add-btn { display: block; }
#add-btn:hover { background: var(--cyan); color: #001; box-shadow: 0 0 40px var(--cyan); transform: scale(1.06); }

/* ---- Node list (top-left, below logo, collapsible) ---- */
#node-list { pointer-events: auto; position: absolute; top: 104px; left: 70px; width: 250px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 0 18px rgba(0,229,255,0.15); backdrop-filter: blur(6px); }
.node-list-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: 11px; letter-spacing: 2px; color: var(--cyan); border-bottom: 1px solid var(--line); background: rgba(0,229,255,0.06); cursor: pointer; user-select: none; }
.node-list-head:hover { background: rgba(0,229,255,0.12); }
#nl-count { color: var(--magenta); }
#nl-arrow { margin-left: auto; color: var(--cyan); font-size: 10px; }
#node-list.collapsed .node-list-head { border-bottom: none; }
#node-list.collapsed #node-list-body { display: none; }
#node-list-body { max-height: 180px; overflow-y: auto; }
#node-list-body::-webkit-scrollbar { width: 4px }
#node-list-body::-webkit-scrollbar-thumb { background: var(--cyan); opacity: 0.5 }
.node-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 11px; color: #bdf; border-bottom: 1px dashed rgba(0,229,255,0.12); transition: 0.15s; }
.node-item:hover { background: rgba(0,229,255,0.12); color: #fff; }
.node-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--cyan)); box-shadow: 0 0 8px var(--c, var(--cyan)); flex: none; }
.node-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-item .num { color: var(--magenta); font-size: 10px; }
.node-item .del { flex: none; width: 18px; height: 18px; line-height: 1; background: transparent; border: 1px solid rgba(255,45,149,0.5); color: var(--magenta); font-size: 10px; cursor: pointer; display: none; opacity: 0.75; }
#hud.dev .node-item .del { display: block; }
.node-item .del:hover { background: var(--magenta); color: #fff; opacity: 1; }

#tip-hint { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); font-size: 10px; letter-spacing: 1px; color: rgba(0,229,255,0.5); white-space: nowrap; }

/* ============ MODAL ============ */
#modal-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,10,0.72); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; }

/* ---- Developer login ---- */
#dev-overlay { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,10,0.78); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; }
#dev-modal { width: min(420px, 90vw); background: linear-gradient(160deg, #120a1e, #060a1e); border: 1px solid var(--magenta); box-shadow: 0 0 40px rgba(255,45,149,0.25), inset 0 0 60px rgba(255,45,149,0.05); padding: 26px; position: relative; }
#dev-modal::before { content: ""; position: absolute; top: -1px; left: -1px; right: -1px; height: 2px; background: linear-gradient(90deg, transparent, var(--magenta), var(--cyan), transparent); }
#dev-modal .input-lbl { color: var(--magenta); text-shadow: 0 0 8px var(--magenta); }
#dev-user, #dev-pass { width: 100%; background: #040a1c; border: 1px solid rgba(255,45,149,0.4); color: #eff; font-family: var(--font); font-size: 14px; padding: 12px 14px; outline: none; letter-spacing: 2px; }
#dev-user:focus, #dev-pass:focus { border-color: var(--magenta); box-shadow: 0 0 16px rgba(255,45,149,0.35); }
#dev-msg { margin-top: 12px; font-size: 12px; min-height: 16px; letter-spacing: 2px; }
#dev-msg.ok { color: var(--green); text-shadow: 0 0 8px var(--green); }
#dev-msg.err { color: var(--magenta); text-shadow: 0 0 8px var(--magenta); }
#dev-login { background: linear-gradient(90deg, var(--magenta), #b11fe0); border: 1px solid var(--magenta); color: #fff; font-weight: 700; box-shadow: 0 0 18px rgba(255,45,149,0.5); }
#dev-login:disabled { filter: grayscale(0.8); opacity: 0.4; cursor: not-allowed; box-shadow: none; }
#dev-login:not(:disabled):hover { box-shadow: 0 0 30px var(--magenta); }
#add-modal { width: min(600px, 92vw); background: linear-gradient(160deg, #0a1030, #060a1e); border: 1px solid var(--cyan); box-shadow: 0 0 40px rgba(0,229,255,0.25), inset 0 0 60px rgba(0,229,255,0.05); padding: 26px; position: relative; }
#add-modal::before { content: ""; position: absolute; top: -1px; left: -1px; right: -1px; height: 2px; background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent); }
.modal-title { font-size: 15px; letter-spacing: 4px; color: var(--cyan); text-shadow: 0 0 10px var(--cyan); margin-bottom: 20px; }

#dropzone { border: 1.5px dashed rgba(0,229,255,0.5); padding: 26px; text-align: center; cursor: pointer; transition: 0.2s; background: rgba(0,229,255,0.03); }
#dropzone.dragover { border-color: var(--magenta); background: rgba(255,45,149,0.08); box-shadow: 0 0 20px rgba(255,45,149,0.3); }
.dz-icon { font-size: 30px; color: var(--magenta); text-shadow: 0 0 12px var(--magenta); }
.dz-inner div { margin-top: 6px; font-size: 13px; color: #cfc; }
.dz-sub { font-size: 10px !important; color: rgba(0,229,255,0.6) !important; }

#file-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#file-preview .fv { position: relative; width: 74px; height: 74px; border: 1px solid var(--line); overflow: hidden; }
#file-preview .fv img, #file-preview .fv video { width: 100%; height: 100%; object-fit: cover; }
#file-preview .fv .fv-x { position: absolute; top: 2px; right: 2px; background: var(--magenta); color: #fff; border: none; width: 16px; height: 16px; font-size: 10px; cursor: pointer; }
#file-preview .fv .fv-tag { position: absolute; left: 0; bottom: 0; right: 0; font-size: 8px; text-align: center; background: rgba(0,0,0,0.6); color: var(--green); }

.input-lbl { display: block; margin: 18px 0 8px; font-size: 11px; letter-spacing: 3px; color: var(--magenta); text-shadow: 0 0 8px var(--magenta); }
#place-input { width: 100%; background: #040a1c; border: 1px solid var(--line); color: #eff; font-family: var(--font); font-size: 14px; padding: 12px 14px; outline: none; letter-spacing: 1px; }
#place-input:focus { border-color: var(--cyan); box-shadow: 0 0 16px rgba(0,229,255,0.3); }

#geo-status { margin-top: 12px; font-size: 12px; min-height: 16px; }
#geo-status.geoing { color: var(--yellow); animation: blink 1.2s infinite; }
#geo-status.ok { color: var(--green); text-shadow: 0 0 8px var(--green); }
#geo-status.err { color: var(--magenta); text-shadow: 0 0 8px var(--magenta); }
@keyframes blink { 50% { opacity: 0.35 } }
#geo-result { margin-top: 10px; border: 1px solid rgba(0,255,136,0.35); background: rgba(0,255,136,0.05); padding: 10px 12px; font-size: 12px; color: var(--green); line-height: 1.8; }

.modal-actions { display: flex; gap: 12px; margin-top: 24px; justify-content: flex-end; }
.modal-actions button { padding: 11px 26px; font-family: var(--font); font-size: 13px; letter-spacing: 2px; cursor: pointer; transition: 0.2s; }
.modal-actions .ghost { background: transparent; border: 1px solid rgba(0,229,255,0.4); color: var(--cyan); }
.modal-actions .ghost:hover { box-shadow: 0 0 14px rgba(0,229,255,0.4); }
.modal-actions .primary { background: linear-gradient(90deg, var(--cyan), #0aa); border: 1px solid var(--cyan); color: #001; font-weight: 700; box-shadow: 0 0 18px rgba(0,229,255,0.5); }
.modal-actions .primary:disabled { filter: grayscale(0.8); opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.modal-actions .primary:not(:disabled):hover { box-shadow: 0 0 30px var(--cyan); }

/* ============ VIEWER ============ */
#viewer { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,8,0.85); backdrop-filter: blur(6px); display: flex; flex-direction: column; }
.viewer-top { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
#viewer-title { color: var(--cyan); letter-spacing: 3px; font-size: 14px; text-shadow: 0 0 10px var(--cyan); }
.viewer-coords { flex: 1; color: rgba(0,229,255,0.6); font-size: 11px; }
#viewer-close { background: transparent; border: 1px solid var(--magenta); color: var(--magenta); width: 34px; height: 34px; cursor: pointer; font-size: 14px; }
#viewer-close:hover { background: var(--magenta); color: #fff; }
#viewer-media { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
#viewer-media img, #viewer-media video { max-width: 92vw; max-height: 82vh; border: 1px solid rgba(0,229,255,0.3); box-shadow: 0 0 30px rgba(0,229,255,0.2); object-fit: contain; }
.viewer-nav { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 14px; }
.viewer-nav button { background: transparent; border: 1px solid var(--cyan); color: var(--cyan); width: 48px; height: 38px; cursor: pointer; font-size: 14px; }
.viewer-nav button:hover { background: var(--cyan); color: #001; }
.viewer-nav button:disabled { opacity: 0.25; cursor: default; }
#viewer-dots { display: flex; gap: 8px; }
.vdot { width: 9px; height: 9px; border: 1px solid var(--cyan); border-radius: 50%; cursor: pointer; }
.vdot.active { background: var(--magenta); border-color: var(--magenta); box-shadow: 0 0 8px var(--magenta); }

/* ============ TOOLTIP ============ */
#tooltip { position: fixed; z-index: 60; pointer-events: none; min-width: 260px; max-width: 320px; background: rgba(6,10,28,0.92); border: 1px solid var(--cyan); box-shadow: 0 0 24px rgba(0,229,255,0.35); padding: 14px 16px; font-size: 12px; line-height: 1.8; backdrop-filter: blur(4px); }
.tt-corners::before, .tt-corners::after { content: ""; position: absolute; width: 12px; height: 12px; border: 1px solid var(--magenta); }
.tt-corners::before { top: -5px; left: -5px; border-right: none; border-bottom: none; }
.tt-corners::after { bottom: -5px; right: -5px; border-left: none; border-top: none; }
.tt-name { color: var(--cyan); font-size: 14px; letter-spacing: 2px; text-shadow: 0 0 10px var(--cyan); margin-bottom: 6px; }
#tt-detail div { display: flex; justify-content: space-between; gap: 16px; }
#tt-detail .k { color: var(--magenta); text-shadow: 0 0 8px var(--magenta); flex: none; }
#tt-detail .v { color: #cff; text-align: right; }

/* tooltip marker mini-pin */
#tooltip .pin { display:block; width: 8px; height: 8px; background:var(--cyan); box-shadow:0 0 10px var(--cyan); margin-bottom:8px; }

/* ============ FLAG LABELS (on globe) ============ */
.flag-label { position: fixed; left: 0; top: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; pointer-events: none; transform-origin: center bottom; will-change: transform, opacity; transition: opacity 0.2s; filter: drop-shadow(0 0 6px var(--fc, #00e5ff)); }
.flag-label .flag-pin { width: 8px; height: 8px; transform: rotate(45deg); background: var(--c); box-shadow: 0 0 10px var(--c); margin-bottom: 3px; }
.flag-label .flag-text { background: rgba(4,8,24,0.72); border: 1px solid var(--c); color: #eaffff; font-size: 11px; padding: 3px 9px; letter-spacing: 1px; white-space: nowrap; box-shadow: 0 0 14px rgba(0,0,0,0.4); font-family: var(--font); }
.flag-label .flag-text::after { content: ""; display: block; width: 120%; height: 1px; margin: 3px auto -4px; background: linear-gradient(90deg, transparent, var(--c), transparent); }
.flag-label.dim { opacity: 0.45; }

@media (max-width: 720px) {
  #node-list { display: none }
  #coords-readout { bottom: 14px; left: 20px }
  .hud-title-sub { display: none }
  #tip-hint { display: none }
}