html,body{
    margin:0;
    width:100%;
    height:100%;
    height:-webkit-fill-available;
  }
  body{
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    min-height:100dvh;
    min-height:-webkit-fill-available;
    overflow:hidden;
    overscroll-behavior:none;
  }
  #map{
    height:100%;
    width:100%;
  }
  .route-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: bold;
    font-size: 12px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  }
  /* Mobile specific UI */
  #topbar {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    display: flex;
    justify-content: space-between;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
  }
  #topbar .btn {
    pointer-events: auto;
    background: rgba(255,255,255,0.95);
    border-radius: 6px;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-weight: 600;
    font-size: 14px;
  }
  /* Avoid overlap between topbar and Leaflet zoom controls */
  .leaflet-top.leaflet-left {
    top: calc(8px + env(safe-area-inset-top) + 44px);
  }
  /* Modal dialog */
  #vehicleModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
    align-items: center;
    justify-content: center;
  }
  #vehicleModal.open {
    display: flex;
  }
  #vehicleModalContent {
    background: white;
    border-radius: 20px;
    width: 85vw;
    max-width: 500px;
    height: 75dvh;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    overflow: hidden;
  }
  #vehicleModalHeader {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  #vehicleModalHeader h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
  }
  #vehicleModalClose {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
  }
  #vehicleModalFilters {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  #vehicleModalFilters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
  }
  #vehicleListInner {
    flex: 1;
    overflow: auto;
    padding: 0;
  }
  #vehicleListInner .item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 200ms ease;
  }
  #vehicleListInner .item:hover {
    background: #f9f9f9;
  }
  #vehicleListInner .item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
  }
  #vehicleListInner .item small {
    color: #666;
    font-size: 13px;
  }
  #mobileInfo {
    position: absolute;
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 1001;
    display: none;
    background: rgba(255,255,255,0.98);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  }
  /* Stops Modal */
  #stopsModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
    align-items: center;
    justify-content: center;
  }
  #stopsModal.open {
    display: flex;
  }
  #stopsModalContent {
    background: white;
    border-radius: 20px;
    width: 85vw;
    max-width: 500px;
    height: 75dvh;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    overflow: hidden;
  }
  #stopsModalHeader {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  #stopsModalHeader h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
  }
  #stopsModalClose {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
  }
  #stopsVehiclesList {
    flex: 1;
    overflow: auto;
    padding: 0;
  }
  #stopsVehiclesList .item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 200ms ease;
  }
  #stopsVehiclesList .item:hover {
    background: #f9f9f9;
  }
  #stopsVehiclesList .item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
  }
  #stopsVehiclesList .item small {
    color: #666;
    font-size: 13px;
  }
  .depart-now {
    color: #d13b2f;
    font-weight: 700;
    letter-spacing: 1px;
    animation: depart-blink 1s steps(2, start) infinite;
  }
  @keyframes depart-blink {
    to { visibility: hidden; }
  }

  /* Responsive adjustments */
  @media (max-width: 768px) {
    #map { height: 100%; }
    .route-label { font-size: 11px; }
    .leaflet-popup-content { font-size: 13px; }
    .leaflet-popup-content-wrapper { padding: 6px 8px; }
    .leaflet-container { touch-action: manipulation; }
    
    /* Topbar responsywność */
    #topbar {
      display: flex;
      top: calc(6px + env(safe-area-inset-top));
      left: calc(6px + env(safe-area-inset-left));
      right: calc(6px + env(safe-area-inset-right));
      gap: 6px;
    }
    
    #topbar .btn {
      padding: 8px 12px;
      font-size: 13px;
      flex: 1;
    }

    .leaflet-top.leaflet-left {
      top: calc(6px + env(safe-area-inset-top) + 48px);
    }
    
    /* Modal responsywność dla tabletów */
    #vehicleModalContent {
      width: 90vw;
      height: 80dvh;
      max-width: 100%;
      max-height: 90dvh;
      border-radius: 16px;
    }
    
    #vehicleModalHeader h2 {
      font-size: 18px;
    }
    
    #vehicleModalFilters {
      padding: 10px;
      gap: 6px;
    }
    
    #vehicleModalFilters input {
      padding: 10px;
      font-size: 16px;
      border-radius: 6px;
    }
    
    #vehicleListInner .item {
      padding: 10px;
    }
    
    #vehicleListInner .item strong {
      font-size: 14px;
    }

    /* Stops Modal responsywność */
    #stopsModalContent {
      width: 90vw;
      height: 80dvh;
      max-width: 100%;
      max-height: 90dvh;
      border-radius: 16px;
    }
    
    #stopsModalHeader h2 {
      font-size: 18px;
    }
    
    #stopsVehiclesList .item {
      padding: 10px;
    }
    
    #stopsVehiclesList .item strong {
      font-size: 14px;
    }
    
    #mobileInfo {
      left: calc(6px + env(safe-area-inset-left));
      right: calc(6px + env(safe-area-inset-right));
      bottom: calc(6px + env(safe-area-inset-bottom));
      padding: 8px;
      border-radius: 8px;
      font-size: 13px;
    }
  }

  /* Telefony w pionie - ekrany bardzo małe */
  @media (max-width: 480px) {
    html, body {
      margin: 0;
      padding: 0;
      height: 100%;
      width: 100%;
      font-size: 16px;
    }
    
    #map { 
      height: 100%;
      width: 100%;
    }
    
    .route-label { 
      font-size: 10px;
    }
    
    /* Topbar na telefonach */
    #topbar {
      top: calc(4px + env(safe-area-inset-top));
      left: calc(4px + env(safe-area-inset-left));
      right: calc(4px + env(safe-area-inset-right));
      gap: 4px;
    }
    
    #topbar .btn {
      padding: 8px 10px;
      font-size: 12px;
      border-radius: 5px;
    }

    .leaflet-top.leaflet-left {
      top: calc(4px + env(safe-area-inset-top) + 52px);
    }
    
    /* Modal na telefonach - pełna wysokość */
    #vehicleModal {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }
    
    #vehicleModalContent {
      width: 95vw;
      height: 85dvh;
      max-width: 100%;
      max-height: 85dvh;
      border-radius: 12px;
      margin: auto;
    }
    
    #vehicleModalHeader {
      padding: 12px;
    }
    
    #vehicleModalHeader h2 {
      font-size: 16px;
      margin: 0;
    }
    
    #vehicleModalClose {
      font-size: 22px;
    }
    
    #vehicleModalFilters {
      padding: 8px;
      gap: 6px;
    }
    
    #vehicleModalFilters input {
      padding: 10px;
      font-size: 16px;
      border-radius: 6px;
      border: 1px solid #ddd;
      width: 100%;
      box-sizing: border-box;
    }
    
    #vehicleModalFilters > div {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    
    #vehicleListInner .item {
      padding: 10px;
      border-bottom: 1px solid #f0f0f0;
    }
    
    #vehicleListInner .item strong {
      font-size: 13px;
      margin-bottom: 3px;
    }
    
    #vehicleListInner .item small {
      font-size: 12px;
    }

    /* Stops Modal na telefonach */
    #stopsModal {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }
    
    #stopsModalContent {
      width: 95vw;
      height: 85dvh;
      max-width: 100%;
      max-height: 85dvh;
      border-radius: 12px;
      margin: auto;
    }
    
    #stopsModalHeader {
      padding: 12px;
    }
    
    #stopsModalHeader h2 {
      font-size: 16px;
      margin: 0;
    }
    
    #stopsModalClose {
      font-size: 22px;
    }
    
    #stopsVehiclesList .item {
      padding: 10px;
      border-bottom: 1px solid #f0f0f0;
    }
    
    #stopsVehiclesList .item strong {
      font-size: 13px;
      margin-bottom: 3px;
    }
    
    #stopsVehiclesList .item small {
      font-size: 12px;
    }
    
    #mobileInfo {
      left: calc(4px + env(safe-area-inset-left));
      right: calc(4px + env(safe-area-inset-right));
      bottom: calc(4px + env(safe-area-inset-bottom));
      padding: 8px;
      border-radius: 8px;
      font-size: 12px;
      max-height: 20vh;
      overflow-y: auto;
    }
    
    .leaflet-popup-content { 
      font-size: 12px;
      margin: 0;
    }
    
    .leaflet-popup-content-wrapper { 
      padding: 4px 6px;
      border-radius: 4px;
    }
    
    .leaflet-container .leaflet-control {
      margin: 4px;
    }
  }

  /* Tablety w orientacji poziomej */
  @media (min-width: 769px) and (max-width: 1024px) {
    #vehicleModalContent {
      width: 80vw;
      max-width: 550px;
      height: 75dvh;
      max-height: 650px;
    }
    
    #vehicleModalHeader h2 {
      font-size: 19px;
    }
  }

  /* Preferencje dla urządzeń dotykowych */
  @media (hover: none) and (pointer: coarse) {
    button {
      min-height: 44px;
      min-width: 44px;
    }
    
    #topbar .btn {
      padding: 10px 14px;
      font-size: 14px;
    }
    
    input {
      font-size: 16px;
    }
    
    #vehicleListInner .item {
      padding: 14px;
      min-height: 60px;
    }
  }

  /* Orientacja pozioma (landscape) */
  @media (max-height: 500px) {
    #vehicleModalContent {
      height: 95dvh;
    }
    
    #vehicleModalFilters {
      padding: 8px;
    }
    
    #topbar .btn {
      padding: 6px 10px;
      font-size: 12px;
    }
  }

  /* Ciemny motyw dla urządzeń (opcjonalnie - prefers-color-scheme) */
  @media (prefers-color-scheme: dark) {
    #vehicleModalContent {
      background: #1e1e1e;
      color: #e0e0e0;
    }
    
    #vehicleModalHeader {
      border-bottom-color: #333;
    }
    
    #vehicleModalHeader h2 {
      color: #e0e0e0;
    }
    
    #vehicleModalClose {
      color: #999;
    }
    
    #vehicleModalFilters input {
      background: #2d2d2d;
      color: #e0e0e0;
      border-color: #444;
    }
    
    #vehicleListInner .item {
      border-bottom-color: #333;
    }
    
    #vehicleListInner .item:hover {
      background: #2d2d2d;
    }
    
    #vehicleListInner .item small {
      color: #999;
    }
    
    #topbar .btn {
      background: rgba(30, 30, 30, 0.95);
      color: #e0e0e0;
      border: 1px solid #444;
    }
    
    #mobileInfo {
      background: rgba(30, 30, 30, 0.98);
      color: #e0e0e0;
      border: 1px solid #444;
    }
  }