@import url('https://fonts.googleapis.com/css2?family=Teko:wght@400;600;700&display=swap');

/* === ZÁKLADNÉ NASTAVENIA === */
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-drag: none;
}

body {
    position: relative;
    height: 100vh;
    background: url('background.jpg') no-repeat center center/cover;
    background-color: #050505;
    opacity: 0;
    transition: opacity 2s ease-in-out;
    overflow: hidden;
    font-family: 'Teko', sans-serif;
}

.loaded {
    opacity: 1;
}

#particles-js {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Skryjeme systémový kurzor len na zariadeniach s myšou – nahrádza ho neónový */
@media (pointer: fine) {
    body, body * {
        cursor: none !important;
    }
}

/* === ŠTARTOVACIA OBRAZOVKA === */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.90);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 25px;
    padding: 20px 0;
    overflow-y: auto;
}

/* margin:auto centruje obsah keď je miesto, ale pri pretečení
   nechá vrch dostupný (na rozdiel od justify-content: center) */
#start-screen > .game-title { margin-top: auto; }
#start-screen > #leaderboard-panel { margin-bottom: auto; }

/* === TITULOK HRY === */
.game-title {
    text-align: center;
    animation: titleEntrance 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.title-logo {
    width: clamp(70px, 12vw, 110px);
    height: clamp(70px, 12vw, 110px);
    margin: 0 auto 5px auto;
    background-color: #0ff;
    -webkit-mask-image: url('the-avengers.svg');
    mask-image: url('the-avengers.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    filter: drop-shadow(0 0 15px #0ff) drop-shadow(0 0 30px #0ff);
    animation: logoSpin 1.5s cubic-bezier(0.25, 1, 0.5, 1) both, logoBreath 3s infinite alternate ease-in-out 1.5s;
    will-change: transform;
}

.game-title h1 {
    font-size: clamp(3rem, 9vw, 5.5rem);
    color: #fff;
    letter-spacing: 6px;
    line-height: 1;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 30px rgba(0, 255, 255, 0.6);
}

.game-title h1 span {
    color: #0ff;
    text-shadow: 0 0 15px #0ff, 0 0 40px #0ff;
}

.title-tagline {
    font-size: clamp(1rem, 3vw, 1.6rem);
    color: #ffcc00;
    letter-spacing: 14px;
    text-indent: 14px; /* Kompenzuje letter-spacing posledného písmena pre presný stred */
    text-shadow: 0 0 10px #ffcc00;
    animation: taglinePulse 2s infinite alternate ease-in-out;
}

@keyframes titleEntrance {
    0% { opacity: 0; transform: translateY(-60px) scale(1.3); filter: blur(10px); }
    100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes logoSpin {
    0% { transform: rotate(-360deg) scale(0); }
    100% { transform: rotate(0deg) scale(1); }
}

/* VÝKON: dýchanie loga animuje transform (GPU) namiesto filter: drop-shadow,
   ktorý sa prekresľoval pri každej snímke */
@keyframes logoBreath {
    0% { transform: scale(1); }
    100% { transform: scale(1.07); }
}

@keyframes taglinePulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.difficulty-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 40px;
    border-radius: 15px;
    border: 2px solid #0ff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.difficulty-container h2 {
    color: #0ff;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 10px;
    text-shadow: 0 0 10px #0ff;
    letter-spacing: 2px;
}

/* === POLE NA MENO HRÁČA === */
#name-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-bottom: 5px;
}

#name-container label {
    color: #ffcc00;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    letter-spacing: 2px;
    text-shadow: 0 0 8px #ffcc00;
}

#playerNameInput {
    width: 100%;
    padding: 10px 15px;
    font-family: 'Teko', sans-serif;
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 204, 0, 0.6);
    border-radius: 8px;
    letter-spacing: 1px;
    outline: none;
    transition: all 0.3s ease;
}

#playerNameInput::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#playerNameInput:focus {
    border-color: #ffcc00;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.5), inset 0 0 8px rgba(255, 204, 0, 0.3);
}

/* === PANEL REBRÍČKA === */
#leaderboard-panel {
    width: min(90vw, 420px);
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid #0ff;
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
}

#leaderboard-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.lb-tab {
    flex: 1;
    padding: 6px 4px;
    font-family: 'Teko', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.25s ease;
}

.lb-tab:hover {
    color: #fff;
    border-color: #0ff;
}

.lb-tab.active {
    color: #000;
    background: #0ff;
    border-color: #0ff;
    box-shadow: 0 0 12px #0ff;
    font-weight: bold;
}

.lb-loading {
    color: rgba(0, 255, 255, 0.7);
    text-align: center;
    animation: textPulse 0.6s infinite alternate;
}

.lb-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lb-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: clamp(1rem, 2.8vw, 1.35rem);
    color: #fff;
    border-bottom: 1px solid rgba(0, 255, 255, 0.12);
}

.lb-list li:last-child { border-bottom: none; }

.lb-rank {
    flex: 0 0 auto;
    min-width: 32px;
    text-align: center;
    font-weight: bold;
    color: #0ff;
}

.lb-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 1px;
}

.lb-score {
    flex: 0 0 auto;
    color: #ffcc00;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(255, 204, 0, 0.5);
}

/* Zvýraznenie vlastného skóre v rebríčku */
.lb-list li.lb-me {
    background: rgba(0, 255, 255, 0.15);
    box-shadow: inset 0 0 12px rgba(0, 255, 255, 0.25);
}
.lb-list li.lb-me .lb-name { color: #0ff; }

.diff-button {
    width: 100%;
    padding: 15px 30px;
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-family: 'Teko', sans-serif;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fff;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.diff-button.easy { border-color: #0f0; box-shadow: 0 0 10px #0f0; }
.diff-button.medium { border-color: #f90; box-shadow: 0 0 10px #f90; }
.diff-button.hard { border-color: #f00; box-shadow: 0 0 10px #f00; }
.diff-button.campaign { border-color: #ffcc00; box-shadow: 0 0 10px #ffcc00; }

.diff-button:hover {
    transform: scale(1.05);
}
.diff-button.easy:hover { background: rgba(0, 255, 0, 0.2); box-shadow: 0 0 20px #0f0; }
.diff-button.medium:hover { background: rgba(255, 153, 0, 0.2); box-shadow: 0 0 20px #f90; }
.diff-button.hard:hover { background: rgba(255, 0, 0, 0.2); box-shadow: 0 0 20px #f00; }
.diff-button.campaign:hover { background: rgba(255, 204, 0, 0.2); box-shadow: 0 0 20px #ffcc00; }

/* === ANIMOVANÉ AURORA POZADIE MENU ===
   Dva rozmazané farebné "obláčiky" pomaly plávajú za obsahom úvodnej obrazovky.
   Animuje sa len transform → beží na GPU. */
#start-screen > .menu-aurora {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

/* Obsah menu musí byť nad aurorou */
#start-screen > *:not(.menu-aurora) {
    position: relative;
    z-index: 1;
}

/* VÝKON: žiadny filter: blur – rozmazanie obrovských vrstiev sa skladalo pri každej
   snímke a spomaľovalo celé menu. Mäkkosť zabezpečuje samotný radial-gradient. */
.menu-aurora::before,
.menu-aurora::after {
    content: '';
    position: absolute;
    width: 65vmax;
    height: 65vmax;
    border-radius: 50%;
    opacity: 0.3;
    will-change: transform;
}

.menu-aurora::before {
    background: radial-gradient(circle, rgba(0, 255, 255, 0.4) 0%, rgba(0, 255, 255, 0.15) 35%, transparent 65%);
    top: -25vmax;
    left: -20vmax;
    animation: auroraDrift1 16s infinite alternate ease-in-out;
}

.menu-aurora::after {
    background: radial-gradient(circle, rgba(255, 60, 60, 0.32) 0%, rgba(255, 60, 60, 0.12) 35%, transparent 65%);
    bottom: -28vmax;
    right: -18vmax;
    animation: auroraDrift2 20s infinite alternate ease-in-out;
}

@keyframes auroraDrift1 {
    to { transform: translate(20vmax, 12vmax) scale(1.15); }
}

@keyframes auroraDrift2 {
    to { transform: translate(-16vmax, -14vmax) scale(1.2); }
}

/* VÝKON: kým je otvorené menu, animácie kariet za priesvitným pozadím stoja –
   prehliadač ich inak skladal pri každej snímke, hoci ich sotva vidno.
   Triedu menu-open nastavuje JS (pri načítaní) a odoberá pri štarte hry. */
body.menu-open .bf-glow,
body.menu-open .back-face::after,
body.menu-open .front-face::after {
    animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .menu-aurora::before,
    .menu-aurora::after {
        animation: none;
    }
}

/* === PANEL ODZNAKOV (ACHIEVEMENTY) === */
#achievements-panel {
    width: min(90vw, 420px);
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid rgba(255, 204, 0, 0.6);
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.25);
}

#achievements-panel h4 {
    margin: 0 0 12px 0;
    color: #ffcc00;
    text-align: center;
    text-shadow: 0 0 6px rgba(255, 204, 0, 0.7);
    letter-spacing: 2px;
    font-size: 1.1rem;
}

#ach-count {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    margin-left: 6px;
}

#achievements-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.ach-badge {
    text-align: center;
    padding: 8px 2px 6px;
    border-radius: 10px;
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ach-badge .ach-icon {
    display: block;
    font-size: 1.7rem;
    line-height: 1.2;
}

.ach-badge small {
    display: block;
    margin-top: 3px;
    font-size: 0.62rem;
    line-height: 1.15;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ach-badge.locked {
    filter: grayscale(1);
    opacity: 0.35;
}

.ach-badge.unlocked {
    border-color: rgba(255, 204, 0, 0.6);
    background: rgba(255, 204, 0, 0.08);
    box-shadow: 0 0 12px rgba(255, 204, 0, 0.3);
}

.ach-badge.unlocked:hover {
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.55);
}

/* === TOAST NOTIFIKÁCIA ODZNAKU === */
#achievement-toast {
    position: fixed;
    top: 85px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(30, 25, 0, 0.95), rgba(0, 0, 0, 0.9));
    border: 2px solid #ffcc00;
    border-radius: 12px;
    box-shadow: 0 0 25px rgba(255, 204, 0, 0.5);
    z-index: 4000;
    opacity: 0;
    transform: translateX(120%);
    pointer-events: none;
    font-family: 'Teko', sans-serif;
}

#achievement-toast.toast-show {
    animation: toastSlide 3.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes toastSlide {
    0%   { opacity: 0; transform: translateX(120%); }
    10%  { opacity: 1; transform: translateX(0); }
    88%  { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(120%); }
}

#achievement-toast .toast-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 8px rgba(255, 204, 0, 0.8));
}

#achievement-toast .toast-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

#achievement-toast .toast-text b {
    color: #ffcc00;
    font-size: 1.15rem;
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(255, 204, 0, 0.6);
}

#achievement-toast .toast-text span {
    color: #fff;
    font-size: 1.35rem;
    letter-spacing: 1px;
}

/* === HORNÉ OVLÁDACIE PRVKY (HUD) === */
.tabulka {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95vw;
    max-width: 700px;
    z-index: 100;
    display: none; /* Flex applied via JS */
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

#restartButton, #muteButton {
    padding: 8px 15px;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    border-radius: 8px;
    border: 2px solid rgba(0, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.6);
    color: #0ff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Teko', sans-serif;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    text-transform: uppercase;
}

#restartButton:hover, #muteButton:hover {
    border-color: #0ff;
    box-shadow: 0 0 15px #0ff, inset 0 0 10px #0ff;
    background: rgba(0, 255, 255, 0.2);
}

#muteButton.muted {
    border-color: #ff3333;
    color: #ff3333;
    box-shadow: 0 0 10px rgba(255, 51, 51, 0.3);
}

#muteButton.muted:hover {
    box-shadow: 0 0 15px #ff3333, inset 0 0 10px #ff3333;
    background: rgba(255, 51, 51, 0.2);
}

/* === ULTIMATE TLAČIDLO (AVENGERS ASSEMBLE) ===
   Kruhový ukazovateľ nabitia: conic-gradient sa plní podľa --charge (0–100),
   ktoré nastavuje JS. Po nabití zlato pulzuje a dá sa stlačiť. */
#ultimateButton {
    --charge: 0;
    position: relative;
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    padding: 0;
    background: conic-gradient(#0ff calc(var(--charge) * 1%), rgba(0, 255, 255, 0.12) 0);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    cursor: pointer;
    transition: box-shadow 0.3s ease;
}

#ultimateButton:disabled {
    cursor: default;
}

#ultimateButton .ult-inner {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: rgba(0, 10, 14, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
}

#ultimateButton .ult-logo {
    width: 65%;
    height: 65%;
    background-color: #0ff;
    -webkit-mask-image: url('the-avengers.svg');
    mask-image: url('the-avengers.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    opacity: 0.45;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

#ultimateButton.ready {
    background: conic-gradient(#ffcc00 100%, transparent 0);
    animation: ultReadyPulse 0.9s infinite alternate ease-in-out;
}

#ultimateButton.ready .ult-logo {
    background-color: #ffcc00;
    opacity: 1;
    filter: drop-shadow(0 0 6px #ffcc00);
}

#ultimateButton.ready:hover {
    box-shadow: 0 0 35px #ffcc00;
}

@keyframes ultReadyPulse {
    from { transform: scale(1); box-shadow: 0 0 12px #ffcc00; }
    to   { transform: scale(1.12); box-shadow: 0 0 28px #ffcc00; }
}

/* Počet pripravených ultimate – zlatý odznak (JS ho ukáže až od 2 kusov,
   keď si hráč v kampani prenesie nevyužité áčko do ďalšej úrovne) */
#ultimateButton .ult-count {
    position: absolute;
    top: -6px;
    right: -10px;
    min-width: 22px;
    height: 22px;
    display: none; /* JS prepína na flex */
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-family: 'Teko', sans-serif;
    font-size: 1rem;
    line-height: 1;
    color: #051414;
    background: #ffcc00;
    border-radius: 11px;
    box-shadow: 0 0 8px #ffcc00;
    z-index: 2;
}

/* Ultimate už bol v tomto kole použitý – vyhasnuté tlačidlo */
#ultimateButton.spent {
    opacity: 0.35;
    filter: grayscale(1);
    box-shadow: none;
}

/* === INDIKÁTORY AKTÍVNYCH EFEKTOV (štít, spider-sense, stop čas) === */
#status-effects {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 8px;
    order: 4; /* pod HUD-om */
}

#status-effects:empty {
    display: none; /* bez efektov nezaberá miesto */
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 14px;
    font-family: 'Teko', sans-serif;
    font-size: clamp(0.95rem, 2.2vw, 1.15rem);
    letter-spacing: 2px;
    color: #ffcc00;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 204, 0, 0.7);
    border-radius: 20px;
    box-shadow: 0 0 12px rgba(255, 204, 0, 0.35);
    text-shadow: 0 0 6px rgba(255, 204, 0, 0.6);
    animation: pillPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both,
               pillPulse 1.2s infinite alternate ease-in-out 0.4s; /* len opacity – GPU */
}

.status-pill .sp-icon {
    font-size: 1.1em;
    filter: drop-shadow(0 0 4px rgba(255, 204, 0, 0.7));
}

@keyframes pillPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pillPulse {
    0% { opacity: 0.75; }
    100% { opacity: 1; }
}

/* === SKÓRE NA OBRAZOVKE KONCA SVETA (KAMPAŇ) === */
#gameover-stats {
    margin-bottom: 40px;
}

#gameover-stats .go-stat {
    font-size: clamp(1.3rem, 3.5vw, 2rem);
    margin-bottom: 8px;
    opacity: 0;
    animation: fadeIn 1s ease forwards 1.8s; /* ukáže sa po dopade nadpisu */
}

#gameover-score {
    color: #ffcc00;
    font-weight: bold;
    text-shadow: 0 0 12px #ffcc00;
}

#gameover-level {
    color: #0ff;
    font-weight: bold;
    text-shadow: 0 0 10px #0ff;
}

#stats-hud {
    display: flex;
    gap: 4px;
    background: linear-gradient(180deg, rgba(0, 25, 35, 0.85), rgba(0, 0, 0, 0.75));
    border: 2px solid rgba(0, 255, 255, 0.5);
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    color: #0ff;
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    text-shadow: 0 0 5px #0ff;
    text-transform: uppercase;
}

/* Jemné oddeľovače medzi štatistikami */
.stat-item + .stat-item {
    border-left: 1px solid rgba(0, 255, 255, 0.2);
}

.stat-icon {
    font-size: 0.9em;
    filter: drop-shadow(0 0 4px rgba(0, 255, 255, 0.6));
}

#unsuccessfulAttemptsDisplay {
    color: #ff3333;
    text-shadow: 0 0 5px #ff3333;
    font-weight: bold;
}
#timerDisplay {
    color: #fff;
    font-weight: bold;
}


/* === HERNÁ PLOCHA === */
.memory-game {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(95vw, 800px); /* Zväčšená šírka pre 6 stĺpcov */
    aspect-ratio: 6 / 4; /* Prispôsobený pomer strán pre 6x4 */
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: clamp(5px, 2vw, 15px);
    z-index: 10;
}

/* === FARBY KARIET PODĽA OBTIAŽNOSTI ===
   Logo „A" a žiara zadnej strany kariet menia farbu podľa úrovne:
   Nováčik modrá, Pokročilý zlatá, Maniak červená.
   Prepína sa cez body[data-diff] v skripte (aj priebežne v kampani). */
body {
    --card-neon: #0ff;
    --card-glow-strong: rgba(0, 255, 255, 0.9);
    --card-glow-soft: rgba(0, 255, 255, 0.7);
}
body[data-diff="novacik"] {
    --card-neon: #0ff; /* Pôvodná tyrkysová – hráčovi sa páčila najviac */
    --card-glow-strong: rgba(0, 255, 255, 0.9);
    --card-glow-soft: rgba(0, 255, 255, 0.7);
}
body[data-diff="pokrocily"] {
    --card-neon: #ffcc33;
    --card-glow-strong: rgba(255, 204, 51, 0.9);
    --card-glow-soft: rgba(255, 204, 51, 0.7);
}
body[data-diff="maniak"] {
    --card-neon: #ff3355;
    --card-glow-strong: rgba(255, 51, 85, 0.9);
    --card-glow-soft: rgba(255, 51, 85, 0.7);
}

/* === ŠTÝLY KARIET === */
.memory-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s ease; /* Zrýchlené normálne otáčanie */
    cursor: pointer;
}

.memory-card.slow-flip {
    transition: transform 2s ease-in-out; /* Veľmi pomalé otočenie pre ukážku */
}

.memory-card.flip {
    transform: rotateY(180deg);
}

.front-face,
.back-face {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 10px;
    background: #051414; /* Tmavé sci-fi pozadie */
    border: 2px solid var(--card-neon, #0ff);
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Udrží odlesk vo vnútri karty */
}

/* Predná strana má neón vo farbe hrdinu (rubová strana má farbu obtiažnosti) */
.front-face {
    border-color: var(--hero-glow, #0ff);
    box-shadow: 0 0 12px var(--hero-glow, #0ff), inset 0 0 12px var(--hero-glow, #0ff);
    transform: rotateY(180deg);
}

.front-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

/* Holografický odlesk prejde cez portrét hrdinu vždy po otočení karty */
.front-face::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.35) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: translateX(-300%) skewX(-25deg);
    pointer-events: none;
    z-index: 2;
}

.memory-card.flip .front-face::after {
    animation: cardShine 2.2s ease 0.35s 1;
}

/* Zadná strana dynamicky "dýcha" – VÝKON: žiara je samostatný element (.bf-glow)
   so statickým box-shadow a pulzuje sa len jeho OPACITY (GPU). Pôvodná animácia
   box-shadow na 24 kartách naraz spôsobovala neustále prekresľovanie a sekanie. */
.bf-glow {
    position: absolute;
    inset: -2px;
    border-radius: 10px;
    box-shadow: 0 0 22px var(--card-glow-strong), inset 0 0 14px var(--card-glow-soft);
    opacity: 0.25;
    animation: glowPulse 2.5s infinite alternate ease-in-out;
    will-change: opacity;
    pointer-events: none;
    z-index: 0;
}

@keyframes glowPulse {
    to { opacity: 1; }
}

/* Namiesto toho vykreslíme A-čko cez masku - to zaručí 100% čistú tyrkysovú farbu bez akýchkoľvek obrysov */
.back-face::before {
    content: '';
    position: absolute;
    width: 65%;
    height: 65%;
    background-color: var(--card-neon, #0ff); /* Farba podľa obtiažnosti */
    -webkit-mask-image: url('the-avengers.svg');
    mask-image: url('the-avengers.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    filter: drop-shadow(0 0 10px var(--card-neon, #0ff)) drop-shadow(0 0 20px var(--card-neon, #0ff));
    z-index: 1;
}

/* Animovaný pohybujúci sa sklenený odlesk (Shine) */
.back-face::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.4) 50%,
        rgba(255,255,255,0) 100%
    );
    /* transform namiesto animácie 'left' – GPU-akcelerované, bez prekresľovania layoutu */
    transform: translateX(-300%) skewX(-25deg);
    animation: cardShine 4s infinite;
    will-change: transform;
    z-index: 2; /* Musí byť nad logom */
}

/* Rozbitie synchronizácie odleskov pre organický vzhľad */
.memory-card:nth-child(2n) .back-face::after { animation-delay: 0.5s; }
.memory-card:nth-child(3n) .back-face::after { animation-delay: 1.2s; }
.memory-card:nth-child(5n) .back-face::after { animation-delay: 2.1s; }
.memory-card:nth-child(7n) .back-face::after { animation-delay: 0.8s; }

@keyframes cardShine {
    0% { transform: translateX(-300%) skewX(-25deg); }
    15% { transform: translateX(500%) skewX(-25deg); }
    100% { transform: translateX(500%) skewX(-25deg); }
}

/* === ANIMÁCIE KARIET === */
@keyframes shake {
    0%, 100% { transform: translateX(0) rotateY(180deg); }
    20%, 60% { transform: translateX(-8px) rotateY(180deg); }
    40%, 80% { transform: translateX(8px) rotateY(180deg); }
}

@keyframes matchGlow {
    0% { box-shadow: 0 0 10px var(--hero-glow, #0ff); border-color: var(--hero-glow, #0ff); transform: scale(1) rotateY(180deg); }
    30% { box-shadow: 0 0 30px var(--hero-glow, #0ff), 0 0 60px var(--hero-accent, #fff); border-color: var(--hero-accent, #fff); transform: scale(1.15) rotateY(180deg); }
    100% { box-shadow: 0 0 10px var(--hero-glow, #0ff); border-color: var(--hero-glow, #0ff); transform: scale(1) rotateY(180deg); }
}

.memory-card.shake .front-face {
    border-color: #ff3333;
    box-shadow: 0 0 15px #ff3333;
}
.memory-card.shake {
    animation: shake 0.4s ease-in-out;
    z-index: 20;
}

/* Lokiho premiešanie – zelený mystický nádych na miešaných kartách */
.memory-card.shuffling .back-face {
    border-color: #66ff99;
    box-shadow: 0 0 25px #33ff88, 0 10px 25px rgba(0, 0, 0, 0.55), inset 0 0 15px rgba(102, 255, 153, 0.8);
}
.memory-card.shuffling .bf-glow {
    animation: none;
    opacity: 0; /* tyrkysovú žiaru vystrieda zelená z back-face */
}
.memory-card.shuffling .back-face::before {
    background-color: #66ff99; /* Avengers "A" dočasne zelené */
    filter: drop-shadow(0 0 10px #33ff88) drop-shadow(0 0 20px #33ff88);
}

.memory-card.match-glow {
    z-index: 50; /* Prekryje ostatné karty počas zväčšenia */
}

.memory-card.match-glow .front-face {
    animation: matchGlow 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}


/* === VYSKAKOVACIE OBRÁZKY === */
#pochvalaObr, #CM, #Scar, #Hulk, #Spider, #Strange, #Furry {
    position: fixed; /* Zmenené z absolute na fixed pre dokonalý stred aj pri scrollovaní */
    top: 50%;
    left: 50%;
    display: none;
    z-index: 500;
    max-width: 650px;
    max-height: 80vh; /* Zabezpečí, že sa zhora/zdola neodrežú */
    transform: translate(-50%, -50%); /* Zjednotené centrovanie pre animáciu */
    animation: popUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

#pochvalaObr img, #CM img, #Scar img, #Hulk img, #Spider img, #Strange img, #Furry img {
    width: 100%; /* Zmenené zo 150% na 100% pre lepšiu kontrolu veľkosti */
    height: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 0 20px rgba(255,255,255,0.3));
}

#pochvalaObr { top: 20%; left: 50%; max-width: 400px; }
#CM { max-width: 500px; }
#Scar { max-width: 480px; }
#Hulk { max-width: 450px; }
#Spider { max-width: 400px; }
#Strange { max-width: 400px; }
#Furry { width: 100%; max-width: 800px; }

@keyframes popUp {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* === RESPONZÍVNE ÚPRAVY PRE MOBILY === */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    /* Úvodná obrazovka: odľahčenie, aby sa zmestila bez orezania */
    #start-screen {
        gap: 14px;
        padding: 14px 0;
    }
    /* Na mobile vypneme auto-margin centrovanie – obsah sedí od vrchu a nikdy sa neoreže */
    #start-screen > .game-title { margin-top: 0; }
    #start-screen > #leaderboard-panel { margin-bottom: 0; }
    .game-title h1 { letter-spacing: 3px; }
    .title-logo { width: 64px; height: 64px; }
    .difficulty-container {
        padding: 20px;
        gap: 12px;
    }
    .difficulty-container h2 { margin-bottom: 2px; }
    .diff-button { padding: 11px 20px; }
    #leaderboard-panel { padding: 12px 15px; }
    #achievements-panel { padding: 12px 15px; }
    #achievements-grid { gap: 6px; }
    .ach-badge .ach-icon { font-size: 1.4rem; }
    .ach-badge small { font-size: 0.55rem; }

    /* Toast na mobile: menší a pri okraji */
    #achievement-toast {
        top: auto;
        bottom: 15px;
        right: 10px;
        left: 10px;
        justify-content: center;
        padding: 10px 14px;
    }

    /* HUD kompaktnejší na malých displejoch */
    .stat-item { padding: 0 6px; gap: 4px; }
    #stats-hud { gap: 0; padding: 6px 8px; }

    .tabulka {
        top: 10px;
        flex-direction: row;
        justify-content: space-around;
        gap: 5px;
    }
    #stats-hud {
        order: 3;
        width: 100%;
        justify-content: space-around;
    }
    .memory-game {
        top: 58%;
        width: 92vw;
        max-height: 70vh; /* aby sa karty zmestili na vysku */
    }
    
    #pochvalaObr, #CM, #Scar, #Hulk, #Spider, #Strange, #Furry {
        max-width: 90vw;
    }
    #pochvalaObr img, #CM img, #Scar img, #Hulk img, #Spider img, #Strange img, #Furry img {
        width: 100%;
    }
}

/* === BONUS ČAS & GAME OVER === */
.bonus-time {
    color: #0f0 !important;
    text-shadow: 0 0 15px #0f0 !important;
    transform: scale(1.3);
    transition: all 0.3s ease;
}

.penalty-time {
    color: #f00 !important;
    text-shadow: 0 0 15px #f00 !important;
    transform: scale(1.3);
    transition: all 0.1s ease;
}

/* === EXTRÉMNY GAME OVER EFEKT === */
body.doomsday {
    animation: earthquake 0.7s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes earthquake {
    0% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-20px, 20px) rotate(-2deg); filter: brightness(200%); }
    20% { transform: translate(25px, -25px) rotate(2deg); filter: invert(100%); }
    30% { transform: translate(-30px, 30px) rotate(-3deg); filter: contrast(200%) blur(5px); }
    40% { transform: translate(35px, -35px) rotate(3deg); filter: invert(100%); }
    50% { transform: translate(-20px, 20px) rotate(-2deg); filter: brightness(200%); }
    60% { transform: translate(15px, -15px) rotate(1deg); filter: none; }
    70% { transform: translate(-5px, 5px) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

#game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('doomsday_bg.webp');
    background-size: cover;
    background-position: center;
    z-index: 2000;
    display: none; /* Flex via JS */
    overflow-y: auto; /* Pridané pre skrolovanie na malých displejoch */
    align-items: center;
    justify-content: center;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

#game-over-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65); /* Tmavý filter pre čitateľnosť textu */
    z-index: 1;
}

#game-over-screen.active {
    display: flex;
    animation: cinematicFadeIn 2s ease-in-out forwards;
}

@keyframes cinematicFadeIn {
    0% { opacity: 0; transform: scale(1.1); filter: grayscale(100%); }
    100% { opacity: 1; transform: scale(1); filter: grayscale(0%); }
}

/* === ROZPIS SKÓRE NA VÍŤAZNEJ OBRAZOVKE === */
.sc-plus { color: #0f0; font-weight: bold; }
.sc-minus { color: #ff3333; font-weight: bold; }
.sc-base { color: #fff; font-weight: bold; }
.sc-divider {
    border: none;
    border-top: 1px solid rgba(0, 255, 255, 0.4);
    margin: 8px 0;
}

/* Kompaktné riadky rozpisu – bez toho preberali obrie písmo (2.5rem) a 50px
   medzery z .game-over-content p a tabuľka na počítači pretekala mimo obrazovky. */
#victory-screen .stats-container {
    font-size: clamp(1rem, 2.2vw, 1.3rem);
    margin: 16px 0;
}
#victory-screen .stats-container p {
    font-size: inherit;
    line-height: 1.35;
    margin: 6px 0;
    color: #fff;
}
#victory-screen .stats-container p:last-child {
    font-size: 1.35em; /* Finálne skóre mierne zvýrazníme */
    margin-top: 4px;
}
/* Voľné odseky vo víťaznej obrazovke (napr. „Svet je v bezpečí.“) – primeraná medzera */
#victory-screen > .game-over-content > p {
    margin: 10px 0 18px;
}

/* === VICTORY SCREEN === */
#victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.90);
    z-index: 2000;
    display: none; /* Flex cez JS */
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
}

#victory-screen .game-over-content {
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid #0ff;
    padding: clamp(20px, 3.5vw, 36px);
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
    text-align: center;
    animation: cinematicFadeIn 1.5s ease-in-out forwards;
    max-height: calc(100vh - 32px); /* Nikdy nevyššia ako okno */
    overflow-y: auto;               /* Ak sa nezmestí (nízke okno), skroluje sa vnútri rámčeka */
    max-width: min(94vw, 720px);    /* Úhľadná šírka na širokých monitoroch */
}

#victory-screen h1 {
    font-size: clamp(2.4rem, 6vw, 4.2rem); /* Menší strop – nech tabuľka nepreteká na nižších obrazovkách */
    margin-bottom: 8px;
    animation: textPulse 1.5s infinite alternate;
}

/* Trblietavý gradientový nadpis – text je priehľadný a presvitá cezeň bežiaci gradient */
#victory-title {
    text-shadow: none; /* Prebije červený glow z .game-over-content h1 – inak presvitá cez priehľadný text */
    background: linear-gradient(90deg, #0ff 0%, #fff 25%, #ffcc00 50%, #fff 75%, #0ff 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 0 14px rgba(0, 255, 255, 0.55));
    animation: recordShimmer 3s linear infinite, textPulse 1.5s infinite alternate;
}

.victory-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

/* Sekundárne tlačidlo (ZDIEĽAŤ) – obrysové, nech HRAŤ ZNOVA ostane hlavné */
#victory-screen button.secondary {
    background: transparent;
    color: #0ff;
    border-color: #0ff;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.4);
}

#victory-screen button.secondary:hover {
    background: rgba(0, 255, 255, 0.15);
    color: #fff;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.7);
    transform: scale(1.05);
}

#victory-screen p {
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: #fff;
}

#victory-screen button {
    margin-top: 18px;
    padding: 14px 40px;
    font-size: 2rem;
    font-family: 'Teko', sans-serif;
    color: #000;
    background: #0ff;
    border: 2px solid #fff;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 0 20px #0ff;
    transition: all 0.3s;
    text-transform: uppercase;
}

#victory-screen button:hover {
    background: #fff;
    color: #000;
    box-shadow: 0 0 40px #0ff;
    transform: scale(1.1);
}

.game-over-content {
    text-align: center;
    position: relative;
    z-index: 2; /* Musí byť nad ::before filtrom */
}

.game-over-content h1 {
    font-size: clamp(4rem, 10vw, 8rem);
    color: #ff0000;
    text-shadow: 0 0 20px #ff0000, 0 0 50px #ff0000, 0 0 100px #ff0000;
    margin-bottom: 20px;
    text-transform: uppercase;
    animation: textSlam 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, textGlitch 0.1s infinite 1s; /* Najprv dopadne, potom sa glitche */
}

@keyframes textSlam {
    0% { transform: scale(5); opacity: 0; filter: blur(20px); }
    30% { transform: scale(0.9); opacity: 1; filter: blur(0px); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes textGlitch {
    0% { transform: translate(3px, -3px); text-shadow: -4px 0 #0ff, 4px 0 #f00; }
    50% { transform: translate(-3px, 3px); text-shadow: 4px 0 #0ff, -4px 0 #f00; }
    100% { transform: translate(3px, -3px); text-shadow: -4px 0 #0ff, 4px 0 #f00; }
}

.game-over-content p {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: #fff;
    margin-bottom: 50px;
    opacity: 0;
    animation: fadeIn 1s ease forwards 1.5s; /* Ukáže sa až po náraze textu */
}

@keyframes fadeIn {
    to { opacity: 1; }
}

#tryAgainButton {
    padding: 20px 50px;
    font-size: 2.5rem;
    font-family: 'Teko', sans-serif;
    color: #fff;
    background: #a00;
    border: 3px solid #f00;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 0 30px #f00, inset 0 0 20px #f00;
    transition: all 0.3s;
    text-transform: uppercase;
    opacity: 0;
    animation: fadeIn 1s ease forwards 2s; /* Zobrazí sa ako posledné */
}

#tryAgainButton:hover {
    background: #f00;
    transform: scale(1.1);
    box-shadow: 0 0 50px #ff0000;
}

/* === CUSTOM KURZOR === */
/* VÝKON: kurzor aj stopa sa posúvajú výhradne cez transform (nastavuje JS v rAF slučke).
   Žiadne left/top zmeny ani CSS transition na pozícii – tie prepočítavali layout
   pri každom pixeli pohybu a spomaľovali celú hru. */
#custom-cursor {
    width: 30px;
    height: 30px;
    border: 2px solid #0ff;
    border-radius: 50%;
    position: fixed;
    left: 0;
    top: 0;
    transform: translate3d(-100px, -100px, 0);
    will-change: transform;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 0 10px #0ff, inset 0 0 5px #0ff;
    transition: width 0.1s, height 0.1s;
}

#custom-cursor::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 6px; height: 6px;
    background: #0ff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px #0ff;
}

#cursor-trail {
    width: 15px;
    height: 15px;
    background: rgba(0, 255, 255, 0.4);
    border-radius: 50%;
    position: fixed;
    left: 0;
    top: 0;
    transform: translate3d(-100px, -100px, 0);
    will-change: transform;
    pointer-events: none;
    z-index: 9998;
    filter: blur(4px);
}

body:active #custom-cursor {
    width: 20px;
    height: 20px;
    border-color: #fff;
    box-shadow: 0 0 20px #fff;
}
body:active #custom-cursor::after { background: #fff; }

/* === ABILITY POPUP === */
#ability-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: clamp(3rem, 6vw, 5rem);
    color: #0ff;
    text-shadow: 0 0 20px #0ff, 0 0 40px #0ff;
    font-weight: bold;
    z-index: 3000;
    pointer-events: none;
    opacity: 0;
    text-align: center;
    text-transform: uppercase;
    white-space: pre-line; /* Umožní combo + schopnosť na dvoch riadkoch */
    line-height: 1.1;
}

.show-ability {
    animation: popupAbility 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popupAbility {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(0.8); opacity: 0; }
}

/* === DANGER MODE ===
   VÝKON: vinetácia je fixný overlay so statickým box-shadow a pulzuje len opacity
   (GPU). Pôvodná animácia box-shadow na body prekresľovala celú obrazovku. */
body.danger-mode::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 800;
    box-shadow: inset 0 0 100px rgba(255, 0, 0, 0.8);
    animation: dangerVignette 1s infinite alternate;
    will-change: opacity;
}

@keyframes dangerVignette {
    0% { opacity: 0.1; }
    100% { opacity: 1; }
}

.danger-text {
    color: #ff3333 !important;
    text-shadow: 0 0 20px #ff3333 !important;
    animation: textPulse 0.5s infinite alternate;
}

@keyframes textPulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* === ZLODUCHOVSKÉ POZADIA A EFEKTY === */
body.bg-thanos {
    background-image: url('thanos_bg.webp') !important;
    animation: earthquake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    filter: grayscale(0.5) contrast(1.2);
    transition: background-image 0.5s ease;
}

body.bg-loki {
    background-image: url('loki_bg.webp') !important;
    filter: hue-rotate(90deg) brightness(1.2); /* Mierne zelenší a svetlejší filter */
    transition: background-image 0.5s ease;
}

/* === VESMÍRNE POZADIE PRI COMBE ===
   Celoobrazovková vrstva medzi pozadím a hracou plochou (z-index 2 < 10),
   takže karty ostanú navrchu viditeľné. Zapína sa triedou body.combo-space-active.
   Animácie bežia len keď je vrstva aktívna (šetrí výkon). */
/* COMBO EFEKT: ENERGETICKÝ NÁVAL – stmavené pozadie + pulzujúca energia zo stredu
   v hrdinských farbách + pulzujúce okraje. VÝKON: animuje sa LEN transform a opacity
   (bežia na GPU). Žiadny obrázok, blur, blend-mode ani animovaný filter. */
#combo-space {
    position: fixed;
    inset: 0;
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    transition: opacity 0.7s ease;
    will-change: opacity;
    contain: layout paint; /* izoluje prekresľovanie mimo tejto vrstvy */
}
body.combo-space-active #combo-space {
    opacity: 1;
}

/* Stmavené pozadie – zvýrazní karty aj energiu (statické, bez animácie) */
#combo-space .cs-base {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 48%,
        rgba(0, 45, 70, 0.5) 0%,
        rgba(2, 2, 12, 0.82) 70%);
}

/* Druhá vrstva hviezd a konické lúče sú vypnuté kvôli výkonu (najťažšie na
   skladanie na GPU). Efekt = vesmírny základ + hmlovina + jedna vrstva warp hviezd. */
#combo-space .cs-stars2,
#combo-space .cs-warp {
    display: none;
}

/* Pulzujúca energia zo stredu – hrdinské farby (tyrkysová→zlatá→červená).
   Animuje sa len transform (scale) a opacity → beží na GPU. */
#combo-space .cs-nebula {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%,
        rgba(190, 255, 255, 0.5) 0%,
        rgba(0, 230, 255, 0.42) 18%,
        rgba(255, 204, 0, 0.3) 40%,
        rgba(255, 70, 70, 0.15) 60%,
        transparent 76%);
    opacity: 0.7;
    will-change: transform, opacity;
    backface-visibility: hidden;
}
body.combo-space-active #combo-space .cs-nebula {
    animation: csSurge 1.5s ease-in-out infinite alternate;
}
@keyframes csSurge {
    0%   { transform: scale(0.82); opacity: 0.5; }
    100% { transform: scale(1.18); opacity: 1; }
}

/* Pulzujúce energetické okraje – inset žiara, animuje sa len opacity (GPU) */
#combo-space .cs-stars {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 150px 25px rgba(0, 220, 255, 0.4),
                inset 0 0 70px 6px rgba(255, 204, 0, 0.22);
    opacity: 0.3;
    will-change: opacity;
    backface-visibility: hidden;
}
body.combo-space-active #combo-space .cs-stars {
    animation: csEdgePulse 1.5s ease-in-out infinite alternate;
}
@keyframes csEdgePulse {
    0%   { opacity: 0.25; }
    100% { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
    body.combo-space-active #combo-space .cs-nebula,
    body.combo-space-active #combo-space .cs-stars {
        animation: none;
    }
}

/* Poznámka: zloduchovská pasca (Thanos/Loki) resetuje combo efekt priamo v JS
   (stopComboSpace v triggerVillainTrap), takže vesmírne pozadie sa zhasne a zvučka
   sa zastaví – zloduchovské pozadie je tak vždy viditeľné. */

/* Keď je zloduch trvalo odhalený na ploche */
.memory-card.villain-revealed .front-face {
    box-shadow: 0 0 30px #ff0000, inset 0 0 20px #ff0000;
    border-color: #ff0000;
}

.memory-card.villain-revealed {
    pointer-events: none; /* Už sa na neho nedá kliknúť */
    transform: rotateY(180deg) scale(0.95);
    filter: drop-shadow(0 0 15px rgba(255,0,0,0.8));
}

/* === SIEŇ SLÁVY (Highscores) === */
#highscores-container {
    font-size: 0.9rem;
    color: #fff;
    text-align: left;
    min-height: 60px;
}

#highscores-container h4 {
    margin: 0 0 10px 0;
    color: #0ff;
    text-align: center;
    text-shadow: 0 0 5px #0ff;
}

/* === OPTIMALIZÁCIA PRE MOBILY === */
@media (max-width: 768px) {
    #custom-cursor, #cursor-trail {
        display: none !important;
    }

    /* VÝKON na mobile: bez aurory (veľké blur vrstvy), bez odleskov kariet
       (24 animovaných vrstiev) a pomalšie dýchanie žiary */
    .menu-aurora {
        display: none;
    }
    .back-face::after,
    .front-face::after {
        display: none;
    }
    .bf-glow {
        animation-duration: 4s;
    }
    .memory-game {
        width: 95vw;
        height: 70vh; /* Roztiahneme hraciu plochu na výšku displeja */
        top: 55%;
        aspect-ratio: auto;
        grid-template-columns: repeat(4, 1fr) !important;
        grid-template-rows: repeat(6, 1fr) !important; /* Na mobiloch 4 stĺpce a 6 riadkov */
        gap: 8px;
    }
}

/* === J.A.R.V.I.S. ZAMERIAVAČ === */
.jarvis-target::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    border: 3px solid #ff0000;
    border-radius: 50%;
    border-top-color: transparent;
    border-bottom-color: transparent;
    box-shadow: 0 0 15px #ff0000;
    z-index: 10;
    animation: targetLock 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.jarvis-target::before {
    content: '+';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff0000;
    font-size: 40px;
    font-weight: bold;
    text-shadow: 0 0 10px #ff0000;
    z-index: 10;
    animation: targetBlink 1s infinite alternate;
}

@keyframes targetLock {
    0% { transform: translate(-50%, -50%) scale(3) rotate(0deg); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1) rotate(180deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.8) rotate(360deg); opacity: 1; }
}

@keyframes targetBlink {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* === EFEKT ZNIČENIA KARTY (IRON MAN LASER) === */
.shattered {
    animation: shatterEffect 1.5s forwards cubic-bezier(0.25, 1, 0.5, 1) !important;
    pointer-events: none !important;
    transition: none !important;
}

@keyframes shatterEffect {
    0% { transform: rotateY(180deg) scale(1) rotate(0deg); opacity: 1; filter: brightness(1) drop-shadow(0 0 0px #0ff); }
    10% { transform: rotateY(180deg) scale(1.1) rotate(-5deg); filter: brightness(2) drop-shadow(0 0 30px #0ff); }
    30% { transform: rotateY(180deg) scale(1.3) rotate(15deg); filter: brightness(3) drop-shadow(0 0 50px #0ff); }
    100% { transform: rotateY(180deg) scale(0) rotate(720deg); opacity: 0; filter: brightness(0); }
}

/* === HOVER EFEKT KARIET (3D TILT) ===
   --tilt-x/--tilt-y nastavuje JS podľa polohy kurzora nad kartou (initCardTilt).
   Karta sa tak naklápa za myšou ako holografická kartička. */
@media (pointer: fine) {
    .memory-card:not(.flip):not(.shattered):hover {
        transform: perspective(700px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(-6px) scale(1.06);
        transition: transform 0.09s ease-out; /* rýchla odozva na pohyb myši */
        z-index: 15;
    }
    .memory-card:not(.flip):not(.shattered):hover .back-face {
        box-shadow: 0 0 30px #0ff, 0 10px 25px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 255, 255, 0.9);
        border-color: #fff;
    }
    .memory-card:not(.flip):not(.shattered):hover .bf-glow {
        animation: none;
        opacity: 0; /* pri hoveri žiari samotná karta */
    }
    .memory-card:not(.flip):not(.shattered):hover .back-face::before {
        background-color: #fff;
        filter: drop-shadow(0 0 15px #fff) drop-shadow(0 0 30px #0ff);
    }
}

/* === ZÁBLESK OBRAZOVKY PRI ZHODE === */
#screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(0, 255, 255, 0.35) 0%, rgba(0, 255, 255, 0) 70%);
    opacity: 0;
    pointer-events: none;
    z-index: 900;
}

#screen-flash.flash {
    animation: screenFlash 0.5s ease-out forwards;
}

@keyframes screenFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* === PLÁVAJÚCE ZMENY ČASU (+10s / -2s) === */
#timerContainer {
    position: relative;
}

#time-delta {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    font-weight: bold;
    font-size: 1.4rem;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

#time-delta.delta-plus {
    color: #0f0;
    text-shadow: 0 0 10px #0f0;
    animation: floatDelta 1.2s ease-out forwards;
}

#time-delta.delta-minus {
    color: #f33;
    text-shadow: 0 0 10px #f33;
    animation: floatDelta 1.2s ease-out forwards;
}

@keyframes floatDelta {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
    20% { opacity: 1; transform: translate(-50%, 8px) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, 35px) scale(1); }
}

/* === ŽIVÉ SKÓRE A COMBO V HUD === */
#scoreDisplay {
    color: #ffcc00;
    text-shadow: 0 0 5px #ffcc00;
    font-weight: bold;
    display: inline-block;
}

#scoreDisplay.score-pop {
    animation: scorePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scorePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); text-shadow: 0 0 15px #ffcc00, 0 0 30px #ffcc00; }
    100% { transform: scale(1); }
}

#comboDisplay {
    color: #0f0;
    text-shadow: 0 0 5px #0f0;
    font-weight: bold;
    display: inline-block;
}

/* Rozpálené combo (3x a viac) */
#comboContainer.combo-hot #comboDisplay {
    color: #ff6600;
    text-shadow: 0 0 10px #ff6600, 0 0 20px #ff3300;
    animation: comboFire 0.5s infinite alternate;
}

@keyframes comboFire {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); text-shadow: 0 0 15px #ffaa00, 0 0 30px #ff3300; }
}

/* === HVIEZDY NA VICTORY OBRAZOVKE === */
#victory-stars {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin: 5px 0 10px 0;
    letter-spacing: 15px;
    text-indent: 15px;
}

#victory-stars .star {
    display: inline-block;
    color: rgba(255, 255, 255, 0.15);
    transform: scale(0);
}

#victory-stars .star.earned {
    color: #ffcc00;
    text-shadow: 0 0 20px #ffcc00, 0 0 40px #ff9900;
    animation: starPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#victory-stars .star.empty {
    animation: starFadeIn 0.4s ease forwards;
}

@keyframes starPop {
    0% { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.5) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes starFadeIn {
    to { transform: scale(1); }
}

/* === NOVÝ REKORD BADGE === */
#new-record-badge {
    display: none;
    font-size: clamp(1.3rem, 3.5vw, 2rem);
    color: #000;
    background: linear-gradient(90deg, #ffcc00, #ffee66, #ffcc00);
    background-size: 200% auto;
    padding: 5px 25px;
    border-radius: 30px;
    margin: 5px auto 10px auto;
    width: fit-content;
    box-shadow: 0 0 25px #ffcc00;
    animation: recordShimmer 2s linear infinite, recordBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

#new-record-badge.show {
    display: block;
}

@keyframes recordShimmer {
    to { background-position: 200% center; }
}

@keyframes recordBounce {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    60% { transform: scale(1.2) rotate(3deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* === PERFEKTNÁ HRA BADGE === */
#perfect-badge {
    display: none;
    font-size: clamp(1.2rem, 3vw, 1.7rem);
    color: #fff;
    background: linear-gradient(90deg, #00cc66, #00ffaa, #00cc66);
    background-size: 200% auto;
    padding: 5px 25px;
    border-radius: 30px;
    margin: 5px auto 10px auto;
    width: fit-content;
    box-shadow: 0 0 25px #00ffaa;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    animation: recordShimmer 2s linear infinite, recordBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both 0.4s;
}

#perfect-badge.show {
    display: block;
}