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

body {
  background: #0d0d1a;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Metro Map Area */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#metro-svg {
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Station labels */
.station-label {
  font-size: 9px;
  fill: #aaa;
  user-select: none;
}

.station-label:hover {
  fill: #fff;
}

.station-label.transfer {
  font-size: 10px;
  fill: #fff;
  font-weight: 600;
}

/* Station dots */
.station-dot {
  cursor: pointer;
  transition: r 0.2s;
}

.station-dot:hover {
  r: 7;
}

.station-dot.transfer {
  stroke-width: 2.5;
}

/* Train markers — circle (at stop) or diamond (moving) */
.train-marker {
  transition: x 1s ease-in-out, y 1s ease-in-out, cx 1s ease-in-out, cy 1s ease-in-out;
}

.train-pulse {
  transition: cx 1s ease-in-out, cy 1s ease-in-out;
}

.train-arrow {
  transition: transform 1s ease-in-out;
}

.train-group {
  cursor: pointer;
}

/* Train tooltip */
.train-tooltip {
  position: absolute;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  pointer-events: none;
  z-index: 100;
  display: none;
  min-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.train-tooltip.visible {
  display: block;
}

.train-tooltip .line-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  text-align: center;
  line-height: 22px;
  font-weight: 700;
  font-size: 13px;
  color: #000;
  margin-right: 6px;
  vertical-align: middle;
}

.train-tooltip .headsign {
  font-weight: 600;
  color: #fff;
}

.train-tooltip .detail {
  color: #999;
  font-size: 12px;
  margin-top: 4px;
}

.train-tooltip .delay-positive {
  color: #ff6b6b;
}

.train-tooltip .delay-negative {
  color: #51cf66;
}

/* Station tooltip (hover departures) */
.station-tooltip {
  position: absolute;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  pointer-events: none;
  z-index: 110;
  display: none;
  min-width: 220px;
  max-width: 300px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

.station-tooltip.visible {
  display: block;
}

.station-tooltip-header {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #333;
}

.tooltip-dep-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.tooltip-line-badge {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  font-weight: 700;
  font-size: 11px;
  color: #000;
  flex-shrink: 0;
}

.tooltip-headsign {
  flex: 1;
  color: #ccc;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tooltip-minutes {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.station-tooltip .detail {
  color: #666;
  font-size: 11px;
  margin-top: 2px;
}

.station-tooltip .delay-positive { color: #ff6b6b; }
.station-tooltip .delay-negative { color: #51cf66; }

/* Reset view button */
#reset-view {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  background: rgba(17, 17, 34, 0.85);
  border: 1px solid #333;
  border-radius: 8px;
  color: #ccc;
  font-size: 20px;
  cursor: pointer;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.2s;
}

#reset-view:hover {
  background: rgba(30, 30, 60, 0.9);
  color: #fff;
}

#reset-view.visible {
  display: flex;
}

/* Sidebar close button */
#sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  z-index: 10;
}

#sidebar-close:hover {
  color: #fff;
}

/* Sidebar overlay backdrop */
#sidebar-overlay {
  display: none;
}

/* Sidebar */
#sidebar {
  width: 340px;
  background: #111122;
  border-left: 1px solid #222;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  position: relative;
  padding: 16px 20px;
  border-bottom: 1px solid #222;
}

#sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

#sidebar-header .subtitle {
  font-size: 12px;
  color: #666;
}

/* Status bar */
#status-bar {
  padding: 10px 20px;
  border-bottom: 1px solid #222;
  display: flex;
  gap: 16px;
  font-size: 12px;
}

.line-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.line-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.line-count {
  color: #aaa;
}

/* Departure board */
#departure-board {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

#departure-board h2 {
  font-size: 14px;
  font-weight: 600;
  color: #888;
  margin-bottom: 12px;
}

#departure-board .station-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
}

.departure-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #1a1a2e;
  gap: 10px;
}

.departure-item .line-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #000;
  flex-shrink: 0;
}

.departure-item .dep-info {
  flex: 1;
}

.departure-item .dep-headsign {
  font-weight: 600;
  font-size: 14px;
  color: #ddd;
}

.departure-item .dep-time {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.departure-item .dep-minutes {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-align: right;
  min-width: 50px;
}

.departure-item .dep-minutes span {
  font-size: 11px;
  font-weight: 400;
  color: #666;
}

.departure-item .dep-delay {
  font-size: 11px;
}

.dep-delay.positive { color: #ff6b6b; }
.dep-delay.negative { color: #51cf66; }

#no-station-selected {
  color: #555;
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
}

/* Update indicator */
#update-indicator {
  padding: 10px 20px;
  border-top: 1px solid #222;
  font-size: 11px;
  color: #444;
  text-align: center;
}

#update-indicator .live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #51cf66;
  border-radius: 50%;
  margin-right: 4px;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Scrollbar */
#departure-board::-webkit-scrollbar {
  width: 4px;
}

#departure-board::-webkit-scrollbar-track {
  background: transparent;
}

#departure-board::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

/* ============ Mobile ============ */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 85vw;
    max-width: 340px;
    height: 100vh;
    height: 100dvh;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    border-left: 1px solid #333;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-close {
    display: block;
  }

  #sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
  }

  #sidebar-overlay.visible {
    display: block;
  }

  #map-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }

  #reset-view {
    width: 44px;
    height: 44px;
  }
}
