:root {
    --asd-verde-scuro: #123d2a;
    --asd-verde: #1f6b42;
    --asd-verde-chiaro: #36a264;
    --asd-blu: #1769e0;
    --asd-acqua: #e8f7f0;
    --asd-sabbia: #f6f0df;
    --asd-card: rgba(255, 255, 255, .88);
    --asd-bordo: rgba(27, 88, 55, .16);
    --asd-testo: #17251d;
    --asd-muted: #66756a;
    --asd-ombra: 0 24px 70px rgba(16, 49, 32, .18);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--asd-testo);
    background:
        radial-gradient(circle at 18% 0%, rgba(54, 162, 100, .22), transparent 32%),
        radial-gradient(circle at 88% 18%, rgba(23, 105, 224, .13), transparent 28%),
        linear-gradient(180deg, #f7f3e8 0%, #eef7f1 48%, #ffffff 100%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.map-app {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: calc(18px + var(--safe-top)) 12px calc(20px + var(--safe-bottom));
}

.map-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--asd-bordo);
    border-radius: 32px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(18,61,42,.98), rgba(31,107,66,.92));
    color: #fff;
    box-shadow: var(--asd-ombra);
}

.map-hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -80px;
    top: -82px;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
}

.hero-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.hero-badge, .hero-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 11px;
    font-weight: 800;
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.hero-badge { background: rgba(255,255,255,.16); }
.hero-pill { background: #fff; color: var(--asd-verde-scuro); }

.map-hero h1 {
    position: relative;
    z-index: 1;
    margin: 20px 0 8px;
    font-size: clamp(2rem, 8vw, 4.2rem);
    line-height: .96;
    letter-spacing: -.05em;
}

.map-hero p {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0;
    color: rgba(255,255,255,.83);
    font-size: 1.02rem;
    line-height: 1.45;
}

.hero-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.btn-primary, .btn-secondary, .btn-light {
    border: 0;
    border-radius: 999px;
    padding: 12px 16px;
    font-weight: 850;
    cursor: pointer;
    min-height: 46px;
}

.btn-primary {
    background: linear-gradient(135deg, #ffffff, #dff4e7);
    color: var(--asd-verde-scuro);
    box-shadow: 0 10px 22px rgba(0,0,0,.13);
}

.btn-secondary {
    background: rgba(255,255,255,.16);
    color: #fff;
    border: 1px solid rgba(255,255,255,.24);
}

.btn-light {
    background: #edf4ef;
    color: var(--asd-verde-scuro);
}

.map-stage {
    position: relative;
    margin-top: 14px;
}

.map-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.65);
    border-radius: 34px;
    padding: 10px;
    background: rgba(255,255,255,.72);
    box-shadow: var(--asd-ombra);
    backdrop-filter: blur(16px);
}

.map-toolbar {
    position: absolute;
    z-index: 700;
    right: 18px;
    top: 18px;
    display: grid;
    gap: 9px;
}

.tool-btn {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 16px;
    background: rgba(255,255,255,.94);
    color: var(--asd-verde-scuro);
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(19,55,37,.18);
}

.tool-btn-blue {
    color: #fff;
    background: linear-gradient(135deg, var(--asd-blu), #54a6ff);
}

.map-canvas {
    display: block;
    width: 100%;
    height: 72vh;
    max-height: 760px;
    min-height: 520px;
    background: #ddeade;
    overflow: hidden;
    isolation: isolate;
    position: relative;
}

@supports (height: min(72vh, 760px)) {
    .map-canvas { height: min(72vh, 760px); }
}

#mappaAsdIlLago,
#mappaAsdIlLago.leaflet-container {
    width: 100% !important;
    min-height: 520px;
}

.leaflet-container img,
.leaflet-container svg,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
    max-width: none !important;
    max-height: none !important;
}

.leaflet-container { background: #ddeade; }

.mappa-ovale {
    border-radius: 48% / 13%;
    border: 5px solid #fff;
    box-shadow: inset 0 0 0 1px rgba(31,91,56,.16);
}

.map-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px 2px;
    color: var(--asd-muted);
    font-size: .9rem;
}

.status-action {
    border: 0;
    background: transparent;
    color: var(--asd-verde);
    font-weight: 850;
    cursor: pointer;
}

.map-panel {
    position: fixed;
    z-index: 900;
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--safe-bottom));
    max-height: min(78vh, 640px);
    overflow: auto;
    transform: translateY(calc(100% + 30px));
    transition: transform .24s ease;
    border: 1px solid rgba(255,255,255,.62);
    border-radius: 30px;
    padding: 16px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 30px 90px rgba(16,49,32,.27);
    backdrop-filter: blur(18px);
}

.map-panel.is-open { transform: translateY(0); }

.panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 850;
    background: rgba(9,24,16,.34);
    backdrop-filter: blur(3px);
}

.panel-close, .modal-close {
    position: absolute;
    right: 14px;
    top: 12px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    background: #eef4ef;
    color: var(--asd-verde-scuro);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.panel-handle {
    width: 48px;
    height: 5px;
    border-radius: 999px;
    background: #d6e2d9;
    margin: 0 auto 14px;
}

.panel-kicker {
    margin: 0 0 3px;
    color: var(--asd-verde);
    font-size: .76rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-weight: 900;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.55rem;
    letter-spacing: -.03em;
    color: var(--asd-verde-scuro);
}

.panel-header p:last-child {
    margin: 6px 0 14px;
    color: var(--asd-muted);
}

.categorie-map {
    display: grid;
    gap: 10px;
}

.categoria-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid #e1eadf;
    border-radius: 18px;
    background: #fbfdfb;
    color: var(--asd-testo);
    cursor: pointer;
    user-select: none;
}

.categoria-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--asd-verde);
}

.categoria-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    flex: 0 0 14px;
    box-shadow: 0 0 0 4px rgba(31,107,66,.09);
}

.panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.panel-actions .btn-secondary {
    color: #fff;
    background: var(--asd-verde);
}

.privacy-note, .modal-small, .mappa-muted {
    color: var(--asd-muted);
    font-size: .88rem;
    line-height: 1.4;
}

.privacy-note {
    margin-top: 14px;
    padding: 12px;
    border-radius: 18px;
    background: #f2f7f3;
}

.leaflet-popup-content-wrapper {
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(16,49,32,.23);
}

.leaflet-popup-content { margin: 14px; }

.popup-mappa h3 {
    margin: 8px 0 6px;
    color: var(--asd-verde-scuro);
    font-size: 1.08rem;
}

.popup-mappa p { margin: 6px 0; line-height: 1.35; }

.popup-tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: .76rem;
    background: #eef7ef;
    color: var(--asd-verde);
    font-weight: 850;
}

.popup-img {
    display: block;
    width: 100%;
    max-height: 150px;
    object-fit: cover;
    border-radius: 15px;
    margin: 8px 0;
}

.popup-link {
    display: inline-block;
    margin-top: 8px;
    color: var(--asd-verde);
    font-weight: 850;
    text-decoration: none;
}

.marker-fallback {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 8px;
    transform: rotate(-45deg);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    border: 3px solid #fff;
    box-shadow: 0 8px 18px rgba(0,0,0,.28);
}

.marker-fallback span { transform: rotate(45deg); }

.user-marker {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #1769e0;
    border: 4px solid #fff;
    box-shadow: 0 0 0 7px rgba(23,105,224,.20), 0 12px 24px rgba(0,0,0,.22);
}

.user-marker::after {
    content: "";
    position: absolute;
    inset: -11px;
    border: 2px solid rgba(23,105,224,.32);
    border-radius: 999px;
    animation: pulseUser 1.7s infinite;
}

@keyframes pulseUser {
    from { transform: scale(.74); opacity: .9; }
    to { transform: scale(1.35); opacity: 0; }
}

.position-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: end center;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    background: rgba(9,24,16,.42);
    backdrop-filter: blur(4px);
}

.position-modal[hidden] { display: none; }

.position-modal-card {
    position: relative;
    width: min(520px, 100%);
    border-radius: 30px;
    padding: 22px;
    background: rgba(255,255,255,.97);
    box-shadow: 0 34px 100px rgba(9,24,16,.34);
}

.modal-icon {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--asd-blu), #54a6ff);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 12px;
}

.position-modal h2 {
    margin: 0 44px 8px 0;
    color: var(--asd-verde-scuro);
    font-size: 1.45rem;
    letter-spacing: -.03em;
}

.position-modal p { color: var(--asd-muted); line-height: 1.45; }

.field-label {
    display: block;
    margin: 14px 0 6px;
    font-size: .88rem;
    font-weight: 850;
    color: var(--asd-verde-scuro);
}

.field-input {
    width: 100%;
    min-height: 50px;
    border: 1px solid #d7e2da;
    border-radius: 16px;
    padding: 0 14px;
    outline: none;
    background: #fbfdfb;
}

.field-input:focus {
    border-color: var(--asd-verde-chiaro);
    box-shadow: 0 0 0 4px rgba(54,162,100,.14);
}

.modal-actions {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 10px;
    margin-top: 14px;
}

.modal-actions .btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--asd-verde), var(--asd-verde-chiaro));
}

@media (min-width: 900px) {
    .map-app { padding-inline: 24px; }
    .map-stage { display: grid; grid-template-columns: 1fr 330px; gap: 18px; align-items: start; }
    .map-panel {
        position: sticky;
        top: 18px;
        left: auto;
        right: auto;
        bottom: auto;
        max-height: calc(100vh - 36px);
        transform: none;
        grid-column: 2;
        grid-row: 1;
    }
    .map-card { grid-column: 1; grid-row: 1; }
    .panel-close, .panel-handle, .panel-backdrop { display: none !important; }
    .map-panel[aria-hidden="true"] { aria-hidden: false; }
    .position-modal { place-items: center; }
}

@media (max-width: 640px) {
    .map-app { padding-inline: 10px; }
    .map-hero { border-radius: 26px; padding: 18px; }
    .hero-topline { align-items: flex-start; }
    .hero-pill { display: none; }
    .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .btn-primary, .btn-secondary, .btn-light { padding-inline: 12px; }
    .map-card { border-radius: 28px; padding: 7px; }
    .map-canvas,
    #mappaAsdIlLago,
    #mappaAsdIlLago.leaflet-container {
        height: 67vh;
        min-height: 470px;
    }
    .mappa-ovale { border-radius: 34px; border-width: 4px; }
    .map-toolbar { right: 16px; top: 16px; }
    .tool-btn { width: 44px; height: 44px; border-radius: 15px; }
    .map-statusbar { font-size: .82rem; }
    .modal-actions, .panel-actions { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
    .map-canvas,
    #mappaAsdIlLago,
    #mappaAsdIlLago.leaflet-container { min-height: 430px; height: 64vh; }
    .map-hero h1 { font-size: 2rem; }
}

/* ==========================================================
   HOTFIX 4.2 - Protezione completa Leaflet
   Alcuni temi/CSS del sito impostano img { width:100% !important; height:auto; }
   oppure impediscono il corretto posizionamento dei tile Leaflet.
   Queste regole ripristinano la griglia cartografica.
   ========================================================== */
#mappaAsdIlLago.leaflet-container {
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
    background: #ddeade !important;
    font: inherit;
}

#mappaAsdIlLago .leaflet-pane,
#mappaAsdIlLago .leaflet-map-pane,
#mappaAsdIlLago .leaflet-tile-pane,
#mappaAsdIlLago .leaflet-overlay-pane,
#mappaAsdIlLago .leaflet-shadow-pane,
#mappaAsdIlLago .leaflet-marker-pane,
#mappaAsdIlLago .leaflet-tooltip-pane,
#mappaAsdIlLago .leaflet-popup-pane,
#mappaAsdIlLago .leaflet-tile-container,
#mappaAsdIlLago .leaflet-layer,
#mappaAsdIlLago .leaflet-zoom-box,
#mappaAsdIlLago .leaflet-image-layer,
#mappaAsdIlLago .leaflet-pane > svg,
#mappaAsdIlLago .leaflet-pane > canvas {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
}

#mappaAsdIlLago .leaflet-pane { z-index: 400; }
#mappaAsdIlLago .leaflet-tile-pane { z-index: 200; }
#mappaAsdIlLago .leaflet-overlay-pane { z-index: 400; }
#mappaAsdIlLago .leaflet-shadow-pane { z-index: 500; }
#mappaAsdIlLago .leaflet-marker-pane { z-index: 600; }
#mappaAsdIlLago .leaflet-tooltip-pane { z-index: 650; }
#mappaAsdIlLago .leaflet-popup-pane { z-index: 700; }

#mappaAsdIlLago .leaflet-tile,
#mappaAsdIlLago img.leaflet-tile {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    display: block !important;
    width: 256px !important;
    height: 256px !important;
    min-width: 256px !important;
    min-height: 256px !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: initial !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    transform-origin: 0 0 !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}

#mappaAsdIlLago .leaflet-tile-loaded {
    visibility: inherit !important;
}

#mappaAsdIlLago .leaflet-marker-icon,
#mappaAsdIlLago .leaflet-marker-shadow {
    position: absolute !important;
    display: block !important;
    max-width: none !important;
    max-height: none !important;
    width: auto;
    height: auto;
    border-radius: 0;
}

#mappaAsdIlLago .leaflet-control-container .leaflet-top,
#mappaAsdIlLago .leaflet-control-container .leaflet-bottom {
    position: absolute !important;
    z-index: 1000 !important;
    pointer-events: none;
}

#mappaAsdIlLago .leaflet-top { top: 0; }
#mappaAsdIlLago .leaflet-bottom { bottom: 0; }
#mappaAsdIlLago .leaflet-left { left: 0; }
#mappaAsdIlLago .leaflet-right { right: 0; }

#mappaAsdIlLago .leaflet-control {
    position: relative !important;
    z-index: 1000 !important;
    pointer-events: auto;
    float: left;
    clear: both;
}

#mappaAsdIlLago .leaflet-right .leaflet-control { float: right; }
#mappaAsdIlLago .leaflet-top .leaflet-control { margin-top: 10px; }
#mappaAsdIlLago .leaflet-bottom .leaflet-control { margin-bottom: 10px; }
#mappaAsdIlLago .leaflet-left .leaflet-control { margin-left: 10px; }
#mappaAsdIlLago .leaflet-right .leaflet-control { margin-right: 10px; }

#mappaAsdIlLago .leaflet-popup {
    position: absolute !important;
    text-align: center;
    margin-bottom: 20px;
}

#mappaAsdIlLago .leaflet-popup-content-wrapper,
#mappaAsdIlLago .leaflet-popup-tip {
    background: white;
}

#mappaAsdIlLago .leaflet-interactive {
    cursor: pointer;
}

/* ==========================================================
   STEP 4.3 - Selettore vista mappa + avatar posizione utente
   ========================================================== */
.basemap-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0 18px;
}

.basemap-btn {
    min-height: 58px;
    border: 1px solid #dfe9e1;
    border-radius: 20px;
    background: #fbfdfb;
    color: var(--asd-verde-scuro);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(16,49,32,.05);
}

.basemap-btn.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--asd-verde), var(--asd-verde-chiaro));
    border-color: rgba(31,107,66,.28);
}

.basemap-ico {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255,255,255,.34);
    font-weight: 900;
}

.panel-header-small {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #edf3ee;
}

.avatar-choice {
    border: 0;
    padding: 0;
    margin: 14px 0 0;
}

.avatar-choice legend {
    padding: 0;
    margin: 0 0 8px;
    font-size: .88rem;
    font-weight: 850;
    color: var(--asd-verde-scuro);
}

.avatar-choice {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.avatar-choice legend {
    grid-column: 1 / -1;
}

.avatar-option {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 10px 6px;
    border: 1px solid #dfe9e1;
    border-radius: 18px;
    background: #fbfdfb;
    cursor: pointer;
    color: var(--asd-verde-scuro);
    font-weight: 800;
    font-size: .86rem;
    user-select: none;
}

.avatar-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.avatar-option:has(input:checked) {
    border-color: rgba(31,107,66,.42);
    background: #eef8f1;
    box-shadow: inset 0 0 0 2px rgba(31,107,66,.08);
}

.avatar-preview {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    font-size: 1.45rem;
    background: #eef4ef;
    box-shadow: 0 8px 18px rgba(16,49,32,.10);
}

.avatar-preview-man { background: #e9f2ff; }
.avatar-preview-woman { background: #fff0f5; }
.avatar-preview-neutral { background: #eef4ef; }

.user-avatar-marker {
    position: relative;
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 999px 999px 999px 18px;
    transform: rotate(-45deg);
    border: 4px solid #fff;
    box-shadow: 0 0 0 7px rgba(23,105,224,.18), 0 14px 28px rgba(0,0,0,.26);
    background: linear-gradient(135deg, #1769e0, #54a6ff);
}

.user-avatar-marker.is-man {
    background: linear-gradient(135deg, #1769e0, #66b3ff);
}

.user-avatar-marker.is-woman {
    background: linear-gradient(135deg, #c2185b, #ff78aa);
    box-shadow: 0 0 0 7px rgba(194,24,91,.18), 0 14px 28px rgba(0,0,0,.26);
}

.user-avatar-marker.is-neutral {
    background: linear-gradient(135deg, #3f7d58, #6fc28a);
    box-shadow: 0 0 0 7px rgba(63,125,88,.18), 0 14px 28px rgba(0,0,0,.26);
}

.user-avatar-marker::after {
    content: "";
    position: absolute;
    inset: -12px;
    border: 2px solid rgba(23,105,224,.30);
    border-radius: 999px;
    animation: pulseUser 1.7s infinite;
}

.user-avatar-marker.is-woman::after {
    border-color: rgba(194,24,91,.30);
}

.user-avatar-marker.is-neutral::after {
    border-color: rgba(63,125,88,.30);
}

.user-avatar-emoji {
    transform: rotate(45deg);
    font-size: 1.8rem;
    line-height: 1;
    z-index: 2;
}

.user-avatar-name {
    position: absolute;
    left: 50%;
    bottom: -28px;
    transform: translateX(-50%) rotate(45deg);
    white-space: nowrap;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.96);
    color: var(--asd-verde-scuro);
    font-size: .74rem;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(0,0,0,.16);
    z-index: 3;
}

@media (max-width: 420px) {
    .avatar-choice {
        grid-template-columns: 1fr;
    }
    .avatar-option {
        grid-template-columns: auto 1fr;
        justify-items: start;
        padding-inline: 12px;
    }
    .basemap-switch {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================
   STEP 4.4 - Modalità Esplora / Arcade sportivo outdoor
   - Arcade: omino fisso al centro e mappa navigabile intorno
   - Esplora: omino-marker classico sulla mappa
   ========================================================== */
.btn-outdoor,
.tool-btn-outdoor {
    background: linear-gradient(135deg, #273f28, #7b5e29) !important;
    color: #fff !important;
    border-color: rgba(255,255,255,.25) !important;
}

.modal-secondary {
    color: #fff !important;
    background: linear-gradient(135deg, #7b5e29, #b88735) !important;
    border: 0 !important;
}

.mode-choice {
    border: 0;
    padding: 0;
    margin: 16px 0 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.mode-choice legend {
    grid-column: 1 / -1;
    padding: 0;
    margin: 0 0 2px;
    font-size: .88rem;
    font-weight: 850;
    color: var(--asd-verde-scuro);
}

.mode-option {
    position: relative;
    display: grid;
    gap: 4px;
    border: 1px solid #dfe9e1;
    border-radius: 18px;
    padding: 12px;
    background: #fbfdfb;
    color: var(--asd-verde-scuro);
    cursor: pointer;
}

.mode-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-option:has(input:checked) {
    border-color: rgba(123,94,41,.42);
    background: #fff8e9;
    box-shadow: inset 0 0 0 2px rgba(123,94,41,.10);
}

.mode-option-title {
    font-weight: 950;
    letter-spacing: -.02em;
}

.mode-option-text {
    font-size: .78rem;
    line-height: 1.25;
    color: var(--asd-muted);
}

.modal-actions-3 {
    grid-template-columns: 1.1fr 1fr .75fr;
}

.arcade-avatar-overlay {
    position: absolute;
    z-index: 820;
    left: 50%;
    top: 53%;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    pointer-events: none;
}

.arcade-avatar-overlay[hidden] {
    display: none;
}

.arcade-avatar-glow {
    position: absolute;
    width: 112px;
    height: 112px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255,255,255,.68) 0%, rgba(54,162,100,.20) 44%, rgba(54,162,100,0) 72%);
    animation: arcadePulse 1.8s infinite ease-out;
}

.arcade-avatar-pin {
    position: relative;
    z-index: 2;
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    border: 5px solid #fff;
    border-radius: 999px 999px 999px 22px;
    transform: rotate(-45deg);
    font-size: 2.15rem;
    background: linear-gradient(135deg, #3f7d58, #6fc28a);
    box-shadow: 0 18px 32px rgba(0,0,0,.30), 0 0 0 9px rgba(63,125,88,.18);
}

.arcade-avatar-overlay .arcade-avatar-pin {
    line-height: 1;
    text-align: center;
}

.arcade-avatar-overlay .arcade-avatar-pin span {
    display: block;
    transform: rotate(45deg);
}

.arcade-avatar-overlay.is-man .arcade-avatar-pin {
    background: linear-gradient(135deg, #1769e0, #66b3ff);
    box-shadow: 0 18px 32px rgba(0,0,0,.30), 0 0 0 9px rgba(23,105,224,.18);
}

.arcade-avatar-overlay.is-woman .arcade-avatar-pin {
    background: linear-gradient(135deg, #c2185b, #ff78aa);
    box-shadow: 0 18px 32px rgba(0,0,0,.30), 0 0 0 9px rgba(194,24,91,.18);
}

.arcade-avatar-name {
    position: absolute;
    top: calc(50% + 42px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(255,255,255,.96);
    color: var(--asd-verde-scuro);
    font-size: .82rem;
    font-weight: 950;
    box-shadow: 0 12px 24px rgba(0,0,0,.18);
}

.explore-controls {
    position: absolute;
    z-index: 830;
    left: 50%;
    bottom: 58px;
    transform: translateX(-50%);
    display: flex;
    gap: 7px;
    padding: 7px;
    border-radius: 999px;
    background: rgba(255,255,255,.88);
    box-shadow: 0 18px 38px rgba(16,49,32,.22);
    backdrop-filter: blur(14px);
}

.explore-controls[hidden] {
    display: none;
}

.explore-chip {
    min-height: 38px;
    border: 0;
    border-radius: 999px;
    padding: 8px 12px;
    background: #edf4ef;
    color: var(--asd-verde-scuro);
    font-size: .84rem;
    font-weight: 950;
    cursor: pointer;
}

.explore-chip.is-active {
    color: #fff;
    background: linear-gradient(135deg, #273f28, #7b5e29);
}

.explore-chip-exit {
    background: #fff0f0;
    color: #a11d1d;
}

.map-app.is-game-mode .map-card {
    background:
        radial-gradient(circle at 50% 45%, rgba(255,255,255,.85), rgba(246,240,223,.78) 48%, rgba(18,61,42,.16) 100%);
    border-color: rgba(255,255,255,.80);
}

.map-app.is-game-mode .map-statusbar {
    font-weight: 800;
}

@keyframes arcadePulse {
    0% { transform: scale(.78); opacity: .9; }
    100% { transform: scale(1.18); opacity: 0; }
}

@media (max-width: 768px) {
    .map-app.is-game-mode {
        padding-top: calc(8px + var(--safe-top));
    }

    .map-app.is-game-mode .map-hero {
        border-radius: 24px;
        padding: 14px 16px;
        margin-bottom: 10px;
    }

    .map-app.is-game-mode .map-hero h1 {
        font-size: 1.48rem;
    }

    .map-app.is-game-mode .map-hero p,
    .map-app.is-game-mode .hero-topline {
        display: none;
    }

    .map-app.is-game-mode .hero-actions {
        margin-top: 10px;
    }

    .map-app.is-game-mode .map-card {
        border-radius: 999px 999px 44px 44px;
        padding: 9px;
    }

    .map-app.is-game-mode .map-canvas,
    .map-app.is-game-mode #mappaAsdIlLago,
    .map-app.is-game-mode #mappaAsdIlLago.leaflet-container {
        height: min(94vw, 620px) !important;
        min-height: min(94vw, 620px) !important;
        aspect-ratio: 1 / 1;
        border-radius: 50% !important;
        border-width: 6px;
        box-shadow: inset 0 0 0 2px rgba(255,255,255,.74), 0 22px 58px rgba(16,49,32,.20);
    }

    .map-app.is-game-mode .map-toolbar {
        right: 18px;
        top: 18px;
        transform: scale(.92);
        transform-origin: top right;
    }

    .map-app.is-game-mode .leaflet-control-zoom {
        transform: scale(.88);
        transform-origin: bottom right;
    }

    .arcade-avatar-overlay {
        top: 48%;
    }

    .explore-controls {
        bottom: 50px;
        max-width: calc(100vw - 32px);
    }

    .explore-chip {
        padding-inline: 10px;
    }
}

@media (max-width: 520px) {
    .modal-actions-3,
    .mode-choice {
        grid-template-columns: 1fr;
    }

    .map-app.is-game-mode .map-canvas,
    .map-app.is-game-mode #mappaAsdIlLago,
    .map-app.is-game-mode #mappaAsdIlLago.leaflet-container {
        height: calc(100vw - 22px) !important;
        min-height: calc(100vw - 22px) !important;
    }

    .arcade-avatar-pin {
        width: 66px;
        height: 66px;
        font-size: 2rem;
    }
}

/* ==========================================================
   STEP 4.5 - Omini utenti condivisi in tempo quasi reale
   ========================================================== */
.user-avatar-marker.other-user-avatar {
    width: 48px;
    height: 48px;
    border-width: 3px;
    box-shadow: 0 0 0 5px rgba(18,61,42,.14), 0 10px 24px rgba(0,0,0,.22);
    opacity: .94;
}

.user-avatar-marker.other-user-avatar .user-avatar-emoji {
    font-size: 1.48rem;
}

.user-avatar-marker.other-user-avatar .user-avatar-name {
    bottom: -24px;
    font-size: .68rem;
    padding: 3px 7px;
    max-width: 96px;
}

.user-avatar-marker.other-user-avatar::after {
    animation-duration: 2.4s;
    opacity: .7;
}

/* ==========================================================
   STEP 4.6 - HOTFIX popup Modalità Esplora su smartphone
   - Il popup diventa scrollabile anche su schermi piccoli
   - Pulsanti sempre raggiungibili
   - Contenuti più compatti in verticale
   ========================================================== */
.position-modal {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.position-modal-card {
    max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@supports not (height: 100dvh) {
    .position-modal-card {
        max-height: calc(100vh - 32px - var(--safe-top) - var(--safe-bottom));
    }
}

.position-modal-card::-webkit-scrollbar {
    width: 7px;
}

.position-modal-card::-webkit-scrollbar-thumb {
    background: rgba(39,63,40,.25);
    border-radius: 999px;
}

.position-modal .modal-actions {
    position: sticky;
    bottom: -1px;
    z-index: 5;
    padding-top: 12px;
    padding-bottom: 2px;
    background: linear-gradient(to top, rgba(255,255,255,1) 0%, rgba(255,255,255,.96) 72%, rgba(255,255,255,0) 100%);
}

@media (max-width: 640px) {
    .position-modal {
        place-items: start center;
        padding: calc(10px + var(--safe-top)) 10px calc(10px + var(--safe-bottom));
    }

    .position-modal-card {
        width: 100%;
        border-radius: 24px;
        padding: 16px;
        max-height: calc(100dvh - 20px - var(--safe-top) - var(--safe-bottom));
    }

    .modal-icon {
        width: 42px;
        height: 42px;
        border-radius: 14px;
        font-size: 1.2rem;
        margin-bottom: 8px;
    }

    .position-modal h2 {
        font-size: 1.22rem;
        margin-bottom: 5px;
    }

    .position-modal p {
        margin: 6px 0;
        font-size: .86rem;
        line-height: 1.30;
    }

    .field-label {
        margin: 9px 0 5px;
    }

    .field-input {
        min-height: 44px;
        border-radius: 14px;
    }

    .avatar-choice,
    .mode-choice {
        gap: 7px;
        margin-top: 10px;
    }

    .avatar-option,
    .mode-option {
        border-radius: 15px;
        padding: 9px 10px;
    }

    .avatar-preview {
        width: 34px;
        height: 34px;
        font-size: 1.1rem;
    }

    .mode-option-text {
        font-size: .74rem;
    }

    .modal-small {
        font-size: .76rem !important;
        line-height: 1.25 !important;
    }
}

@media (max-width: 430px) {
    .position-modal-card {
        padding: 14px;
        border-radius: 22px;
    }

    .position-modal > .position-modal-card > p:first-of-type {
        display: none;
    }

    .avatar-choice {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .avatar-option {
        display: grid;
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 4px;
        font-size: .78rem;
    }

    .mode-choice {
        grid-template-columns: 1fr 1fr;
    }

    .mode-option {
        padding: 9px;
    }

    .mode-option-title {
        font-size: .9rem;
    }

    .mode-option-text {
        display: none;
    }

    .modal-actions-3 {
        grid-template-columns: 1fr 1fr;
    }

    .modal-actions-3 #btnAttivaPosizione {
        grid-column: 1 / -1;
    }

    .modal-actions-3 button {
        min-height: 44px;
        padding: 10px 9px;
        font-size: .86rem;
    }
}

@media (max-height: 700px) {
    .position-modal > .position-modal-card > p:first-of-type,
    .position-modal .modal-small {
        display: none;
    }

    .position-modal-card {
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

/* STEP 5 - Icone personalizzate punti di interesse */
.categoria-icon {
    width: 24px;
    height: 28px;
    object-fit: contain;
    flex: 0 0 auto;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,.18));
}
.poi-svg-icon {
    filter: drop-shadow(0 8px 14px rgba(0,0,0,.30));
    z-index: 650 !important;
}
.popup-mappa .popup-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
@media (max-width: 640px) {
    .categoria-icon {
        width: 22px;
        height: 26px;
    }
    .poi-svg-icon {
        filter: drop-shadow(0 7px 12px rgba(0,0,0,.32));
    }
}

/* STEP 7.2 - Interazione tracciati / accesso link dedicato */
#mappaAsdIlLago .asd-map-hit-line {
    cursor: pointer !important;
    pointer-events: stroke !important;
}
#mappaAsdIlLago .leaflet-overlay-pane path.leaflet-interactive {
    pointer-events: visiblePainted !important;
    cursor: pointer !important;
}
#mappaAsdIlLago .asd-map-track-marker {
    display: grid !important;
    place-items: center;
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    color: #145332 !important;
    border: 2px solid #145332 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    font-size: 19px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer !important;
}
#mappaAsdIlLago .asd-map-track-tooltip {
    background: #ffffff;
    color: #145332;
    border: 1px solid #c6dece;
    border-radius: 9px;
    box-shadow: 0 5px 18px rgba(0,0,0,.16);
    padding: 5px 9px;
    font-weight: 700;
}

#mappaAsdIlLago .leaflet-overlay-pane path.asd-map-hit-line {
    pointer-events: stroke !important;
    cursor: pointer !important;
}
