body.game-active {
    overflow: hidden;
}

body.game-active #gameRoot * {
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.game-screen {
    touch-action: pan-y;
}

body.game-active #gameRoot {
    display: block !important;
    padding: 1rem 3rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    box-sizing: border-box;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;

    background-color: #fff;
    background-image:
        radial-gradient(rgb(255, 255, 252) 0%, rgba(255, 253, 248, 0.95) 20%, rgba(255, 253, 245, 0) 70%),
        radial-gradient(at 50% 10%, rgba(180, 170, 220, 0.5) 0%, rgba(180, 130, 220, 0) 55%),
        radial-gradient(at 85% 20%, rgba(230, 150, 255, 0.45) 0%, rgba(230, 150, 255, 0) 50%),
        radial-gradient(at 10% 25%, rgba(130, 200, 255, 0.45) 0%, rgba(130, 200, 255, 0) 50%),
        radial-gradient(at 90% 60%, rgba(255, 180, 220, 0.5) 0%, rgba(255, 180, 220, 0) 45%),
        radial-gradient(at 5% 55%, rgba(160, 220, 255, 0.55) 0%, rgba(160, 220, 255, 0) 45%),
        radial-gradient(at 75% 80%, rgba(180, 220, 255, 0.45) 0%, rgba(180, 220, 255, 0) 50%),
        radial-gradient(at 20% 85%, rgba(255, 190, 230, 0.45) 0%, rgba(255, 190, 230, 0) 50%),
        linear-gradient(rgba(100, 90, 255, 0.9) 0%, rgba(100, 90, 255, 0) 30%);

}

@media (min-width: 1200px) {

    body.game-active #gameRoot .game-container,
    body.game-active #gameRoot .game-header {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }

    body.game-active #gameRoot .game-header {
        justify-content: center;
    }
}

@media (max-width: 600px) {

    body.game-active #gameRoot .game-container,
    body.game-active #gameRoot .game-header {
        font-size: smaller;
    }


}


#gameRoot {
    height: 100%;
    margin: 0;
    padding: 2rem 0;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;

    background-color: var(--wp--preset--color--bg-teal);


    color: var(--wp--preset--color--purple);


}

#gameRoot h2,
#gameRoot h3,
#gameRoot h4 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 1rem;
    color: currentColor;
}

#gameRoot .levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    justify-content: flex-start;
    gap: 1.5rem;
    max-width: var(--wp--style--global--content-size);
    margin-left: auto !important;
    margin-right: auto !important;
    padding-right: var(--wp--style--root--padding-right);
    padding-left: var(--wp--style--root--padding-left);
}

#gameRoot h2,
#gameRoot h3 {
    max-width: var(--wp--style--global--content-size);
    margin-left: auto !important;
    margin-right: auto !important;
    padding-right: var(--wp--style--root--padding-right);
    padding-left: var(--wp--style--root--padding-left);
}

@media (max-width: 768px) {
    #gameRoot .levels-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    #gameRoot {
        min-height: 100vh;
        min-height: 100dvh;
    }
}

.game-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.game-header img {
    max-width: 100px;
}

.game-title {
    display: flex;
    flex-direction: column;
    line-height: 1;
    gap: 6px;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 1px 1px 5px rgba(0, 0, 0, 0.1), 0 0px 10px rgba(0, 0, 0, 0.1);
}

.game-title .game-name {
    font-weight: bold;
}

.game-title .level-name {
    font-size: smaller;
}


#gameRoot .level-button,
#gameRoot .category-button {

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: currentColor;
    padding: 1rem 1rem;
    min-height: 60px;

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
        inset -2px -2px 4px 0px rgba(255, 255, 255, 0.1),
        0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 1rem;
    transition: all 0.2s ease;
    font-size: smaller;
    cursor: pointer;
    text-align: left;
    position: relative;
}

#gameRoot .level-button:hover,
#gameRoot .category-button:hover {
    transform: translateY(-8px);
    background: #fff6d6;
    box-shadow:
        inset -2px -2px 4px 0px rgba(255, 255, 255, 0.2),
        0 8px 16px -2px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

#gameRoot .level-button img {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;

}

#gameRoot .level-button.free {}

#gameRoot .level-button.premium {
    background: #fff6c8;
}

.badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.premium .badge {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: white;
}

.free .badge {
    background: linear-gradient(135deg, #a2e710 0%, #58d510 100%);
    color: white;
}

.level-emoji {
    font-size: 5rem;
}

.levels-grid.memory-game .level-icon-wrapper {
    font-size: clamp(3rem, 5vw, 5rem);
}

.progress-bar-bg {
    background: #d9e0eb;
    border: solid 3px #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
    border-radius: 2rem;
    margin-bottom: 1rem;
    font-size: smaller;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.game-controls .progress-bar-bg {
    margin: 0
}

.progress-bar-fill {
    border-radius: 2rem;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}


.progress-text {
    padding: 0 1rem;
    white-space: nowrap;
}


.game-instructions {
    display: flex;
    width: fit-content;
    margin: 1rem auto;
    font-size: smaller;
}

.glow {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 240, 250, 0.6) 25%, rgba(240, 248, 255, 0.6) 50%, rgba(255, 250, 240, 0.6) 75%, rgba(255, 255, 255, 0.6) 100%);
    backdrop-filter: blur(10px);
    box-shadow: rgba(0, 0, 0, 0.08) 0px 4px 15px, rgba(255, 200, 255, 0.15) 0px 0px 20px, rgba(255, 255, 255, 0.8) 0px 0px 20px inset;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.game-instructions.success {
    color: #2e7d32;
    font-weight: bold;
    animation: popBlink 0.35s ease-out;
}

.game-instructions.error {
    color: #c62828;
    font-weight: bold;
    animation: popBlink 0.35s ease-out;
}

@keyframes popBlink {
    0% {
        opacity: 0.4;
        transform: scale(0.96);
    }

    40% {
        opacity: 1;
        transform: scale(1.04);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@media screen and (max-width: 600px) {
    body.game-active #gameRoot {
        padding: 1rem;
    }
}



.glass {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.4) 100%);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 8px 32px rgba(180, 130, 220, 0.2), 0 2px 8px rgba(255, 255, 255, 0.5) inset;
}



body.game-active #gameRoot:has(.game-screen.blockdoku) {
    background: radial-gradient(ellipse at 0% 50%, hsl(165, 70%, 60%) 0%, transparent 50%), radial-gradient(ellipse at 100% 50%, hsl(280, 65%, 55%) 0%, transparent 50%), radial-gradient(ellipse at 50% 100%, hsl(200, 60%, 55%) 0%, transparent 50%), linear-gradient(135deg, #4edac2, #913bce)
}


body.game-active #gameRoot:has(.game-screen.mahjong) {
    background: radial-gradient(ellipse at 0% 100%, hsl(175, 50%, 35%) 0%, transparent 55%), radial-gradient(ellipse at 100% 0%, hsl(145, 55%, 40%) 0%, transparent 55%), radial-gradient(ellipse at 50% 50%, hsl(160, 50%, 30%) 0%, transparent 50%), linear-gradient(135deg, #2a796c, #2f9361)
}

body.game-active #gameRoot:has(.game-screen.mastermind) {
    background: radial-gradient(ellipse at 20% 20%, hsl(220, 50%, 18%) 0%, transparent 50%), radial-gradient(ellipse at 80% 80%, hsl(280, 45%, 15%) 0%, transparent 50%), radial-gradient(ellipse at 50% 50%, hsl(250, 48%, 12%) 0%, transparent 55%), linear-gradient(135deg, #151e37, #1b0f24)
}

body.game-active #gameRoot:has(.game-screen.match3) {
    background: radial-gradient(ellipse at 0% 0%, hsl(35, 90%, 55%) 0%, transparent 50%), radial-gradient(ellipse at 100% 100%, hsl(290, 70%, 50%) 0%, transparent 55%), radial-gradient(ellipse at 70% 30%, hsl(330, 80%, 55%) 0%, transparent 45%), linear-gradient(135deg, #ee8c2b, #9b2dd2)
}



body.game-active #gameRoot:has(.game-screen.solitaire) {
    background: radial-gradient(ellipse at 0% 100%, hsl(175, 50%, 35%) 0%, transparent 55%), radial-gradient(ellipse at 100% 0%, hsl(145, 55%, 40%) 0%, transparent 55%), radial-gradient(ellipse at 50% 50%, hsl(160, 50%, 30%) 0%, transparent 50%), linear-gradient(135deg, #2a796c, #2f9361)
}

body.game-active #gameRoot:has(.game-screen.sudoku) {
    background: radial-gradient(ellipse at 0% 30%, hsl(190, 70%, 55%) 0%, transparent 50%), radial-gradient(ellipse at 100% 70%, hsl(330, 60%, 65%) 0%, transparent 50%), radial-gradient(ellipse at 50% 50%, hsl(250, 50%, 60%) 0%, transparent 60%), linear-gradient(135deg, #57badb, #d161ac)
}



:root {
    --slot-size: 60px;
}

@media (max-width: 480px) {
    :root {
        --slot-size: 40px;
    }
}


.word-slots {
    display: flex;
    width: fit-content;
    margin: 2rem auto;
    gap: 4px;
    justify-content: center;
    background: rgba(0, 0, 0, 0.06);
    padding: 1rem;
    border-radius: 12px;
    flex-wrap: wrap;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.letter-tray {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
    z-index: 1;
}

.letter-slot {
    width: var(--slot-size);
    height: var(--slot-size);
    border: 2px dashed #999;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.letter-slot.highlight {
    border-color: #2196F3;
    background: #e3f2fd;
}

.letter-slot.prefilled {
    background: #e8f5e9;
    border-color: #a5d6a7;
    box-shadow: none;
    border-style: solid;
}

.letter-piece.prefilled {
    box-shadow: none;
    background: linear-gradient(145deg, #dedcf1, #a3e2e7);
}


.letter-piece {
    text-transform: uppercase;
    width: calc(var(--slot-size) - 6px);
    height: calc(var(--slot-size) - 6px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #f1e7dc, #e7daa3);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1),
        inset 0 -2px 8px rgba(0, 0, 0, 0.15),
        inset 0 2px 8px rgba(255, 255, 255, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.4);
    position: relative;
    border-radius: 8px;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.letter-piece::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), transparent);
    border-radius: 4% 4% 80% 100% / 4% 100% 80% 80%;
    pointer-events: none;
}

.letter-piece:hover:not(.prefilled):not(.is-dragging) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.letter-piece:active:not(.prefilled) {
    cursor: grabbing;
}

.letter-piece.is-dragging {
    cursor: grabbing !important;
    pointer-events: none;
    z-index: 9999 !important;
}

.letter-piece-placeholder {
    width: var(--slot-size);
    height: var(--slot-size);
    visibility: hidden;
    flex-shrink: 0;
}


.letter-tray .letter-piece:nth-of-type(7n+1) {
    transform: rotate(-5deg);
}

.letter-tray .letter-piece:nth-of-type(7n+2) {
    transform: rotate(3deg);
}

.letter-tray .letter-piece:nth-of-type(7n+3) {
    transform: rotate(-2deg);
}

.letter-tray .letter-piece:nth-of-type(7n+4) {
    transform: rotate(4deg);
}

.letter-tray .letter-piece:nth-of-type(7n+5) {
    transform: rotate(-4deg);
}

.letter-tray .letter-piece:nth-of-type(7n+6) {
    transform: rotate(1deg);
}

.letter-tray .letter-piece:nth-of-type(7n+0) {
    transform: rotate(-3deg);
}



.game-popup {
    position: relative;
    z-index: 20;
    background: #fff8d7;
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.8) translateY(-30px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}