.track-container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-family: 'Roboto', sans-serif;
}

/* UPDATED: Selector is now more specific to ensure centering overrides other styles */
.track-container .track-selector {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 500px;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    background: #f3f4f6;
}

.track-title {
    font-size: 3rem;
    font-weight: 800;
    text-transform: uppercase;
    background: linear-gradient(45deg, #009540, #005a27);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    padding: 1rem 0;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 2rem;
    /* FIX: Prevents a single long word from overflowing the screen */
    overflow-wrap: break-word;
}
.track-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.track-card {
    background: linear-gradient(145deg, #f9fafb, #e5e7eb);
    border: 1px solid #d1d5db;
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.track-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.track-card h3 {
    font-size: 1rem;
    font-weight: 500;
    color: #4b5563;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.track-card h3 i {
    font-size: 1.25rem;
    color: #009540;
    margin-right: 0.75rem;
}
.track-card p {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1f2937;
}
.track-segments {
    margin-top: 1.5rem;
    text-align: center;
}
.track-segments-list {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    padding: 1rem 0;
}
.track-segment-link {
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 0;
    text-align: center;
    font-weight: 600;
    border: 2px solid #009540;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-decoration: none;
    color: #1f2937;
    transition: background 0.3s, border-color 0.3s;
}
.track-segment-link:hover {
    background: #d1d5db;
}

/* UPDATED: Add styles for the different segment types */
.track-segment-link.segment-schleife {
    border-color: #009540; /* Green for Schleife */
}
.track-segment-link.segment-etappe {
    border-color: #6b7280; /* Grey for Etappe */
}

.track-segment-link i {
    font-size: 1rem;
    margin-right: 0;
    margin-bottom: 2px;
}
.dashed-line {
    flex-grow: 1;
    max-width: 50px;
    border-bottom: 2px solid #d1d5db !important;
    height: 2px !important;
    margin: 0 !important;
    display: inline-block !important;
    vertical-align: middle !important;
    align-self: center !important;
}
.start-icon { color: #16a34a; }
.finish-icon { color: #dc2626; }
.waypoint-icon { color: #4b5563; }
.track-banner {
    background: #fefcbf;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 600;
    color: #7f6600;
    border: 1px solid #fed7aa;
}
.sponsor-info {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    text-align: center;
    border: 1px solid #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.sponsor-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}
.sponsor-logo {
    max-width: 200px;
    max-height: 100px;
    width: auto;
    height: auto;
    margin: 0 auto 0.5rem;
    display: block;
}
#track-sponsor-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}
#track-sponsor-custom-information {
    font-size: 1rem;
    color: #4b5563;
    line-height: 1.5;
}
.sponsor-thanks {
    font-size: 0.9rem;
    color: #4b5563;
    font-style: italic;
    margin-top: 0.5rem;
}
.custom-info {
    background: #f9fafb;
    padding: 1.5rem;
    border-radius: 0.375rem;
    margin-top: 1.5rem;
    border: 1px solid #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.custom-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}
#track-custom-information {
    font-size: 1rem;
    color: #4b5563;
    line-height: 1.5;
}
.track-grid-alternative {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #d1d5db;
}
.track-grid-alternative h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 1rem;
    text-align: center;
}
.track-search-form {
    text-align: center;
    margin-bottom: 1rem;
}
.track-search-form input {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    width: 300px;
    max-width: 100%;
    box-sizing: border-box;
}
.track-search-form button {
    padding: 0.5rem 1rem;
    background: #1f2937;
    color: white;
    border-radius: 0.375rem;
    margin-left: 0.5rem;
    cursor: pointer;
}
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.grid-item {
    padding: 0.75rem;
    background: #f3f4f6;
    border-radius: 0.375rem;
    text-decoration: none;
    color: #1f2937;
    transition: background 0.3s;
    /* New styles for alignment */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center; /* Fallback for older browsers */
    min-height: 70px; /* Ensures all boxes have a consistent height */
}
.grid-item:hover {
    background: #d1d5db;
}
.pagination {
    text-align: center;
    margin-top: 1rem;
}
.pagination-link {
    padding: 0.5rem 1rem;
    background: #1f2937;
    color: white;
    border-radius: 0.375rem;
    margin: 0 0.5rem;
    text-decoration: none;
}
.pagination-link:hover {
    background: #4b5563;
}

/* --- LAYOUT FIXES FOR MAP & PAGE BUILDER --- */

.track-container .e-con-inner {
    height: auto !important;
}
/* map size and layout are defined by the GPX Viewer plugin (gpxViewer.css) */
.track-container #track_viewer .gpxv-view {
    margin: 0;
    border: none;
    box-shadow: none;
}
#map-container {
    margin: 1.5rem 0;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 767px) {
   /* .track-container .gpxv-view {
        display: none !important;
    }*/
    .dashed-line {
        border-bottom: 2px solid #d1d5db !important;
        height: 2px !important;
    }
}


/* ==========================================================================
   STYLES FOR THE NEW ROUTE OVERVIEW PAGE
   ========================================================================== */

.route-overview-container {
    /* Uses the same base styles as your main track container for consistency */
    max-width: 1000px;
    margin: 2rem auto;
    font-family: 'Roboto', sans-serif;
}

.route-section {
    margin-bottom: 3rem;
}

.route-section-title {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    color: #1f2937;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.overview-grid {
    display: grid;
    /* Creates a responsive grid of cards */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.route-card {
    display: block;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.route-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.route-card-number {
    position: absolute;
    top: -20px;
    right: 5px;
    font-size: 4rem;
    font-weight: 800;
    color: #f3f4f6;
    z-index: 1;
}

.route-card-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}

.route-card-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    font-size: 1rem;
    color: #4b5563;
    position: relative;
    z-index: 2;
}

.route-card-stats i {
    margin-right: 0.5rem;
    color: #009540; /* Brand Green */
}

/* ==========================================================================
   ENHANCED MOBILE STYLES FOR TRACK SEGMENTS TIMELINE
   ========================================================================== */
@media (max-width: 767px) {

    /* 1. Set up the container for vertical layout and positioning */
    .track-segments-list {
        flex-direction: column; /* Stack items vertically */
        position: relative;       /* Needed to position the vertical line */
        padding-top: 1rem;        /* Add some space at the top */
        padding-bottom: 1rem;     /* Add some space at the bottom */
        gap: 1.5rem !important;   /* Increase space between circles */
    }

    /* 2. Create the continuous vertical line behind the circles */
    .track-segments-list::before {
        content: '';
        position: absolute;
        /* UPDATED: Start and end the line at the center of the first/last circles */
        top: 30px;
        bottom: 30px;
        left: 50%; /* Center the line horizontally */
        transform: translateX(-50%);
        width: 2px; /* Line thickness */
        background-color: #d1d5db;
        z-index: 0; /* Place the line behind the circles */
    }

    /* 3. Ensure circles appear above the new vertical line */
    .track-segment-link {
        position: relative; /* Establish stacking context */
        z-index: 1;         /* Ensure circles are on top of the line */
        background: #ffffff;/* White background covers the line passing through */
    }

    /* 4. Hide the old horizontal dashed lines */
    .dashed-line {
        display: none !important;
    }
}
/* This is the container for the track number and name */
.grid-item .grid-item-text {
    transition: opacity 0.3s ease-in-out;
}

/* Style for sponsored tracks to make them stand out */
.grid-item.is-sponsored {
    position: relative; /* Needed for the icon and logo container */
    background: #f0fdf4; /* A light green background */
    border: 1px solid #bbf7d0;
    padding-right: 25px; /* Space for the star icon */
}


/* A small star icon to indicate a sponsored track */
.grid-item.is-sponsored::after {
    content: '\f005';
    font-family: 'Font Awesome 5 Free', 'Font Awesome 6 Free';
    font-weight: 900; /* UPDATED: This tells it to use the solid star icon */
    position: absolute;
    top: 5px;
    right: 8px;
    color: #facc15; /* A gold/yellow color */
    font-size: 12px;
}

/* This is the container for the logo, which is hidden by default */
.grid-item .sponsor-logo-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    background: #ffffff; /* White background to cover the text on hover */
    border-radius: 0.375rem; /* Match the parent's border-radius */
}

/* Ensure the logo fits perfectly inside its container */
.grid-item .sponsor-logo-container img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    object-fit: contain;
}

/* --- The Hover Effect --- */

/* On hover, hide the text... */
.grid-item.is-sponsored:hover .grid-item-text {
    opacity: 0;
}

/* ...and show the logo container */
.grid-item.is-sponsored:hover .sponsor-logo-container {
    opacity: 1;
}

.track-creator-container {
    background: #E9ECEF; /* UPDATED: Background color */
    border: 1px solid #dee2e6; /* A subtle border that complements the background */
    border-radius: 8px; /* UPDATED: Border Radius */
    padding: 2rem;
    max-width: 800px;
    margin: 2rem auto;
    text-align: center;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1); /* UPDATED: Box Shadow */
    font-family: 'Roboto', sans-serif; /* UPDATED: Font */
}

.track-creator-title {
    font-size: 2rem;
    font-weight: 700;
    color: #009540; /* UPDATED: Heading Text Color */
    margin-bottom: 0.5rem;
    font-family: 'Roboto', sans-serif; /* UPDATED: Font */
}

.track-creator-subtitle {
    font-size: 1rem;
    color: #7A7A7A; /* UPDATED: Body Text Color */
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    font-family: 'Roboto', sans-serif; /* UPDATED: Font */
}

#track-creator-segments {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 767px) {
    #track-creator-segments {
        grid-template-columns: 1fr; /* Stack on mobile */
    }
}

.segment-chooser {
    display: flex;
    align-items: center;
    background: #ffffff;
    padding: 0.75rem;
    border-radius: 8px; /* UPDATED: Border Radius */
    border: 1px solid #d1d5db;
}

.segment-label {
    font-weight: 600;
    color: #7A7A7A; /* UPDATED: Body Text Color */
    margin-right: auto;
    font-family: 'Roboto', sans-serif; /* UPDATED: Font */
}

.segment-options {
    display: flex;
    border-radius: 8px; /* UPDATED: Border Radius */
    overflow: hidden;
}

.segment-option {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
    margin-left: -1px; /* Overlap borders */
    font-family: 'Roboto', sans-serif; /* UPDATED: Font */
    width: 110px;
    box-sizing: border-box;
    text-align: center;
}

.segment-option:first-child {
    margin-left: 0;
    /* NEW: Add rounded corners to the left side of the first button */
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

/* NEW: This rule targets the last button in the group */
.segment-option:last-child {
    /* NEW: Add rounded corners to the right side of the last button */
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.segment-option.active {
    background: #007a33; /* darker brand green: WCAG AA contrast with white text */
    color: #ffffff;
    border-color: #007a33;
    z-index: 1;
}

.track-creator-footer {
    padding-top: 1.5rem;
    border-top: 1px solid #dee2e6;
}

#create-track-button {
    background: #007a33; /* darker brand green: WCAG AA contrast with white text */
    color: white;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px; /* UPDATED: Border Radius */
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    font-family: 'Roboto', sans-serif; /* UPDATED: Font */
}

#create-track-button:hover {
    background: #005a27; /* Darker version of button color */
}

/* Simple spinner for loading state */
.track-creator-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #009540; /* UPDATED: Button Color */
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#track-creator-message {
    margin-top: 1rem;
    font-weight: 600;
    height: 1.5em; /* Reserve space to prevent layout jump */
    font-family: 'Roboto', sans-serif;
}
#track-creator-message.error {
    color: #dc2626;
}
#track-creator-message.success {
    color: #16a34a;
}

.sponsors-list-container {
    max-width: 1100px;
    margin: 2rem auto;
    font-family: 'Roboto', sans-serif;
}

.sponsors-grid {
    display: grid;
    /* Creates a responsive grid of sponsor cards */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.sponsor-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Ensures child elements respect the border radius */
}

.sponsor-card-logo {
    width: 100%;
    height: 180px;
    background-color: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
    border-bottom: 1px solid #e5e7eb;
}

.sponsor-card-logo img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    object-fit: contain;
}

.sponsor-card-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allows content to fill space */
}

.sponsor-card-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1f2937;
    margin-top: 0;
    margin-bottom: 1rem;
}

.sponsor-card-info {
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    flex-grow: 1; /* Pushes the track list to the bottom */
}

.sponsor-card-info p:first-child {
    margin-top: 0;
}

.sponsor-card-tracks {
    font-size: 0.9rem;
    border-top: 1px solid #e5e7eb;
    padding-top: 1rem;
}

.sponsor-card-tracks p {
    margin: 0 0 0.5rem 0;
    color: #1f2937;
    font-weight: 600;
}

.sponsor-card-tracks ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sponsor-card-tracks li a {
    display: block;
    padding: 0.25rem 0;
    color: #009540; /* Brand Green */
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.sponsor-card-tracks li a:hover {
    color: #005a27; /* Darker Green */
}

.startpage-carousel-wrapper {
    max-width: 1200px;
    margin: 2rem auto;
    position: relative;
}

.startpage-carousel {
    width: 100%;
    height: 250px; /* UPDATED: A smaller, more appropriate height */
    border-radius: 8px;
    overflow: hidden; /* Important for clean slide rendering */
}

.startpage-carousel .slide-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    text-decoration: none;
}

.startpage-carousel .swiper-slide {
    position: relative;
    background: #ffffff; 
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem; 
    box-sizing: border-box;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.startpage-carousel .swiper-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* The caption is now a div, not a link */
.slide-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    padding: 2.5rem 1rem 1rem;
    transition: opacity 0.3s;
    opacity: 0; 
    border-radius: 0 0 8px 8px;
}

.startpage-carousel .swiper-slide:hover .slide-caption {
    opacity: 1; 
}

.slide-caption h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    font-family: 'Roboto', sans-serif; /* UPDATED: Font family */
}

/* Style for the navigation arrows */
.startpage-carousel .swiper-button-next,
.startpage-carousel .swiper-button-prev {
    color: #009540; 
}

/* Style for the pagination dots */
.startpage-carousel .swiper-pagination-bullet-active {
    background: #009540;
}



/* ==========================================================================
   TOUCH DEVICES & KEYBOARD
   ========================================================================== */

/* Touch screens have no hover: show sponsor logos and carousel captions permanently */
@media (hover: none) {
    .grid-item.is-sponsored {
        flex-direction: column;
        gap: 0.4rem;
    }
    .grid-item .sponsor-logo-container {
        position: static;
        opacity: 1;
        height: 36px;
        padding: 0;
        background: transparent;
    }
    .grid-item.is-sponsored:hover .grid-item-text {
        opacity: 1;
    }
    .startpage-carousel .slide-caption {
        opacity: 1;
    }
}

.grid-item:focus-visible,
.route-card:focus-visible,
.track-segment-link:focus-visible,
.pagination-link:focus-visible,
.segment-option:focus-visible,
#create-track-button:focus-visible,
.track-search-form button:focus-visible,
.track-search-form input:focus-visible,
.track-container .track-selector:focus-visible,
.sponsor-card a:focus-visible,
.slide-caption:focus-visible {
    outline: 3px solid #005a27;
    outline-offset: 2px;
}
