*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #111;
    color: #e8e8e8;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

/*
 * Mobile  (default): two-row grid
 *   row 1: [title ···················] [auth + reset]
 *   row 2: [progress bar ─────────────────────────────]
 *
 * Desktop (≥ 600px): single row
 *   [title] [── progress ──] [legend] [auth + reset]
 */
#header {
    display: grid;
    grid-template-areas:
        "title  right"
        "prog   prog ";
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 16px;
    row-gap: 8px;
    padding: 10px 16px;
    background: #0e0e0e;
    border-bottom: 1px solid #2a2a2a;
    flex-shrink: 0;
    z-index: 1000;
}

@media (min-width: 1024px) {
    #header {
        grid-template-areas: "title prog legend right";
        grid-template-columns: auto 1fr auto auto;
        row-gap: 0;
        padding: 0 20px;
        height: 48px;
    }
}

#header h1 {
    grid-area: title;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #e8f0dc;
    line-height: 1;
}

#header h1 span {
    color: #555;
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* ── Right controls ──────────────────────────────────────────────────────── */

#header-right {
    grid-area: right;
    display: flex;
    align-items: center;
    gap: 8px;
}

#auth-section {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#signin-btn,
#signout-btn {
    background: none;
    border: 1px solid #333;
    color: #999;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11px;
    letter-spacing: 0.05em;
    cursor: pointer;
    white-space: nowrap;
    transition:
        border-color 0.15s,
        color 0.15s;
}
#signin-btn:hover,
#signout-btn:hover {
    border-color: #666;
    color: #ccc;
}
#signin-btn {
    color: #4ade80;
    border-color: #2a5c3f;
}
#signin-btn:hover {
    border-color: #4ade80;
    color: #86efac;
}

#reset-btn {
    background: none;
    border: 1px solid #2a2a2a;
    color: #999;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11px;
    letter-spacing: 0.05em;
    cursor: pointer;
    white-space: nowrap;
    transition:
        border-color 0.15s,
        color 0.15s;
}
#reset-btn:hover {
    border-color: #555;
    color: #ccc;
}

/* ── Progress ────────────────────────────────────────────────────────────── */

#progress-wrap {
    grid-area: prog;
}

#progress-track {
    background: #2a2a2a;
    border-radius: 4px;
    height: 4px;
    overflow: hidden;
}

#progress-fill {
    background: linear-gradient(90deg, #22c55e, #4ade80);
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.35s ease;
}

#progress-label {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ── Legend ──────────────────────────────────────────────────────────────── */

#legend {
    grid-area: legend;
    display: none;
    align-items: center;
    gap: 14px;
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    padding: 0 4px;
}

@media (min-width: 1024px) {
    #legend {
        display: flex;
    }
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-swatch {
    width: 22px;
    height: 3px;
    border-radius: 2px;
}
.swatch-unexplored {
    background: #f97316;
}
.swatch-visited {
    background: #22c55e;
}

#map {
    flex: 1;
    min-height: 0;
}

#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 5000;
}
#overlay.hidden {
    display: none;
}

#overlay-msg {
    font-size: 14px;
    color: #ccc;
    letter-spacing: 0.04em;
}
#overlay-sub {
    font-size: 12px;
    color: #555;
    max-width: 320px;
    text-align: center;
    line-height: 1.6;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #333;
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(20, 20, 20, 0.92);
    color: #e8e8e8;
    padding: 9px 18px;
    border-radius: 24px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    z-index: 3000;
    border: 1px solid #2a2a2a;
    white-space: nowrap;
}
#toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.leaflet-control-zoom a {
    background: #1a1a1a !important;
    color: #ccc !important;
    border-color: #333 !important;
}
.leaflet-control-zoom a:hover {
    background: #2a2a2a !important;
    color: #fff !important;
}
.leaflet-control-attribution {
    display: none !important;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

#footer {
    flex-shrink: 0;
    background: #0e0e0e;
    padding: 4px 20px;
    font-size: 11px;
    color: #999;
    letter-spacing: 0.02em;
    text-align: center;
    line-height: 1.4;
}

#footer a {
    color: #999;
    text-decoration: underline;
    text-decoration-color: #444;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

#footer a:hover {
    color: #ccc;
}

@media (max-width: 599px) {
    .footer-map {
        display: block;
    }
}

/* ── Help button ─────────────────────────────────────────────────────────── */

#help-btn {
    background: none;
    border: 1px solid #2a2a2a;
    color: #999;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition:
        border-color 0.15s,
        color 0.15s;
}
#help-btn:hover {
    border-color: #555;
    color: #ccc;
}

/* ── Intro modal ─────────────────────────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6000;
    padding: 16px;
}
.modal-backdrop.hidden {
    display: none;
}

.modal-box {
    position: relative;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 28px 28px 24px;
    max-width: 420px;
    width: 100%;
    color: #ccc;
    line-height: 1.6;
}

.modal-box h2 {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #e8f0dc;
    margin-bottom: 14px;
}
.modal-box h2 span {
    color: #555;
    font-weight: 400;
    letter-spacing: 0.05em;
}

.modal-box p {
    font-size: 13px;
    color: #999;
    margin-bottom: 14px;
}

.modal-box ul {
    list-style: none;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.modal-box ul li {
    font-size: 13px;
    color: #999;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.how-swatch {
    display: inline-block;
    width: 22px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 9px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: #444;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.modal-close:hover {
    color: #aaa;
}

.modal-primary {
    margin-top: 6px;
    width: 100%;
    padding: 10px;
    background: #166534;
    border: 1px solid #22c55e;
    color: #4ade80;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}
.modal-primary:hover {
    background: #15803d;
    color: #86efac;
}

.park-label-anchor {
    background: none !important;
    border: none !important;
}
.park-label {
    display: inline-block;
    transform: translate(-50%, -50%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #2d5a3d;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    text-shadow:
        0 0 3px rgba(255, 255, 255, 0.9),
        0 0 6px rgba(255, 255, 255, 0.7);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
