:root {
    --primary: #007aff;
    --safe: #2ecc71;
    --warn: #f1c40f;
    --danger: #e74c3c;
    --gray: #95a5a6;
    --nav-h: 70px;
    --theme: var(--safe);
    --nav-bg: #0084ff; /* 珍珠白 */
}

[data-status="safe"] { --theme: var(--safe); }
[data-status="warning"] { --theme: var(--warn); }
[data-status="danger"] { --theme: var(--danger); }

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Noto Sans TC', sans-serif; }
body, html { width: 100%; height: 100%; overflow: hidden; background: #fff; }

/* ==== 琉急式導覽列 (珍珠白) ==== */
.main-navbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--nav-h); z-index: 10000;
    display: flex; align-items: center;
    background: var(--nav-bg);
    border-bottom: 3px solid var(--theme);
    box-shadow: 0 2px 10px rgb(233, 231, 231);
    transition: 0.3s;
}
.nav-container { width: 100%; max-width: 1400px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; padding: 0 1.5rem; }
.nav-left .logo { height: 42px; display: block; }
.nav-right a { color: #ecebeb; text-decoration: none; font-size: 1rem; padding: 5px 12px; font-weight: 900; }

/* ==== 物理裁剪引擎：四倍寬度偏移法 ==== */
#viewport {
    position: absolute;
    top: var(--nav-h);
    left: 0; width: 100%; height: calc(100% - var(--nav-h));
    overflow: hidden; 
    z-index: 1;
    background: #eee;
}

#map-iframe {
    position: absolute;
    /* 預設裁剪 */
    top: -80px; 
    left: -150%; 
    width: 400%; 
    height: 180%; 
    border: none;
    z-index: 1;
}

/* 終極手機版屏蔽邏輯 */
@media (max-width: 768px) {
    #map-iframe {
        width: 500%; /* 手機版拉到五倍寬 */
        left: -200%; /* 精確將地圖中心對準，資訊欄被推到極遠處 */
        top: -85px;
        height: 170%;
    }
    .nav-left .logo { height: 35px; }
}

/* ==== 抬頭顯示儀表板 (HUD) ==== */
#hud {
    position: fixed;
    top: calc(var(--nav-h) + 15px);
    left: 50%; transform: translateX(-50%);
    width: 92%; max-width: 500px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 15px; padding: 12px 20px;
    z-index: 9000;
    border-left: 10px solid var(--theme);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: flex; justify-content: space-between; align-items: center;
    pointer-events: none; /* 防止 HUD 擋住地圖操作 */
}
#location-title { font-size: 14px; color: #777; font-weight: 700; }
#location-name { font-size: 20px; font-weight: 900; color: #111; margin-top: 2px; }
#coord { font-size: 11px; color: #999; font-family: monospace; font-weight: 700; }
#alt-limit { font-size: 32px; font-weight: 900; color: var(--theme); text-align: right; }

/* ==== 規則說明書 (Modal) ==== */
#rules-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 20000;
    display: flex; align-items: center; justify-content: center;
}
.rules-card {
    background: #fff; width: 90%; max-width: 500px;
    border-radius: 20px; padding: 25px; max-height: 85vh; overflow-y: auto;
}
.rules-card h2 { text-align: center; margin-bottom: 20px; color: #000; font-weight: 900; font-size: 22px; }
.rule-box { margin-bottom: 12px; padding: 15px; border-radius: 12px; font-size: 13px; line-height: 1.5; font-weight: 500; color: #333; }
.btn-agree {
    width: 100%; padding: 18px; background: #000; color: #fff;
    border: none; border-radius: 12px; font-weight: 900; font-size: 18px; margin-top: 10px; cursor: pointer;
}

/* ==== 底部標記 ==== */
#footer-info {
    position: fixed; bottom: 20px; left: 15px;
    z-index: 8000; pointer-events: none;
}
.legend-tag {
    background: rgba(255,255,255,0.95); padding: 15px 18px;
    border-radius: 10px; font-size: 14px; font-weight: 900; margin-bottom: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); color: #333;
}
.source-tag { font-size: 11px; color: #333; font-weight: 900; text-shadow: 0 0 10px #fff; }

.pulse { animation: danger-blink 1s infinite; }
@keyframes danger-blink { 0%, 100% { border-left-color: var(--danger); opacity: 1; } 50% { border-left-color: #eee; opacity: 0.8; } }