* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

html {
    container-type: size;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    width: 100cqw;
    height: 100cqh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Fredoka', sans-serif;
    color: #3a3528;
}

.game-wrapper {
    width: 100cqw;
    height: 100cqh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: url('assets/bg_image.webp') no-repeat center center;
    background-size: cover;
    overflow: hidden;
    position: relative;
    transition: background-image 0.4s ease;
}

.game-wrapper.win-bg {
    background-image: url('assets/result_bg_image.webp');
}

.game-wrapper:has(#game-scene.active)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.15);
    pointer-events: none;
    z-index: 1;
}

.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100cqw;
    height: 100cqh;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.particle {
    position: absolute;
    bottom: -2cqh;
    width: 0.8cqw;
    height: 0.8cqw;
    background-color: rgba(212, 175, 55, 0.25);
    border-radius: 50%;
    animation: floatUp 8s infinite linear;
    filter: blur(0.1cqw);
}

.particle:nth-child(1) {
    left: 10cqw;
    width: 0.6cqw;
    height: 0.6cqw;
    animation-duration: 9s;
    animation-delay: 0s;
}

.particle:nth-child(2) {
    left: 25cqw;
    width: 1cqw;
    height: 1cqw;
    animation-duration: 7s;
    animation-delay: 1.5s;
}

.particle:nth-child(3) {
    left: 40cqw;
    width: 0.5cqw;
    height: 0.5cqw;
    animation-duration: 11s;
    animation-delay: 3s;
}

.particle:nth-child(4) {
    left: 55cqw;
    width: 0.8cqw;
    height: 0.8cqw;
    animation-duration: 8s;
    animation-delay: 0.5s;
}

.particle:nth-child(5) {
    left: 70cqw;
    width: 1.2cqw;
    height: 1.2cqw;
    animation-duration: 6s;
    animation-delay: 2.5s;
}

.particle:nth-child(6) {
    left: 85cqw;
    width: 0.7cqw;
    height: 0.7cqw;
    animation-duration: 10s;
    animation-delay: 4s;
}

.particle:nth-child(7) {
    left: 15cqw;
    width: 0.9cqw;
    height: 0.9cqw;
    animation-duration: 8.5s;
    animation-delay: 5s;
}

.particle:nth-child(8) {
    left: 35cqw;
    width: 1.1cqw;
    height: 1.1cqw;
    animation-duration: 6.5s;
    animation-delay: 3.5s;
}

.particle:nth-child(9) {
    left: 65cqw;
    width: 0.6cqw;
    height: 0.6cqw;
    animation-duration: 9.5s;
    animation-delay: 1s;
}

.particle:nth-child(10) {
    left: 90cqw;
    width: 0.8cqw;
    height: 0.8cqw;
    animation-duration: 7.5s;
    animation-delay: 5.5s;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(-105cqh) translateX(3cqw);
        opacity: 0;
    }
}

.game-container {
    container-type: size;
    width: min(96cqw, 170.66cqh);
    height: min(54cqw, 96cqh);
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 3;
}

.scene {
    display: none;
    width: 100cqw;
    height: 100cqh;
}

.scene.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#game-scene.active {
    justify-content: flex-start;
    padding-top: 1.5cqh;
}

#start-scene {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 4cqh 4cqw;
    width: 100cqw;
    height: 100cqh;
}

.logo-wrapper {
    position: relative;
    overflow: hidden;
    display: block;
    margin: 0 auto;
    animation: logoPulsate 3s infinite ease-in-out;
}


@keyframes logoPulsate {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.04);
    }
}

.start-logo-wrapper {
    width: 65cqw;
    margin-bottom: 5cqh;
}

.start-title-logo {
    width: 100%;
    height: auto;
    display: block;
}

.btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.5cqw;
    font-weight: 600;
    color: #8a6d21;
    background: #ffffff;
    border: 0.3cqw solid #ffd700;
    border-radius: 5cqw;
    padding: 2cqh 6cqw;
    cursor: pointer;
    box-shadow: 0 0.8cqh 2cqh rgba(212, 175, 55, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
    outline: none;
}

.btn:hover {
    transform: translateY(-0.3cqh);
    background: linear-gradient(135deg, #ffdb70 0%, #d4af37 100%);
    color: #ffffff;
    box-shadow: 0 1cqh 2.5cqh rgba(212, 175, 55, 0.25);
}

.btn:active {
    transform: translateY(0.1cqh);
    background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
    color: #ffffff;
    box-shadow: 0 0.5cqh 1.2cqh rgba(212, 175, 55, 0.15);
}

.play-image-btn {
    width: 22cqw;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 0.8cqh 1.8cqh rgba(212, 175, 55, 0.3));
    display: block;
    margin: 0 auto;
}

.play-image-btn:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 1.2cqh 2.5cqh rgba(212, 175, 55, 0.5));
}

.play-image-btn:active {
    transform: scale(0.96);
}

.top-hud {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100cqw;
    position: relative;
    margin-bottom: 2cqh;
    padding: 0 4cqw;
    height: 8cqh;
}

.instruction-box {
    background: linear-gradient(135deg, #ffffff 0%, #fffdf9 100%);
    border: 0.3cqw solid #ffdb70;
    border-radius: 4cqw;
    padding: 0 4cqw;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0.6cqh 2cqh rgba(212, 175, 55, 0.12), inset 0 0 1cqw rgba(255, 219, 112, 0.15);
    animation: instructionFloat 4s infinite ease-in-out;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

.instruction-text {
    font-size: 2cqw;
    font-weight: 600;
    background: linear-gradient(to right, #4a4235 25%, #d4af37 45%, #ffffff 50%, #d4af37 55%, #4a4235 75%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    letter-spacing: 0.05cqw;
    animation: textShimmer 3s infinite linear;
}

@keyframes instructionFloat {

    0%,
    100% {
        transform: translate3d(0, 0, 0);
        border-color: #ffdb70;
        box-shadow: 0 0.6cqh 2cqh rgba(212, 175, 55, 0.12), inset 0 0 1cqw rgba(255, 219, 112, 0.15);
    }

    50% {
        transform: translate3d(0, -0.4cqh, 0);
        border-color: #ffd700;
        box-shadow: 0 1cqh 2.5cqh rgba(212, 175, 55, 0.22), 0 0 1.5cqw rgba(255, 215, 0, 0.15), inset 0 0 1.5cqw rgba(255, 219, 112, 0.25);
    }
}

@keyframes textShimmer {
    0% {
        background-position: 200% center;
    }

    100% {
        background-position: -200% center;
    }
}

.score-box {
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    border: 0.2cqw solid #ffffff;
    border-radius: 1.5cqw;
    padding: 0 3cqw;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0.6cqh 1.8cqh rgba(212, 175, 55, 0.2), inset 0 -0.4cqh 0.8cqh rgba(0, 0, 0, 0.1);
    position: absolute;
    right: 4cqw;
}

.score-box.sparkle {
    animation: scoreSparkle 0.5s ease-out;
}

@keyframes scoreSparkle {
    0% {
        transform: scale(1);
        box-shadow: 0 0.6cqh 1.8cqh rgba(212, 175, 55, 0.2), inset 0 -0.4cqh 0.8cqh rgba(0, 0, 0, 0.1);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 3cqw #ffd700, 0 0 6cqw rgba(255, 215, 0, 0.8), inset 0 0 2cqw rgba(255, 255, 255, 0.6);
        filter: brightness(1.2);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0.6cqh 1.8cqh rgba(212, 175, 55, 0.2), inset 0 -0.4cqh 0.8cqh rgba(0, 0, 0, 0.1);
    }
}

#progress-text {
    font-size: 2cqw;
    font-weight: 700;
    color: #3d2b00;
    white-space: nowrap;
}

.images-container {
    display: flex;
    gap: 3.5cqw;
    width: 100cqw;
    justify-content: center;
    margin-bottom: 2cqh;
}

.image-wrapper {
    container-type: size;
    width: 35.4cqw;
    height: 84cqh;
    position: relative;
    z-index: 2;
}

.image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffffff 0%, #faf8f2 100%);
    border: 0.6cqw solid #d4af37;
    border-radius: 2cqw;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1.2cqh 3.6cqh rgba(212, 175, 55, 0.15);
    overflow: hidden;
    user-select: none;
}

.original {
    animation: borderGlow 10s infinite ease-in-out;
}



@keyframes borderGlow {

    0%,
    90%,
    100% {
        border-color: #d4af37;
        box-shadow: 0 1.2cqh 3.6cqh rgba(212, 175, 55, 0.15);
    }

    95% {
        border-color: #ffd700;
        box-shadow: 0 0 3cqw rgba(255, 215, 0, 0.4);
    }
}

@keyframes diagonalFlash {

    0%,
    90% {
        transform: translateX(-150%);
    }

    100% {
        transform: translateX(150%);
    }
}

.game-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.placeholder-label {
    font-size: 2.6cqw;
    color: #ffffff;
    font-weight: 600;
    text-shadow: 0.15cqw 0.15cqh 0.3cqw rgba(0, 0, 0, 0.3);
}

.altered {
    cursor: pointer;
}

.markers-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.difference-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 2.2cqw;
    font-weight: 800;
    text-shadow: 0 0.1cqh 0.2cqh rgba(0, 0, 0, 0.5);
    pointer-events: none;
    aspect-ratio: 1 / 1;
    z-index: 11;
    transition: all 0.3s ease;
}

.difference-marker.unfound {
    display: none;
}

.difference-marker.found {
    display: flex;
    border: 0.5cqw solid #ffd700;
    background-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 2.5cqw #ffd700, inset 0 0 1.5cqw #ffd700, 0 0 5cqw rgba(255, 215, 0, 0.8);
    animation: markerPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes markerPop {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

#end-scene.active {
    justify-content: center;
    align-items: center;
    padding: 0;
}

.win-logo-wrapper {
    width: 60cqw;
    margin-bottom: 3cqw;
    position: relative;
    z-index: 20;
}

.win-title-image {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 0.8cqh 2cqh rgba(212, 175, 55, 0.3));
}

.shake {
    animation: shakeEffect 0.4s ease-in-out;
}

@keyframes shakeEffect {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-1cqw);
    }

    40% {
        transform: translateX(1cqw);
    }

    60% {
        transform: translateX(-0.8cqw);
    }

    80% {
        transform: translateX(0.8cqw);
    }

    100% {
        transform: translateX(0);
    }
}

.watermark-logo {
    position: absolute;
    bottom: 4cqh;
    left: 3cqw;
    width: 10cqw;
    height: auto;
    pointer-events: none;
    z-index: 100;
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.flower-rain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

.flower-petal {
    position: absolute;
    top: -10vh;
    left: var(--left-position);
    will-change: transform;
    animation: flowerFall var(--fall-duration) var(--animation-delay) linear infinite;
}

.flower-petal-sway {
    will-change: transform;
    animation: flowerSway var(--sway-duration) ease-in-out infinite alternate;
}

.flower-petal-inner {
    color: #ffffff;
    text-shadow: 0 0 1vw #ffffff, 0 0 2vw rgba(212, 175, 55, 0.6);
    font-size: var(--flower-size);
    opacity: var(--flower-opacity);
    display: inline-block;
    will-change: transform;
    animation: flowerSpin var(--spin-duration) linear infinite;
}

@keyframes flowerFall {
    0% {
        transform: translate3d(0, 0, 0);
    }
    100% {
        transform: translate3d(0, 120vh, 0);
    }
}

@keyframes flowerSway {
    0% {
        transform: translate3d(calc(-1 * var(--sway-distance)), 0, 0);
    }
    100% {
        transform: translate3d(var(--sway-distance), 0, 0);
    }
}

@keyframes flowerSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@media (max-aspect-ratio: 1/1) {
    .game-container {
        width: min(96cqw, 54cqh);
        height: min(170.66cqw, 96cqh);
    }

    .start-logo-wrapper {
        width: 65cqw;
        margin-bottom: 15cqh;
    }

    .btn {
        font-size: 4cqw;
        padding: 2.5cqh 8cqw;
    }

    .play-image-btn {
        width: 30cqw;
    }

    .top-hud {
        flex-direction: column;
        gap: 1.5cqh;
        height: auto;
        margin-bottom: 2cqh;
        padding: 0;
    }

    .instruction-box {
        width: 90cqw;
        height: 6cqh;
        border: 0.5cqw solid #ffdb70;
        border-radius: 3cqw;
        padding: 0 3cqw;
    }

    .instruction-text {
        font-size: 3.5cqw;
    }

    .score-box {
        position: static;
        height: 5cqh;
        border: 0.3cqw solid #ffffff;
        border-radius: 2cqw;
        padding: 0 5cqw;
    }

    #progress-text {
        font-size: 3.5cqw;
    }

    .images-container {
        flex-direction: column;
        gap: 1.5cqh;
        align-items: center;
    }

    .image-wrapper {
        width: 52cqw;
        height: 39cqh;
        z-index: 2;
    }

    .placeholder-label {
        font-size: 4.5cqw;
    }

    .difference-marker {
        font-size: 3.8cqw;
    }

    .win-logo-wrapper {
        width: 80cqw;
    }
}