* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Poppins", "Comic Sans MS", Arial, sans-serif;
}

body {
    overflow-x: hidden;
    color: #2b235f;
    background:
        linear-gradient(rgba(255,255,255,.04), rgba(255,255,255,.04)),
        url("../image/animal-bg.webp") center center / cover no-repeat fixed;
}

.animal-page {
    min-height: 100vh;
    padding: 14px 24px 28px;
    position: relative;
}

/* Header */

.animal-header {
    width: min(1350px, 88%);
    min-height: 82px;
    margin: 0 auto 14px;
    padding: 10px 22px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;

    border-radius: 30px;
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(12px);

    box-shadow:
        0 10px 24px rgba(70,90,150,.12),
        inset 0 1px rgba(255,255,255,.85);
}

.animal-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.animal-icon-btn {
    min-width: 80px;
    min-height: 58px;

    border: 0;
    border-radius: 20px;
    padding: 8px 12px;

    background: rgba(255,255,255,.95);
    color: #4d38a6;
    text-decoration: none;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;

    font-size: 13px;
    font-weight: 900;

    box-shadow:
        0 7px 16px rgba(70,70,140,.12),
        inset 0 -3px rgba(0,0,0,.04);

    cursor: pointer;
}

.animal-icon-btn i {
    font-size: 23px;
}

.animal-icon-btn b {
    padding: 3px 10px;
    border-radius: 999px;
    background: #20bf63;
    color: #fff;
    font-size: 11px;
}

.animal-logo {
    text-align: center;
}

.animal-logo img {
    width: 48px;
    display: block;
    margin: 0 auto 2px;
}

.animal-logo h1 {
    margin: 0;
    color: #ff4b72;
    font-size: clamp(26px, 3vw, 44px);
    font-weight: 900;
    line-height: 1;
    text-shadow:
        0 4px 0 #fff,
        0 8px 16px rgba(0,0,0,.12);
}

.animal-logo p {
    width: fit-content;
    margin: 6px auto 0;
    padding: 4px 24px;

    border-radius: 999px;
    background: linear-gradient(135deg, #20c878, #11a85e);
    color: #fff;

    font-size: 14px;
    font-weight: 900;
}

/* Stats */

.animal-stats {
    width: min(1000px, 76%);
    margin: 0 auto 16px;

    display: grid;
    grid-template-columns: 170px 1fr 170px;
    gap: 16px;
    align-items: center;
}

.stat-card,
.progress-card {
    min-height: 66px;
    border-radius: 23px;
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(9px);
    box-shadow:
        0 8px 20px rgba(70,90,150,.12),
        inset 0 1px rgba(255,255,255,.85);
}

.stat-card {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.stat-card i {
    width: 48px;
    height: 48px;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #fff;
    font-size: 25px;
    background: linear-gradient(135deg, #ffe56d, #ffb22e);
}

.stat-card span {
    display: block;
    color: #7a4edb;
    font-size: 14px;
    font-weight: 900;
}

.stat-card strong {
    display: block;
    color: #22a84a;
    font-size: 30px;
    font-weight: 900;
    line-height: 1;
}

.progress-card {
    padding: 14px 20px;
}

.progress-card span {
    display: block;
    margin-bottom: 9px;
    color: #6136bd;
    font-size: 20px;
    font-weight: 900;
}

.progress-track {
    height: 15px;
    border-radius: 999px;
    background: #eee;
    overflow: hidden;
    box-shadow: inset 0 3px 8px rgba(0,0,0,.12);
}

.progress-fill {
    width: 5%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #55d947, #b8ff40);
    transition: .35s;
}

/* Levels */

.level-map {
    width: min(1050px, 86%);
    margin: 0 auto 16px;

    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.level-card {
    min-height: 96px;
    border: 0;
    border-radius: 24px;
    padding: 14px;

    background: rgba(255,255,255,.84);
    color: #2b235f;

    cursor: pointer;
    box-shadow:
        0 8px 20px rgba(70,90,150,.13),
        inset 0 -4px rgba(0,0,0,.04);

    transition: .25s;
}

.level-card span {
    display: block;
    color: #ffb22e;
    font-size: 15px;
    font-weight: 900;
}

.level-card strong {
    display: block;
    margin-top: 4px;
    color: #1a9e55;
    font-size: 24px;
    font-weight: 900;
}

.level-card small {
    display: block;
    margin-top: 5px;
    color: #5c4a9d;
    font-size: 13px;
    font-weight: 800;
}

.level-card:hover,
.level-card.active {
    transform: translateY(-4px);
    background: linear-gradient(135deg, #fff7d2, #eaffef);
    outline: 4px solid rgba(74, 196, 96, .5);
}

/* Board */

.animal-board {
    width: min(980px, 72%);
    margin: 0 auto 16px;
    padding: 28px;

    min-height: 460px;

    border-radius: 34px;
    border: 4px solid rgba(80, 205, 130, .55);

    background: rgba(255,255,255,.28);
    backdrop-filter: blur(10px);

    box-shadow:
        0 14px 36px rgba(72,72,130,.10),
        inset 0 1px rgba(255,255,255,.45);

    text-align: center;
}

.sound-panel {
    width: min(640px, 96%);
    margin: 0 auto 22px;
    padding: 18px 20px;

    border-radius: 28px;
    background: rgba(255,246,210,.88);

    box-shadow:
        0 10px 22px rgba(120,90,50,.10),
        inset 0 1px rgba(255,255,255,.85);
}

.sound-title {
    color: #321e72;
    font-size: clamp(22px, 2.4vw, 32px);
    font-weight: 900;
}

.listen-btn {
    margin-top: 14px;
    min-width: 190px;
    min-height: 64px;

    border: 0;
    border-radius: 24px;

    background: linear-gradient(135deg, #42c7ff, #2a84f2);
    color: #fff;

    font-size: 25px;
    font-weight: 900;

    cursor: pointer;

    box-shadow:
        0 10px 20px rgba(40,120,230,.25),
        inset 0 -5px rgba(0,0,0,.12);
}

.listen-btn i {
    margin-right: 8px;
}

#chooseText {
    margin: 18px 0 18px;
    color: #5c32b8;
    font-size: 28px;
    font-weight: 900;
}

.animal-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;

    width: min(720px, 96%);
    margin: 0 auto;
}

.animal-choice {
    min-height: 190px;

    border: 4px solid #7fd1ff;
    border-radius: 28px;

    background: rgba(255,255,255,.9);
    color: #321e72;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;

    cursor: pointer;
    transition: .25s;

    box-shadow:
        0 10px 20px rgba(70,90,150,.13),
        inset 0 -5px rgba(0,0,0,.05);
}

.animal-choice:hover {
    transform: translateY(-5px) scale(1.03);
}

.animal-choice img {
    width: 105px;
    height: 105px;
    object-fit: contain;
}

.animal-choice span {
    font-size: 22px;
    font-weight: 900;
}

.animal-choice.correct {
    border-color: #39d65d;
    background: #eaffef;
    animation: correctPulse .5s;
}

.animal-choice.wrong {
    border-color: #ff4f72;
    background: #fff0f4;
    animation: wrongShake .45s;
}

.hint-dim {
    opacity: .25;
    filter: grayscale(1);
    pointer-events: none;
}

@keyframes correctPulse {
    50% { transform: scale(1.08); }
}

@keyframes wrongShake {
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-5px); }
}

/* Bottom */

.animal-bottom {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    width: min(600px, 80%);
    margin: 0 auto;
}

.bottom-btn {
    min-width: 175px;
    min-height: 54px;

    border: 0;
    border-radius: 22px;
    padding: 12px 20px;

    background: rgba(255,255,255,.92);
    color: #5a3ca7;

    font-size: 18px;
    font-weight: 900;

    cursor: pointer;
    box-shadow:
        0 8px 18px rgba(80,65,160,.13),
        inset 0 -4px rgba(0,0,0,.06);
}

.bottom-btn.restart {
    background: linear-gradient(135deg, #ffa842, #ff7627);
    color: #fff;
}

/* Popup */

.popup-overlay,
.result-popup {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: none;
    align-items: center;
    justify-content: center;

    background: rgba(0,0,0,.45);
    backdrop-filter: blur(8px);
}

.result-popup {
    display: flex;
    overflow: hidden;
}

.popup-box,
.result-box {
    width: min(430px, 90%);
    padding: 34px 28px;

    border-radius: 32px;
    background: #fff;

    text-align: center;

    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.popup-box h2,
.result-box h2 {
    color: #ff4b72;
    font-size: 34px;
    font-weight: 900;
}

.popup-box p,
.result-box p {
    color: #5d3db0;
    font-size: 18px;
    font-weight: 800;
}

.popup-btn,
.result-buttons a {
    display: inline-block;
    margin-top: 15px;
    padding: 13px 26px;

    border: 0;
    border-radius: 20px;

    background: #8f4dff;
    color: #fff;

    text-decoration: none;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
}

/* Footer */

.footer {
    width: min(850px, 70%);
    margin: 24px auto 0;
    border-radius: 18px;
    background: rgba(5, 20, 30, .58);
    backdrop-filter: blur(8px);
    text-align: center;
}

.footer h4 {
    margin: 0;
    padding: 12px;
    color: #ffe66d;
}

/* Mobile */

@media (max-width: 900px) {
    body {
        background-attachment: scroll;
           background:url("../image/animal-bg-mob.webp") center / cover no-repeat fixed;
    }

    .animal-page {
        padding: 10px 8px 26px;
    }

    .animal-header {
        width: 96%;
        flex-wrap: wrap;
        justify-content: center;
    }

    .animal-logo {
        order: 1;
        width: 100%;
    }

    .animal-controls {
        order: 2;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .animal-stats {
        grid-template-columns: 1fr;
        width: 96%;
    }

    .level-map {
        grid-template-columns: 1fr;
        width: 96%;
    }

    .animal-board {
        width: 96%;
        min-height: auto;
        padding: 20px 14px;
    }

    .animal-options {
        grid-template-columns: 1fr;
    }

    .animal-choice {
        min-height: 150px;
    }

    .animal-choice img {
        width: 90px;
        height: 90px;
    }

    .footer {
        width: 94%;
    }
}

.next-level-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 13px 26px;
    border: 0;
    border-radius: 20px;
    background: #8f4dff;
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
}

.result-box {
    position: relative;
    overflow: hidden;
    animation: popupBounce .55s ease;
}

.result-icon {
    font-size: 52px;
    margin-bottom: 10px;
    animation: trophyPop 1s infinite alternate;
}

.result-effects {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.result-effects span {
    position: absolute;
    top: -20px;
    font-size: 24px;
    animation: fallStars 2.8s linear infinite;
}

.result-effects span:nth-child(1) { left: 12%; animation-delay: 0s; }
.result-effects span:nth-child(2) { left: 28%; animation-delay: .4s; }
.result-effects span:nth-child(3) { left: 48%; animation-delay: .8s; }
.result-effects span:nth-child(4) { left: 66%; animation-delay: .2s; }
.result-effects span:nth-child(5) { left: 84%; animation-delay: .6s; }

.result-row {
    width: 82%;
    margin: 10px auto;
    padding: 10px 16px;
    border-radius: 16px;
    background: #f5f2ff;

    display: flex;
    justify-content: space-between;

    color: #2b235f;
    font-size: 17px;
    font-weight: 900;
}

.result-row b {
    color: #20a84f;
}

.win-popup .result-box {
    background:
        radial-gradient(circle at top, #fff9c9, #ffffff 42%),
        #fff;
}

.lose-popup .result-box {
    background:
        radial-gradient(circle at top, #fff1f5, #ffffff 45%),
        #fff;
}

@keyframes popupBounce {
    0% { transform: scale(.75); opacity: 0; }
    70% { transform: scale(1.06); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes trophyPop {
    from { transform: rotate(-5deg) scale(1); }
    to { transform: rotate(5deg) scale(1.15); }
}

@keyframes fallStars {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 0;
    }
    15% { opacity: 1; }
    100% {
        transform: translateY(420px) rotate(260deg);
        opacity: 0;
    }
}