* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: #000;
  color: #e0e0e0;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
}

#canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#loading-overlay.error p {
  color: #ff6b6b;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(0, 255, 204, 0.2);
  border-top-color: #00ffcc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-overlay p {
  margin: 0;
  color: #00ffcc;
  font-size: 1rem;
}

#tooltip {
  position: fixed;
  z-index: 5;
  padding: 0.6rem 0.9rem;
  background: rgba(20, 25, 30, 0.92);
  border: 1px solid rgba(0, 255, 204, 0.3);
  border-radius: 8px;
  font-size: 0.875rem;
  max-width: 280px;
  pointer-events: none;
  display: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#tooltip.visible {
  display: block;
}

.tooltip-name {
  font-weight: 600;
  color: #00ffcc;
  margin-bottom: 0.25rem;
}

.tooltip-country, .tooltip-papers {
  color: #b0b0b0;
  font-size: 0.8rem;
}

#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: rgba(15, 18, 22, 0.85);
  border-right: 1px solid rgba(0, 255, 204, 0.2);
  z-index: 5;
  display: flex;
  transition: transform 0.25s ease, width 0.25s ease;
}

#sidebar.collapsed {
  width: 48px;
}

#sidebar.collapsed #sidebar-content {
  opacity: 0;
  pointer-events: none;
}

#sidebar-toggle {
  position: absolute;
  right: -32px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 48px;
  background: rgba(15, 18, 22, 0.9);
  border: 1px solid rgba(0, 255, 204, 0.2);
  border-left: none;
  color: #00ffcc;
  cursor: pointer;
  font-size: 0.7rem;
  border-radius: 0 6px 6px 0;
  padding: 0;
  line-height: 1;
}

#sidebar.collapsed #sidebar-toggle {
  right: -32px;
  content: "▶";
}

#sidebar-toggle:hover {
  background: rgba(0, 255, 204, 0.15);
}

#sidebar-content {
  padding: 1.5rem 1.25rem;
  flex: 1;
  transition: opacity 0.2s ease;
}

#sidebar-content h1 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: #00ffcc;
}

#sidebar-content p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #b0b0b0;
}

#sidebar-content label {
  display: block;
  margin: 1rem 0 0.4rem;
  font-size: 0.85rem;
  color: #a0a0a0;
}

#search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 255, 204, 0.3);
  border-radius: 6px;
  color: #e0e0e0;
  outline: none;
}

#search-input::placeholder {
  color: #666;
}

#search-input:focus {
  border-color: #00ffcc;
  box-shadow: 0 0 0 2px rgba(0, 255, 204, 0.2);
}

#sidebar-content .leaderboard {
  margin-top: 1.5rem;
}

#sidebar-content .leaderboard h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #00ffcc;
}

#sidebar-content .leaderboard ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

#sidebar-content .leaderboard li {
  display: grid;
  grid-template-columns: 1.25rem 1fr auto;
  gap: 0.5rem 0.75rem;
  align-items: baseline;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(0, 255, 204, 0.08);
}

#sidebar-content .leaderboard li:last-child {
  border-bottom: none;
}

#sidebar-content .leaderboard li.leaderboard-empty {
  grid-template-columns: 1fr;
  color: #808080;
  font-size: 0.8rem;
}

#sidebar-content .leaderboard li.leaderboard-clickable {
  cursor: pointer;
}

#sidebar-content .leaderboard li.leaderboard-clickable:hover {
  color: #00ffcc;
}

#sidebar-content .leaderboard li.leaderboard-clickable.selected {
  background: rgba(0, 255, 204, 0.12);
  color: #00ffcc;
}

#sidebar-content .leaderboard-rank {
  color: #00ffcc;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#sidebar-content .leaderboard-name {
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sidebar-content .leaderboard-count {
  color: #a0a0a0;
  font-variant-numeric: tabular-nums;
}
