html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000;
    overflow: hidden;
}
#map {
    height: 100%;
    width: 100%;
}

/* 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: 10px 12px;
    color: #ffdd00;
    max-width: 220px;
}
.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;
}

/* 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: flex;           /* <-- was none */
    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;
}

/* 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;
}

/* 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: red;
    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;
}

/* Route long banner */
.route-long-banner {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #002B80;
    color: #FFFFFF;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    display: none;
    white-space: nowrap;
    z-index: 9999;
}

/* 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%;
}
