* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #E63946;
    --primary-dark: #B8202C;
    --gold: #F4A100;
    --dark: #1D1D2C;
    --darker: #14141F;
    --light: #F8F9FA;
    --glass: rgba(29, 29, 44, 0.9);
}
html, body { height: 100%; }
body { font-family: 'Source Sans Pro', sans-serif; background: var(--darker); color: var(--light); overflow: hidden; }
#map { width: 100%; height: 100vh; z-index: 1; }

.header { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; background: linear-gradient(180deg, #ffffffed, transparent 100%); padding: 20px 30px 40px; pointer-events: none; }
.header-content { display: flex; align-items: center; gap: 20px; pointer-events: auto; }
.logo-badge { width: 60px; height: 60px; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); border-radius: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4); flex-shrink: 0; }
.logo-badge svg { width: 32px; height: 32px; fill: white; }
.title-group h1 { font-family: 'Bebas Neue', sans-serif; font-size: 2.2rem; letter-spacing: 2px; color: rgba(29, 29, 44, 0.9); text-shadow: 0 2px 10px rgba(0,0,0,0.5); line-height: 1; }
.title-group .subtitle { font-size: 0.95rem; color: var(--gold); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

.info-panel { position: fixed; bottom: 30px; left: 30px; z-index: 1000; background: var(--glass); backdrop-filter: blur(20px); border-radius: 8px; padding: 24px; max-width: 340px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.info-panel h3 { font-family: 'Bebas Neue', sans-serif; font-size: 1.4rem; letter-spacing: 1px; margin-bottom: 0px; display: flex; align-items: center; gap: 10px; position: relative; padding-right: 35px; cursor: pointer; user-select: none; }
.info-panel h3::before { content: ''; width: 4px; height: 24px; background: var(--primary); border-radius: 2px; }
.info-panel h3 .toggle-icon { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 1.2rem; transition: transform 0.3s ease; color: var(--gold); }
.info-panel.collapsed h3 .toggle-icon { transform: translateY(-50%) rotate(-180deg); }
.info-panel-content { max-height: 1000px; overflow: hidden; transition: max-height 0.3s ease, opacity 0.3s ease; opacity: 1; margin-top: 12px; }
.info-panel.collapsed .info-panel-content { max-height: 0; opacity: 0; margin-top: 0; }
.intro-text { font-size: 0.85rem; color: rgba(255,255,255,0.8); line-height: 1.5; margin-bottom: 12px; }

.legend-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.85rem; }
.legend-line { width: 40px; height: 6px; background: var(--primary); border-radius: 3px; box-shadow: 0 0 10px rgba(230, 57, 70, 0.5); flex-shrink: 0; }
.legend-line.approssimato { background: transparent; height: 0; border-top: 3px dashed var(--gold); box-shadow: none; }

.stats { display: flex; gap: 16px; margin-top: 16px; }
.stat-box { flex: 1; background: rgba(255,255,255,0.05); border-radius: 10px; padding: 12px; text-align: center; }
.stat-number { font-family: 'Bebas Neue', sans-serif; font-size: 2rem; color: var(--gold); line-height: 1; }
.stat-label { font-size: 0.7rem; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

.circ-breakdown { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); }
.circ-breakdown-title { font-size: 0.75rem; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.circ-breakdown-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 0.82rem; }
.circ-breakdown-nome { flex: 1; color: rgba(255,255,255,0.85); }
.circ-breakdown-bar-wrap { flex: 1; height: 5px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.circ-breakdown-bar { height: 100%; background: var(--gold); border-radius: 3px; }
.circ-breakdown-vals { color: rgba(255,255,255,0.6); font-size: 0.75rem; white-space: nowrap; min-width: 78px; text-align: right; }

.source-info { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.8rem; color: rgba(255,255,255,0.7); }
.source-info a { color: var(--gold); text-decoration: none; transition: all 0.2s ease; }
.source-info a:hover { color: var(--primary); text-decoration: underline; }
.cronoprogramma-info { margin-top: 8px; color: rgba(255,255,255,0.55); font-style: italic; }
.cronoprogramma-info i { margin-right: 4px; }

.credits-section { margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); }
.credits-toggle { padding: 12px 0; cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; font-weight: 600; color: rgba(255,255,255,0.8); transition: color 0.2s ease; }
.credits-toggle:hover { color: var(--gold); }
.credits-icon { font-size: 0.7rem; transition: transform 0.3s ease; color: var(--gold); }
.credits-section.collapsed .credits-icon { transform: rotate(-180deg); }
.credits-content { max-height: 200px; overflow: hidden; transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease; opacity: 1; padding-top: 8px; }
.credits-section.collapsed .credits-content { max-height: 0; opacity: 0; padding-top: 0; }
.credits-content p { font-size: 0.8rem; color: rgba(255,255,255,0.7); line-height: 1.5; }
.credits-content a { color: var(--gold); text-decoration: none; }
.credits-content a:hover { color: var(--primary); text-decoration: underline; }

.map-controls { position: fixed; bottom: 30px; right: 30px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.control-btn { width: 42px; height: 42px; background: var(--glass); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; color: white; }
.control-btn:hover { background: var(--primary); transform: scale(1.05); }
.control-btn.active { background: var(--primary); }

.street-list-toggle { position: fixed; top: 100px; right: 30px; z-index: 1000; }
.toggle-btn { background: var(--glass); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 10px 20px; color: white; font-family: 'Source Sans Pro', sans-serif; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: all 0.3s ease; }
.toggle-btn:hover { background: var(--primary); }

.street-panel { position: fixed; top: 150px; right: 30px; bottom: 100px; width: 320px; background: var(--glass); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; z-index: 1100; overflow: hidden; display: none; }
.street-panel.active { display: block; }
.street-panel-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.street-panel-header h4 { font-family: 'Bebas Neue', sans-serif; font-size: 1.2rem; letter-spacing: 1px; }
.street-list { padding: 10px; height: calc(100% - 70px); overflow-y: auto; }
.street-list::-webkit-scrollbar { width: 6px; }
.street-list::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
.street-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.street-item { padding: 12px 14px; border-radius: 10px; cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.9rem; border-left: 4px solid var(--primary); }
.street-item:hover { background: rgba(255,255,255,0.1); }
.street-item.approssimato { border-left-color: var(--gold); }
.street-item-nome { flex: 1; }
.street-item-lunghezza { font-size: 0.75rem; color: var(--gold); opacity: 0.85; white-space: nowrap; }

.maplibregl-ctrl-top-right, .maplibregl-ctrl-top-left, .maplibregl-ctrl-bottom-left { display: none !important; }
.maplibregl-ctrl-bottom-right { z-index: 900 !important; }
.maplibregl-popup-content { background: var(--dark); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); color: white; font-family: 'Source Sans Pro', sans-serif; padding: 14px 18px; }
.maplibregl-popup-tip { border-top-color: var(--dark) !important; border-bottom-color: var(--dark) !important; }
.maplibregl-popup-close-button { color: rgba(255,255,255,0.6); font-size: 1.3rem; width: 26px; height: 26px; line-height: 26px; top: 6px; right: 6px; border-radius: 50%; transition: all 0.15s ease; }
.maplibregl-popup-close-button:hover { color: white; background: rgba(255,255,255,0.15); }
.popup-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
.popup-badge { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: #1a1a1a; background: var(--gold); padding: 3px 8px; border-radius: 5px; }
.popup-badge.approssimato { background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.85); }
.popup-tipo { font-size: 0.78rem; color: rgba(255,255,255,0.55); margin-top: 8px; }
.popup-lunghezza { font-size: 0.85rem; color: rgba(255,255,255,0.85); font-weight: 600; margin-top: 2px; }
.popup-territorio { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.12); display: flex; flex-direction: column; gap: 3px; }
.popup-territorio-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.76rem; color: rgba(255,255,255,0.75); }
.popup-territorio-label { color: rgba(255,255,255,0.45); }

@media (max-width: 768px) {
    .header { padding: 15px 20px 30px; }
    .logo-badge { width: 50px; height: 50px; }
    .title-group h1 { font-size: 1.6rem; }
    .info-panel { left: 15px; right: 15px; bottom: 40px; max-width: none; padding: 10px; }
    .info-panel.collapsed { padding-bottom: 10px; }
    .street-list-toggle { top: 90px; right: 15px; }
    .street-panel { left: 15px; right: 15px; top: 140px; bottom: 200px; width: auto; }
    .map-controls { bottom: auto; top: 90px; right: auto; left: 15px; flex-direction: row; }
}

@media (min-width: 769px) {
    .info-panel h3 { cursor: default; }
    .info-panel h3 .toggle-icon { display: none; }
}
