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

html,
body {
  width: 100%;
  height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  background: #0f172a;
  color: #f1f5f9;
}

body {
  display: flex;
  flex-direction: column;
}

#mapCanvas {
  flex: 1;
  width: 100%;
  height: 100%;
}

.header {
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header__stats {
  display: flex;
  gap: 24px;
  font-size: 13px;
}

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

.unit-toggle {
  display: inline-flex;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.7);
}

.unit-toggle__button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.unit-toggle__button:hover {
  background: rgba(148, 163, 184, 0.14);
}

.unit-toggle__button.active {
  background: #fbbf24;
  color: #0f172a;
}

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

.stat__label {
  color: #cbd5e1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat__value {
  font-weight: 600;
  font-size: 14px;
}

.header__btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.header__btn:hover {
  background: #fbbf24;
  color: #0f172a;
}

.settings-dropdown {
  position: relative;
}

.settings-dropdown__btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.settings-dropdown__btn:hover,
.settings-dropdown__btn.open {
  background: #fbbf24;
  color: #0f172a;
}

.settings-dropdown__list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  padding: 8px 0;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.settings-dropdown__list.open {
  display: block;
}

.settings-dropdown__section {
  padding: 4px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-top: 4px;
}

.settings-dropdown__section:first-child {
  margin-top: 0;
}

.settings-dropdown__item {
  padding: 8px 14px;
}

.settings-dropdown__divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.12);
  margin: 4px 14px;
}

.settings-dropdown__item .unit-toggle {
  width: 100%;
}

.settings-dropdown__item .unit-toggle__button {
  flex: 1;
}

.settings-dropdown__item .labels-btn {
  width: 100%;
  text-align: center;
}

.settings-dropdown__item .trail-setting {
  justify-content: space-between;
}

.settings-dropdown__item .trail-setting__input {
  width: 70px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 15px;
}

.modal__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.modal__close:hover {
  color: #f1f5f9;
}

.modal__content {
  padding: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
}

.modal__content p {
  margin-bottom: 12px;
}

.modal__content p:last-child {
  margin-bottom: 0;
}

.modal__content a {
  color: #fbbf24;
  text-decoration-color: rgba(251, 191, 36, 0.55);
}

.modal__content a:hover {
  color: #fde68a;
}

.connection-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.connection-status.connected {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.connection-status.disconnected {
  background: #ef4444;
}

.player-dropdown {
  position: relative;
}

.player-dropdown__btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.player-dropdown__btn:hover,
.player-dropdown__btn.open {
  background: #fbbf24;
  color: #0f172a;
}

.player-dropdown__list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  padding: 6px 0;
  z-index: 1000;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.player-dropdown__list.open {
  display: block;
}

.player-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
}

.player-dropdown__item:hover {
  background: rgba(148, 163, 184, 0.12);
}

.player-dropdown__item.active {
  background: rgba(251, 191, 36, 0.12);
}

.player-dropdown__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0, 0, 0, 0.25);
}

.player-dropdown__name {
  font-weight: 600;
  color: #f1f5f9;
}

.player-dropdown__car {
  color: #94a3b8;
  font-size: 12px;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.labels-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.labels-btn:hover,
.labels-btn.active {
  background: #fbbf24;
  color: #0f172a;
}

.leaflet-tooltip.player-label {
  background: rgba(15, 23, 42, 0.88);
  color: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.leaflet-tooltip.player-label::before {
  border-top-color: rgba(148, 163, 184, 0.25);
}

.player-dropdown__empty {
  padding: 12px 14px;
  color: #64748b;
  font-size: 12px;
  text-align: center;
}

.trail-setting {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trail-setting__input {
  width: 60px;
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.trail-setting__input:focus {
  outline: none;
  border-color: #fbbf24;
}

@media (max-width: 768px) {
  .header {
    gap: 8px;
    flex-wrap: wrap;
  }

  .header__stats {
    gap: 12px;
  }

  .header__controls {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .stat__value {
    font-size: 13px;
  }

  .settings-dropdown__list {
    right: -40px;
  }
}

/* === Heatmap page === */
.heatmap-page {
  display: flex;
  flex-direction: column;
}

.heatmap-header {
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.heatmap-header__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.heatmap-header__stats {
  display: flex;
  gap: 24px;
  font-size: 13px;
}

.heatmap-header__back {
  color: #fbbf24;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 6px 12px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 999px;
  transition: background 0.15s;
}

.heatmap-header__back:hover {
  background: rgba(251, 191, 36, 0.12);
}

.progress-bar {
  height: 3px;
  background: rgba(148, 163, 184, 0.15);
  width: 100%;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ff00, #ffff00, #ff6600, #ff0000);
  transition: width 0.3s ease;
}
