*, *::before, *::after {
    box-sizing: border-box;
}

.container-contest {
    max-width: 900px;
    margin: 10px auto;
    background: transparent;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: visible;
}

.sidebar {
    width: 100%;
    background: transparent;            
    padding: 5px;
    margin-bottom: 5px;                      
}

.contest-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.contest-table tr {
    display: table-row;
}

.contest-table td {
    display: table-cell;
    padding: 5px;
    text-align: center;
    box-sizing: border-box;
    word-wrap: break-word; 
    width: 25%; /* Pevná šířka pro 4 sloupce */
    vertical-align: top;
}

.contest-item {
    background: transparent;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
    margin: 2px;
    display: block;
    width: 100%;
    box-sizing: border-box;
    height: 60px; /* Pevná výška pro jednotný vzhled */
}

.contest-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.contest-item.active {
    background: #40e0d0; /* tyrkysové pozadí vybraného závodu */
    color: #000;
}

.contest-link {
    display: flex;
    width: 100%;             
    height: 100%; /* Vyplní celou výšku */
    box-sizing: border-box;
    overflow: hidden;
    flex-wrap: nowrap;
    padding: 0;
    text-decoration: none;
    color: #40e0d0; /* tyrkysový text */
    font-weight: 500;
    border: 2px solid #667eea;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.75rem; /* Menší font pro delší texty */
    align-items: stretch;
}

.contest-link:link,
.contest-link:visited,
.contest-link:hover,
.contest-link:active,
.contest-link:focus {
    color: #40e0d0; /* stejná barva ve všech stavech (přebije globální a:visited) */
}

.contest-item:not(.active) .contest-link:hover {
    border-color: #667eea;
    background-color: rgba(102, 126, 234, 0.1);
}

.contest-item.active .contest-link,
.contest-item.active .contest-link:link,
.contest-item.active .contest-link:visited,
.contest-item.active .contest-link:hover,
.contest-item.active .contest-link:active,
.contest-item.active .contest-link:focus {
    border-color: #40e0d0;
    color: #000; /* černý text vybraného závodu */
}

.contest-text {
    padding: 6px 8px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    overflow: hidden;
    min-width: 0;
    word-wrap: break-word;
    hyphens: auto;
    line-height: 1.2;
    font-size: 0.75rem; /* Menší font pro dlouhé texty */
}

.contest-number {
    background: #667eea;
    color: white;
    font-size: 1.1rem; /* Menší font pro konzistenci */
    font-weight: 700; 
    flex: 0 0 50px; /* Menší šířka pro více místa na text */
    border-radius: 6px 0 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.contest-item.active .contest-number {
    background: rgba(0, 0, 0, 0.15); /* o trochu tmavší tyrkysová */
    color: #000;
}

.main-content {
    width: 100%;
    padding-top: 5px;  
    padding-bottom: 5px;
    margin-bottom: 5px;          
    background: transparent;
    margin-top: 5px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.welcome-message {
    text-align: center;
    color: #40e0d0 !important;
    padding: 10px 10px;  
}

.welcome-message h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 5px;
}

.welcome-message p {
    text-align: center;            
    font-size: 1.1rem;
}

.contest-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

.contest-header h2 {
    color: #333;
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.error {
    background: #fee;
    color: #c33;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #c33;
}

.no-contest {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.contest-nav {
    margin: 10px;
    padding-top: 5px;           
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-button {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 25px;
    margin: 0;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
    min-width: 120px;
    text-align: center;
}

.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.nav-button.disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Media Queries - opravené pro tablet a mobil */
@media (max-width: 1024px) {
    .contest-table td {
        width: 33.33%; /* 3 sloupce na tabletech */
    }
}

@media (max-width: 768px) {
    .sidebar {
        padding: 5px;
    }
    
    .contest-table {
        display: block; /* Zrušíme table layout na mobilu */
        width: 100%;
    }
    
    .contest-table tr {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        margin-bottom: 5px;
    }
    
    .contest-table td {
        display: block;
        flex: 1 1 calc(50% - 5px); /* 2 sloupce na mobilu s mezerou */
        width: auto;
        min-width: 150px;
        padding: 2.5px;
    }
    
    .contest-item {
        height: 50px; /* Menší výška na mobilu */
        margin: 0;
    }
    
    .contest-link {
        font-size: 0.8rem;
    }
    
    .contest-number {
        flex: 0 0 45px; /* Menší šířka na mobilu */
        font-size: 1rem;
    }
    
    .contest-text {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    /* Navigační tlačítka na mobilu */
    .contest-nav {
        margin: 15px 5px;
        gap: 8px;
    }
    
    .nav-button {
        padding: 10px 20px;
        font-size: 0.85rem;
        min-width: 100px;
        flex: 1;
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .contest-table td {
        flex: 1 1 calc(50% - 5px); /* Zachováme 2 sloupce i na velmi malých obrazovkách */
        min-width: 140px; /* Menší minimální šířka */
    }
    
    .contest-item {
        height: 45px;
    }
    
    .contest-number {
        flex: 0 0 35px; /* Ještě menší šířka čísla */
        font-size: 0.8rem;
    }
    
    .contest-text {
        padding: 4px 6px;
        font-size: 0.65rem; /* Ještě menší font */
        line-height: 1.1;
    }
    
    /* Navigační tlačítka na malých mobilech */
    .contest-nav {
        margin: 10px 5px;
        gap: 5px;
        flex-direction: column;
    }
    
    .nav-button {
        padding: 12px 16px;
        font-size: 0.8rem;
        width: 100%;
        max-width: none;
        margin-bottom: 5px;
    }
}
