* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
:root {
    --puzzle-image: url("../img/puzzle2.png");
}
body {
    font-family: Arial;
    background-color: #fbf7f4;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#home {
    position: fixed;
    top: 25px;
    left: 25px;
    height: 75px;
    width: 75px;
    border-radius: 100%;
    border: 3px solid #30abe8;
    padding: 15px;
    background-color: rgba(48, 171, 232, 0.12);
    cursor: pointer;
    opacity: 0.85;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#home:hover {
    transition: 0.3s ease;
    transform: scale(1.05);
    opacity: 1;
    background-color: rgba(48, 171, 232, 0.22);
}
#home svg {
    width: 28px;
    height: 28px;
    color: #262f40;
}
.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: start;
    position: relative;
    gap: 2%;
    padding: 10px;
}
.sub-container{
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.div-container{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 500px;
    background-color: white;
    border-radius: 20px;
    padding: 20px;
    z-index: 0;
}
.title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #262f40;
}
.buttons-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.button {
    background-color: #30abe8;
    padding: 10px;
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    font-size: 20px;
}
.button:hover {
    background-color: #0088cb;
    transition: background-color 0.5s;
}
.button:disabled {
    opacity: 0.55;
    cursor: default;
}
.nav-button {
    width: 44px;
    font-weight: bold;
    padding: 10px 0;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}
.nav-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2.2;
    flex-shrink: 0;
}
#result-container {
    width: 400px;
    height: 400px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 5px;
    gap: 7px;
}
#result-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--puzzle-image);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.45;
    z-index: -1;
}
#pieces-container {
    width: 430px;
    height: 430px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
}
.piece {
    width: 133px;
    height: 133px;
    cursor: grab;

    background-image: var(--puzzle-image);
    background-size: 300% 300%;
    background-repeat: no-repeat;
}
.square-container{
    width: 125px;
    height: 125px;
    border: 3px dotted gray;
    display: flex;
    justify-content: center;
    align-items: center;
}

.square-container .piece {
    flex-shrink: 0;
}
#win-indicator {
    display: none;
    position: fixed;
    inset: 0;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.win-badge {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background-color: #1fb85a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.2);
}

.win-icon {
    width: 82px;
    height: 82px;
    stroke-width: 2.6;
}

#win-indicator.animate .win-badge {
    animation:
        winGrow 0.3s ease-out forwards,
        winPulse 0.35s ease-in-out 0.3s 4,
        winFade 0.3s ease-in 1.7s forwards;
}

@keyframes winGrow {
    from {
        opacity: 0;
        transform: scale(0.2);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes winPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes winFade {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Tablet */
@media (max-width: 1020px) {
    body {
        height: auto;
        min-height: 100vh;
        align-items: start;
        justify-content: center;
        padding: 20px 12px;
    }
    .container {
        align-items: center;
        gap: 16px;
        width: 100%;
        padding: 0;
    }
    .sub-container {
        width: 100%;
    }
    .div-container {
        height: 400px;
        padding: 16px;
        border-radius: 16px;
    }
    .title {
        font-size: 1.35rem;
        margin-bottom: 8px;
    }
    #result-container {
        width: 320px;
        height: 320px;
        padding: 4px;
        gap: 6px;
    }
    #pieces-container {
        width: 344px;
        height: 344px;
        gap: 4px;
    }
    .square-container {
        width: 100px;
        height: 100px;
    }
    .piece {
        width: 106px;
        height: 106px;
    }
    .button {
        font-size: 15px;
    }
    .nav-button {
        width: 38px;
    }
    .win-badge {
        width: 120px;
        height: 120px;
    }
    .win-icon {
        width: 72px;
        height: 72px;
    }
    #home {
        top: 16px;
        left: 16px;
        width: 64px;
        height: 64px;
        padding: 12px;
    }
    #home svg {
        width: 24px;
        height: 24px;
    }

}

/* Mobile */
@media (max-width: 768px) {
    body {
        padding: 14px 8px;
    }
    .container {
        flex-direction: column;
        gap: 12px;
    }
    .div-container {
        padding: 12px;
        height: 300px;
        border-radius: 12px;
    }
    .title {
        font-size: 1.1rem;
        margin-bottom: 6px;
    }
    #result-container {
        width: 258px;
        height: 258px;
        padding: 3px;
        gap: 4px;
    }
    #pieces-container {
        width: 278px;
        height: 278px;
        gap: 3px;
    }
    .square-container {
        width: 80px;
        height: 80px;
        border-width: 2px;
    }
    .piece {
        width: 85px;
        height: 85px;
    }
    .nav-button {
        width: 34px;
    }
    .win-badge {
        width: 100px;
        height: 100px;
    }
    .win-icon {
        width: 60px;
        height: 60px;
    }
    #home {
        top: 12px;
        left: 12px;
        width: 56px;
        height: 56px;
        padding: 10px;
    }
    #home svg {
        width: 22px;
        height: 22px;
    }
}
