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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: #f5f5f0;
  color: #1a1a18;
}

#map {
  flex: 1;
  height: 100vh;
  cursor: crosshair;
}

#sidebar {
  width: 320px;
  min-width: 320px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #e0dfd8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}

#sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #e0dfd8;
}

h1 {
  font-size: 17px;
  font-weight: 600;
  color: #1a1a18;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 12px;
  color: #888;
  line-height: 1.5;
}

#controls {
  padding: 14px 20px;
  border-bottom: 1px solid #e0dfd8;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-row label {
  font-size: 11px;
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#metric-tabs {
  display: flex;
  gap: 4px;
}

.metric-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
  border: 1px solid #e0dfd8;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: #555;
  transition: all 0.15s;
}

.metric-btn:hover { background: #f5f5f0; }
.metric-btn.active {
  background: #1a1a18;
  color: #fff;
  border-color: #1a1a18;
}

#layer-toggles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #444;
  cursor: pointer;
}

.toggle-label input { cursor: pointer; }

#friends-panel {
  padding: 14px 20px;
  border-bottom: 1px solid #e0dfd8;
}

.panel-title {
  font-size: 11px;
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

#friends-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 10px;
}

#friends-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
}

.friend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.friend-coords {
  font-size: 11px;
  color: #aaa;
  margin-left: auto;
}

#clear-btn {
  font-size: 12px;
  color: #e05c3a;
  background: none;
  border: 1px solid #e05c3a;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

#clear-btn:hover { background: #fff0ec; }

#results-panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
}

.result-card {
  border: 1px solid #e0dfd8;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.result-card:hover { background: #f9f9f7; border-color: #ccc; }
.result-card.winner {
  border-color: #2a9d5c;
  background: #f0faf5;
}

.result-rank {
  font-size: 10px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-card.winner .result-rank { color: #2a9d5c; }

.result-name {
  font-size: 14px;
  font-weight: 500;
  margin: 3px 0 6px;
}

.result-type {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f0f0eb;
  color: #666;
  margin-bottom: 8px;
}

.result-stats {
  display: flex;
  gap: 8px;
}

.stat {
  flex: 1;
  text-align: center;
  padding: 5px;
  background: #f5f5f0;
  border-radius: 5px;
}

.stat-val {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a18;
}

.stat-label {
  font-size: 10px;
  color: #aaa;
}

.dist-bars {
  margin-top: 8px;
}

.dist-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.dist-bar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dist-bar-track {
  flex: 1;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
}

.dist-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.dist-bar-val {
  font-size: 11px;
  color: #888;
  min-width: 36px;
  text-align: right;
}

#status-bar {
  padding: 10px 20px;
  font-size: 12px;
  color: #888;
  border-top: 1px solid #e0dfd8;
  background: #fafaf8;
}

.status-loading { color: #e09a3a; }
.status-ready { color: #2a9d5c; }
.status-error { color: #e05c3a; }

/* Leaflet overrides */
.leaflet-container { font-family: inherit; }

.poi-tooltip {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #ddd;
  background: #fff;
}

.floating-tooltip {
  position: fixed;
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  font-size: 12px;
}

@keyframes pulse-winner {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

.winner-pulse { animation: pulse-winner 1s ease-in-out 3; }
