/* ===========================================
   Animal Bucket Game - Styles
   iPad-optimized PWA
   =========================================== */

/* CSS Variables */
:root {
    --bg-sky: #87CEEB;
    --bg-grass: #90EE90;
    --bucket-dark: #8B4513;
    --bucket-main: #A0522D;
    --bucket-light: #CD853F;
    --accent-primary: #4CAF50;
    --accent-secondary: #FF9800;
    --text-dark: #333333;
    --text-light: #FFFFFF;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: linear-gradient(180deg, var(--bg-sky) 0%, var(--bg-sky) 60%, var(--bg-grass) 60%, var(--bg-grass) 100%);
}

.hidden {
    display: none !important;
}

/* ===========================================
   Start Screen
   =========================================== */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, var(--bg-sky) 0%, #5BA3C6 100%);
    z-index: 100;
}

#start-screen h1 {
    font-size: 4rem;
    color: var(--text-light);
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 1rem;
}

#start-screen p {
    font-size: 1.5rem;
    color: var(--text-light);
    margin-bottom: 3rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

#start-button {
    font-size: 2rem;
    padding: 1.5rem 4rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(180deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

#start-button:active {
    transform: scale(0.95);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* ===========================================
   Game Container
   =========================================== */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 2fr 2fr 1.5fr;
    grid-template-rows: 1fr;
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px);
}

/* ===========================================
   Animal Pile (Left Side)
   =========================================== */
#animal-pile {
    position: relative;
    overflow: hidden;
    padding: 10px;
}

.animal {
    width: 70px;
    height: 70px;
    cursor: grab;
    transition: transform 0.2s ease;
    filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.3));
}

.animal:active {
    cursor: grabbing;
}

.animal img,
.animal svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.animal.wobble {
    animation: wobble 1s ease-in-out infinite;
}

.animal.selected {
    transform: scale(1.1);
    z-index: 100;
}

.animal.dragging {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    transform: scale(1.2);
    transition: none;
}

.animal.flying {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
}

.animal.landing {
    animation: shrink-into-bucket 0.4s ease-in forwards;
}

.animal.trail {
    animation: none !important;
    filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.2));
}

/* ===========================================
   Play Area (Middle)
   =========================================== */
#play-area {
    position: relative;
}

/* ===========================================
   Bucket Area (Right Side)
   =========================================== */
#bucket-area {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 10%;
}

#bucket {
    width: 240px;
    height: auto;
    transition: transform 0.1s ease;
}

.bucket-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(5px 5px 10px rgba(0, 0, 0, 0.4));
}

#bucket.splash {
    animation: bucket-splash 0.4s ease-out;
}

/* ===========================================
   Progress Indicator
   =========================================== */
#progress {
    position: fixed;
    top: env(safe-area-inset-top, 20px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 30px;
    border-radius: 25px;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-dark);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-top: 10px;
}

#animals-remaining {
    color: var(--accent-primary);
    font-size: 1.5rem;
}

/* ===========================================
   Start Over Button
   =========================================== */
#start-over-button {
    position: fixed;
    top: env(safe-area-inset-top, 20px);
    right: env(safe-area-inset-right, 20px);
    margin-top: 15px;
    margin-right: 15px;
    font-size: 1.6rem;
    padding: 18px 45px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(180deg, #F44336 0%, #D32F2F 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 50;
}

#start-over-button:active {
    transform: scale(0.95);
    box-shadow: 0 3px 12px rgba(244, 67, 54, 0.4);
}

/* ===========================================
   Animal Display (shown when landed)
   =========================================== */
#animal-display {
    position: fixed;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#animal-display.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#animal-display img {
    width: 180px;
    height: 180px;
    filter: drop-shadow(5px 5px 15px rgba(0, 0, 0, 0.4));
    animation: pop-bounce 0.5s ease-out;
}

#animal-display .animal-name-text {
    font-size: 3rem;
    font-weight: bold;
    color: var(--text-light);
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5),
                 -1px -1px 0px rgba(0, 0, 0, 0.3),
                 1px -1px 0px rgba(0, 0, 0, 0.3),
                 -1px 1px 0px rgba(0, 0, 0, 0.3),
                 1px 1px 0px rgba(0, 0, 0, 0.3);
    background: linear-gradient(180deg, #4CAF50 0%, #388E3C 100%);
    padding: 15px 40px;
    border-radius: 50px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* ===========================================
   Celebration Screen
   =========================================== */
#celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    background: rgba(0, 0, 0, 0.3);
}

#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#celebration-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 210;
}

#congrats-text {
    font-size: 4rem;
    color: var(--text-light);
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.5);
    animation: bounce-in 0.6s ease-out;
    margin-bottom: 2rem;
}

#play-again-button {
    font-size: 1.8rem;
    padding: 1.2rem 3rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(180deg, #FF9800 0%, #F57C00 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    opacity: 0;
    animation: fade-in 0.5s ease-out 1.5s forwards;
}

#play-again-button:active {
    transform: scale(0.95);
}

/* ===========================================
   Animations
   =========================================== */
@keyframes wobble {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

@keyframes bucket-splash {
    0% { transform: scale(1) translateY(0); }
    30% { transform: scale(1.1) translateY(-15px); }
    50% { transform: scale(0.95) translateY(0); }
    70% { transform: scale(1.03) translateY(-5px); }
    100% { transform: scale(1) translateY(0); }
}

@keyframes shrink-into-bucket {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.2) translateY(50px);
    }
}

@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pop-bounce {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.15);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

/* ===========================================
   Responsive Adjustments
   =========================================== */
@media (max-height: 600px) {
    .animal {
        width: 55px;
        height: 55px;
    }

    #bucket {
        width: 180px;
    }

    #start-screen h1 {
        font-size: 2.5rem;
    }

    #congrats-text {
        font-size: 3rem;
    }
}

@media (min-width: 1200px) {
    .animal {
        width: 85px;
        height: 85px;
    }

    #bucket {
        width: 280px;
    }
}

/* iPad Pro specific */
@media (min-width: 1024px) and (min-height: 1300px) {
    .animal {
        width: 90px;
        height: 90px;
    }

    #bucket {
        width: 300px;
    }

    #progress {
        font-size: 1.5rem;
    }
}
