:root {
  /* accent (replaces all greens / the old unused yellow) */
  --accent: #2C95D0;
  --accent-strong: #1F7DB3;               /* backgrounds with small white text (>= 4.5:1) */
  --accent-soft: rgba(44, 149, 208, 0.14);
  --accent-border: rgba(44, 149, 208, 0.45);
  --warning: #ffb300;

  /* surfaces, darkest first */
  --surface-0: #0E1014;
  --surface-1: #171b21;
  --surface-2: #212529;
  --surface-3: #343A40;
  --surface-4: #454d55;

  /* legacy glass tokens used by map controls and the selection card */
  --bg-dark: rgba(20, 24, 28, 0.95);
  --btn-dark: rgba(40, 45, 50, 0.95);
  --glass: rgba(33, 37, 41, 0.75);

  /* text */
  --text-light: rgba(255, 255, 255, 0.9);
  --text-primary: rgba(255, 255, 255, 0.92);
  --text-secondary: rgba(255, 255, 255, 0.70);
  --text-muted: rgba(255, 255, 255, 0.60);

  /* lines */
  --line-subtle: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.14);

  /* semantic */
  --danger: #DC3545;
  --danger-soft: rgba(220, 53, 69, 0.16);

  /* sizing */
  --touch-target: 44px;
  --touch-target-large: 56px;
  --panel-mobile-max-width: 720px;
  --mobile-side-gap: 12px;
  --marker-scale-mobile: 1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* type */
  --font-ui: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 26px;

  /* z-index scale (relative order unchanged) */
  --z-map: 1;
  --z-marker: 5;
  --z-controls: 10;
  --z-tooltip: 400;
  --z-panel: 450;
  --z-menu: 500;
  --z-overlay-low: 540;   /* route details sits below service alerts */
  --z-overlay: 600;       /* alerts, vehicle info, fav config */
  --z-modal: 1000;        /* menu, stop-time, generic .overlay-visible */
  --z-top: 1100;          /* tooltip in the timetable grid */
  --z-popup: 1200;        /* multi-marker popup */
  --z-city-popup: 1300;

  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
}

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

button, input, select, textarea { font: inherit; color: inherit; }

button {
  background: none;
  border: 0;
  cursor: pointer;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.maplibregl-map { font-family: var(--font-ui); }

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

#mapa {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.ui-overlay {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ui-overlay > * {
  pointer-events: auto;
}

/* ========================= */
/* STRONA WYBORU MIASTA */
/* ========================= */

.selection-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(145deg, #1f252b, #171b20);
  padding: 40px;
  border-radius: 20px;
  width: 95%;
  max-width: 520px;
  text-align: center;
  color: white;
  box-shadow: 0 15px 40px rgba(0,0,0,0.5);
}

.logo-icon {
  width: 80px;
  margin-bottom: 15px;
}

.main-title {
  font-size: 42px;
  font-weight: 800;
  background: linear-gradient(90deg, #FFFFFF, #EBEBEB);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

.subtitle {
  color: #ccc;
  font-weight: 300;
  margin-bottom: 25px;
}

.subtitle--tagline {
  font-style: italic;
}

.choose-text {
  font-size: 18px;
  margin-bottom: 25px;
  line-height: 1.4;
}

.city-button {
  background: var(--btn-dark);
  border-radius: 10px;
  padding: 15px 18px;
  margin: 10px 0;
  display: flex;
  align-items: flex-start;
  text-decoration: none;
  transition: 0.2s ease;
  color: white;
  cursor: pointer;
}

button.city-button {
  width: 100%;
  text-align: left;
  border: 0;
}

.city-name-line {
  display: block;
}

@media (hover: hover) and (pointer: fine) { .city-button:hover {
  background: #3a4047;
  transform: translateY(-2px);
} }

.flag {
  font-size: 26px;
  margin-right: 15px;
  margin-top: 2px;
}

.city-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.city-name-line {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.city-description {
  font-size: 13px;
  color: #adb5bd;
  line-height: 1.4;
  margin-left: 8px;
}

/* ========================= */
/* STRONA MAPY */
/* ========================= */

.left-controls,
.right-controls {
  position: absolute;
  top: calc(15px + var(--safe-area-top));
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.left-controls {
  left: calc(15px + var(--safe-area-left));
}

.right-controls {
  right: calc(15px + var(--safe-area-right));
}

.bottom-control {
  position: absolute;
  bottom: calc(15px + var(--safe-area-bottom));
  right: calc(15px + var(--safe-area-right));
}

.map-btn {
  background: var(--glass);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: 0.2s ease;
}

.map-btn--lg {
  width: var(--touch-target-large);
  height: var(--touch-target-large);
  border-radius: 14px;
}

.map-btn--sm {
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 10px;
}

@media (hover: hover) and (pointer: fine) { .map-btn:hover {
  background: rgba(60, 65, 70, 0.95);
  transform: scale(1.05);
} }

.map-btn svg,
.map-btn i {
  width: 20px;
  height: 20px;
}

/* ========================= */
/* OVERLAYS (MENU, ROZKŁADY, USTAWIENIA, O STRONIE) */
/* ========================= */

.overlay-hidden {
  display: none;
}

.overlay-visible {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: var(--z-modal);
  pointer-events: auto;
}

.menu-icon {
  width: 40px;
  height: 40px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-right: 15px;
  margin-top: 0;
}

.menu-buttons {
  margin-bottom: 15px;
}

#menu-overlay.overlay-visible {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#menu-overlay .selection-card {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  width: min(520px, calc(100vw - 24px));
  max-width: 520px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 32px 24px 24px;
}

#menu-overlay .selection-card::-webkit-scrollbar {
  width: 6px;
}

#menu-overlay .selection-card::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

#menu-overlay .logo-icon {
  margin-bottom: 12px;
}

#menu-overlay .main-title {
  margin-bottom: 8px;
}

#menu-overlay .subtitle {
  margin-bottom: 20px;
}

.menu-current-city {
  color: #d6d9dd;
  font-size: 20px;
  line-height: 1.4;
  margin: 0 0 22px;
}

.menu-current-city strong {
  color: #ffffff;
  font-weight: 700;
  overflow-wrap: anywhere;
}

#menu-overlay .menu-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

#menu-overlay .city-button {
  margin: 0;
  padding: 14px 16px;
  min-width: 0;
  align-items: center;
}

#menu-overlay .menu-icon {
  width: 38px;
  height: 38px;
  margin-right: 12px;
  flex-shrink: 0;
}

#menu-overlay .city-name-line {
  font-size: 17px;
  margin-bottom: 0;
}

/* Ostatni przycisk wyśrodkowany gdy liczba przycisków jest nieparzysta (siatka 2-kolumnowa) */
#menu-overlay .menu-buttons .city-button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: calc(50% - 5px);
  margin: 0 auto;
}

@media (max-width: 640px) {
  #menu-overlay .selection-card {
    width: min(440px, calc(100vw - 24px));
    padding: 28px 20px 22px;
  }
}

@media (max-width: 480px) {
  #menu-overlay .menu-buttons {
    grid-template-columns: 1fr;
  }

  /* single column: the odd-item centering rule is not needed */
  #menu-overlay .menu-buttons .city-button:last-child:nth-child(odd) {
    max-width: none;
  }
}

/* Menu: contact / social links (logo-only buttons) */
.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0 0 18px;
}

.contact-link {
  width: var(--touch-target-large);
  height: var(--touch-target-large);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border-radius: 10px;
  color: #fff;
  text-decoration: none;
  opacity: 0.9;
  transition: 0.2s ease;
}

.contact-link-icon {
  width: 26px;
  height: 26px;
}

@media (hover: hover) and (pointer: fine) { .contact-link:hover {
  opacity: 1;
  transform: translateY(-2px);
} }

.about-content {
  background: var(--btn-dark);
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
  text-align: left;
  line-height: 1.6;
}

.about-content p {
  margin-bottom: 12px;
}

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

/* ========================= */
/* ZNACZNIKI PRZYSTANKÓW NA MAPIE */
/* ========================= */

/* Warstwy markerów MapLibre */
.maplibregl-marker {
  z-index: var(--z-marker);
}

/* stops below vehicles; no !important needed thanks to the extra class */
.maplibregl-marker.custom-marker { z-index: 1; }
.maplibregl-marker.vehicle-custom-marker { z-index: 100; }

.custom-marker {
  cursor: pointer;
}

.stop-marker {
  transform-origin: 50% 100%; /* środek DOŁU */
  will-change: transform;
}

.stop-marker-hitbox {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (hover: hover) and (pointer: fine) { .stop-marker:hover {
  transform: scale(1.3);
  z-index: 10;
} }

.stop-icons-container {
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}

.stop-icon {
  background-color: #122732; /* ciemna ikona przystanku */
  flex-shrink: 0;
}

/* Style dla popup */
.maplibregl-popup-content {
  background-color: rgba(33, 37, 41, 0.95);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
}

.maplibregl-popup-tip {
  border-top-color: rgba(33, 37, 41, 0.95);
}

.maplibregl-popup-close-button {
  color: white;
  font-size: 18px;
}

@media (hover: hover) and (pointer: fine) { .maplibregl-popup-close-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
} }

@media (max-width: 768px), (pointer: coarse) {
  :root {
    --mobile-side-gap: 10px;
    --marker-scale-mobile: 1;
  }

  .selection-card {
    width: min(calc(100vw - (var(--mobile-side-gap) * 2)), var(--panel-mobile-max-width));
    padding: 24px 18px;
  }

  .left-controls,
  .right-controls {
    top: calc(10px + var(--safe-area-top));
    gap: 8px;
  }

  .left-controls {
    left: calc(10px + var(--safe-area-left));
  }

  .right-controls {
    right: calc(10px + var(--safe-area-right));
  }

  .bottom-control {
    right: calc(10px + var(--safe-area-right));
    bottom: calc(10px + var(--safe-area-bottom));
  }

  .map-btn {
    box-shadow: 0 8px 22px rgba(0,0,0,0.28);
  }

  .map-btn--lg {
    border-radius: 15px;
  }

  .map-btn--sm {
    border-radius: 12px;
  }

  .map-btn--lg svg,
  .map-btn--lg i {
    width: 24px;
    height: 24px;
  }

  #menu-overlay .selection-card {
    width: min(calc(100vw - (var(--mobile-side-gap) * 2)), 460px);
    padding: 24px 18px 20px;
  }

  .city-button {
    padding: 16px 16px;
  }

  .menu-icon {
    width: 44px;
    height: 44px;
  }

  @media (hover: hover) and (pointer: fine) { .stop-marker:hover {
    transform: none;
  } }
}

@media (hover: none) {
  .map-btn:hover,
  .stop-marker:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
