:root {
    --primary-color: #FF5722;
    --primary-gradient: linear-gradient(135deg, #FF6B45 0%, #FF3D00 100%);
    --secondary-color: #2979FF;
    --bg-color: #F8F9FA;
    --text-color: #1A1A1A;
    --text-muted: #666666;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Noto Sans JP', sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

/* Header with Glassmorphism */
/* Header with Premium Gradient */
header {
    background: var(--primary-gradient);
    border-bottom: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 2000;
    height: 60px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(255, 87, 34, 0.3);
}

.header-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header h1 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 i {
    color: white;
    font-size: 1.1em;
}

.header-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    backdrop-filter: blur(4px);
}

.header-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.header-btn:active {
    transform: translateY(0);
}

/* App Layout */
.app-container {
    padding-top: 60px; /* Header height */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.map-wrapper {
    position: relative;
    width: 100%;
    height: 50vh; /* Mobile default - overridden in media query */
    background: #e0e0e0;
    overflow: hidden; /* Contain overlays */
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Floating Search Bar (Slide Down) */
.search-overlay {
    position: absolute;
    top: -120px; /* Hidden by default */
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 500px;
    z-index: 2000;
    transition: top 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    gap: 8px; /* Slightly reduced gap */
    align-items: center;
    flex-wrap: nowrap; /* Prevent wrapping */
}

.search-overlay.active {
    top: 15px; /* Slide down position */
}

.search-box {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 5px 5px 5px 15px; /* Reduced left padding */
    display: flex;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.8);
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

.search-box:focus-within {
    box-shadow: 0 12px 30px rgba(255, 87, 34, 0.2);
    border-color: rgba(255, 87, 34, 0.3);
}

.search-icon {
    /* Hidden in new layout */
    display: none;
}

#searchBox {
    border: none;
    background: transparent;
    flex: 1;
    font-size: 16px;
    font-family: var(--font-body);
    font-weight: 500;
    outline: none;
    padding: 10px 0;
    /* Prevent iOS zoom on focus */
    font-size: 16px;
    min-width: 0; /* Allow shrinking */
}

.search-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 40px;
    padding: 10px 16px; /* Reduced padding */
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0; /* Prevent shrinking */
}

.search-btn:active {
    transform: scale(0.95);
}

.close-search-btn {
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    flex-shrink: 0; /* Prevent shrinking */
}

/* Ensure Leaflet controls don't overlap with header or search bar */
.leaflet-top {
    top: 70px; /* Below header (60px) + 10px */
}

/* Floating Controls */
.map-controls-floating {
    position: absolute;
    bottom: 90px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.float-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.float-btn:hover {
    transform: scale(1.1);
    background: #fafafa;
    color: var(--primary-color);
}

.float-btn:active {
    transform: scale(0.95);
}

/* Radius Filter */
.radius-floating {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 10px;
}

.radius-selector {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 6px;
    border-radius: 40px;
    display: flex;
    gap: 4px;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    flex-wrap: wrap; /* Allow wrapping on very small screens */
    max-width: 100%;
}

.radius-opt {
    position: relative;
    cursor: pointer;
}

.radius-opt input {
    display: none;
}

.radius-opt span {
    display: block;
    padding: 8px 12px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
    white-space: nowrap;
}

.radius-opt input:checked + span {
    background: var(--text-color);
    color: white;
}

.custom-radius-box {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-left: 8px;
    border-left: 1px solid #ddd;
    margin-left: 4px;
}

#customRadiusInput {
    width: 50px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px;
    text-align: center;
    font-size: 0.9rem;
}

.mini-btn {
    background: var(--text-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.reset-btn-inline {
    background: #757575; /* Gray for secondary action */
    margin-left: 4px;
    padding: 4px 10px;
}


.mini-btn:hover {
    background: var(--primary-color);
}

#customRadiusInput.active {
    background: var(--text-color);
    color: white;
    border-color: var(--text-color);
}

/* Info Panel & Lists */
.info-panel {
    flex: 1;
    background: var(--bg-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-top: -20px; /* Overlap map slightly */
    z-index: 10;
    position: relative;
    padding: 30px 20px;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.05);
}

/* Ranking Cards */
.ranking-box {
    background: white;
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.03);
    position: relative;
    overflow: hidden;
}

/* Decorate Ranking */
.ranking-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
}

.ranking-header {
    margin: 0 0 20px 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ranking-header i {
    color: #FFC107;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-rank {
    font-weight: 700;
    font-family: var(--font-heading);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    margin-right: 12px;
    background: #eee;
    color: #555;
}

.ranking-rank.rank-1 { background: linear-gradient(135deg, #FFD700, #FDB931); color: #856404; box-shadow: 0 2px 5px rgba(255, 215, 0, 0.4); }
.ranking-rank.rank-2 { background: linear-gradient(135deg, #E0E0E0, #BDBDBD); color: #424242; }
.ranking-rank.rank-3 { background: linear-gradient(135deg, #E6DABf, #C4A484); color: #5D4037; }

/* Station List Items */
.station-item {
    background: #fffaf0;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #f5f5f5;
    position: relative;
    cursor: pointer;
    scroll-margin-top: 5px; /* Minimal buffer to hide previous item border */
}

.station-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

@keyframes highlight-flash {
    0% { background-color: rgba(255, 87, 34, 0.2); }
    100% { background-color: #fff3e0; }
}

.station-item.active {
    border: 2px solid var(--primary-color);
    background-color: #fff3e0; /* Distinct Orange Tint */
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(255, 87, 34, 0.25);
    z-index: 5;
    animation: highlight-flash 0.4s ease-out;
}

.station-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 8px;
}

.station-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.price-tag {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-color);
    font-family: var(--font-heading);
}

/* Empty State */
.empty-state {
    text-align: center;
    color: #999;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* Modal Styling */
#postModal > div {
    background: white;
    border-radius: 20px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    padding: 30px !important;
}

#postModal h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    margin-top: 0;
}

/* Buttons in Modal */
button[type="submit"] {
    background: var(--primary-gradient) !important;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(255, 87, 34, 0.3) !important;
}

/* Footer Styling */
.site-footer {
    background: #333;
    color: #ccaca0; /* Slightly muted text for boundary definition */
    padding: 10px 20px;
    font-size: 0.8rem;
    z-index: 2000;
    width: 100%;
    margin-top: auto; /* Push to bottom in flex column context if needed */
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.footer-links {
    display: flex;
    gap: 15px;
}

.footer-links a {
    color: #e0e0e0;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
}


/* Responsive */
@media (min-width: 768px) {
    .app-container {
        flex-direction: row;
        /* Subtract header(60px) and footer(~40px) */
        height: calc(100vh - 40px); 
        overflow: hidden;
    }
    
    .map-wrapper {
        flex: 3;
        height: 100%;
    }

    .info-panel {
        flex: 2;
        height: 100%;
        margin-top: 0;
        border-radius: 0;
        overflow-y: auto;
        box-shadow: -5px 0 20px rgba(0,0,0,0.05);
        max-width: 500px;
        z-index: 10;
        background: white;
    }
    
    /* On Desktop, move Controls to top left or keep floating neatly */
    .search-overlay {
        left: auto;
        right: 20px;
        transform: none;
        width: 380px;
    }
}

/* AdSense Containers */
.ads-infeed {
    text-align: center;
    margin-bottom: 16px;
    background: transparent;
    padding: 0;
    box-shadow: none;
    border: none;
}

.ads-sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 3000;
    text-align: center;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    display: none; /* Hide by default, show via JS if needed or CSS media query */
}


/* --- Mobile Bottom Sheet / Accordion Logic --- */
@media (max-width: 767px) {
    /* Hide Title Text on Mobile */
    .site-title-text {
        display: none;
    }
    header h1 i {
        font-size: 1.5rem;
    }

    /* Horizontal Scroll for Radius Selector to prevent wrapping/overlap */
    .radius-floating {
        bottom: 25px;
        left: 10px;
        /* Ensure we leave space for the button on the right (50px + 20px margin + gap) */
        max-width: calc(100% - 90px);
        width: auto;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .radius-selector {
        padding: 4px 8px;
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* Critical for flex item to shrink and scroll */
        flex: 1;
        min-width: 0;
        padding-right: 20px; /* Add padding to end of scroll area so Go button isn't cut off */
    }
    
    .radius-selector::-webkit-scrollbar { display: none; }
    
    .radius-opt span {
        padding: 6px 10px;
        font-size: 0.75rem;
        white-space: nowrap;
    }
    
    .custom-radius-box {
        padding-left: 4px;
        margin-left: 2px;
        flex-shrink: 0;
        display: flex; /* Ensure flex layout */
        align-items: center;
    }

    /* Hide 'km' text on mobile to save space for Go button */
    .custom-radius-box span {
        display: none !important;
    }

    #customRadiusInput {
        width: 40px; /* Force narrow input */
        padding: 4px;
        font-size: 0.8rem;
    }

    .mini-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
        white-space: nowrap;
        margin-left: 2px;
    }

    .app-container {
        display: block; /* Stack */
        height: auto;
        overflow: hidden;
    }

    .map-wrapper {
        position: fixed;
        top: 60px; /* Header */
        left: 0;
        width: 100%;
        height: calc(100vh - 60px); /* Full screen map */
        z-index: 1;
    }

    /* Bottom Sheet Panel */
    .info-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 80vh; /* Max height when expanded */
        background: white;
        z-index: 2000; /* Above Leaflet controls */
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.15);
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        
        /* Initial State: Hidden completely or just handle visible? 
           Request: "Initial screen map only". 
           So initially transform down. */
        transform: translateY(100%); 
        
        display: flex;
        flex-direction: column;
        padding-top: 0; /* Handle area is separate */
    }

    /* Peek State (Visible Handle + Banner) */
    .info-panel.has-results {
        /* Show less: Handle(30) + Banner(Small) - Lower it to not block controls */
        transform: translateY(calc(100% - 100px));
    }

    /* Expanded State (Full View) */
    .info-panel.expanded {
        transform: translateY(0);
    }
    
    /* Panel Handle Area */
    .panel-handle {
        display: flex !important; /* Force show */
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 30px;
        width: 100%;
        cursor: pointer;
        background: white;
        border-radius: 24px 24px 0 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .handle-bar {
        width: 40px;
        height: 5px;
        background: #ddd;
        border-radius: 5px;
        margin-bottom: 2px;
    }
    
    .panel-handle i {
        color: var(--primary-color);
        font-size: 0.9rem;
    }
    
    /* Scrollable Content Area */
    #stationList {
        flex: 1;
        overflow-y: auto;
        padding: 10px 20px 80px 20px; /* Bottom padding for safety */
        -webkit-overflow-scrolling: touch;
    }
    
    .contribution-banner {
        margin: 10px 20px;
        flex-shrink: 0;
    }

    /* Adjust controls position to be above the "Peek" height */
    .map-controls-floating, .radius-floating {
        z-index: 1500; /* Below panel but above map */
        bottom: 160px !important; /* Move strictly above the panel (100px + buffer) */
        transition: bottom 0.3s;
    }
    
    /* Small font for empty/ranking messages in panel on mobile */
    .ranking-box {
        font-size: 0.85rem;
        padding: 15px;
    }
    .ranking-box i {
        font-size: 1rem;
    }
    
    /* When panel is expanded, maybe hide map controls or move them? 
       Moving them might be weird. Let's keep them there, they will be covered. */
       
    .ads-sticky-footer {
        z-index: 3000; /* Above panel */
    }
    
    /* Prevent body scroll when map is fixed */
    /* body { overflow: hidden; } REMOVED */
}


/* Contribution Banner */
.contribution-banner {
    background: linear-gradient(135deg, #fff8e1 0%, #fff3e0 100%);
    color: #f57c00;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    margin: 10px 20px;
    font-weight: 700;
    font-size: 0.8rem; /* Smaller font for mobile */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #ffe0b2;
    text-align: center;
    white-space: nowrap; /* Prevent wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Adjust banner specifically for mobile if needed */
@media (max-width: 380px) {
    .contribution-banner {
        font-size: 0.7rem;
    }
}

.contribution-banner i {
    font-size: 1.2rem;
    color: #ff9800;
}


/* Center Popup Styles */
div.center-popup-content {
    text-align: center;
    padding: 2px 5px;
    font-family: var(--font-body);
}

div.center-popup-content .popup-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

div.center-popup-content .popup-sub {
    font-size: 0.75rem;
    color: #666;
    font-weight: 500;
}

/* Numbered Markers */
.custom-div-icon {
    background: transparent;
    border: none;
}
.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    background: #FF5722;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -15px 0 0 -15px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.3);
}
.custom-div-icon .marker-num {
    position: absolute;
    width: 30px;
    top: 1px;
    left: 0;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: white;
    z-index: 10;
}
/* Station Item Flex Layout for Numbering */
.station-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.station-number-box {
    background: #FF5722;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px; /* Slightly rounded square */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 4px 6px rgba(255, 87, 34, 0.3);
}

.station-content {
    flex: 1;
    min-width: 0; /* Prevent overflow */
}

