:root {
    --inv-scale: 1;
}

@font-face {
    font-family: 'HelveticaMap';
    src: url('../Helvetica.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}
@font-face {
    font-family: 'HelveticaMap-Bold';
    src: url('../Helvetica-Bold.ttf') format('truetype');
    font-weight: bold; font-style: normal;
}

body { 
    margin: 0; padding: 0; background-color: #E6E6E6; overflow: hidden; font-family: sans-serif; 
    touch-action: none; -webkit-touch-callout: none; 
}

#viewport { width: 100vw; height: 100vh; background-color: #E6E6E6; overflow: hidden; position: relative; cursor: grab; transition: border 0.3s; box-sizing: border-box; }
#viewport.edit-mode { border: 5px solid #e74c3c; cursor: crosshair; }
#viewport.notes-mode { border: 5px solid #f39c12; cursor: crosshair; }

#map-container { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }

/* --- DLAŽDICE A PLYNULÉ PROLÍNÁNÍ --- */
.tile { 
    position: absolute; 
    width: 170px; 
    height: 170px; 
    display: block;
    user-select: none; -webkit-user-drag: none; background-color: transparent; 
    opacity: 0; 
    transition: opacity 0.5s ease-in-out; 
    will-change: opacity; 
}
.tile.tile-loaded {
    opacity: 1; 
}

.debug-label { position: absolute; width: 170px; height: 170px; display: flex; justify-content: center; align-items: center; color: rgba(255, 255, 255, 0.9); font-size: 15px; font-weight: bold; text-shadow: 1px 1px 3px #000, -1px -1px 3px #000, 1px -1px 3px #000, -1px 1px 3px #000; border: 1px dashed rgba(255, 255, 255, 0.4); box-sizing: border-box; pointer-events: none; z-index: 4; display: none; }

/* ========================================= */
/* IKONY, ŠPENDLÍK A ŽIVÍ HRÁČI */
/* ========================================= */
.custom-marker { 
    position: absolute; width: 30px; height: 30px; 
    transform: translate(calc(-50% + var(--ox, 0px)), calc(-50% + var(--oy, 0px))) scale(var(--inv-scale)); 
    cursor: pointer; z-index: 10; display: flex; justify-content: center; align-items: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
}

.custom-marker::before {
    content: ''; position: absolute; width: 100%; height: 100%;
    background: #e74c3c; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    opacity: 0; transition: opacity 0.2s, transform 0.2s; z-index: -1;
    box-shadow: 2px -2px 10px rgba(0,0,0,0.4); 
    border: 2px solid #fff; box-sizing: border-box;
}

.custom-marker img { 
    width: 100%; height: 100%; object-fit: contain; z-index: 1; user-select: none; -webkit-user-drag: none;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.6)); 
    transition: all 0.2s ease; 
}

.custom-marker:hover { transform: translate(calc(-50% + var(--ox, 0px)), calc(-50% + var(--oy, 0px))) scale(calc(var(--inv-scale) * 1.2)); z-index: 20; }

.custom-marker.active-marker {
    transform: translate(calc(-50% + var(--ox, 0px)), calc(-100% + 5px + var(--oy, 0px))) scale(calc(var(--inv-scale) * 1.4));
    z-index: 30;
}
.custom-marker.active-marker::before { opacity: 1; transform: translateY(-12%) rotate(-45deg); }
.custom-marker.active-marker img { width: 70%; height: 70%; filter: none; transform: translateY(-12%); }

.live-player-marker {
    position: absolute; width: 38px; height: 38px;
    transform: translate(-50%, -50%) scale(var(--inv-scale));
    z-index: 7; 
    pointer-events: auto; 
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    transition: left 2s linear, top 2s linear, transform 0.2s ease-out;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.6)); 
}

.live-player-marker svg { width: 100%; height: 100%; display: block; }

/* ========================================= */
/* TEXTY MĚST A POZNÁMKY */
/* ========================================= */
.map-label {
    position: absolute; 
    color: #2c3e50; 
    /* OPRAVA: Místo hrubých 2px posunů používáme jemný 1px obrys a krásný měkký glow */
    text-shadow: 
        -1px -1px 0 #fff,  
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff,
         0 0 5px #fff,
         0 0 10px rgba(255,255,255,0.9);
    pointer-events: none; 
    z-index: 8; 
    white-space: nowrap; 
    user-select: none;
    transition: transform 0.2s ease-out; 
    -webkit-font-smoothing: antialiased;
}
.label-large { font-family: 'HelveticaMap-Bold', sans-serif; font-size: 24px; text-transform: uppercase; letter-spacing: 2px; }
.label-small { font-family: 'HelveticaMap', sans-serif; font-size: 14px; }

.map-note {
    position: absolute; width: 34px; height: 34px;
    pointer-events: auto; z-index: 12; cursor: pointer;
    transition: transform 0.2s ease-out;
    display: none; 
}
.map-note img {
    width: 100%; height: 100%; display: block;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.6)); 
    transition: transform 0.2s ease;
}
.map-note:hover img { transform: scale(1.15); }

#routes-layer { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 5; }
.map-curve { pointer-events: stroke; cursor: pointer; transition: stroke-width 0.2s; }
.map-curve:hover { stroke-width: 12px !important; }

/* ========================================= */
/* UI PRVKY (INFO PANEL, MENU, ZOOM) */
/* ========================================= */
#map-info {
    position: absolute; bottom: 20px; left: 20px;
    background: rgba(255, 255, 255, 0.95); padding: 12px 18px; border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25); 
    font-size: 13px; color: #2c3e50;
    z-index: 2000; pointer-events: none; line-height: 1.6; border: 1px solid #ddd;
}

#map-settings-dropdown { position: absolute; top: 20px; left: 20px; z-index: 2000; }
#btn-map-settings { 
    background: #fff; color: #2c3e50; border: 1px solid #ddd; padding: 10px 16px; border-radius: 8px; 
    box-shadow: 0 2px 12px rgba(0,0,0,0.25); 
    font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 14px; transition: background 0.2s; 
}
#btn-map-settings:hover { background: #f9f9f9; }
#btn-map-settings svg { width: 18px; height: 18px; fill: #27ae60; }

#map-settings-content { 
    display: none; background: #fff; border-radius: 8px; 
    box-shadow: 0 4px 25px rgba(0,0,0,0.3); 
    margin-top: 10px; padding: 20px; width: 260px; max-height: calc(100vh - 100px); overflow-y: auto; box-sizing: border-box;
}
#map-settings-content.open { display: block; }

#zoom-controls-floating { 
    position: absolute; top: 20px; right: 20px; background: #fff; border-radius: 8px; 
    box-shadow: 0 2px 12px rgba(0,0,0,0.25); 
    display: flex; flex-direction: column; z-index: 2000; overflow: hidden; border: 1px solid #ddd;
}
#zoom-controls-floating button { 
    background: transparent; border: none; font-size: 22px; font-weight: bold; width: 44px; height: 44px; 
    cursor: pointer; color: #555; transition: background 0.2s; display: flex; align-items: center; justify-content: center;
}
#zoom-controls-floating button:hover { background: #f0f0f0; color: #000; }
.zoom-divider { height: 1px; background: #eee; width: 100%; }

#poi-side-panel { 
    position: absolute; top: 0; right: 0; height: 100vh; width: 360px; max-width: 85vw; 
    background: rgba(255, 255, 255, 0.98); 
    box-shadow: -4px 0 25px rgba(0,0,0,0.25); 
    z-index: 2000; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); display: flex; flex-direction: column;
}
#poi-side-panel.open { transform: translateX(0); }
.panel-content { width: 100%; height: 100%; padding: 25px; overflow-y: auto; box-sizing: border-box; position: relative; }

#layers-title { margin: 0 0 15px 0; font-size: 16px; color: #333; }
.layer-item { margin-bottom: 12px; display: flex; align-items: center; cursor: pointer; font-size: 14px; }
.layer-item input { margin-right: 10px; cursor: pointer; transform: scale(1.2); }
.menu-divider { border: 0; border-top: 1px solid #eee; margin: 18px 0; }
.tool-title { font-size: 12px; text-transform: uppercase; color: #888; margin-bottom: 12px; font-weight: bold; }

.btn-edit { background: #34495e; color: white; border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; width: 100%; font-size: 13px; font-weight: bold; transition: background 0.2s; margin-bottom: 5px;}
.btn-edit:hover { background: #2c3e50; }
.btn-edit.active { background: #e74c3c; }
.btn-edit.active:hover { background: #c0392b; }

#editor-tools { display: none; background: #f9f9f9; border: 1px solid #eee; padding: 12px; border-radius: 6px; margin-top: 10px; font-size: 13px; }
#editor-tools label { display: block; margin-bottom: 8px; cursor: pointer; }
#btn-finish-curve { background: #27ae60; color: white; border: none; padding: 8px; width: 100%; border-radius: 6px; cursor: pointer; font-weight: bold; margin-top: 5px; display: none; }
#btn-finish-curve:hover { background: #2ecc71; }

#btn-close-poi { 
    background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 8px 15px; 
    cursor: pointer; margin-bottom: 25px; font-weight: bold; color: #555; 
    font-size: 13px; transition: background 0.2s; display: inline-flex; align-items: center; gap: 5px;
}
#btn-close-poi:hover { background: #f0f0f0; color: #000;}

.poi-title-icon { width: 32px !important; height: 32px !important; margin: 0 !important; box-shadow: none !important; border-radius: 0 !important; object-fit: contain; }

#poi-details h2 { margin: 0; color: #2c3e50; font-size: 22px; line-height: 1.2; }
#poi-details p { color: #555; line-height: 1.6; font-size: 15px; margin-bottom: 15px; }
#poi-details a { color: #3498db; text-decoration: none; font-weight: bold; }
#poi-details a:hover { text-decoration: underline; color: #2980b9; }
#poi-details img { max-width: 100%; height: auto; border-radius: 6px; margin-top: 5px; display: block; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
#poi-details iframe { width: 100%; max-width: 100%; border: none; border-radius: 6px; margin-top: 10px; display: block; background: #f9f9f9; }

#custom-tooltip { 
    position: absolute; background: rgba(30, 30, 30, 0.95); color: #fff; padding: 6px 12px; border-radius: 6px; 
    pointer-events: none; display: none; z-index: 2000; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.4); 
    border: 1px solid #555; white-space: nowrap; 
}
#custom-tooltip h4 { margin: 0; font-size: 13px; font-weight: normal; }

#output-panel { 
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); width: 80%; max-width: 800px; 
    background: #222; border-radius: 8px; 
    box-shadow: 0 10px 35px rgba(0,0,0,0.6); 
    z-index: 3000; display: none; padding: 15px; flex-direction: column; 
}
#output-panel h3 { margin: 0 0 10px 0; color: #fff; font-size: 14px; }
#output-panel textarea { width: 100%; height: 150px; background: #111; color: #0f0; border: 1px solid #444; padding: 10px; font-family: monospace; font-size: 13px; box-sizing: border-box; resize: vertical; outline: none; }

#image-modal {
    display: none; position: fixed; z-index: 5000; left: 0; top: 0; width: 100vw; height: 100vh;
    background-color: rgba(0,0,0,0.85); align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease; backdrop-filter: blur(4px);
}
#image-modal.open { display: flex; opacity: 1; }
#image-modal-img { 
    max-width: 90vw; max-height: 90vh; border-radius: 4px; 
    box-shadow: 0 5px 30px rgba(0,0,0,0.6); 
    transform: scale(0.95); transition: transform 0.3s ease; 
}
#image-modal.open #image-modal-img { transform: scale(1); }
#image-modal-close { 
    position: absolute; top: 20px; right: 30px; color: #fff; font-size: 40px; 
    font-weight: bold; cursor: pointer; z-index: 5001; user-select: none;
}
#image-modal-close:hover { color: #ccc; }

@media (prefers-color-scheme: dark) {
    body, #viewport { background-color: #121212; }
    
    .tile { filter: invert(90%) hue-rotate(180deg) brightness(95%) contrast(105%); }
    .tile-contour { filter: none !important; } 
    
    #btn-map-settings, #map-settings-content, #zoom-controls-floating, #poi-side-panel { background: rgba(30, 30, 30, 0.95); color: #ecf0f1; border-color: #444; }
    #btn-map-settings:hover { background: #444; color: #fff; }
    #layers-title { color: #ecf0f1; }
    .layer-item { color: #ecf0f1; }
    .tool-title { color: #aaa; }
    .menu-divider { border-top: 1px solid #444; }
    #zoom-controls-floating button { color: #ecf0f1; }
    #zoom-controls-floating button:hover { background: #444; color: #fff; }
    .zoom-divider { background: #555; }
    #editor-tools { background: #222; border-color: #444; color: #ecf0f1; }
    
    .map-label { 
        color: #f1f1f1; 
        /* OPRAVA I PRO TMAVÝ REŽIM */
        text-shadow: 
            -1px -1px 0 #111,  
             1px -1px 0 #111,
            -1px  1px 0 #111,
             1px  1px 0 #111,
             0 0 5px #111,
             0 0 10px rgba(0,0,0,0.9);
    }
    
    .map-note { background: #d35400; border-color: #e67e22; color: #fff; }
    .map-note::after { border-color: #d35400 transparent transparent transparent; }

    .custom-marker.active-marker::before { border-color: #111; box-shadow: 0 0 12px rgba(231, 76, 60, 0.6); }
    
    #btn-close-poi { background: #333; border-color: #555; color: #ecf0f1; }
    #btn-close-poi:hover { background: #444; color: #fff; }
    #poi-details h2 { color: #f1c40f; }
    #poi-details p { color: #ccc; }
    #poi-details iframe { background: #222; }
    
    #map-info { background: rgba(30, 30, 30, 0.95); color: #ecf0f1; border-color: #444; }
}