.map-container {
    width: 100%;
    height: 100%;
    background-color: #e5e5f7; /* blueprint-like bg */
    overflow: hidden;
    position: relative;
    cursor: grab;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    touch-action: none; /* Prevent default touch scrolling */
}

body.browser-zoom-active .map-container,
body.browser-zoom-active .map-container > svg {
    touch-action: auto;
}

.map-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--secondary-color);
    background: rgba(229, 229, 247, 0.92);
    text-align: center;
    pointer-events: none;
    z-index: 1;
}

.map-loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 0.25rem solid rgba(44, 62, 80, 0.2);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: map-spinner-rotate 0.8s linear infinite;
}

.map-loading-text {
    font-weight: 600;
}

.map-container:active {
    cursor: grabbing;
}

.map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.map-controls button {
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1.2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
}

@media (max-width: 768px) {
    .map-controls {
        right: 14px;
        bottom: 14px;
        gap: 10px;
    }

    .map-controls button {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        font-size: 1.1rem;
    }
}

.map-controls button:hover {
    background: #f8f9fa;
}

.map-legend {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 4;
    display: grid;
    gap: 0.4rem;
    padding: 0.75rem;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(44, 62, 80, 0.16);
    border-radius: 0.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    font-size: 0.85rem;
}

.map-legend-title {
    font-weight: 700;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stand-route-menu {
    position: absolute;
    z-index: 6;
    min-width: 180px;
    overflow: hidden;
    background: white;
    border: 1px solid rgba(44, 62, 80, 0.18);
    border-radius: 0.75rem;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.stand-route-menu-title {
    padding: 0.7rem 0.85rem 0.45rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.stand-route-menu button {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 0.65rem 0.85rem;
    border: 0;
    border-top: 1px solid rgba(44, 62, 80, 0.08);
    background: white;
    color: var(--text-color);
    font: inherit;
    font-weight: 600;
    text-align: left;
}

.stand-route-menu button:hover,
.stand-route-menu button:focus-visible {
    background: #eaf2f8;
    outline: none;
}

.map-legend-swatch {
    width: 1.25rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-radius: 0.2rem;
}

.map-legend-yes {
    color: #0f4d2f;
    background: #00c853;
}

.map-legend-maybe {
    color: #3f0071;
    background: repeating-linear-gradient(45deg, #a855f7 0 4px, #f3e8ff 4px 8px);
}

.map-legend-visited {
    color: #4f5b63;
    background: repeating-linear-gradient(135deg, #95a5a6 0 3px, #d8dee0 3px 6px);
}

/* SVG Styles */
.map-container > svg {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0; /* Important for manual transform logic */
    touch-action: none; /* Ensure mobile browsers don't hijack gestures */
    transition: none;
}

.generated-map {
    width: 100%;
    height: 100%;
    background: #f8fafc;
}

.map-hall-background {
    fill: #ffffff;
    stroke: none;
    stroke-width: 0;
    rx: 16px;
    filter: none;
}

.map-hall-outline-edges line {
    stroke: #000000;
    stroke-width: 4px;
    stroke-linecap: square;
    stroke-linejoin: miter;
    vector-effect: non-scaling-stroke;
}

.map-hall-outline-edges .map-hall-divider-edge {
    stroke: #cbd5e1;
    stroke-width: 1px;
    stroke-dasharray: 6 8;
}

.map-hall-label {
    fill: #2c3e50;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 76px;
    font-weight: 800;
    letter-spacing: 0.02em;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 10px;
    stroke-linejoin: round;
}

.generated-map .map-stand {
    fill: #f8b133;
    stroke: none;
    stroke-width: 0;
    vector-effect: non-scaling-stroke;
}

.generated-map .map-stand:hover {
    fill: #dbeafe;
    opacity: 1;
}

.map-stand-label {
    fill: #000000;
    font-family: "Nunito Sans", "Myriad Pro", Myriad, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
}

/* Stand Styles injected into SVG elements */
/* Note: These assume the SVG structure exposes ID/Classes nicely */

/* Base stand style (to be applied via JS if not in SVG) */
.map-stand {
    cursor: pointer;
    transition: fill 0.2s, stroke 0.2s;
    pointer-events: all; 
}

.map-stand:focus-visible {
    stroke: #1e90ff !important;
    stroke-width: 2px !important;
    outline: none;
}

/* Selected Stand */

.stand-selected {
    opacity: 1;
    stroke: #d97706 !important;
    stroke-width: 3px !important;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 3px rgba(217, 119, 6, 0.45));
}

.stand-selected:not(.stand-status-visited) {
    fill: #fde68a !important;
}

.stand-selected.stand-status-visited {
    opacity: 0.85;
}

.stand-selected.stand-status-yes {
    stroke: #0f4d2f !important;
}

.stand-selected.stand-status-maybe {
    stroke: #6b21a8 !important;
}

.stand-selected * {
    opacity: 1;
}

/* Statuses */

/* Visited */
.stand-status-visited {
    fill: url(#stand-pattern-visited) #95a5a6 !important; /* Greyed out */
    opacity: 0.75;
}

/* Yes - Strong Interest */
.stand-status-yes {
    fill: #00c853 !important; /* Bright green */
    stroke: #0f4d2f !important;
}

/* Maybe - Light Interest */
.stand-status-maybe {
    fill: url(#stand-pattern-maybe) #a855f7 !important; /* Purple */
    stroke: #6b21a8 !important;
}

/* Route Path styling */
.route-path {
    stroke: #e74c3c;
    stroke-width: 4px;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 14 8;
    fill: none;
    pointer-events: none;
    animation: route-flow 0.9s linear infinite;
}

@keyframes route-flow {
    to {
        stroke-dashoffset: -22;
    }
}

@keyframes map-spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .map-container > svg {
        transition: none;
    }

    .map-loading-spinner {
        animation: none;
    }

    .route-path {
        animation: none;
    }
}
