:root {
    color-scheme: dark;
    --pine: #103c32;
    --pine-light: #285946;
    --berry: #b42642;
    --paper: #071a16;
    --surface: #122b24;
    --field: #13251e;
    --border: #395448;
    --ink: #f8f7ef;
    --muted: #c1d2c7;
    --glow: #611e2b;
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
}
:root[data-season="halloween"] {
    --pine: #352344;
    --pine-light: #594065;
    --berry: #ab441a;
    --paper: #1b1120;
    --surface: #302235;
    --field: #2a202d;
    --border: #5d465e;
    --ink: #fff5e9;
    --muted: #ded0df;
    --glow: #633519;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(ellipse at 100% 0%,var(--glow),transparent 38%),linear-gradient(135deg,var(--paper),var(--pine) 150%); min-height: 100vh; }
a { color: inherit; text-underline-offset: .18em; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
    outline: 3px solid #3072a1; outline-offset: 3px;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
.map-card a:hover { text-decoration: underline; }
main { width: min(100% - clamp(28px,5vw,88px),1840px); margin: auto; padding: 20px 0 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.map-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.map-breadcrumb { text-decoration: none; font-size: .9rem; }
h1, h2 { margin: 0; color: var(--ink); }
h1 { font: 500 clamp(1.75rem,3.15vw,3rem)/1.1 'DM Serif Text', Georgia, serif; letter-spacing: -.04em; }
h2 { font-size: 1.15rem; }
.map-tools select, .map-tools input {
    background: var(--field); border: 1px solid var(--border); color: var(--ink); border-radius: 11px;
    padding: 10px 12px; min-width: 0; min-height: 44px; width: 100%;
}
.map-tools label { display: grid; gap: 4px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.map-tools select, .map-tools input { font-size: 1rem; }
.map-layout {
    display: grid; grid-template-columns: minmax(0,1fr) clamp(280px,25%,360px); grid-template-rows: auto minmax(0,1fr);
    border-radius: 18px; border: 1px solid var(--border); background: var(--surface); overflow: hidden;
    box-shadow: 0 16px 45px #02080644; height: clamp(455px,calc(100svh - 215px),920px);
}
.map-tools {
    grid-column: 1/-1; grid-row: 1; display: flex; align-items: center; flex-wrap: wrap;
    gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); position: relative; z-index: 3;
}
.map-search { flex: 1 1 200px; max-width: 570px; }
.map-layer { max-width: 210px; }
.house-filters { display: flex; align-items: center; gap: 8px; }
.feature-panel { position: relative; margin: 0; }
.feature-panel summary, .map-tools .map-checkbox, .filter-done {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 12px;
    color: var(--ink); background: var(--field); border: 1px solid var(--border); border-radius: 11px; font-weight: 600; cursor: pointer;
}
.feature-panel summary { list-style: none; }
.feature-panel summary::-webkit-details-marker { display: none; }
.feature-panel summary::after { content: ''; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.feature-panel[open] summary::after { transform: translateY(2px) rotate(225deg); }
.filter-popover {
    position: absolute; right: 0; margin-top: 6px; width: 320px; padding: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 36px #0007;
    display: grid; gap: 9px; max-height: min(65svh,460px); overflow-y: auto; overscroll-behavior: contain;
}
.filter-popover fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.map-town-links {padding:.65rem .25rem;color:var(--ink)}
.map-town-links summary {cursor:pointer;width:fit-content}
.map-town-links ul {display:flex;gap:.65rem 1.2rem;flex-wrap:wrap;margin:.6rem 0;padding:0;list-style:none}
.filter-popover {max-height:min(68svh,560px);overflow:auto;overscroll-behavior:contain}
.filter-popover legend { padding: 0 0 5px; font-weight: 700; }
.map-features { max-height: min(27svh,215px); overflow: auto; scrollbar-gutter: stable; }
.map-features .map-feature { display: flex; align-items: center; gap: 9px; min-height: 42px; color: var(--ink); cursor: pointer; }
.filter-done { justify-self: end; background: var(--pine-light); }
.map-feature input { flex-shrink: 0; }
.map-feature-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.feature-note { display: block; padding-top: 4px; color: var(--muted); font-size: .84rem; }
.map-tools input[type=checkbox] { min-height: 0; width: 19px; height: 19px; margin: 0; accent-color: #3c865e; }
.map-list-switch { flex: none; padding: 9px 14px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-size: .94rem; font-weight: 650; }
.taxonomy-chip { grid-column: 1/-1; justify-self: start; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--field); color: var(--ink); }
.map-card .schedule-badge, .map-popup .schedule-badge { font-size: .84rem; font-weight: 700; letter-spacing: .01em; }
.map-card .schedule-badge.open { color: #94d8ab; }
.map-popup .schedule-badge.open { color: #176239; }
.route-choice, #route-summary { grid-column: 1/-1; }
.map-tools [hidden] { display: none; }
#route-summary { margin: 0; color: var(--muted); line-height: 1.45; font-size: .93rem; }
.route-direction { display: grid; place-items: center; pointer-events: none; }
.route-chevron { width: 9px; height: 9px; border-top: 3px solid #fff; border-right: 3px solid #fff; filter: drop-shadow(0 0 1.5px #362238); }
.map-locate, .map-show, #more { background: var(--pine); border: 0; color: #fff; min-height: 44px; border-radius: 11px; padding: 10px 16px; font-weight: 650; }
.map-locate { align-self: end; background: var(--berry); }
.map-locate:disabled { opacity: .65; }
.map-results { grid-column: 2; border-left: 1px solid var(--border); grid-row: 2; overflow: auto; overscroll-behavior: contain; padding: 0 20px 16px; }
.map-results header { padding: 16px 0 10px; }
#summary, #list-notice, .map-card p, .map-popup p, .map-footer { color: var(--muted); font-size: .92rem; line-height: 1.5; }
#places, #places-more { list-style: none; padding: 0; margin: 0; }
.map-feed-ad { clear: both; width: 100%; }
.map-feed-ad[hidden] { display: none; }
.map-card { padding: 14px 0; border-top: 1px solid var(--border); }
.map-card-main { display: flex; gap: 12px; align-items: flex-start; }
.map-card img { width: 62px; height: 62px; border-radius: 10px; object-fit: cover; }
.map-card a, .map-popup a { font-weight: 700; }
.map-card p, .map-popup p { margin: 4px 0; overflow-wrap: anywhere; }
.map-show { background: none; color: var(--ink); padding: 5px 0; text-decoration: underline; min-height: 40px; }
.map-canvas-wrap { grid-column: 1; grid-row: 2; min-height: 0; position: relative; isolation: isolate; }
#map { width: 100%; height: 100%; background: #e6ebe3; color: #172e29; color-scheme: light; z-index: 0; font-family: inherit; }
.map-skip { position: absolute; left: 8px; top: 8px; z-index: 2; background: var(--surface); padding: 8px; }
.map-skip:not(:focus) { width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; white-space: nowrap; }
#map-notice { position: absolute; top: 8px; right: 8px; margin: 0; max-width: min(70%,330px); font-size: .94rem; background: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: 0 2px 8px #0002; z-index: 1; }
.map-pin, .map-cluster { color: #fff; background: var(--berry); border: 2px solid #fff; box-shadow: 0 1px 6px #0004; }
.map-pin { border-radius: 50% 50% 50% 3px; transform-origin: center; display: grid; place-items: center; font: 700 17px/1 'Segoe UI Symbol',sans-serif; }
.map-cluster { background: var(--pine); border-radius: 50%; display: grid; place-items: center; font: 700 15px/1 system-ui,sans-serif; }
.map-popup { max-width: 230px; line-height: 1.4; font: 1rem/1.4 'Segoe UI',sans-serif; }
.map-popup p { color: #45594e; }
.map-popup img { display: block; width: 100%; max-height: 110px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.leaflet-control-attribution { max-width: 100%; }
.map-footer { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; padding: 15px 0; }

.map-title { align-items: center; margin: 0 0 16px; }
.map-canvas-wrap { display: flex; flex-direction: column; }
#map { min-height: 0; flex: 1; }
.map-canvas-wrap .luli-marker-legend { flex: none; margin: 0; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.map-canvas-wrap .luli-marker-legend[hidden] { display: none; }
.map-card { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; }
.map-card a { text-decoration: none; }
.map-card-main { min-width: 0; gap: 10px; }
.map-card-main > div { min-width: 0; overflow-wrap: anywhere; }
.map-card .map-show { text-decoration: none; min-width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; display: grid; place-items: center; }
.map-card .map-show::before { content: ''; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 50%; background: radial-gradient(circle,currentColor 0 3px,transparent 3.5px); }
.map-card .schedule-badge.closed { color: #ffc3c6; }
.map-popup .schedule-badge.closed { color: #942f42; }
.map-layout:has(.feature-panel[open]) .map-tools { z-index: 4; }
#map .leaflet-control-zoom a { width: 40px; height: 40px; line-height: 40px; }
#map .leaflet-control-zoom { overflow: hidden; border: 0; border-radius: 10px; box-shadow: 0 2px 9px #162b3940; }
summary:focus-visible { outline: 3px solid #9bcaff; outline-offset: 2px; }
@media (max-width: 830px), (max-height: 500px) and (max-width: 1000px) {
    main { width: min(100% - 20px,720px); padding-top: 12px; }
    .map-title { margin-bottom: 10px; gap: 7px; }
    .map-title h1 { font-size: clamp(1.55rem,5.3vw,2.05rem); }
    .map-list-switch { padding: 7px 10px; font-size: .86rem; }
    .map-layout { display: flex; flex-direction: column; height: auto; border-radius: 14px; }
    .map-tools { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 7px; padding: 9px; }
    .map-search { grid-column: 1/3; max-width: none; }
    .map-locate { grid-column: 3; }
    .map-layer { grid-column: 1; max-width: none; min-width: 0; }
    .house-filters { grid-column: 2/4; justify-content: end; }
    .map-tools .route-choice, .map-tools .taxonomy-chip, #route-summary { grid-column: 1/-1; }
    .map-tools .route-choice { width: 100%; }
    .feature-panel summary,.map-tools .map-checkbox { padding-inline: 10px; font-size: .9rem; }
    .feature-panel { position: static; }
    .filter-popover { left: 8px; right: 8px; width: auto; }
    .map-canvas-wrap { height: clamp(290px,55svh,570px); }
    .map-canvas-wrap .luli-marker-legend { column-gap: 10px; row-gap: 4px; padding: 7px 9px; }
    .luli-marker-legend .luli-legend-item { gap: 4px; font-size: .77rem; }
    .map-results { overflow: visible; padding: 0 12px 12px; border: 0; border-top: 1px solid var(--border); }
    .map-card, .map-results header { padding-block: 12px; }
    #map .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; }
}
@media (max-width: 360px) {
    .map-tools .map-checkbox { padding-inline: 7px; }
}
@media (max-width:830px) {
    .map-tools:has(.house-filters[hidden]) .map-layer { grid-column: 1/-1; }
}
@media (max-width:360px) {
    .map-tools { padding: 7px; gap: 5px; }
    .map-layer select { padding-inline: 4px; }
    .house-filters { gap: 5px; }
    .feature-panel summary { padding-inline: 7px; }
}
@media (orientation:landscape) and (max-height:500px) and (max-width:1000px) {
    main { width: calc(100% - 16px); padding-top: 4px; }
    .map-title { margin-bottom: 4px; }
    .map-title h1 { font-size: 1.5rem; }
    .map-list-switch { padding-block: 4px; }
    .map-tools { display: flex; padding: 5px 8px; }
    .map-search { min-width: 120px; flex: 1 1 120px; }
    .map-layer { flex: 0 1 155px; }
    .map-canvas-wrap { height: max(230px,calc(100svh - 148px)); }
}
@media(prefers-reduced-motion:reduce) { *, *::after, *::before { scroll-behavior: auto!important; transition-duration: 0s!important; animation-duration: 0s!important; } }
