/* ---------- RESET ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

/* ---------- BODY WITH JUNGLE BACKGROUND ---------- */
body {
    min-height: 100vh;
    background-image: url('../images/background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    font-family: 'Comic Sans MS', 'Chalkboard SE', cursive, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    position: relative;
    overflow-x: hidden;
}

/* ---------- FLOATING ANIMALS (Background) ---------- */
.floating-animals {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-animal {
    position: absolute;
    font-size: 2.5rem;
    opacity: 0.2;
    animation: floatAnim 20s ease-in-out infinite;
}

.floating-animal:nth-child(odd) {
    animation-duration: 25s;
}

.floating-animal:nth-child(3n) {
    animation-duration: 30s;
    font-size: 3rem;
}

.floating-animal:nth-child(5n) {
    animation-duration: 18s;
    font-size: 2rem;
}

@keyframes floatAnim {
    0% {
        transform: translateY(0px) rotate(0deg) scale(1);
        opacity: 0.1;
    }
    25% {
        transform: translateY(-60px) rotate(5deg) scale(1.1);
        opacity: 0.25;
    }
    50% {
        transform: translateY(-120px) rotate(-3deg) scale(0.9);
        opacity: 0.15;
    }
    75% {
        transform: translateY(-60px) rotate(8deg) scale(1.05);
        opacity: 0.25;
    }
    100% {
        transform: translateY(0px) rotate(0deg) scale(1);
        opacity: 0.1;
    }
}

/* ---------- MAIN CONTAINER ---------- */
.container {
    max-width: 1000px;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(6px);
    border-radius: 60px;
    padding: 24px 18px 28px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.15);
    position: relative;
    z-index: 1;
}

/* ---------- HEADER ---------- */
h1 {
    font-size: 2.8rem;
    color: #ffffff;
    text-shadow: 4px 4px 0 #2d5a1e, 0 4px 30px rgba(0, 0, 0, 0.4);
    letter-spacing: 2px;
    animation: wiggle 1.2s ease-in-out infinite;
    display: inline-block;
}

@keyframes wiggle {
    0%,
    100% {
        transform: rotate(-2deg) scale(1);
    }
    25% {
        transform: rotate(2deg) scale(1.02);
    }
    50% {
        transform: rotate(-2deg) scale(1);
    }
    75% {
        transform: rotate(2deg) scale(1.02);
    }
}

.subtitle {
    font-size: 1.1rem;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    display: inline-block;
    padding: 4px 22px;
    border-radius: 40px;
    margin-top: 4px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-weight: bold;
}

/* ---------- SURPRISE BUTTON ---------- */
.surprise-section {
    margin: 14px 0 12px;
}

.surprise-btn {
    background: linear-gradient(135deg, #ff6b6b, #ff4757, #ff6b81);
    color: white;
    border: none;
    padding: 12px 32px;
    font-size: 1.4rem;
    font-weight: bold;
    border-radius: 60px;
    cursor: pointer;
    box-shadow: 0 6px 0 #c0392b, 0 8px 20px rgba(255, 71, 87, 0.4);
    transition: transform 0.12s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
    font-family: 'Comic Sans MS', cursive;
    animation: rainbow-border 2s linear infinite;
    border: 4px solid transparent;
}

.surprise-btn:active {
    transform: translateY(6px) scale(0.96);
    box-shadow: 0 2px 0 #c0392b, 0 4px 12px rgba(255, 71, 87, 0.3);
}

/* ---------- ANIMAL GRID (PHONE-FIXED) ---------- */
.animal-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 16px 0 14px;
    padding: 2px;
}

/* ---------- ANIMAL BUTTONS ---------- */
.animal-btn {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(2px);
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 12px 4px 10px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.2s ease;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1), 0 6px 16px rgba(0, 0, 0, 0.08);
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    animation: rainbow-border 3s linear infinite;
    border-color: transparent;
}

@keyframes rainbow-border {
    0% {
        border-color: rgba(255, 107, 107, 0.6);
    }
    16% {
        border-color: rgba(254, 202, 87, 0.6);
    }
    33% {
        border-color: rgba(72, 219, 251, 0.6);
    }
    50% {
        border-color: rgba(29, 209, 161, 0.6);
    }
    66% {
        border-color: rgba(162, 155, 254, 0.6);
    }
    83% {
        border-color: rgba(253, 121, 168, 0.6);
    }
    100% {
        border-color: rgba(255, 107, 107, 0.6);
    }
}

.animal-btn:active,
.animal-btn.pressed {
    transform: translateY(6px) scale(0.92);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.animal-btn img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(2px 4px 8px rgba(0, 0, 0, 0.2));
}

.animal-btn .label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    padding: 0 10px;
    border-radius: 30px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* ---------- FOOTER ---------- */
footer {
    margin-top: 16px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    opacity: 0.8;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ---------- POPUP OVERLAY ---------- */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
}

.popup-overlay.active {
    display: flex;
}

.popup-content {
    background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #1dd1a1, #a29bfe);
    background-size: 300% 300%;
    animation: gradientMove 4s ease-in-out infinite;
    border-radius: 50px;
    padding: 25px 30px 30px;
    text-align: center;
    border: 6px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    position: relative;
    z-index: 102;
    animation: popupBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes popupBounce {
    0% {
        transform: scale(0.5) rotate(-5deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.1) rotate(1deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.popup-emoji-burst {
    font-size: 1.8rem;
    letter-spacing: 6px;
    animation: sparkle 1.5s ease-in-out infinite;
    margin-bottom: 4px;
}

@keyframes sparkle {
    0%,
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
        opacity: 1;
    }
}

.popup-content img {
    width: 200px;
    height: 200px;
    object-fit: contain;
    display: block;
    margin: 0 auto 10px;
    filter: drop-shadow(0 10px 40px rgba(0, 0, 0, 0.3));
    animation: popupImage 0.6s ease;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    padding: 8px;
    border: 4px solid rgba(255, 255, 255, 0.3);
}

@keyframes popupImage {
    0% {
        transform: scale(0) rotate(-15deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.15) rotate(3deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.popup-name {
    font-size: 3rem;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    margin-bottom: 4px;
    animation: namePop 0.6s ease;
}

@keyframes namePop {
    0% {
        transform: scale(0) rotate(-5deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.2) rotate(2deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.popup-sound {
    font-size: 2.8rem;
    animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.2) rotate(5deg);
    }
}

.popup-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.2s ease;
    font-family: Arial, sans-serif;
    backdrop-filter: blur(4px);
}

.popup-close:active {
    transform: rotate(90deg) scale(1.1);
}

/* ---------- FLYING EMOJIS ---------- */
.flying-emojis {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 101;
    overflow: hidden;
}

.flying-emoji {
    position: absolute;
    font-size: 2.5rem;
    opacity: 0.9;
    animation: flyUp 5s ease-in forwards;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

@keyframes flyUp {
    0% {
        transform: translateY(0px) rotate(0deg) scale(0.5);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(-20px) rotate(5deg) scale(1);
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-350px) rotate(20deg) scale(0.8);
        opacity: 0;
    }
}

/* ---------- CONFETTI CANVAS ---------- */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

/* ---------- RESPONSIVE (PHONE FIX) ---------- */
@media (max-width: 600px) {
    .container {
        border-radius: 40px;
        padding: 16px 10px 20px;
    }
    h1 {
        font-size: 2rem;
    }
    .subtitle {
        font-size: 0.95rem;
        padding: 4px 16px;
    }
    .surprise-btn {
        font-size: 1.1rem;
        padding: 10px 24px;
    }
    .animal-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    .animal-btn img {
        width: 48px;
        height: 48px;
    }
    .animal-btn .label {
        font-size: 0.7rem;
        padding: 0 6px;
    }
    .animal-btn {
        padding: 8px 2px 8px;
        border-radius: 16px;
    }
    .floating-animal {
        font-size: 1.6rem !important;
    }
    .popup-content {
        padding: 18px 14px 22px;
        border-radius: 30px;
        max-width: 95%;
    }
    .popup-content img {
        width: 150px;
        height: 150px;
        padding: 6px;
    }
    .popup-name {
        font-size: 2.2rem;
    }
    .popup-sound {
        font-size: 2rem;
    }
    .popup-close {
        width: 36px;
        height: 36px;
        font-size: 1.4rem;
        top: 8px;
        right: 12px;
    }
    .popup-emoji-burst {
        font-size: 1.2rem;
    }
    .flying-emoji {
        font-size: 1.8rem !important;
    }
}

@media (max-width: 450px) {
    .animal-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .animal-btn img {
        width: 56px;
        height: 56px;
    }
    .animal-btn .label {
        font-size: 0.7rem;
    }
}

@media (max-width: 360px) {
    .animal-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .animal-btn img {
        width: 44px;
        height: 44px;
    }
    .animal-btn .label {
        font-size: 0.6rem;
        padding: 0 4px;
    }
    h1 {
        font-size: 1.6rem;
    }
    .popup-content img {
        width: 120px;
        height: 120px;
    }
    .popup-name {
        font-size: 1.8rem;
    }
}

/* ---------- ACCESSIBILITY ---------- */
@media (prefers-reduced-motion: reduce) {
    .animal-btn,
    .surprise-btn,
    h1,
    .floating-animal,
    .popup-content,
    .popup-content img,
    .popup-overlay,
    .popup-name,
    .popup-emoji-burst,
    .popup-sound,
    .flying-emoji {
        animation: none !important;
        transition: none !important;
    }
    .animal-btn:active {
        transform: scale(0.94);
    }
}