:root {
    --tile-size: 160px;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-blur: blur(16px);
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e1e2f, #252542, #1a1a2e);
    background-attachment: fixed;
    color: #ffffff;
    margin: 0; 
    padding: 0; 
    user-select: none;
    -webkit-user-select: none;
    touch-callout: none;
    touch-action: pan-x pan-y; /* Zakáže pinch-zoom, zlepší detekci kliknutí při držení */
    min-height: 100vh;
}

/* Horní navigační lišta (Skleněný efekt) */
#top-bar { 
    display: flex; 
    align-items: center; 
    padding: 8px 16px; 
    background: rgba(30, 30, 47, 0.6); 
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    font-size: 1.5rem; 
    height: 70px; 
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

#back-btn { 
    display: none;
    align-items: center;
    gap: 8px;
    cursor: pointer; 
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50px;
    padding: 10px 20px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    min-width: 90px;
    transition: background 0.15s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}
#back-btn:active { 
    background: rgba(255,255,255,0.4);
    transform: scale(0.93); 
}

#title { 
    font-weight: 600; 
    flex-grow: 1; 
    text-align: center; 
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: #ccc;
}

input[type=range] {
    accent-color: #00d2ff;
}

/* Kontejner s obsahem - Grid přizpůsobující se velikosti dlaždic */
#content { 
    padding: 30px 20px; 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(var(--tile-size), 1fr));
    gap: 20px; 
    justify-items: center;
    max-width: 1200px;
    margin: 0 auto;
    min-height: calc(100vh - 70px); /* vyplní zbytek obrazovky pod top-barem */
    align-content: start; /* dlaždice zůstanou nahoře, zbytek plochy je prázdný a klikatelný */
    transition: opacity 0.18s ease;
}

/* Dlaždice (Skleněný design) */
.tile { 
    background: var(--glass-bg); 
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 24px; 
    width: var(--tile-size); 
    height: var(--tile-size); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Tlačítka s animovaným gradientem */
.tile-has-gradient {
    border: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.tile:hover { 
    transform: translateY(-5px) scale(1.02); 
    box-shadow: 0 14px 40px rgba(0,0,0,0.5);
    border-color: rgba(255, 255, 255, 0.4);
}

.tile:active { 
    transform: scale(0.95); 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Odlišení složek */
.tile.category {
    border-bottom: 4px solid #00d2ff;
}

/* Obal pro text kategorie s obrázkem, aby byl čitelný */
.cat-title-box {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    max-width: 85%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.tile img { 
    width: 65%; 
    height: 65%; 
    object-fit: contain; 
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    transition: transform 0.2s;
}

.tile:hover img {
    transform: scale(1.08);
}

.tile .category-icon {
    font-size: calc(var(--tile-size) * 0.45);
    line-height: 1;
    margin-bottom: 5px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.tile span { 
    font-size: calc(var(--tile-size) * 0.12); 
    font-weight: 700; 
    text-align: center; 
    padding: 0 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 0.5px;
}

/* Subtle Random Play Button */
.play-random-subtle {
    border: 2px dashed rgba(255, 255, 255, 0.3) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: all 0.2s ease;
}
.play-random-subtle:hover {
    border-color: #00d2ff !important;
    background: rgba(0, 210, 255, 0.08) !important;
    transform: translateY(-3px) scale(1.02) !important;
}
.play-random-subtle:active {
    transform: scale(0.95) !important;
}

/* Přehrávač videa */
#video-container { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh; 
    background: rgba(0,0,0,0.96); 
    z-index: 1000; 
    align-items: center; 
    justify-content: center; 
    user-select: none;
    -webkit-user-select: none;
}
video { width: 100%; height: 100%; object-fit: contain; }
#close-btn { 
    position: absolute; 
    top: 20px; 
    right: 20px; 
    color: white; 
    background: rgba(22, 22, 34, 0.75); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.25); 
    border-radius: 50%; 
    width: 56px; 
    height: 56px; 
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001; 
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: background 0.2s, transform 0.15s, border-color 0.2s;
}
#close-btn:hover { background: rgba(239, 68, 68, 0.85); border-color: transparent; }
#close-btn:active { transform: scale(0.92); }

/* Skrytí textů pro děti co neumí číst */
body.hide-text .cat-title-box { display: none !important; }
body.hide-text .play-random-subtle span { display: none !important; }
body.hide-text .play-random-subtle svg { width: 48px; height: 48px; margin: 0; }
body.hide-text .play-random-subtle { justify-content: center; }

/* RESPONZIVITA PRO MOBILY */
@media (max-height: 500px) and (orientation: landscape) {
    #top-bar {
        min-height: 45px !important;
        height: 45px !important;
        padding: 4px 8px !important;
    }
    #top-bar button svg {
        width: 20px;
        height: 20px;
    }
    #top-bar button {
        margin-right: 8px !important;
    }
    #title { font-size: 1rem !important; }
    #content { padding: 10px !important; }
}
@media (max-width: 768px) {
    #top-bar {
        padding: 8px;
        height: auto;
        min-height: 60px;
        gap: 5px;
    }
    #title {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0 5px;
    }
    #back-btn {
        min-width: unset;
        padding: 6px 12px;
        font-size: 0.95rem;
        gap: 4px;
    }
    .controls {
        gap: 8px;
    }
    /* Na mobilu skryjeme slider velikosti, mřížka se tam přizpůsobí sama */
    #size-slider, .controls > svg:not(button svg) {
        display: none !important;
    }
    .controls button {
        margin-right: 0 !important;
    }
    .controls button svg {
        width: 22px;
        height: 22px;
    }
    #lang-btn {
        font-size: 20px !important;
    }
}
