@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&display=swap');

:root {
    --primary-sky: #7dd3fc;
    --primary-emerald: #10b981;
    --common: #94a3b8;
    --uncommon: #22c55e;
    --rare: #e11d48;
    --legendary: #6366f1;
}

body {
    font-family: 'Fredoka', sans-serif;
    margin: 0;
    padding: 0;
    /* Safe Area Support */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow: hidden;
    background: linear-gradient(to bottom, #7dd3fc, #e0f2fe, #d1fae5);
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-15px);
    }

    100% {
        transform: translateY(0px);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.animate-shake {
    animation: shake 0.2s infinite;
}

@keyframes coin-fly {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0.5);
        opacity: 0;
    }
}

.coin-particle {
    position: absolute;
    pointer-events: none;
    z-index: 100;
    animation: coin-fly 1s ease-out forwards;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 2rem;
    max-width: 90%;
    width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 8px solid #f0f9ff;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.pet-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.pet-card:hover {
    transform: translateY(-5px) scale(1.05);
}

.pet-card:active {
    transform: scale(0.95);
}

.rarity-common {
    background-color: var(--common);
}

.rarity-uncommon {
    background-color: var(--uncommon);
}

.rarity-rare {
    background-color: var(--rare);
}

.rarity-legendary {
    background-color: var(--legendary);
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    main {
        justify-content: flex-start !important;
        padding-top: 15vh !important;
    }

    .lucky-block {
        width: 140px !important;
        height: 140px !important;
    }

    .lucky-block>div {
        font-size: 3rem !important;
        border-width: 4px !important;
    }

    #active-pet-renderer {
        font-size: 6rem !important;
    }

    .modal-content {
        padding: 1.25rem !important;
        border-width: 4px !important;
        width: 95% !important;
    }

    #inventory-grid {
        grid-template-cols: repeat(2, 1fr) !important;
    }
}

.lucky-block {
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1));
    transition: transform 0.1s ease;
}

.lucky-block:active {
    transform: scale(0.9);
}

#hud-layer {
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
    padding-left: calc(env(safe-area-inset-left, 0px) + 1rem);
    padding-right: calc(env(safe-area-inset-right, 0px) + 1rem);
}

nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 2rem) !important;
}

#bottom-nav-inner {
    max-width: 448px;
    margin: 0 auto;
}

.sell-btn {
    background: #fee2e2;
    color: #ef4444;
    font-size: 8px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-top: 4px;
    transition: all 0.2s;
    border: 1px solid #fecaca;
}

.sell-btn:hover {
    background: #ef4444;
    color: white;
}

#nickname-input {
    border: 4px solid #f0f9ff;
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    width: 100%;
    font-family: inherit;
    font-weight: 600;
    color: #0c4a6e;
    outline: none;
    transition: border-color 0.2s;
    text-align: center;
}

#nickname-input:focus {
    border-color: #38bdf8;
}

/* Level Up & Reveal Specifics */
@keyframes celebrate {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-celebrate {
    animation: celebrate 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes rainbow-text {
    0% {
        color: #f87171;
    }

    25% {
        color: #fbbf24;
    }

    50% {
        color: #34d399;
    }

    75% {
        color: #60a5fa;
    }

    100% {
        color: #f87171;
    }
}

.text-rainbow {
    animation: rainbow-text 2s linear infinite;
}

@keyframes reveal-sparkle {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.5) rotate(180deg);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotate(360deg);
        opacity: 0;
    }
}

.reveal-sparkle {
    position: absolute;
    pointer-events: none;
    animation: reveal-sparkle 1s ease-in-out infinite;
}

.xp-bar-container {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.xp-bar-fill {
    height: 100%;
    background: #38bdf8;
    width: 0%;
    transition: width 0.3s ease;
}