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

:root {
  --color-bg: #0d0d0d;
  --color-surface: #141414;
  --color-surface-2: #1f1f1f;
  --color-border: #333333;
  --color-text: #f0f0f0;
  --color-accent: #C8102E;
  --color-accent-hover: #E31837;
  --color-gray: #878787;
  --color-text-muted: var(--color-gray);
  --color-route-a: #F5C518;
  --color-route-b: #FF4081;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --timeline-width: 420px;
  --brand-z: 1000;
  --timeline-z: 900;
  --modal-z: 2000;
  --title-z: 800;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.leaflet-gesture-handling-tooltip {
  background: var(--color-surface-2) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 8px !important;
  padding: 8px 16px !important;
  font-family: var(--font-family) !important;
  font-size: 13px !important;
}

#branding {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: var(--brand-z);
  pointer-events: none;
}

.logo-img {
  max-height: 56px;
  width: auto;
  display: block;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 12px 18px;
}

.shield-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
}

#title-bar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--title-z);
  pointer-events: none;
}

.title-bar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  padding: 8px 24px;
}

.title-bar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.title-bar-route {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.title-bar-date {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text);
}

#timeline-toggle {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--timeline-z);
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--color-accent);
  border: 2px solid rgba(255,255,255,0.15);
  padding: 16px 32px;
  border-radius: 100px;
  box-shadow: 0 6px 30px rgba(200, 16, 46, 0.5);
  cursor: pointer;
  pointer-events: all;
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
  animation: pulse-toggle 2.5s ease-in-out infinite;
}

@keyframes pulse-toggle {
  0%, 100% { box-shadow: 0 6px 30px rgba(200, 16, 46, 0.5); transform: translateX(-50%) scale(1); }
  50% { box-shadow: 0 8px 44px rgba(200, 16, 46, 0.75); transform: translateX(-50%) scale(1.04); }
}

#timeline-toggle:hover {
  background: var(--color-accent-hover);
  animation: none;
}

.toggle-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-label {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

#timeline-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--timeline-width);
  height: 100%;
  z-index: var(--timeline-z);
  background: rgba(10, 10, 15, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: all;
}

#timeline-panel.hidden {
  transform: translateX(100%);
}

.timeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.timeline-header-left {
  min-width: 0;
}

.timeline-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.timeline-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.timeline-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 2px;
}

#timeline-close {
  background: var(--color-surface-2);
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

#timeline-close:hover {
  background: var(--color-border);
  color: #fff;
}

#tour-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tour-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--color-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.tour-btn:hover {
  background: var(--color-accent-hover);
  transform: scale(1.1);
}

.tour-btn:active {
  transform: scale(0.95);
}

.gps-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4CAF50;
  animation: gps-blink 1.2s ease-in-out infinite;
}

@keyframes gps-blink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
}

.tour-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 0;
}

.tour-location {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
}

.tour-pct {
  font-size: 10px;
  font-weight: 400;
  color: var(--color-text-muted);
}

#tour-progress {
  height: 2px;
  background: var(--color-border);
  position: relative;
}

#tour-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  transition: width 0.3s ease;
}

.timeline-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 24px;
  scroll-behavior: smooth;
}

.timeline-scroll::-webkit-scrollbar {
  width: 3px;
}

.timeline-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.timeline-scroll::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.day-card {
  position: relative;
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.day-card:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-2);
}

.day-card:active {
  transform: scale(0.98);
  border-left-color: var(--color-accent);
}

.day-card.active {
  border-color: var(--color-accent);
  background: rgba(200, 16, 46, 0.08);
  border-left-color: var(--color-accent);
}

.day-card-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
}

.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-right: 12px;
}

.day-info {
  flex: 1;
  min-width: 0;
}

.day-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.day-date {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.day-route {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
  line-height: 1.4;
  padding-left: 40px;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--modal-z);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: all;
}

#modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

#modal {
  position: relative;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 32px;
  overflow-y: auto;
  transform: translateY(24px) scale(0.96);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#modal-overlay.visible #modal {
  transform: translateY(0) scale(1);
}

#modal::-webkit-scrollbar {
  width: 3px;
}

#modal::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

#modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--color-surface-2);
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s;
}

#modal-close:hover {
  background: var(--color-border);
  color: #fff;
}

.modal-day-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.modal-day-badge .day-number {
  margin-right: 0;
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.modal-day-badge .day-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-title {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.2;
}

.modal-date {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.modal-route-info {
  font-size: 14px;
  color: var(--color-text);
  padding: 14px 18px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  line-height: 1.6;
}

.leaflet-popup-content-wrapper {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-popup-tip {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  border-top: none !important;
  border-left: none !important;
}

.leaflet-popup-close-button {
  color: var(--color-text-muted) !important;
}

.custom-marker {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.custom-marker svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  transition: transform 0.2s ease;
}

.custom-marker:hover svg {
  transform: scale(1.15);
}

.car-marker {
  background: none !important;
  border: none !important;
  z-index: 10000 !important;
}

.car-marker-inner {
  width: 40px;
  height: 24px;
  animation: car-float 2s ease-in-out infinite;
}

@keyframes car-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.location-label {
  background: rgba(10, 10, 15, 0.8) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 6px !important;
  padding: 3px 8px !important;
  font-family: var(--font-family) !important;
  font-size: 10px !important;
  font-weight: 500 !important;
  color: var(--color-text) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
  white-space: nowrap;
}

.location-label::before {
  display: none !important;
}

@media (max-width: 1024px) {
  :root {
    --timeline-width: 340px;
  }
}

@media (max-width: 768px) {
  #branding {
    top: 10px;
    left: 10px;
  }

  .brand-logo {
    padding: 6px 10px;
    gap: 8px;
    border-radius: 8px;
  }

  .shield-icon {
    width: 28px;
    height: 28px;
  }

  .brand-title {
    font-size: 10px;
  }

  .brand-subtitle {
    display: none;
  }

  .logo-img {
    max-height: 36px;
  }

  #title-bar {
    display: none;
  }

  .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px !important;
    margin-right: 12px !important;
  }

  .leaflet-control-zoom a {
    width: 44px;
    height: 44px;
    line-height: 44px;
    font-size: 22px;
    font-weight: 700;
    background: rgba(15, 15, 15, 0.96);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.12);
    transition: background 0.15s;
    text-decoration: none;
  }

  .leaflet-control-zoom a:first-child {
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  .leaflet-control-zoom a:hover {
    background: rgba(40, 40, 40, 0.96);
    color: #fff;
  }

  .leaflet-control-zoom a.leaflet-disabled {
    color: rgba(255,255,255,0.25);
  }

  #timeline-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 54vh;
    border-left: none;
    border-top: 2px solid rgba(200, 16, 46, 0.5);
    border-radius: 20px 20px 0 0;
    transform: translateY(calc(100% - 72px));
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.7);
    background: rgba(10, 10, 15, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  #timeline-panel::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--color-accent);
    border-radius: 3px;
    z-index: 1;
    opacity: 0.5;
  }

  #timeline-panel.hidden {
    transform: translateY(calc(100% - 72px));
  }

  #timeline-panel.expanded {
    transform: translateY(0);
  }

  #timeline-toggle {
    display: flex;
  }

  .timeline-header {
    padding: 14px 12px 12px 16px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
  }

  .timeline-header:active {
    cursor: grabbing;
  }

  .timeline-header h2 {
    font-size: 14px;
  }

  .timeline-subtitle {
    display: none;
  }

  .timeline-scroll {
    padding: 8px 12px 20px;
  }

  .day-card {
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    border-left-width: 3px;
  }

  .day-card:active {
    transform: scale(0.97);
  }

  .day-name {
    font-size: 13px;
  }

  .day-number {
    width: 28px;
    height: 28px;
    font-size: 11px;
    margin-right: 10px;
  }

  .day-date {
    font-size: 10px;
  }

  .day-route {
    font-size: 11px;
    padding-left: 38px;
  }

  #modal {
    padding: 24px 20px;
    width: 92%;
    max-height: 80vh;
    border-radius: 14px;
  }

  .modal-title {
    font-size: 22px;
  }

  .modal-route-info {
    font-size: 13px;
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  #timeline-panel {
    height: 60vh;
  }

  #timeline-toggle {
    padding: 14px 24px;
    bottom: 24px;
  }

  .toggle-label {
    font-size: 13px;
  }

  .brand-title {
    font-size: 10px;
  }

  .brand-logo {
    padding: 5px 8px;
    gap: 6px;
  }

  .shield-icon {
    width: 24px;
    height: 24px;
  }

  .logo-img {
    max-height: 32px;
  }

  .day-card {
    padding: 12px 14px;
  }
}
