:root {
    --primary-color: #2563eb;
    --bg-hover: #f1f5f9;
    --border-color: #e2e8f0;
}

body { margin: 0; padding: 0; font-family: "Inter", "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif; overflow: hidden; }

/* 地図容器 */
#map { height: 100vh; width: 100%; z-index: 1; }

/* 統一コントロールパネル */
.custom-control-bar {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1000;
    pointer-events: auto;
}

.leaflet-bar {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 8px !important;
    overflow: visible; 
}

.leaflet-bar a.custom-btn {
    background-color: #fff;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #64748b;
    transition: all 0.2s ease;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.leaflet-bar a.custom-btn:last-child {
    border-bottom: none;
}

.leaflet-bar a.custom-btn:hover {
    background-color: var(--bg-hover);
    color: var(--primary-color);
}

.leaflet-bar a.custom-btn.active {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.custom-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* 現代点マーカー */
.modern-dot-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}
.dot-inner {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border: 1.5px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}
.modern-dot-marker:hover .dot-inner {
    transform: scale(1.3);
    background-color: #1d4ed8;
}

.marker-cluster-estimated {
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ライブラリのデフォルトスタイルを上書きするために、セレクタの特異性を高める */
.marker-cluster .marker-cluster-core {
    /* marginをリセットして、親要素のflexboxで中央揃えを制御する */
    margin: 0;
    border-radius: 999px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* --- Cluster Sizing --- */
.marker-cluster .marker-cluster-core-s {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.marker-cluster .marker-cluster-core-m {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

.marker-cluster .marker-cluster-core-l {
    width: 40px;
    height: 40px;
    font-size: 12px;
}

.marker-cluster .marker-cluster-core-xl {
    width: 48px;
    height: 48px;
    font-size: 13px;
}

.marker-cluster .marker-cluster-core-heat {
    letter-spacing: -0.02em;
}

/* --- 聚合点热力图颜色 (7个等级，冷色到暖色) --- */

/* Level 1: Blue (冷色) */
.marker-cluster-heat-1 {
    background: rgba(59, 130, 246, 0.2);
}
.marker-cluster-core-1 {
    background: rgba(59, 130, 246, 0.95);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Level 2: Cyan */
.marker-cluster-heat-2 {
    background: rgba(34, 211, 238, 0.2);
}
.marker-cluster-core-2 {
    background: rgba(34, 211, 238, 0.95);
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
}

/* Level 3: Green */
.marker-cluster-heat-3 {
    background: rgba(74, 222, 128, 0.22);
}
.marker-cluster-core-3 {
    background: rgba(74, 222, 128, 0.95);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

/* Level 4: Yellow */
.marker-cluster-heat-4 {
    background: rgba(250, 204, 21, 0.24);
}
.marker-cluster-core-4 {
    background: rgba(250, 204, 21, 0.95);
    box-shadow: 0 4px 14px rgba(250, 204, 21, 0.34);
}

/* Level 5: Orange */
.marker-cluster-heat-5 { background: rgba(251, 146, 60, 0.28); }
.marker-cluster-core-5 { background: rgba(251, 146, 60, 0.95); box-shadow: 0 4px 14px rgba(251, 146, 60, 0.34); }

/* Level 6: Red */
.marker-cluster-heat-6 { background: rgba(239, 68, 68, 0.3); }
.marker-cluster-core-6 { background: rgba(239, 68, 68, 0.95); box-shadow: 0 4px 14px rgba(239, 68, 68, 0.34); }

/* Level 7: Dark Red (热色) */
.marker-cluster-heat-7 { background: rgba(190, 18, 60, 0.35); }
.marker-cluster-core-7 { background: rgba(190, 18, 60, 0.95); box-shadow: 0 4px 14px rgba(190, 18, 60, 0.34); }

/* 地域選択メニュー */
.region-control {
    position: relative;
}

.region-dropdown {
    position: absolute;
    right: 48px;
    top: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    display: none; 
    flex-direction: column;
    min-width: 160px;
    max-height: 400px;
    overflow-y: auto;
    padding: 6px;
    z-index: 1001;
}

.region-dropdown::after {
    content: "";
    position: absolute;
    top: 0;
    right: -10px;
    width: 10px;
    height: 100%;
}

.region-option {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    color: #334155;
    transition: all 0.2s;
    text-align: left;
    background: none;
    border: none;
    width: 100%;
}

.region-option:hover {
    background-color: var(--bg-hover);
    color: var(--primary-color);
}

.region-option.selected {
    background-color: var(--primary-color);
    color: white;
}

/* ローディング */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    font-size: 14px;
    color: var(--primary-color);
    backdrop-filter: blur(4px);
}
.spinner {
    width: 30px; height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 統計ポップアップ */
.school-info h3 { margin: 0 0 6px 0; color: #1e293b; font-size: 15px; font-weight: 700; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    color: white;
    background-color: var(--primary-color);
    margin-bottom: 8px;
}
.school-info p { margin: 4px 0; font-size: 12px; color: #64748b; }
