html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000;
    position: relative;
}
#map {
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Error + loading overlays */
.error {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #dc3545;
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    z-index: 2000;
    display: none;
}
.error.active {
    display: block;
}
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    text-align: center;
    z-index: 2000;
    display: none;
}
.loading.active {
    display: block;
}
.loading .spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    margin: 0 auto 8px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Control panel */
.control-panel {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1500;
    background: rgba(0, 27, 92, 0.9);
    border-radius: 10px;
    padding: 42px 12px 10px 12px;
    color: #ffdd00;
    max-width: 220px;
}

/* Control panel close button */
.control-panel-close {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 8px 12px;
    line-height: 1.2;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    background: rgba(220, 53, 69, 0.8);
    border-radius: 4px;
    cursor: pointer;
    z-index: 1510;
    user-select: none;
    white-space: nowrap;
}

.control-panel-close:hover {
    background: rgba(220, 53, 69, 1.0);
    transform: scale(1.05);
}
.control-panel label {
    font-size: 0.8rem;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}
.control-panel input[type="text"] {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 2px solid #003366;
    font-size: 1rem;
    text-align: center;
    font-weight: bold;
    background: #fff;
    color: #002b5c;
    margin-bottom: 8px;
}
.direction-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dir-button {
    width: 100%;
    padding: 8px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 6px;
    border: 2px solid #003366;
    cursor: pointer;
    background: #FFF7A8;
    color: #003366;
}
.dir-button.selected {
    background: #A9F5A9;
}
.dir-button.disabled-dir {
    background: #FFF7A8;
    opacity: 0.7;
    cursor: not-allowed;
}
.go-button {
    width: 100%;
    margin-top: 4px;
    padding: 10px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 6px;
    border: 2px solid #003366;
    cursor: pointer;
    background: #4CAF50;
    color: #fff;
}
.go-button:hover {
    filter: brightness(1.05);
}
.go-button.end-mode {
    background: #f44336;
    color: #fff;
}

/* Hide route input and direction buttons when route is active */
.control-panel.route-active label[for="routeNumber"],
.control-panel.route-active #routeNumber,
.control-panel.route-active .dir-button {
    display: none !important;
}

/* Hide the entire control panel when route is active (END button is moved to body) */
.control-panel.route-active {
    display: none !important;
}

/* END button positioned at bottom left when route is active */
.go-button.end-mode.route-active-position,
.go-button.route-active-position {
    position: fixed;
    bottom: 10px;
    left: 10px;
    z-index: 1500;
    width: auto;
    min-width: 100px;
    padding: 10px 20px;
    margin-top: 0;
    border-radius: 6px;
    border: 2px solid #003366;
    background: #f44336;
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: block !important; /* Ensure button is visible */
}

/* BIG bottom keyboard (copied from idx.css) */
.soft-keyboard {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1600;

    height: 32vh;
    max-height: 260px;
    min-height: 180px;

    background: rgba(0, 0, 0, 0.85);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));

    display: none;             /* JS toggles to flex */
    flex-direction: column;
    gap: 4px;
}

.soft-keyboard-row {
    flex: 1;
    display: flex;
    gap: 4px;
}
.soft-key {
    flex: 1;
    width: auto;
    max-width: none;
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 8px;
    border: 1px solid #555;
    background: #222;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 600;
    padding: 6px 0;

    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.soft-key.wide {
    flex: 1.5;
}
.soft-key:active {
    background: #444;
}
@media (max-height: 650px) {
    .soft-keyboard {
        height: 40vh;
        max-height: none;
    }
    .soft-key {
        font-size: 1.5rem;
    }
}

/* Next stop banner */
.next-stop-banner {
    position: fixed;
    top: 15px;
    right: 15px;
    background: rgba(0, 51, 102, 0.85);
    color: #ffdd00;

    padding: 12px 20px;
    border-radius: 8px;

    font-size: 1.15em;
    font-weight: bold;
    z-index: 1999;

    display: inline-block;
    white-space: nowrap;
}

/* Street stops count banner (below next stop banner) */
.street-stops-banner {
    position: fixed;
    top: 75px;
    right: 15px;
    background: rgba(0, 102, 51, 0.85);
    color: #ffffff;

    padding: 10px 18px;
    border-radius: 8px;

    font-size: 1em;
    font-weight: bold;
    z-index: 1998;

    display: inline-block;
    white-space: nowrap;
}

/* Route info overlay */
.route-info-overlay.active {
    display: none !important;
}
.route-info-overlay h2 {
    margin: 0 0 6px;
    font-size: 0.9rem;
    color: #002b5c;
}
.route-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 3px;
}
.route-info-item label {
    display: inline-block;
    min-width: 90px;
    font-weight: 600;
}
.route-info-item span {
    font-weight: 500;
}

/* Map controls */
.map-controls-overlay {
    position: fixed;
    bottom: 70px;
    left: 10px;
    z-index: 1400;
    background: rgba(0,0,0,0.65);
    color: #fff;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    display: flex;
    gap: 8px;
    align-items: center;
}
.map-controls-overlay select,
.map-controls-overlay button {
    font-size: 0.8rem;
    border-radius: 6px;
    border: 1px solid #ccc;
    padding: 4px 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    transition: all 0.2s;
}

.map-controls-overlay button:hover {
    background: rgba(255, 255, 255, 1);
}

.map-controls-overlay button.fixed-active {
    background: #ff6b6b;
    color: #fff;
    border-color: #ff5252;
    font-weight: bold;
}

/* Footer + About/Contact */
.footer-overlay {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1400;
    text-align: center;
    font-size: 0.75rem;
    color: #fff;
    text-shadow: 0 0 4px #000;
}
.footer-overlay a {
    color: #ffdd00;
}
.footer-buttons {
    margin-top: 4px;
    display: flex;
    justify-content: center;
    gap: 6px;
}
.footer-btn {
    padding: 6px 12px;
    background: #002b5c;
    color: #ffdd00;
    border: 1px solid #ffdd00;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.75rem;
}
.footer-btn:hover {
    background: #ffdd00;
    color: #002b5c;
}

/* Bus marker */
.bus-marker-icon .bus-marker-inner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #F54927; /* RED bus icon */
    border: 2px solid white;
}

/* Fullscreen exit (X) */
.fs-exit-btn {
    position: fixed;
    top: 6px;
    left: 6px;
    z-index: 2100;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    display: none;
    user-select: none;
}

/* Agency name banner - bottom center, above BUS ROUTE NAVIGATOR */
/* COMMENTED OUT
.agency-name-banner {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #008080 !important;
    color: #FFFFFF !important;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.95rem !important;
    font-weight: bold !important;
    z-index: 2000 !important;
    display: inline-block !important;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    visibility: visible !important;
    opacity: 1 !important;
    width: fit-content;
    text-align: center;
    line-height: 1.2;
}
*/

/* Route long banner – positioned at bottom, above bottom banner */
.route-long-banner {
    position: fixed;
    bottom: 50px; /* Above bottom banner (BUS ROUTE NAVIGATOR) and END button (bottom: 10px) */
    left: 50%;
    transform: translateX(-50%);
    background: #002B80;
    color: #FFFFFF;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem; /* Reduced from 18px */
    font-weight: bold;
    display: none;
    z-index: 1001; /* Above bottom banner (1000), below other overlays */
    max-width: calc(100vw - 140px); /* Leave space for END button on left (120px) and margins */
    white-space: normal;
    word-wrap: break-word;
    text-align: center;
    line-height: 1.3;
}

/* When route is active, keep banner at bottom */
.route-long-banner.route-active-banner {
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 140px);
}

/* Distance text below route name - smaller font */
.route-long-distance {
    font-size: 0.75rem;
    margin-top: 2px;
    opacity: 0.9;
}

/* ============================================================
   RESPONSIVE: Mobile phones (max-width: 480px)
   ============================================================ */
@media (max-width: 480px) {
    /* Next stop banner - smaller font and padding on phones */
    .next-stop-banner {
        font-size: 0.85rem;
        padding: 8px 12px;
        max-width: calc(100vw - 80px); /* Leave space for controls */
        top: 10px;
        right: 10px;
    }

    /* Street stops banner - smaller on phones */
    .street-stops-banner {
        font-size: 0.8rem;
        padding: 6px 12px;
        max-width: calc(100vw - 80px);
        top: 60px; /* Closer to next stop banner */
        right: 10px;
    }

    /* Route long banner - smaller font and better width constraint */
    .route-long-banner {
        font-size: 0.75rem;
        padding: 6px 10px;
        max-width: calc(100vw - 80px); /* Reduced from 140px for smaller screens */
        bottom: 50px;
        left: 50%;
        transform: translateX(-50%);
        line-height: 1.2;
    }

    .route-long-banner.route-active-banner {
        max-width: calc(100vw - 80px);
    }

    /* Route long distance - even smaller on phones */
    .route-long-distance {
        font-size: 0.65rem;
    }
}

/* Bottom banner - BUS ROUTE NAVIGATOR */
.bottom-banner {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: fit-content;
    display: inline-block;
    padding: 6px 14px;
    white-space: nowrap;
    background: #000000; /* Blue background */
    color: #FFFFFF; /* White text */
    text-align: center;
    font-size: 0.75rem; /* Small font */
    font-weight: normal;
    z-index: 1000;
    box-sizing: border-box;
}

/* Make all controls align */
.control-panel {
    width: 220px;
    box-sizing: border-box;
}
.control-panel * {
    box-sizing: border-box;
}
.control-panel input[type="text"],
.control-panel .dir-button,
.control-panel .go-button {
    display: block;
    width: 100%;
}
.bottom-banner{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;

  width: fit-content;        /* key bit */
  display: inline-block;     /* prevents full-width block stretch */
  padding: 6px 14px;         /* whatever looks right */
  white-space: nowrap;       /* keep the 3 words on one line */
}
.turn-arrow{
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 18px solid #FFD700;   /* arrow color */
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.7));
  transform-origin: 50% 70%;
}
