:root {
    --primary: #3b82f6;      /* Modern Blue */
    --primary-hover: #2563eb;
    --background: #0f172a;
    --surface: rgba(15, 23, 42, 0.15); /* EXTREM transparent */
    --surface-border: rgba(255, 255, 255, 0.1);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --route-color: #15803d;  /* Dark Green track */
    --radius: 16px;
    --spacing: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background-color: var(--background);
    color: var(--text);
}

/* Map Container */
#map {
    width: 160vw;
    height: 160vh;
    position: absolute;
    top: -30vh;
    left: -30vw;
    z-index: 10;
    transform-origin: center center;
    transition: transform 0.5s linear;
}

/* Glassmorphism Panel (Stats am oberen Rand) */
.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--surface-border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

#stats-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    /* Nutze die Notch-Sicherheitszone für moderne Handys, ansonsten sehr schlankes Padding */
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateY(-100%);
    opacity: 0;
}

#stats-panel:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stat-divider {
    width: 1px;
    height: 24px;   /* Kürzerer Strich */
    background: var(--surface-border);
}

.stat-label {
    font-size: 0.65rem;
    color: white !important; /* Strahlend weiß */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    font-weight: 800; /* Dicker */
    text-shadow: 0 1px 4px rgba(0,0,0,1.0), 0 0 8px rgba(0,0,0,0.8); /* Maximaler Kontrast-Schatten */
}

.stat-value {
    font-size: 1.0rem;
    font-weight: 800; /* Dicker */
    color: white;
    text-shadow: 0 1px 4px rgba(0,0,0,1.0), 0 0 10px rgba(0,0,0,0.8); 
}

.stat-value small {
    font-size: 0.75rem;
    font-weight: 600;
    color: white !important;
    text-shadow: 0 1px 4px rgba(0,0,0,1.0), 0 0 8px rgba(0,0,0,0.8); 
}

/* Watermark */
#brand-watermark {
    position: absolute;
    bottom: 25px;
    left: 15px;
    z-index: 1000;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

#brand-watermark .brand-sub {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
}

/* Floating Action Buttons */
.fab-container {
    position: absolute;
    bottom: var(--spacing);
    right: var(--spacing);
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.fab:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.1);
}

.fab-primary {
    background: rgba(21, 128, 61, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 15px rgba(21, 128, 61, 0.2);
    color: white;
}

.fab-primary:active {
    background: var(--primary-hover);
}

.fab i {
    pointer-events: none;
}

.fab i.active-gps {
    color: #ffd700;
    animation: pulse-gps 2s infinite;
}

@keyframes pulse-gps {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Compass Button */
.fab-compass {
    background: rgba(15, 23, 42, 0.4);
    font-size: 20px;
    transition: all 0.3s ease;
}

.fab-compass.compass-active {
    background: rgba(239, 68, 68, 0.4);
    border-color: rgba(239, 68, 68, 0.3);
}

.fab-compass i.rotated {
    color: #ef4444;
}

/* Lade-Screen Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--surface-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Benachrichtigung */
.toast {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Pulsierender Blauer Punkt für Standorte */
.gps-marker-container {
    width: 40px;
    height: 40px;
    position: relative;
}
.gps-marker-core {
    width: 14px;
    height: 14px;
    background-color: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}
.gps-marker-pulse {
    width: 40px;
    height: 40px;
    background-color: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
    animation: pulsate 2s ease-out infinite;
    z-index: 1;
}

/* Richtungspfeil (Heading Arrow) */
.gps-heading-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    z-index: 2;
    width: 32px;
    height: 32px;
    transition: transform 0.3s ease-out, opacity 0.3s;
    opacity: 0;
    pointer-events: none;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

.gps-heading-arrow svg {
    width: 100%;
    height: 100%;
}

@keyframes pulsate {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* Dark Mode Leaflet Fixes */
.leaflet-container {
    background: var(--background);
}
.leaflet-control-zoom {
    display: none; /* Hide default zoom controls on mobile */
}
.leaflet-control-attribution {
    display: none !important; /* Komplett ausblenden auf Wunsch */
}

/* Ordner-Icon für Karten aus der Ecke ins Panel integrieren */
#stats-panel .leaflet-control-layers {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: white !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Symbol im Ebenen-Knopf: Scharfes SVG (Material Style) */
#stats-panel .leaflet-control-layers-toggle {
    filter: none;
    opacity: 1.0;
    width: 40px; /* Noch etwas größer für bessere Toucheingabe */
    height: 40px;
    background-size: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 16L3 9L12 2L21 9L12 16ZM12 18.5L21 11.5L22.5 12.75L12 21.5L1.5 12.75L3 11.5L12 18.5Z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat;
    background-position: center;
}

/* Ausklapp-Menü des Ordners (muss dunkel sein) */
#stats-panel .leaflet-control-layers-expanded {
    position: absolute;
    top: 100%; 
    left: 10px;  /* Links ausgerichtet, da Icon jetzt links ist */
    right: auto;
    background: rgba(15, 23, 42, 0.9) !important;
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--surface-border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* Hardcore Querformat-Schlankmacher */
@media screen and (orientation: landscape) and (max-height: 500px) {
    #stats-panel {
        padding: 4px 16px; /* Extrem dünn */
    }
    .stat-label {
        font-size: 0.6rem;
    }
    .stat-value {
        font-size: 0.9rem;
    }
    .stat-divider {
        height: 18px;
    }
}
