@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-deep: #07090e;
  --bg-map-dark: #12161f;
  --panel-bg: rgba(13, 17, 26, 0.82);
  --panel-border: rgba(255, 255, 255, 0.09);
  --panel-hover: rgba(255, 255, 255, 0.15);
  --accent-cyan: #00f0ff;
  --accent-green: #10b981;
  --accent-red: #f43f5e;
  --accent-violet: #a855f7;
  --accent-amber: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --glow-cyan: 0 0 20px rgba(0, 240, 255, 0.4);
  --glow-green: 0 0 16px rgba(16, 185, 129, 0.4);
  --glow-red: 0 0 16px rgba(244, 63, 94, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-map, rgb(27, 27, 29));
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  user-select: none;
  transition: background-color 0.4s ease;
}

#map-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: var(--bg-map, rgb(27, 27, 29));
  transition: background-color 0.4s ease;
}

#map-south-background {
  position: absolute;
  inset: 0;
  background: var(--bg-map-south, rgb(12, 12, 12));
  pointer-events: none;
  z-index: 1;
}

#synapse-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* Glassmorphic Panel Styles */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease;
  pointer-events: auto;
}

.glass-panel:hover {
  border-color: var(--panel-hover);
}

/* HUD Layer */
#hud-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.5s;
}

/* Zen Mode: Smoothly hide all HUD elements */
body.zen-active #hud-overlay {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

body.zen-active {
  cursor: none;
}

body.zen-active.show-cursor {
  cursor: default;
}

/* Top Header Bar */
.top-header {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 20px;
}

/* App Brand Title - Top Left */
.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  cursor: default;
  z-index: 2;
  min-width: 0;
  flex-shrink: 1;
}

.brand-beacon {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  flex-shrink: 0;
}

.brand-beacon::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 1px solid var(--accent-cyan);
  animation: beacon-ripple 3.2s ease-out infinite;
  pointer-events: none;
}

.brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  animation: soft-pulse-glow 3.6s ease-in-out infinite;
}

@keyframes soft-pulse-glow {
  0%, 100% {
    color: rgba(241, 245, 249, 0.82);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.2),
                 0 0 16px rgba(0, 240, 255, 0.1);
  }
  50% {
    color: #ffffff;
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.6),
                 0 0 22px rgba(0, 240, 255, 0.3),
                 0 0 32px rgba(0, 240, 255, 0.12);
  }
}

@keyframes beacon-ripple {
  0% {
    transform: scale(0.7);
    opacity: 0.85;
  }
  50% {
    transform: scale(2.2);
    opacity: 0;
  }
  100% {
    transform: scale(0.7);
    opacity: 0;
  }
}

/* Live Telemetry Rate Value */

.telemetry-value {
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.telemetry-value.cyan { color: var(--accent-cyan); }
.telemetry-value.green { color: var(--accent-green); }
.telemetry-value.red { color: var(--accent-red); }

/* Header Actions / Controls */
.header-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}

#btn-toggle-georesolved {
  width: 176px;
  justify-content: center;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-icon.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-text {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 36px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  text-decoration: none;
}

.btn-text svg {
  flex-shrink: 0;
}

.btn-text:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-text.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.25);
}

.btn-text.zen-btn {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(0, 240, 255, 0.18));
  border-color: rgba(168, 85, 247, 0.35);
  color: #fff;
}

.btn-text.zen-btn:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25);
}

/* Side Activity Feed Drawer */
.activity-drawer {
  position: absolute;
  top: 86px;
  left: 16px;
  width: 350px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

.drawer-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--panel-border);
}

.drawer-title {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-rate-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.22);
  border-radius: 6px;
  user-select: none;
  line-height: 1;
}

.drawer-rate-badge .telemetry-value {
  font-size: 11px;
  gap: 3px;
}

#btn-feed-translate {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-feed-translate.active {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

/* Feed Filter & Language Bar */
.drawer-filter-bar {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--panel-border);
  position: relative;
}

.lang-selector-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-lang-selector {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.btn-lang-selector:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.4);
}

.btn-lang-selector.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.1);
  color: #fff;
}

.lang-flag {
  font-size: 13px;
  line-height: 1;
}

.lang-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-chevron {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.btn-lang-selector.open .lang-chevron {
  transform: rotate(180deg);
}

.btn-clear-lang {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear-lang:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: var(--accent-red);
  color: #fff;
}

/* Language Dropdown Popover */
.lang-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  max-height: 280px;
  background: rgba(10, 14, 23, 0.96);
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 16px rgba(0, 240, 255, 0.15);
  border-radius: 8px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(20px);
  animation: slideDown 0.18s ease;
}

.lang-search-box {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.3);
}

.lang-search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.lang-search-box input {
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  outline: none;
}

.lang-search-box input::placeholder {
  color: var(--text-muted);
}

.lang-options-list {
  overflow-y: auto;
  max-height: 220px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.lang-options-list::-webkit-scrollbar {
  width: 4px;
}

.lang-options-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.lang-option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'JetBrains Mono', monospace;
}

.lang-option-item:hover, .lang-option-item.selected {
  background: rgba(0, 240, 255, 0.12);
  color: #fff;
}

.lang-option-item.selected {
  border-left: 2px solid var(--accent-cyan);
}

.lang-opt-flag {
  font-size: 12px;
}

.lang-opt-code {
  font-weight: 600;
  color: var(--accent-cyan);
  min-width: 24px;
  text-transform: uppercase;
}

.lang-opt-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-opt-country {
  font-size: 9px;
  color: var(--text-dim);
}

/* Feed Pause Banner / Pill */
.feed-pause-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: #fef3c7;
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.resume-pill {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.25);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.resume-pill:hover {
  background: var(--accent-amber);
  color: #000;
}

.feed-container {
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  contain: paint;
}

.feed-container::-webkit-scrollbar {
  width: 4px;
}

.feed-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Feed Item Card with Layout Containment */
.feed-card {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  contain: content;
  will-change: transform, opacity;
  position: relative;
}

.feed-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.3);
  transform: translateX(3px);
}

/* Selected Card Highlight */
.feed-card.selected {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.2);
}

.feed-card.selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent-cyan);
  border-radius: 0 2px 2px 0;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.feed-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wiki-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.diff-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.diff-badge.add {
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.12);
}

.diff-badge.del {
  color: var(--accent-red);
  background: rgba(244, 63, 94, 0.12);
}

.feed-card-title {
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  user-select: none;
}

.feed-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  gap: 6px;
}

.feed-route {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-amber);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
  flex-shrink: 0;
}

.feed-card.geotagged {
  border-left: 2.5px solid var(--accent-cyan);
}

/* Synapse Inspector Panel */
.inspector-panel {
  position: absolute;
  bottom: 80px;
  left: 380px;
  width: 380px;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 15;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.inspector-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--panel-border);
}

.inspector-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag-wiki {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.12);
  padding: 3px 8px;
  border-radius: 4px;
}

.tag-type {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 4px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.inspector-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.inspect-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.inspect-title a {
  color: #fff;
  text-decoration: none;
  transition: color 0.2s ease;
}

.inspect-title a:hover {
  color: var(--accent-cyan);
}

.inspect-card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.inspect-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field-label {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.field-value {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-value.highlight {
  color: var(--accent-amber);
  font-weight: 600;
}

.field-value.cyan {
  color: var(--accent-cyan);
}

.inspect-comment-box {
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comment-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  font-style: italic;
  max-height: 70px;
  overflow-y: auto;
}

.inspect-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 4px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  text-transform: uppercase;
}

.meta-val {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.inspect-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

/* Floating Bottom Controls */
.bottom-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  z-index: 10;
}

.controls-cluster {
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 28px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.controls-cluster.expanded {
  border-color: rgba(0, 240, 255, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 16px rgba(0, 240, 255, 0.12);
}

.controls-expanded-group {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  white-space: nowrap;
  margin: 0;
  padding: 0;
  transform: scaleX(0.95);
  transform-origin: right center;
  transition: max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease,
              margin 0.35s ease,
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.controls-cluster.expanded .controls-expanded-group {
  max-width: 480px;
  opacity: 1;
  pointer-events: auto;
  margin-right: 6px;
  transform: scaleX(1);
}

.controls-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.controls-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.controls-cluster.expanded .controls-toggle,
.controls-toggle.active {
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.controls-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 3px;
  flex-shrink: 0;
}

.btn-pill {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.btn-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.btn-pill.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--accent-cyan);
  color: #fff;
}

/* Zen Mode Prompt Notification */
#zen-exit-hint {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 17, 26, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 100;
}

#zen-exit-hint kbd {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
}

body.zen-active.show-hint #zen-exit-hint {
  opacity: 1;
}

/* Attribution Control (Retracted / Compact by default) */
.maplibregl-ctrl-attrib {
  background: rgba(13, 17, 26, 0.72) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text-dim, #64748b) !important;
  font-family: 'JetBrains Mono', monospace, -apple-system, sans-serif;
  font-size: 10px;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: opacity 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, width 0.3s ease, padding 0.3s ease;
  overflow: hidden;
}

/* When retracted (compact and details not open) */
.maplibregl-ctrl-attrib.maplibregl-compact:not([open]):not(:hover):not(.maplibregl-compact-show) {
  padding: 0 !important;
  width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  border-radius: 50% !important;
}

.maplibregl-ctrl-attrib.maplibregl-compact:not([open]):not(:hover):not(.maplibregl-compact-show) .maplibregl-ctrl-attrib-inner {
  display: none !important;
}

/* When expanded (hovered or opened) */
.maplibregl-ctrl-attrib.maplibregl-compact[open],
.maplibregl-ctrl-attrib.maplibregl-compact:hover,
.maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show {
  padding: 2px 10px 2px 28px !important;
  border-radius: 12px !important;
  width: auto !important;
}

.maplibregl-ctrl-attrib.maplibregl-compact[open] .maplibregl-ctrl-attrib-inner,
.maplibregl-ctrl-attrib.maplibregl-compact:hover .maplibregl-ctrl-attrib-inner,
.maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
  display: inline-block !important;
}

.maplibregl-ctrl-attrib a {
  color: var(--text-muted, #94a3b8) !important;
  text-decoration: none;
  transition: color 0.2s ease;
}

.maplibregl-ctrl-attrib a:hover {
  color: var(--accent-cyan, #00f0ff) !important;
  text-decoration: underline;
}

.maplibregl-ctrl-attrib-button {
  background-color: transparent !important;
  filter: invert(1) opacity(0.65);
  transition: filter 0.2s ease, opacity 0.2s ease;
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  outline: none !important;
  cursor: pointer;
}

.maplibregl-ctrl-attrib-button:hover,
.maplibregl-ctrl-attrib:hover .maplibregl-ctrl-attrib-button {
  filter: invert(1) opacity(1);
}

/* Zen Mode: OpenFreeMap disclaimer is dark and faint, but clicking it exits Zen Mode */
body.zen-active .maplibregl-ctrl-attrib {
  background: rgba(13, 17, 26, 0.35) !important;
  border-color: rgba(255, 255, 255, 0.04);
  opacity: 0.32;
  cursor: pointer !important;
  user-select: none;
}

body.zen-active .maplibregl-ctrl-attrib a,
body.zen-active .maplibregl-ctrl-attrib summary,
body.zen-active .maplibregl-ctrl-attrib-inner,
body.zen-active .maplibregl-ctrl-attrib * {
  color: rgba(255, 255, 255, 0.35) !important;
  cursor: pointer !important;
}

body.zen-active .maplibregl-ctrl-attrib:hover {
  opacity: 0.9;
  background: rgba(13, 17, 26, 0.85) !important;
  border-color: rgba(0, 240, 255, 0.35);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25);
}

body.zen-active .maplibregl-ctrl-attrib:hover a,
body.zen-active .maplibregl-ctrl-attrib:hover summary,
body.zen-active .maplibregl-ctrl-attrib:hover * {
  color: var(--text-main, #f8fafc) !important;
}

body.zen-active.show-cursor .maplibregl-ctrl-attrib,
body.zen-active.show-cursor .maplibregl-ctrl-attrib * {
  cursor: pointer !important;
}

.map-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  transform: translate(-50%, -100%);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(13, 17, 26, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.2);
  color: #fff;
  white-space: nowrap;
  margin-top: -12px;
  display: none;
}

/* Responsive Header Adaptations */

@media (max-width: 1040px) {
  .brand-text {
    font-size: 12px;
    letter-spacing: 0.02em;
  }
  #btn-toggle-georesolved span,
  #btn-toggle-scoreboard span {
    display: none;
  }
  #btn-toggle-georesolved,
  #btn-toggle-scoreboard {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}

/* ==========================================
 * GLOBAL EDIT SCOREBOARD / LEADERBOARD
 * ========================================== */

.scoreboard-panel {
  position: absolute;
  top: 80px;
  right: 16px;
  width: 420px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 16;
  border-radius: 20px;
}
.scoreboard-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 18px 12px; flex-shrink: 0; }
.scoreboard-title-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.scoreboard-trophy-icon { font-size: 28px; }
.scoreboard-title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.5px; }
.scoreboard-subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }
.scoreboard-header-actions { display: flex; align-items: center; gap: 6px; }
.race-reset { border: 1px solid var(--panel-border); border-radius: 12px; background: rgba(255,255,255,.04); color: var(--text-muted); padding: 8px 10px; min-height: 44px; font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
.race-reset:hover { color: var(--text-main); background: rgba(255,255,255,.1); }
.scoreboard-header .btn-close { min-width: 44px; min-height: 44px; }
.scoreboard-panel button:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }
.scoreboard-summary { margin: 0; padding: 0 18px 14px; color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.scoreboard-body { min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 0 12px 8px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.scoreboard-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; flex-shrink: 0; }
.scoreboard-toolbar .scoreboard-summary { padding: 0; }
.bot-filter-status { margin: 4px 18px 12px; font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
#btn-hide-bots.active { background: rgba(99,215,207,.13); border-color: #63d7cf; color: #90ece5; }
.race-edit-details { grid-column: 1 / -1; margin: 0; font-size: 11px; color: var(--text-muted); }
.race-incoming { grid-column: 1 / -1; border-top: 1px solid var(--panel-border); padding-top: 9px; min-width: 0; }
.race-incoming-heading { font-size: 11px; font-weight: 600; color: var(--text-main); }
.race-incoming-heading span { font-weight: 400; color: var(--text-muted); }
.race-incoming-list { list-style: none; padding: 0; margin: 7px 0 0; display: grid; gap: 5px; }
.race-incoming-list li { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 7px; align-items: center; font-size: 12px; }
.incoming-flag { font-size: 15px; }
.incoming-name { overflow-wrap: anywhere; }
.incoming-count { color: var(--text-main); font-variant-numeric: tabular-nums; white-space: nowrap; }
.race-no-incoming { margin: 7px 0 0; font-size: 11px; color: var(--text-muted); }
.country-race-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.scoreboard-panel [hidden] { display: none !important; }
.race-row { display: grid; grid-template-columns: 20px 32px minmax(0,1fr) auto auto; align-items: center; gap: 8px; padding: 14px 12px; border: 1px solid rgba(255,255,255,.05); border-radius: 14px; background: rgba(255,255,255,.025); }
.race-row.is-leader { border-color: rgba(243,198,101,.35); background: linear-gradient(110deg, rgba(243,198,101,.12), rgba(243,198,101,.025)); }
.race-rank { font-size: 12px; color: var(--text-muted); text-align: center; font-variant-numeric: tabular-nums; }
.race-flag { font-size: 26px; line-height: 1.2; }
.race-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.race-score { grid-column: 5; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.race-crown { grid-column: 4; font-size: 18px; }
.race-track { grid-column: 3 / -1; display: block; height: 6px; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.07); }
.race-bar { display: block; height: 100%; border-radius: inherit; background: var(--race-color); transition: width .35s ease; }
.is-leader .race-bar { background: #f3c665; }
.is-leader .race-score { color: #f3c665; }
.race-crown.celebrate { animation: crownPulse .65s ease; }
@keyframes crownPulse { 0%,100% { transform: scale(1) rotate(0); } 45% { transform: scale(1.35) rotate(-12deg); } }
.scoreboard-rules { margin: 0; padding: 14px 12px; border-top: 1px solid var(--panel-border); color: var(--text-muted); font-size: 11px; line-height: 1.6; text-align: center; flex-shrink: 0; }
.scoreboard-rules strong { color: var(--text-main); font-weight: 500; }
.scoreboard-empty { text-align: center; padding: 36px 12px; color: var(--text-muted); font-size: 13px; }
.race-empty-icon { display: block; font-size: 40px; margin-bottom: 16px; }
.scoreboard-empty p { font-size: 17px; color: var(--text-main); margin: 0 0 8px; font-weight: 600; }
@media (max-width: 480px) {
  .race-row { grid-template-columns: 18px 30px minmax(0, 1fr) 24px; }
  .race-score { grid-column: 3 / -1; grid-row: 2; }
  .race-track { grid-row: 3; }
  .race-rank, .race-flag { grid-row: 1 / 3; }
  .race-crown { grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) { .race-bar { transition: none; } .race-crown.celebrate { animation: none; } }

@media (max-width: 640px) {
  .scoreboard-panel {
    top: 70px;
    right: 8px;
    left: 8px;
    width: auto;
  }
  .controls-cluster.expanded .controls-expanded-group {
    max-width: calc(100vw - 88px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .controls-cluster.expanded .controls-expanded-group::-webkit-scrollbar {
    display: none;
  }
}

/* Mobile controls reuse the desktop actions; only their placement changes. */
.mobile-only, #mobile-menu, #btn-exit-zen { display: none; }
#btn-fullscreen[hidden] { display: none !important; }
#inspect-details > summary { display: none; }
#inspect-details[open] { display: grid; gap: 12px; }

@media (max-width: 767px), (max-width: 1023px) and (max-height: 500px) and (pointer: coarse) {
  :root {
    --mobile-top: calc(8px + env(safe-area-inset-top));
    --mobile-bottom: calc(64px + env(safe-area-inset-bottom));
    --mobile-view-height: 100dvh;
    --mobile-sheet-height: min(calc(var(--mobile-view-height) * 0.54), calc(var(--mobile-view-height) - var(--mobile-top) - var(--mobile-bottom) - 72px));
    --panel-bg: rgba(13, 17, 26, 0.96);
  }
  html, body { height: 100dvh; }
  #hud-overlay { height: var(--mobile-view-height); bottom: auto; }
  .mobile-only { display: flex; }
  .glass-panel { border-radius: 16px; box-shadow: 0 6px 20px #0003; }
  .top-header {
    top: var(--mobile-top);
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    height: 56px;
    padding: 0 10px 0 14px;
    gap: 8px;
  }
  .brand-title { min-width: 0; flex-shrink: 1; gap: 8px; }
  .brand-text, .header-actions, .bottom-controls { display: none; }
  .mobile-brand { font-size: 14px; font-weight: 600; white-space: nowrap; }
  .brand-beacon { box-shadow: none; width: 6px; height: 6px; }
  .brand-beacon::after { display: none; }
  .mobile-header-actions { align-items: center; gap: 8px; }
  .mobile-stream-status { font-size: 11px; color: var(--text-muted); }
  .mobile-stream-status[data-live="true"] { color: var(--accent-green); }
  #hud-overlay button, #hud-overlay .btn-text, #btn-exit-zen {
    min-height: 44px;
    min-width: 44px;
    height: auto;
    font-size: 14px;
    box-shadow: none;
    touch-action: manipulation;
  }
  button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent-cyan) !important;
    outline-offset: 2px;
  }
  #btn-mobile-menu { padding: 0 12px; }
  #mobile-menu:not([hidden]) {
    display: block;
    position: absolute;
    top: calc(var(--mobile-top) + 64px);
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    max-height: calc(var(--mobile-view-height) - var(--mobile-top) - var(--mobile-bottom) - 76px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    z-index: 30;
  }
  #mobile-menu h2 { font-size: 16px; margin-bottom: 12px; }
  #mobile-menu h3 { font-size: 12px; color: var(--text-muted); margin: 20px 0 8px; font-weight: 500; }
  #mobile-menu-actions, #mobile-menu-appearance { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #mobile-menu button { width: 100%; padding: 10px; gap: 8px; justify-content: flex-start; text-align: left; white-space: normal; border-radius: 10px; font-family: inherit; letter-spacing: normal; }
  #mobile-menu button svg { flex-shrink: 0; }
  #mobile-menu #btn-toggle-scoreboard span, #mobile-menu #btn-toggle-georesolved span, #mobile-menu #btn-hide-bots span { display: inline; }
  #mobile-menu button.active { border-color: rgba(0, 240, 255, 0.4); background: rgba(0, 240, 255, 0.08); }
  #activity-drawer, #inspector-panel, #scoreboard-panel {
    top: auto;
    bottom: var(--mobile-bottom);
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    width: auto;
    height: var(--mobile-sheet-height);
    max-height: var(--mobile-sheet-height);
    animation: none;
    overscroll-behavior: contain;
  }
  body[data-mobile-panel="collapsed"] #activity-drawer { height: 60px; max-height: 60px; }
  body[data-mobile-panel="collapsed"] #activity-drawer > :not(.drawer-header) { display: none !important; }
  body[data-mobile-panel="inspector"] #activity-drawer,
  body[data-mobile-panel="scoreboard"] #activity-drawer { visibility: hidden; pointer-events: none; }
  body.mobile-menu-open #activity-drawer,
  body.mobile-menu-open #inspector-panel,
  body.mobile-menu-open #scoreboard-panel { visibility: hidden; pointer-events: none; }
  .drawer-header { padding: 7px 12px; gap: 8px; flex-shrink: 0; min-height: 58px; }
  .drawer-title { display: none; }
  .mobile-feed-toggle { background: none; border: 0; color: var(--text-main); align-items: center; justify-content: space-between; gap: 12px; flex: 1; text-align: left; font-weight: 600; }
  .mobile-feed-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
  .drawer-rate-badge { border: 0; padding: 0; background: none; }
  .drawer-rate-badge .telemetry-value { font-size: 13px; }
  .drawer-filter-bar { padding: 8px 12px; flex-shrink: 0; }
  .mobile-feed-tools { gap: 8px; margin-bottom: 8px; }
  #mobile-translate-slot { flex: 1; }
  #mobile-translate-slot #btn-feed-translate { width: 100%; gap: 8px; padding: 8px; }
  .feed-container, .inspector-body, .scoreboard-body {
    min-height: 0;
    overscroll-behavior: contain;
    touch-action: pan-y;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .feed-container { padding: 8px 12px 12px; }
  .feed-container:empty::after { content: 'Waiting for live edits…'; display: block; padding: 20px 0; color: var(--text-muted); font-size: 14px; text-align: center; }
  .feed-card { padding: 12px; box-shadow: none; animation: none; border-radius: 10px; }
  .feed-card.selected { box-shadow: none; }
  .feed-card-title { font-size: 15px; line-height: 1.45; }
  .feed-card-meta { font-size: 12px; }
  .feed-pause-banner { flex-shrink: 0; font-size: 12px; padding: 4px 12px; }
  .lang-dropdown-panel { position: absolute; top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: calc(var(--mobile-sheet-height) - 76px); background: #0d111a; }
  .lang-search-box { flex-shrink: 0; }
  .lang-search-box input { font-size: 16px; min-height: 44px; }
  .lang-option-item { min-height: 44px; font-size: 14px; }
  .inspector-header, .scoreboard-header { flex-shrink: 0; padding: 8px 12px; }
  .inspector-body { padding: 12px 16px; }
  .inspect-title { font-size: 18px; }
  .inspect-title, .field-value, .comment-text { overflow-wrap: anywhere; }
  .field-value, .comment-text { font-size: 14px; }
  .inspect-card-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inspect-field { min-width: 0; }
  .field-value { white-space: normal; }
  .inspect-actions { flex-wrap: wrap; }
  #inspect-details { border-top: 1px solid var(--panel-border); }
  #inspect-details > summary { display: list-item; padding: 14px 0; min-height: 44px; color: var(--text-muted); cursor: pointer; font-size: 14px; }
  #inspect-details[open] { display: block; }
  #inspect-details .inspect-meta-grid { margin-top: 12px; }
  .scoreboard-header { flex-wrap: wrap; gap: 4px; }
  .scoreboard-title { font-size: 19px; }
  .scoreboard-header-actions { margin-left: auto; }
  .scoreboard-body { padding: 12px; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: env(safe-area-inset-bottom); max-width: calc(100vw - 16px); }
  .maplibregl-ctrl-bottom-right { right: env(safe-area-inset-right); }
  .maplibregl-ctrl-bottom-left { left: env(safe-area-inset-left); }
  .maplibregl-ctrl-attrib.maplibregl-compact { min-height: 44px !important; max-width: calc(100vw - 20px); }
  #map-container .maplibregl-ctrl-attrib.maplibregl-compact:not([open]):not(.maplibregl-compact-show) { padding: 0 !important; width: 44px !important; height: 44px !important; min-height: 44px !important; border-radius: 50% !important; }
  #map-container .maplibregl-ctrl-attrib.maplibregl-compact:not([open]):not(.maplibregl-compact-show) .maplibregl-ctrl-attrib-inner { display: none !important; }
  .maplibregl-ctrl-attrib-button { width: 44px !important; height: 44px !important; background-repeat: no-repeat; background-position: center; }
  .maplibregl-ctrl-attrib.maplibregl-compact[open], .maplibregl-ctrl-attrib.maplibregl-compact:hover, .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show { padding-left: 48px !important; }
  #zen-exit-hint { display: none; }
  body.zen-active #btn-exit-zen { display: flex; position: fixed; top: var(--mobile-top); right: max(8px, env(safe-area-inset-right)); z-index: 110; padding: 0 16px; background: var(--panel-bg); border-radius: 24px; }
  body.zen-active { cursor: auto; }
}

@media (max-width: 767px) and (max-height: 500px), (max-width: 1023px) and (max-height: 500px) and (pointer: coarse) {
  :root { --mobile-sheet-height: calc(var(--mobile-view-height) - var(--mobile-top) - var(--mobile-bottom) - 72px); }
  .mobile-feed-tools { margin-bottom: 0; }
  .drawer-filter-bar { display: flex; gap: 8px; }
  .lang-selector-wrapper { flex: 1; min-width: 0; }
  #mobile-translate-slot #btn-feed-translate { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  #hud-overlay *, #btn-exit-zen { animation: none !important; transition: none !important; }
}
