/* ═══════════════════════════════════════════════════════════
   CSS VARIABLES & RESET
═══════════════════════════════════════════════════════════ */
:root {
  --bg:            #060a06;
  --bg2:           #0b120b;
  --bg3:           #0f1a0f;
  --bg-overlay:    rgba(6,10,6,0.75);
  --accent:        #39ff14;
  --accent-dim:    #1a7a08;
  --accent-rgb:    57,255,20;
  --accent-glow:   rgba(57,255,20,0.18);
  --accent-glow2:  rgba(57,255,20,0.06);
  --amber:         #ffb700;
  --amber-dim:     #7a5700;
  --red:           #ff3c3c;
  --text:          #b8e8b0;
  --text-dim:      #527a4a;
  --border:        #1e3a1a;
  --border-bright: #2d5c27;
  --radius:        4px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  overflow-x: hidden;
}

/* Subtle scanline overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Noise grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9998;
  opacity: 0.35;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════ */
.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ═══════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  height: 48px;
  width: auto;
  filter: brightness(0) saturate(100%) invert(79%) sepia(53%) saturate(1471%) hue-rotate(50deg) brightness(102%) contrast(101%);
}

.logo-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  height: 42px;
}

.logo-text {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-shadow:
    0 0 8px var(--accent),
    0 0 24px rgba(var(--accent-rgb),0.4);
  line-height: 1.1;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  line-height: 1.1;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-dim);
  flex-shrink: 0;
}
.status-dot.live {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse-dot 1.8s ease-in-out infinite;
}
.status-dot.warn { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.status-dot.off  { background: var(--text-dim); }

@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.7); }
}

#clock {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* ═══════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════ */
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 20px;
  padding: 16px 0 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.footer a {
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.05em;
}

.footer a:hover {
  color: var(--accent);
}

.footer-copy {
  width: 100%;
  text-align: center;
  opacity: 0.5;
  margin-top: 4px;
  font-size: 10px;
}

/* ═══════════════════════════════════════════════════════════
   MAIN GRID — form (260px) | map (flex) | cards (260px)
═══════════════════════════════════════════════════════════ */
.main {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  grid-template-areas: "form map cards";
  gap: 20px;
  padding: 20px 0 32px;
  align-items: start;
  min-height: 0;
}

/* ── COL-MAP (centre column) ── */
.col-map {
  grid-area: map;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 20px;
}

/* Map display container — rectangular, fills available space */
.map-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 180px);
  min-height: 400px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 0 0 6px var(--bg2),
    0 0 0 7px var(--border),
    0 0 60px rgba(var(--accent-rgb),0.08),
    0 0 120px rgba(var(--accent-rgb),0.04);
}

/* MapLibre fills the wrap */
#mapContainer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.maplibregl-map {
  width: 100% !important;
  height: 100% !important;
}

/* Hide all MapLibre default controls — attribution handled via static HTML */
.maplibregl-ctrl-logo,
.maplibregl-compact,
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-bottom-right {
  display: none !important;
}

/* Custom map controls overlay */
.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-ctrl-btn {
  width: 32px;
  height: 32px;
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: 'Share Tech Mono', monospace;
}

.map-ctrl-btn:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 10px var(--accent-glow);
}

#centerBtn { font-size: 13px; }
#tiltBtn   { font-size: 13px; }
#tiltBtn.active {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Map corner branding overlay */
.map-overlay-label {
  position: absolute;
  bottom: 8px;
  left: 10px;
  z-index: 10;
  font-family: 'Orbitron', sans-serif;
  font-size: 8px;
  letter-spacing: 0.25em;
  color: rgba(var(--accent-rgb),0.35);
  pointer-events: none;
  text-transform: uppercase;
}

/* Waiting for GPS overlay */
.map-waiting-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--bg-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
}

.map-waiting-overlay.hidden { display: none; }

.map-waiting-icon {
  font-size: 48px;
  opacity: 0.25;
  animation: locked-pulse 3s ease-in-out infinite;
}

.map-waiting-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.map-waiting-sub {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.6;
  letter-spacing: 0.1em;
}

/* ── CUSTOM MAP MARKERS ── */

/* Self marker */
.marker-self {
  cursor: pointer;
}

/* Emoji variant — container sizes to emoji so ring centers on it */
/* position: relative required as positioned ancestor for the ring */
.marker-self--emoji {
  width: 32px;
  height: 32px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner wrapper — provides sizing and positioning context for ring and core */
.marker-self-inner {
  width: 18px;
  height: 18px;
  position: relative;
}

.marker-self-core {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.25), 0 0 16px var(--accent);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: self-pulse 2s ease-in-out infinite;
}

@keyframes self-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.25), 0 0 16px var(--accent); }
  50%      { box-shadow: 0 0 0 7px rgba(var(--accent-rgb),0.08), 0 0 28px var(--accent); }
}

.marker-self-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--accent-rgb),0.4);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: ring-expand 2s ease-out infinite;
}

@keyframes ring-expand {
  0%   { transform: translate(-50%,-50%) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%,-50%) scale(2.2); opacity: 0; }
}

/* Other user marker — pulsing dot style, mirrors self marker */
.marker-user {
  cursor: pointer;
}

.marker-user:hover {
  filter: drop-shadow(0 2px 12px rgba(255,183,0,0.8));
}

/* Emoji variant — container sizes to emoji so ring centers on it */
.marker-user--emoji {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner wrapper — provides sizing and positioning context for ring and core */
.marker-user-inner {
  width: 18px;
  height: 18px;
  position: relative;
}

.marker-user-core {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffb700;
  box-shadow: 0 0 0 3px rgba(255,183,0,0.25), 0 0 16px #ffb700;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: user-pulse 2s ease-in-out infinite;
}

@keyframes user-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(255,183,0,0.25), 0 0 16px #ffb700; }
  50%      { box-shadow: 0 0 0 7px rgba(255,183,0,0.08), 0 0 28px #ffb700; }
}

.marker-user-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,183,0,0.4);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: ring-expand 2s ease-out infinite;
}

/* Emoji avatar marker — replaces pin or self-core when avatar is set */
.marker-emoji {
  font-size: 28px;
  line-height: 1;
  display: block;
  user-select: none;
  transform-origin: center bottom;
}

/* Squash-and-stretch — fires on open (click handlers) and close (popup.on close) */
.emoji-squash {
  animation: emoji-squash 0.6s ease-out forwards;
}

@keyframes emoji-squash {
  0%   { transform: scale(1,    1);    }
  20%  { transform: scale(1.3,  0.6);  }
  40%  { transform: scale(0.95, 1.1);  }
  60%  { transform: scale(1.1,  0.9);  }
  80%  { transform: scale(0.98, 1.02); }
  100% { transform: scale(1,    1);    }
}

/* Map popup style */
.maplibregl-popup-content {
  background: var(--bg2) !important;
  border: 1px solid var(--border-bright) !important;
  border-radius: var(--radius) !important;
  color: var(--text) !important;
  font-family: 'Share Tech Mono', monospace !important;
  font-size: 12px !important;
  padding: 10px 14px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7) !important;
  min-width: 180px;
}

.maplibregl-popup-tip {
  border-top-color: var(--border-bright) !important;
  border-bottom-color: var(--border-bright) !important;
}

.maplibregl-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 16px !important;
  right: 6px !important;
  top: 4px !important;
}

.maplibregl-popup-close-button:hover {
  color: var(--accent) !important;
  background: none !important;
}

.popup-topic-eyebrow {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.popup-topic {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb),0.3);
  margin-bottom: 4px;
  word-break: break-word;
  line-height: 1.3;
}

.popup-age-gender {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.popup-instructions {
  font-size: 11px;
  color: var(--text);
  background: var(--bg3);
  border-left: 2px solid var(--border);
  padding: 5px 7px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  line-height: 1.4;
}

.popup-static ins {
  display: block;
}

.popup-static ins a,
.card-static ins a {
  color: var(--accent);
}

.popup-static ins iframe,
.card-static ins iframe {
  display: block;
}

.popup-distance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  margin-top: 6px;
}

.popup-dist-val {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,183,0,0.35);
}

.popup-bearing {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  color: var(--text);
}

.popup-bearing-arrow {
  font-size: 18px;
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent);
  display: inline-block;
}

.popup-duration {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  letter-spacing: 0.05em;
}

/* ── PANEL BOX ── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.panel-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--accent-dim);
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── JOIN FORM ── */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-group label .required {
  color: var(--red);
  margin-left: 2px;
}

.radio-group {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0.05em;
}

.radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.checkbox-input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.radio-label:hover span {
  color: var(--accent);
}

.form-group select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23527a4a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-group select:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-glow2), 0 0 12px var(--accent-glow2);
}

.form-group select.error {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(255,60,60,0.12);
}

.form-group select option {
  background: var(--bg3);
  color: var(--accent);
}

.form-group select option:disabled {
  color: var(--text-dim);
}

/* Avatar select — auto width overrides the 100% default from .form-group select */
#inp-avatar {
  width: auto;
}

.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: var(--accent);
}

.form-group input::placeholder { color: var(--text-dim); opacity: 0.6; }

.form-group input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-glow2), 0 0 12px var(--accent-glow2);
}

.form-group input.error {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(255,60,60,0.12);
}

.char-counter {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: right;
  letter-spacing: 0.05em;
}

.btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: 11px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 0;
}
.btn:hover::before { transform: translateX(0); }
.btn:hover { color: var(--bg); border-color: var(--accent); box-shadow: 0 0 20px var(--accent-glow); }
.btn span { position: relative; z-index: 1; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn:disabled::before { display: none; }

#joinBtn, #leaveBtn {
  margin-top: 14px;
}

.btn-leave {
  border-color: var(--red);
  color: var(--red);
  font-size: 10px;
}
.btn-leave::before { background: var(--red); }
.btn-leave:hover { color: #fff; border-color: var(--red); }

/* ── GEO STATUS ── */
.geo-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
  padding: 8px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── GPS HELP PANEL ── */
.gps-help-panel {
  display: none;
  margin: 15px 0;
  padding: 12px;
  background: rgba(255,183,0,0.1);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
}

.gps-help-title {
  font-size: 13px;
  font-weight: bold;
  color: var(--amber);
  margin-bottom: 8px;
}

.gps-help-body {
  font-size: 11px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.gps-help-instructions {
  margin-bottom: 10px;
  font-size: 10px;
  color: var(--text-dim);
}

.gps-help-instructions ul {
  margin: 5px 0 0 15px;
  padding: 0;
  line-height: 1.6;
}

.gps-help-after {
  margin-top: 10px;
  font-size: 10px;
  color: var(--text-dim);
}

.gps-help-after ul {
  margin: 5px 0 0 15px;
  padding: 0;
}

#lockedPanel .locked-icon {
  font-size: 36px;
}

#retryGpsBtn {
  padding: 8px;
  font-size: 12px;
}

/* ── INFO TOGGLE (Compact Expandable Sections) ── */
.info-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 14px;
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.info-toggle:hover {
  border-color: var(--border-bright);
  background: var(--bg2);
}

.info-toggle-icon {
  font-size: 11px;
  color: var(--accent-dim);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.info-toggle.expanded .info-toggle-icon {
  transform: rotate(90deg);
}

.info-toggle-label {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.info-toggle-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-dim);
}

.info-toggle-content.expanded {
  max-height: 1000px;
}

.info-toggle-inner {
  padding: 12px 10px;
}

.info-toggle-content ul {
  margin: 6px 0 0 16px;
  padding: 0;
}

.info-toggle-content li {
  margin-bottom: 4px;
}

.info-toggle-content strong {
  color: var(--text);
}

/* ── POSITION STRIP (below map) ── */
.pos-strip {
  display: flex;
  gap: 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  flex-wrap: wrap;
}

.pos-cell {
  flex: 1;
  min-width: 70px;
}

.pos-label {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.pos-val {
  font-size: 11px;
  color: var(--accent);
  text-shadow: 0 0 4px rgba(var(--accent-rgb),0.25);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pos-val.dim { color: var(--text-dim); text-shadow: none; }

.pos-cell-sync { padding-top: 4px; }
.pos-cell-sync .poll-bar { margin: 0; }

/* ── OSM ATTRIBUTION ── */
.osm-attribution {
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
  padding: 4px 2px 0;
  letter-spacing: 0.04em;
}

.osm-attribution a {
  color: var(--accent-dim);
  text-decoration: none;
}

.osm-attribution a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── COMPACT CARD OVERRIDES (260px cards column) ── */
.user-card .card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 8px;
}

.user-card .meta-item .label {
  font-size: 8px;
}

.user-card .meta-item .value {
  font-size: 11px;
}

.user-card .card-coords {
  padding: 6px 8px;
  margin-bottom: 7px;
}

.user-card .coord-pair .label { font-size: 8px; }
.user-card .coord-pair .value { font-size: 10px; }

.user-card .age-gender {
  font-size: 11px;
}

.user-card .topic-eyebrow {
  font-size: 7px;
}

.user-card .topic {
  font-size: 11px;
}

.user-card .card-instructions {
  font-size: 10px;
  padding: 5px 7px;
  margin-bottom: 8px;
}

.user-card .card-distance {
  padding: 6px 8px;
}

.dist-value { font-size: 13px; }
.bearing-arrow { font-size: 17px; }
.bearing-text { font-size: 11px; }

/* ═══════════════════════════════════════════════════════════
   COL-FORM (left column) — form inputs, buttons, info toggle
   COL-CARDS (right column) — locked/live panels, user cards
═══════════════════════════════════════════════════════════ */
.col-form {
  grid-area: form;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) var(--bg2);
}

.col-form::-webkit-scrollbar { width: 4px; }
.col-form::-webkit-scrollbar-track { background: var(--bg2); }
.col-form::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

.col-cards {
  grid-area: cards;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) var(--bg2);
}

.col-cards::-webkit-scrollbar { width: 4px; }
.col-cards::-webkit-scrollbar-track { background: var(--bg2); }
.col-cards::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

.users-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.users-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--accent-dim);
  text-transform: uppercase;
}

.users-count {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb),0.5);
  line-height: 1;
}

.users-count span { font-size: 11px; color: var(--text-dim); margin-left: 4px; }

/* ── USER CARDS ── */
.users-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
  animation: card-in 0.35s ease both;
  cursor: pointer;
}

.user-card:hover:not(.is-me) {
  border-color: var(--amber-dim);
  box-shadow: 0 0 14px rgba(255,183,0,0.1);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.user-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-dim);
  transition: background 0.3s;
}

.user-card.is-me {
  border-color: var(--accent-dim);
  box-shadow: 0 0 20px var(--accent-glow2), inset 0 0 20px rgba(var(--accent-rgb),0.03);
}
.user-card.is-me::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.user-card.stale { opacity: 0.5; border-style: dashed; }

.user-card .card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.user-card .age-gender {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-card .topic-wrap {
  margin-bottom: 8px;
}

.user-card .topic-eyebrow {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 6px;
  margin-top: 4px;  
}

.user-card .topic {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb),0.3);
  word-break: break-word;
  line-height: 1.3;
}

.user-card .card-instructions {
  font-size: 11px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 10px;
  padding: 6px 8px;
  background: var(--bg3);
  border-left: 2px solid var(--border);
  border-radius: var(--radius);
}

.card-static ins {
  display: block;
  margin-bottom: 10px;
}

.user-card .me-badge {
  font-size: 9px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 2px;
  padding: 2px 6px;
  letter-spacing: 0.15em;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.user-card .card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.meta-item .label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.meta-item .value {
  font-size: 12px;
  color: var(--text);
}

.user-card .card-coords {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.coord-pair .label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}
.coord-pair .value {
  font-size: 11px;
  color: var(--accent);
}

/* ── DISTANCE / BEARING ROW ── */
.card-distance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dist-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,183,0,0.35);
}

.bearing-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bearing-arrow {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
  display: inline-block;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
}

.bearing-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.1em;
  min-width: 36px;
  text-align: right;
}

/* ── EMPTY STATE ── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .big {
  font-family: 'Orbitron', sans-serif;
  font-size: 40px;
  opacity: 0.15;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.empty-state .sub {
  margin-top: 6px;
  font-size: 10px;
  opacity: 0.6;
  text-transform: none;
  letter-spacing: 0.05em;
}

.card-distance-me {
  justify-content: center;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.card-distance-gps {
  color: var(--text-dim);
  font-size: 11px;
}

/* ── POLL STATUS BAR ── */
.poll-bar {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
  margin-top: 4px;
}

.poll-bar-inner {
  height: 100%;
  background: var(--accent-dim);
  width: 0%;
  transition: width 0.1s linear;
}

.poll-bar-inner.active { background: var(--accent); }

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 10000;
  white-space: nowrap;
}

#toast.show { transform: translateX(-50%) translateY(0); }
#toast.ok   { border-color: var(--accent); color: var(--accent); }
#toast.err  { border-color: var(--red);   color: var(--red); }

/* ── LOCKED PANEL ── */
.locked-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  min-height: 180px;
}

.locked-icon {
  font-size: 56px;
  opacity: 0.12;
  margin-bottom: 20px;
  animation: locked-pulse 3s ease-in-out infinite;
}

@keyframes locked-pulse {
  0%,100% { opacity: 0.10; transform: scale(1); }
  50%      { opacity: 0.20; transform: scale(1.06); }
}

.locked-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.locked-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  opacity: 0.6;
  max-width: 280px;
  line-height: 1.7;
  text-align: center;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }

/* Mobile: single column — form, map, cards stacked in natural order */
@media (max-width: 860px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas: "form" "map" "cards";
  }
  .col-form,
  .col-cards {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .col-map {
    position: static;
  }
  .map-wrap {
    height: 65vw;
    min-height: 300px;
  }
  /* Allow page scroll when touch starts on map on mobile */
  #mapContainer {
    touch-action: pan-y;
  }
}

/* ═══════════════════════════════════════════════════════════
   LIGHT THEME
═══════════════════════════════════════════════════════════ */
[data-mode="light"] {
  --bg:            #f0f2f5;
  --bg2:           #e4e8ef;
  --bg3:           #d8dde8;
  --bg-overlay:    rgba(240,242,245,0.85);
  --accent:        #7c3aed;
  --accent-dim:    #4c1d95;
  --accent-rgb:    124,58,237;
  --accent-glow:   rgba(124,58,237,0.18);
  --accent-glow2:  rgba(124,58,237,0.06);
  --amber:         #d97706;
  --amber-dim:     #92400e;
  --red:           #dc2626;
  --text:          #1e1b4b;
  --text-dim:      #6d6a85;
  --border:        #c4bfe0;
  --border-bright: #9d96c8;
}

/* Light theme: scanline is lighter so it doesn't darken the background */
[data-mode="light"] body::before {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
}

/* Light theme: reduce noise opacity */
[data-mode="light"] body::after {
  opacity: 0.15;
}

/* Light theme: logo filter for purple tint */
[data-mode="light"] .logo-img {
  filter: brightness(0) saturate(100%) invert(25%) sepia(80%) saturate(1500%) hue-rotate(250deg) brightness(90%) contrast(110%);
}

/* Light theme: select dropdown arrow uses light theme text-dim color (#6d6a85) */
[data-mode="light"] .form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236d6a85'/%3E%3C/svg%3E");
}

/* ── MODE TOGGLE SWITCH ── */
.mode-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}

.mode-toggle-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
}

.mode-toggle input[type="checkbox"] {
  display: none;
}

.mode-toggle-track {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--border-bright);
  border: 1px solid var(--border-bright);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.mode-toggle input:checked + .mode-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.mode-toggle-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s, background 0.2s;
}

.mode-toggle input:checked + .mode-toggle-track .mode-toggle-thumb {
  transform: translateX(14px);
}
