:root {
    --primary-color: #007bff;
    --primary-dark: #0056b3;
    --secondary-bg: #f8f9fa;
    --text-color: #333;
    --header-bg-start: #2c3e50;
    --header-bg-end: #1a252f;
    --border-color: #dee2e6;
    --success-color: #28a745;
    
    /* Specific column colors */
    --col-main: #343a40;
    --col-blue: #007bff;
    --col-green: #28a745;
    --col-pink: #e83e8c;
    --col-purple: #6f42c1;
}

body { font-family: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif; margin: 0; background-color: #ebedef; color: var(--text-color); line-height: 1.5; font-size: 13px; }

/* --- HEADER --- */
.header {
    background: linear-gradient(135deg, var(--header-bg-start), var(--header-bg-end));
    color: white;
    padding: 10px 20px; /* Zmniejszono padding */
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-wrap: wrap; /* Pozwala zawijać elementy na mobile */
    gap: 10px;
}
.header-brand { display: flex; align-items: center; gap: 15px; }
.header-brand h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: 0.5px; }
.header-brand span { font-size: 12px; opacity: 0.7; font-weight: 400; background: rgba(255,255,255,0.1); padding: 2px 8px; border-radius: 4px; }

.header nav { display: flex; gap: 5px; }
.header nav a { 
    color: rgba(255,255,255,0.85); 
    text-decoration: none; 
    padding: 8px 16px; 
    font-size: 14px; 
    border-radius: 4px; 
    transition: all 0.2s; 
    font-weight: 500;
}
.header nav a:hover { background-color: rgba(255,255,255,0.15); color: white; }

/* --- LAYOUT --- */
.container { width: 95%; max-width: 1700px; margin: 30px auto; }

.card { background: white; border-radius: 8px; box-shadow: 0 2px 15px rgba(0,0,0,0.05); overflow: hidden; margin-bottom: 30px; padding: 20px; }
.card h2 { margin-top: 0; color: #444; border-bottom: 2px solid #f0f0f0; padding-bottom: 10px; margin-bottom: 20px; }

/* --- COMPACT UPDATE BOX --- */
.compact-box {
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 25px;
    border-left: 5px solid var(--success-color);
    flex-wrap: wrap;
}
.compact-box h2 { margin: 0; font-size: 16px; color: #555; font-weight: 600; }
.compact-controls { display: flex; align-items: center; gap: 15px; flex-grow: 1; justify-content: flex-end; }

#update-btn, .btn-reset { 
    background-color: var(--success-color); 
    color: white; 
    border: none; 
    padding: 6px 16px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 13px; 
    font-weight: 600;
    transition: background 0.2s;
}
#update-btn:hover { background-color: #218838; }
#update-btn:disabled { background-color: #6c757d; cursor: not-allowed; }
.btn-reset { background-color: var(--col-main); }
.btn-reset:hover { background-color: #23272b; }

#progress-bar-container { background-color: #e9ecef; border-radius: 2px; height: 4px; width: 150px; overflow: hidden; display: none; margin-right: 10px; }
#progress-bar { width: 0%; height: 100%; background-color: var(--primary-color); transition: width 0.5s ease; }

#update-status { font-size: 13px; font-weight: 500; }
.status-success { color: var(--success-color); } .status-error { color: #dc3545; } .status-info { color: #17a2b8; }

/* --- DATE PILLS --- */
.date-container { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 25px; justify-content: flex-start; }
.date-btn {
    padding: 6px 14px;
    background-color: white;
    border: 1px solid #dcdcdc;
    color: #555;
    text-decoration: none;
    border-radius: 50px;
    font-size: 12px;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.date-btn:hover { border-color: var(--primary-color); color: var(--primary-color); transform: translateY(-1px); }
.date-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 3px 6px rgba(0,123,255,0.3);
}

/* --- TABLE --- */
.table-responsive { overflow-x: auto; border-radius: 6px; border: 1px solid #eee; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; text-align: center; margin-top: 0; min-width: 800px; /* Wymusza przewijanie na małych ekranach */ }
th, td { border: 1px solid #dee2e6; padding: 8px 6px; }

/* Colored Headers */
th { color: white; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; position: sticky; top: 0; z-index: 10; }
.header-main { background: var(--col-main); }
.header-blue { background: var(--col-blue); }
.header-pink { background: var(--col-pink); }
.header-green { background: var(--col-green); }
.header-purple { background: var(--col-purple); }

tr:nth-child(even) { background: #f9f9f9; }
tr:hover { background: #f1f8ff; }

.family-tag { font-weight: bold; color: #000; font-size: 13px; }
.sub-tags { display: block; font-size: 10px; color: #777; font-weight: normal; margin-top: 2px;}

/* Ranks */
.rank1 { background-color: #d4edda !important; color: #155724; font-weight: bold; border: 1px solid #c3e6cb; }
.rank2 { background-color: #e2e3e5 !important; color: #383d41; }
.rank3 { background-color: #fff3cd !important; color: #856404; }

/* --- MAP SECTION --- */
#map-section { text-align: center; }
#map-viewport { 
    width: 800px; 
    height: 800px; 
    margin: 20px auto; 
    border: 1px solid #ccc; 
    background-color: #111; 
    overflow: hidden; 
    position: relative; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); 
    border-radius: 4px; 
}
canvas { image-rendering: auto; cursor: grab; }
canvas:active { cursor: grabbing; }

#legend { margin: 20px auto; max-width: 1000px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.legend-item { display: flex; align-items: center; font-size: 12px; padding: 4px 10px; background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 20px; }
.color-box { width: 14px; height: 14px; margin-right: 6px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }

.map-controls { margin-bottom: 15px; }

/* Kontener dla dropdowna */
.world-dropdown { position: relative; display: inline-block; margin-right: 20px; }

/* Wygląd przycisku */
.dropbtn {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 10px 16px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    border-radius: 4px;
    transition: 0.3s;
}

.world-dropdown:hover .dropbtn { background-color: rgba(255, 255, 255, 0.3); }

/* Ukryta lista linków */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #333;
    min-width: 120px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
    z-index: 1000;
    border-radius: 4px;
    overflow: hidden;
}

/* Linki wewnątrz listy */
.dropdown-content a {
    color: white;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    font-size: 14px;
}

.dropdown-content a:hover {background-color: #555;}
.dropdown-content a.active {background-color: #4CAF50;}

/* Pokazanie menu po najechaniu */
.world-dropdown:hover .dropdown-content { display: block; }

/* --- STYLE CSS (Filtry & Tooltip) --- */
.filter-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.filter-controls input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    width: 200px;
    background-color: #fff;
}
.filter-controls input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.legend-item { cursor: pointer; user-select: none; transition: all 0.2s; border: 1px solid transparent; }
.legend-item:hover { background-color: #e2e6ea; border-color: #adb5bd; }
.legend-item.hidden-family { opacity: 0.4; background-color: #eee; text-decoration: line-through; filter: grayscale(100%); }

#coord-tooltip {
    position: absolute;
    display: none;
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Segoe UI', sans-serif;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transform: translate(15px, 15px);
}

/* ========================================= */
/* --- RESPONSYWNOŚĆ (MOBILE & TABLET) --- */
/* ========================================= */

@media (max-width: 900px) {
    /* 1. Header: Zmiana układu i tekstu */
    .header {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }
    
    .header-brand {
        justify-content: center;
        margin-bottom: 10px;
    }

    /* Ukrywanie pełnej nazwy i pokazywanie skrótu PL */
    .header-brand span.full-text { display: none; }
    .header-brand span.mobile-text { display: inline; }

    .world-dropdown { 
        width: 100%; 
        margin-right: 0; 
        margin-bottom: 5px; 
    }
    .dropbtn { width: 100%; text-align: center; }
    .dropdown-content { width: 100%; position: relative; } /* Menu jako lista pod przyciskiem na mobile */
    
    .header nav {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
    }
    .header nav a {
        flex-grow: 1;
        text-align: center;
        font-size: 13px;
        padding: 8px 5px;
    }

    /* 2. Ukrywanie sub-tagów w tabeli */
    .sub-tags { display: none !important; }
    
    /* Zmniejszenie czcionki w tabeli na telefonach */
    th, td { font-size: 11px; padding: 6px 3px; }

    /* 3. Mapa - Responsywność */
    #map-viewport {
        width: 100% !important; /* Szerokość ekranu */
        height: auto !important; /* Wysokość auto */
        aspect-ratio: 1 / 1; /* Utrzymanie kwadratu */
        max-width: 500px; /* Maksymalna szerokość na tablecie */
    }
    
    /* Canvas musi się skalować */
    canvas {
        width: 100% !important;
        height: 100% !important;
    }

    /* 4. Filtry jeden pod drugim */
    .filter-controls { flex-direction: column; }
    .filter-controls input { width: 100%; box-sizing: border-box; }
    
    /* Update box na mobile */
    .compact-box { flex-direction: column; align-items: stretch; text-align: center; }
    .compact-controls { justify-content: center; flex-direction: column; }
    #progress-bar-container { width: 100%; margin: 10px 0; }
    
    /* Layout */
    .container { width: 100%; padding: 0 5px; margin: 10px auto; }
    .card { border-radius: 0; padding: 10px; }
}