* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #1a1a1a; color: #ccc; font-family: 'Helvetica Neue', Arial, sans-serif; overflow: hidden; }

#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  background: rgba(26,26,26,0.92); backdrop-filter: blur(8px);
  padding: 12px 24px; display: flex; align-items: center; gap: 18px;
  border-bottom: 1px solid #333;
}
#header h1 { font-size: 18px; color: #E8B4B8; white-space: nowrap; }
#controls { display: flex; align-items: center; gap: 12px; flex: 1; }
#controls button, #year-selector select {
  background: #333; color: #ccc; border: 1px solid #555; border-radius: 6px;
  padding: 6px 14px; cursor: pointer; font-size: 14px; transition: background 0.15s;
}
#controls button:hover, #year-selector select:hover { background: #444; }
#controls button.active { background: #E8B4B8; color: #1a1a1a; border-color: #E8B4B8; }

#year-selector select {
  font-weight: bold; appearance: auto;
}

#progress-bar {
  flex: 1; height: 6px; background: #333; border-radius: 3px; cursor: pointer;
  position: relative;
}
#progress-fill { height: 100%; background: #E8B4B8; border-radius: 3px; width: 0%; transition: width 0.05s; }
#stats { font-size: 13px; color: #999; white-space: nowrap; }
#timestamp { font-size: 13px; color: #E8B4B8; white-space: nowrap; font-weight: bold; }

#speed-controls { display: flex; gap: 4px; }
#speed-controls button { padding: 4px 8px; font-size: 12px; }

svg { display: block; }
.node-label {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: bold;
  font-size: 11px;
  pointer-events: none;
  text-anchor: middle;
}
.link { fill: none; stroke-width: 1.5; }

#tooltip {
  position: fixed; pointer-events: none; z-index: 20;
  background: rgba(0,0,0,0.85); color: #eee; padding: 8px 12px;
  border-radius: 6px; font-size: 12px; display: none;
  border: 1px solid #555;
}

#leaderboard {
  position: fixed; top: 56px; right: 0; z-index: 10;
  width: 280px; height: calc(100vh - 56px);
  background: rgba(26,26,26,0.94); backdrop-filter: blur(8px);
  border-left: 1px solid #333;
  overflow-y: auto; padding: 16px;
}
#lb-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#lb-header h2 {
  font-size: 15px; color: #E8B4B8; margin: 0;
  text-transform: uppercase; letter-spacing: 1px;
}
#lb-toggle {
  display: none;
  background: #333; color: #ccc; border: 1px solid #555; border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-size: 14px;
}

@media (max-width: 768px) {
  #header { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  #header h1 { font-size: 15px; }
  #controls { gap: 6px; flex-wrap: wrap; }
  #controls button, #year-selector select { padding: 4px 8px; font-size: 12px; }
  #speed-controls button { padding: 3px 6px; font-size: 11px; }
  #stats, #timestamp { font-size: 11px; }

  #leaderboard {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: auto; max-height: 45vh;
    border-left: none; border-top: 1px solid #333;
    padding: 10px 14px;
    transition: max-height 0.3s ease, padding 0.3s ease;
  }
  #leaderboard.collapsed { max-height: 42px; padding-bottom: 0; overflow: hidden; }
  #leaderboard.collapsed #lb-entries { display: none; }
  #lb-toggle { display: block; }
}
.lb-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 5px; margin-bottom: 4px;
  transition: background 0.3s, box-shadow 0.3s;
}
.lb-entry:hover { background: rgba(255,255,255,0.05); }
.lb-entry.active {
  background: rgba(255,255,255,0.1);
  box-shadow: inset 3px 0 0 currentColor;
}
.lb-entry.active .lb-name { color: #fff; }
.lb-entry.active .lb-count { color: #fff; }
.lb-rank { font-size: 13px; color: #666; width: 20px; text-align: right; flex-shrink: 0; }
.lb-color { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.lb-name { font-size: 14px; color: #ddd; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { font-size: 14px; color: #999; font-weight: bold; flex-shrink: 0; }

#loading {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 20px; color: #E8B4B8; z-index: 30;
  display: none;
}
#loading.visible { display: block; }

#view-toggle { display: flex; gap: 4px; }
#view-toggle button { padding: 4px 10px; font-size: 12px; }

#race-container {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #1a1a1a;
}
#race-container.visible { display: block; }

#race-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 48px 0;
}
#race-title {
  font-size: 28px; font-weight: bold; color: #E8B4B8;
  font-family: 'Helvetica Neue', Arial, sans-serif;
}
#race-counter {
  font-size: 48px; font-weight: bold; color: rgba(232,180,184,0.3);
  font-family: 'Helvetica Neue', Arial, sans-serif;
}

#race-canvas { display: block; width: 100%; }

.race-bar-label {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: bold;
  font-size: 14px;
  fill: #888;
  transition: font-size 0.3s;
}
.race-bar-count {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: bold;
  font-size: 13px;
  fill: #ccc;
}
.race-bar-new {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 12px;
  fill: rgba(255,255,255,0.5);
  font-style: italic;
}

@media (max-width: 768px) {
  #race-header { display: none; }
}
