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

:root {
  --bg-dark: #0a0a0f;
  --bg-darker: #050508;
  --glass-bg: rgba(15, 15, 25, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  --text-primary: #e8e8ec;
  --text-secondary: #6b6b7b;
  --text-muted: #3d3d4a;
  --accent-green: #00d66b;
  --accent-green-dim: rgba(0, 214, 107, 0.15);
  --accent-yellow: #ffd93d;
  --accent-yellow-dim: rgba(255, 217, 61, 0.15);
  --accent-orange: #ff7849;
  --accent-orange-dim: rgba(255, 120, 73, 0.15);
  --blur-amount: 20px;
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@font-face {
  font-family: 'Geist';
  src: local('Geist'), local('SF Pro Display'), local('Segoe UI');
  font-weight: 100 900;
}

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(0, 214, 107, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(255, 217, 61, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 120, 73, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: gradientPulse 15s ease-in-out infinite alternate;
}

@keyframes gradientPulse {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.1); }
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Glass panel mixin-style */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--glass-border);
}

/* Header */
header {
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  padding: 0.875rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  z-index: 100;
  animation: headerSlide 0.6s var(--transition-smooth) both;
}

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

/* Alerts Banner */
.alerts-banner {
  background: linear-gradient(135deg, rgba(255, 180, 50, 0.15), rgba(255, 120, 73, 0.1));
  border-bottom: 1px solid rgba(255, 180, 50, 0.3);
  padding: 0.625rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  z-index: 99;
  animation: alertSlide 0.5s var(--transition-smooth) both;
}

@keyframes alertSlide {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alerts-banner.hidden {
  display: none;
}

.alert-icon {
  color: var(--accent-yellow);
  flex-shrink: 0;
  animation: alertPulse 2s ease-in-out infinite;
}

@keyframes alertPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.alert-content {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-primary);
}

#alert-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.alert-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.alert-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

header h1 {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.train-count-badge {
  background: var(--accent-green-dim);
  border: 1px solid rgba(0, 214, 107, 0.3);
  color: var(--accent-green);
  padding: 0.35rem 0.9rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.3s var(--transition-smooth);
}

.train-count-badge:hover {
  background: rgba(0, 214, 107, 0.25);
  transform: scale(1.05);
}

#train-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#last-update {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

#refresh-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.25s var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

#refresh-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-green-dim), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#refresh-btn:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
  transform: translateY(-1px);
}

#refresh-btn:hover::before {
  opacity: 1;
}

#refresh-btn:active {
  transform: translateY(0) scale(0.98);
}

#refresh-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.auto-refresh {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.auto-refresh:hover {
  color: var(--text-secondary);
}

.auto-refresh input {
  accent-color: var(--accent-green);
  cursor: pointer;
}

/* Main content */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

#map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-darker);
}

/* Legend */
#legend {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  padding: 1rem 1.25rem;
  border-radius: 16px;
  z-index: 1000;
  border: 1px solid var(--glass-border);
  animation: legendFade 0.8s var(--transition-smooth) 0.3s both;
  transition: transform 0.3s var(--transition-smooth), box-shadow 0.3s ease;
}

#legend:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

@keyframes legendFade {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#legend h3 {
  font-size: 0.65rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0.4rem 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.legend-icon.station {
  background: var(--text-secondary);
  border: 2px solid var(--text-primary);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.legend-icon.train {
  background: var(--accent-orange);
  border: 2px solid var(--text-primary);
  box-shadow: 0 0 12px var(--accent-orange);
  animation: trainPulse 2s ease-in-out infinite;
}

@keyframes trainPulse {
  0%, 100% { box-shadow: 0 0 8px var(--accent-orange); }
  50% { box-shadow: 0 0 16px var(--accent-orange), 0 0 24px rgba(255, 120, 73, 0.3); }
}

.legend-line {
  width: 20px;
  height: 3px;
  border-radius: 2px;
}

.legend-line.green {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.legend-line.yellow {
  background: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow);
}

/* Sidebar */
#sidebar {
  width: 380px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  overflow-y: auto;
  overflow-x: hidden;
  border-left: 1px solid var(--glass-border);
  transform: translateX(0);
  transition: transform 0.5s var(--transition-smooth);
  animation: sidebarSlide 0.7s var(--transition-smooth) 0.2s both;
}

@keyframes sidebarSlide {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

#sidebar-content {
  padding: 1.5rem;
}

/* Search */
.search-container {
  padding: 1rem 1rem 0;
  position: sticky;
  top: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  z-index: 10;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.875rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s ease;
}

#station-search {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 2.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: all 0.25s var(--transition-smooth);
}

#station-search::placeholder {
  color: var(--text-muted);
}

#station-search:focus {
  border-color: var(--accent-green);
  background: rgba(0, 214, 107, 0.03);
  box-shadow: 0 0 0 3px rgba(0, 214, 107, 0.1);
}

#station-search:focus + .search-icon,
.search-input-wrapper:focus-within .search-icon {
  color: var(--accent-green);
}

.search-clear {
  position: absolute;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.search-clear:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.search-clear.hidden {
  display: none;
}

.search-results {
  margin-top: 0.5rem;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  overflow: hidden;
  animation: searchResultsSlide 0.2s var(--transition-smooth);
}

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

.search-results.hidden {
  display: none;
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: rgba(0, 214, 107, 0.1);
}

.search-result-item:active {
  background: rgba(0, 214, 107, 0.15);
}

.search-result-name {
  flex: 1;
}

.search-result-name mark {
  background: rgba(0, 214, 107, 0.3);
  color: var(--accent-green);
  border-radius: 2px;
  padding: 0 2px;
}

.search-result-code {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin-left: 0.75rem;
}

.search-no-results {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.sidebar-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 1.5rem;
  animation: placeholderFade 0.5s ease;
}

@keyframes placeholderFade {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.placeholder-icon {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  opacity: 0.5;
  animation: iconFloat 4s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.sidebar-placeholder h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.sidebar-placeholder p {
  font-size: 0.8rem;
  line-height: 1.6;
  max-width: 240px;
  margin: 0 auto;
}

/* Station info */
.station-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border);
  animation: stationHeaderSlide 0.4s var(--transition-smooth) both;
}

@keyframes stationHeaderSlide {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.station-header h2 {
  font-size: 1.375rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.station-header .station-code {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0.05em;
}

.platform-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.875rem;
  transition: all 0.3s var(--transition-smooth);
  animation: platformSlide 0.5s var(--transition-smooth) both;
}

.platform-section:nth-child(1) { animation-delay: 0.1s; }
.platform-section:nth-child(2) { animation-delay: 0.2s; }
.platform-section:nth-child(3) { animation-delay: 0.3s; }
.platform-section:nth-child(4) { animation-delay: 0.4s; }

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

.platform-section:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateX(4px);
}

.platform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--glass-border);
}

.platform-number {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.platform-number::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-green);
}

.platform-direction {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.25rem 0.625rem;
  border-radius: 6px;
  max-width: 150px;
  text-align: right;
  line-height: 1.3;
}

.arrival-list {
  list-style: none;
}

.arrival-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: all 0.2s ease;
  animation: arrivalFade 0.4s var(--transition-smooth) both;
}

.arrival-item:nth-child(1) { animation-delay: 0.15s; }
.arrival-item:nth-child(2) { animation-delay: 0.25s; }
.arrival-item:nth-child(3) { animation-delay: 0.35s; }
.arrival-item:nth-child(4) { animation-delay: 0.45s; }
.arrival-item:nth-child(5) { animation-delay: 0.55s; }

@keyframes arrivalFade {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.arrival-item:hover {
  background: rgba(255, 255, 255, 0.02);
  margin: 0 -0.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  border-radius: 8px;
}

.arrival-item:last-child {
  border-bottom: none;
}

.arrival-info {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}

.arrival-line-indicator {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}

.arrival-line-indicator.green {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.arrival-line-indicator.yellow {
  background: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow);
}

.arrival-destination {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.line-tag {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.line-tag.green {
  background: var(--accent-green-dim);
  color: var(--accent-green);
  border: 1px solid rgba(0, 214, 107, 0.3);
}

.line-tag.yellow {
  background: var(--accent-yellow-dim);
  color: var(--accent-yellow);
  border: 1px solid rgba(255, 217, 61, 0.3);
}

.arrival-status {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.arrival-time {
  font-weight: 600;
  padding: 0.3rem 0.625rem;
  border-radius: 6px;
  font-size: 0.75rem;
  min-width: 55px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: all 0.3s var(--transition-bounce);
}

.arrival-time.arrived {
  background: var(--accent-green-dim);
  color: var(--accent-green);
  border: 1px solid rgba(0, 214, 107, 0.3);
  animation: arrivalPulse 1.5s ease-in-out infinite;
}

@keyframes arrivalPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 214, 107, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(0, 214, 107, 0); }
}

.arrival-time.due {
  background: var(--accent-orange-dim);
  color: var(--accent-orange);
  border: 1px solid rgba(255, 120, 73, 0.3);
}

.arrival-time.waiting {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}

.no-arrivals {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
}

/* Footer */
footer {
  background: rgba(5, 5, 8, 0.9);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  padding: 0.75rem 1.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--glass-border);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--accent-green);
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.75rem;
}

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

/* Train popup */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-tip {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-top: none;
  border-left: none;
}

.leaflet-popup-content {
  margin: 12px 14px;
  color: var(--text-primary);
}

.train-popup {
  min-width: 160px;
}

.train-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.train-popup .train-id {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.train-popup .line-tag {
  font-size: 0.55rem;
}

.train-popup p {
  margin: 0.25rem 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.train-popup strong {
  color: var(--text-muted);
  font-weight: 500;
}

/* Station markers */
.station-marker {
  background: rgba(100, 100, 120, 0.9);
  border: 2px solid var(--text-primary);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: all 0.2s var(--transition-smooth);
}

.station-marker:hover {
  transform: scale(1.3);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.3);
}

.station-marker.selected {
  background: var(--accent-orange);
  transform: scale(1.4);
  box-shadow: 0 0 20px var(--accent-orange), 0 0 40px rgba(255, 120, 73, 0.3);
  animation: selectedPulse 2s ease-in-out infinite;
}

@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 20px var(--accent-orange), 0 0 40px rgba(255, 120, 73, 0.3); }
  50% { box-shadow: 0 0 30px var(--accent-orange), 0 0 60px rgba(255, 120, 73, 0.4); }
}

/* Train markers */
.train-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.train-icon {
  width: 18px;
  height: 18px;
  background: var(--accent-orange);
  border: 2px solid var(--text-primary);
  border-radius: 50%;
  box-shadow: 0 0 16px var(--accent-orange), 0 4px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  animation: trainGlow 2s ease-in-out infinite;
}

.train-icon.green {
  background: var(--accent-green);
  box-shadow: 0 0 16px var(--accent-green), 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: trainGlowGreen 2s ease-in-out infinite;
}

.train-icon.yellow {
  background: var(--accent-yellow);
  box-shadow: 0 0 16px var(--accent-yellow), 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: trainGlowYellow 2s ease-in-out infinite;
}

@keyframes trainGlow {
  0%, 100% { 
    box-shadow: 0 0 12px var(--accent-orange), 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: scale(1);
  }
  50% { 
    box-shadow: 0 0 24px var(--accent-orange), 0 0 40px rgba(255, 120, 73, 0.4);
    transform: scale(1.05);
  }
}

@keyframes trainGlowGreen {
  0%, 100% { 
    box-shadow: 0 0 12px var(--accent-green), 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: scale(1);
  }
  50% { 
    box-shadow: 0 0 24px var(--accent-green), 0 0 40px rgba(0, 214, 107, 0.4);
    transform: scale(1.05);
  }
}

@keyframes trainGlowYellow {
  0%, 100% { 
    box-shadow: 0 0 12px var(--accent-yellow), 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: scale(1);
  }
  50% { 
    box-shadow: 0 0 24px var(--accent-yellow), 0 0 40px rgba(255, 217, 61, 0.4);
    transform: scale(1.05);
  }
}

.train-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
  height: 5px;
  background: var(--text-primary);
  border-radius: 50%;
}

/* Leaflet overrides */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

.leaflet-control-zoom a {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  color: var(--text-secondary) !important;
  border: 1px solid var(--glass-border) !important;
  transition: all 0.2s ease !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary) !important;
}

.leaflet-control-zoom-in {
  border-radius: 8px 8px 0 0 !important;
}

.leaflet-control-zoom-out {
  border-radius: 0 0 8px 8px !important;
  border-top: none !important;
}

.leaflet-control-attribution {
  background: rgba(10, 10, 15, 0.8) !important;
  backdrop-filter: blur(10px);
  color: var(--text-muted) !important;
  font-size: 0.6rem !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* Tooltip styling */
.leaflet-tooltip {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.leaflet-tooltip::before {
  border-top-color: var(--glass-bg);
}

/* Responsive */
@media (max-width: 900px) {
  main {
    flex-direction: column;
  }
  
  #map-container {
    height: 55vh;
  }
  
  #sidebar {
    width: 100%;
    max-height: 45vh;
    border-left: none;
    border-top: 1px solid var(--glass-border);
    animation: sidebarSlideUp 0.7s var(--transition-smooth) 0.2s both;
  }
  
  @keyframes sidebarSlideUp {
    from {
      opacity: 0;
      transform: translateY(50px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  header {
    padding: 0.625rem 1rem;
  }
  
  header h1 {
    font-size: 1rem;
  }
  
  .train-count-badge {
    display: none;
  }
  
  #legend {
    bottom: 12px;
    left: 12px;
    padding: 0.75rem 1rem;
  }
  
  .alerts-banner {
    padding: 0.5rem 1rem;
  }
  
  .alert-content {
    font-size: 0.75rem;
  }
  
  .search-container {
    padding: 0.75rem 0.75rem 0;
  }
  
  #station-search {
    font-size: 1rem; /* Prevents zoom on iOS */
  }
  
  #sidebar-content {
    padding: 1rem;
  }
  
  .platform-section {
    padding: 0.75rem;
  }
}

@media (max-width: 500px) {
  .header-left h1 {
    font-size: 0.9rem;
  }
  
  #last-update {
    display: none;
  }
  
  .header-controls {
    gap: 0.5rem;
  }
  
  #refresh-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }
  
  #legend {
    display: none;
  }
  
  .station-header h2 {
    font-size: 1.1rem;
  }
  
  .platform-direction {
    max-width: 100px;
    font-size: 0.6rem;
  }
  
  .arrival-destination {
    font-size: 0.8rem;
  }
  
  .arrival-time {
    font-size: 0.7rem;
    min-width: 48px;
    padding: 0.25rem 0.5rem;
  }
}

/* Safe area support for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  footer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
  
  header {
    padding-top: calc(0.875rem + env(safe-area-inset-top));
  }
}
