/* ═══════════════════════════════════════════════════
   Feed the Animals — Counting Game Styles
   ═══════════════════════════════════════════════════ */

:root {
    --bg-sky: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 40%, #90EE90 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --btn-shadow: 0 6px 0;
    --text-color: #4a4a4a;
    --correct-color: #2ecc71;
    --wrong-color: #e74c3c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: var(--bg-sky);
    min-height: 100vh;
    color: var(--text-color);
    overflow: hidden;
    position: relative;
}

/* ═══ Background Decorations ═══ */
.bg-decor {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.grass {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 15vh;
    background: linear-gradient(180deg, #7ec850 0%, #5da832 100%);
    border-radius: 50% 50% 0 0 / 30px 30px 0 0;
}

.cloud {
    position: absolute;
    font-size: 4rem;
    opacity: 0.6;
    animation: drift 30s infinite linear;
}

.cloud.c1 {
    top: 5%;
    left: -10%;
    animation-duration: 40s;
}

.cloud.c2 {
    top: 15%;
    left: -10%;
    animation-duration: 55s;
    animation-delay: 15s;
    font-size: 3rem;
}

.sun {
    position: absolute;
    top: 3%;
    right: 5%;
    font-size: 4rem;
    animation: pulse 3s infinite ease-in-out;
}

@keyframes drift {
    from {
        transform: translateX(-20vw);
    }

    to {
        transform: translateX(120vw);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ═══ Top Bar ═══ */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 20px 10px 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.home-btn {
    font-size: 2rem;
    text-decoration: none;
    background: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 #ccc;
    transition: transform 0.1s;
}

.home-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.score-display {
    font-size: 1.8rem;
    font-weight: 700;
    color: #f39c12;
}

.round-display {
    font-size: 1.2rem;
    font-weight: 600;
    color: #666;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 16px;
    border-radius: 20px;
}

/* ═══ Game Container ═══ */
.game-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 80px 20px 20px 20px;
    gap: 15px;
}

/* ═══ Animal Section ═══ */
.animal-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: bounceIn 0.6s;
}

.animal-frame {
    width: 220px;
    height: 220px;
    background: white;
    border-radius: 30px;
    box-shadow: var(--shadow), 0 0 0 6px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
}

.animal-frame.happy {
    box-shadow: 0 0 40px rgba(46, 204, 113, 0.5), 0 0 0 6px rgba(46, 204, 113, 0.3);
    animation: happyBounce 0.5s;
}

.animal-frame.hungry {
    box-shadow: 0 0 40px rgba(231, 76, 60, 0.4), 0 0 0 6px rgba(231, 76, 60, 0.3);
    animation: shake 0.4s;
}

.animal-frame.full {
    box-shadow: 0 0 40px rgba(155, 89, 182, 0.4), 0 0 0 6px rgba(155, 89, 182, 0.3);
    animation: wobble 0.6s;
}

.animal-frame.disgusted {
    box-shadow: 0 0 40px rgba(241, 196, 15, 0.5), 0 0 0 6px rgba(241, 196, 15, 0.3);
    animation: shake 0.4s;
}

.animal-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

/* ═══ Speech Bubble ═══ */
.speech-bubble {
    background: white;
    padding: 14px 28px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 400px;
    text-align: center;
    animation: fadeInUp 0.4s;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border: 12px solid transparent;
    border-bottom-color: white;
    border-top: 0;
}

#speech-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: #6c5ce7;
    line-height: 1.3;
}

.number-clue {
    width: min(100%, 420px);
    padding: 10px 18px;
    border: 3px dashed rgba(108, 92, 231, 0.42);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.82);
    text-align: center;
    box-shadow: 0 4px 14px rgba(74, 74, 74, 0.10);
}

.number-clue-label {
    display: block;
    color: #5a4bb3;
    font-size: 1rem;
    font-weight: 800;
}

.number-clue-fruit {
    display: block;
    min-height: 1.45em;
    margin-top: 2px;
    font-size: clamp(2rem, 4.4vw, 3.3rem);
    letter-spacing: 0.06em;
    line-height: 1.15;
}

.number-clue-image {
    display: block;
    width: min(100%, 210px);
    max-height: 104px;
    margin: 3px auto 0;
    object-fit: contain;
}

/* ═══ Fruit Choices Grid ═══ */
.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 550px;
    padding: 0 10px;
}

.choices-grid.number-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 690px;
}

.fruit-card {
    background: white;
    border-radius: 25px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 0 #ddd, var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    border: 4px solid transparent;
    position: relative;
}

.fruit-card:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #ddd, 0 2px 10px rgba(0, 0, 0, 0.1);
}

.fruit-card.correct {
    border-color: var(--correct-color);
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.4);
    animation: popCorrect 0.4s;
}

.fruit-card.wrong {
    border-color: var(--wrong-color);
    animation: shake 0.3s;
}

.fruit-card.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.fruit-card-emoji {
    font-size: 3rem;
    line-height: 1.2;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
}

.fruit-card-label {
    font-size: 1.3rem;
    font-weight: 700;
    color: #555;
}

.fruit-card-count {
    position: absolute;
    top: 8px;
    right: 12px;
    background: #6c5ce7;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.4);
}

.fruit-card.number-card {
    min-height: 174px;
    justify-content: center;
    background: linear-gradient(180deg, #fffdf5 0%, #fff 100%);
}

.number-card-numeral {
    color: #5f4cc3;
    font-size: clamp(4.8rem, 12vw, 7.5rem);
    font-weight: 900;
    line-height: 0.9;
    text-shadow: 0 4px 0 rgba(95, 76, 195, 0.12);
}

.number-card-label {
    color: #555;
    font-size: 1.1rem;
    font-weight: 800;
}

/* ═══ Celebration Overlay ═══ */
.celebration {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.celebration.active {
    display: flex;
}

.celebration-content {
    background: white;
    border-radius: 40px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: bounceIn 0.5s;
    max-width: 400px;
    width: 90%;
}

.celebration-emoji {
    font-size: 4rem;
    margin-bottom: 15px;
}

.celebration-title {
    font-size: 2.5rem;
    color: #6c5ce7;
    margin-bottom: 10px;
}

.celebration-score {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 25px;
}

.play-again-btn {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 18px 40px;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 0 #5f27cd;
    font-family: 'Fredoka', sans-serif;
    transition: transform 0.1s;
    display: block;
    width: 100%;
    margin-bottom: 15px;
}

.play-again-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #5f27cd;
}

.home-link {
    display: block;
    font-size: 1.3rem;
    color: #666;
    text-decoration: none;
    font-weight: 600;
}

/* ═══ Loading Screen ═══ */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-animal {
    font-size: 6rem;
    animation: bounce 1s infinite;
}

.loading-text {
    font-size: 2rem;
    color: #6c5ce7;
    font-weight: 700;
    margin-top: 20px;
}

/* ═══ Confetti ═══ */
.confetti {
    position: fixed;
    z-index: 100;
    font-size: 2rem;
    pointer-events: none;
    animation: fall 2s ease-in forwards;
}

@keyframes fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* ═══ Animations ═══ */
@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

@keyframes wobble {

    0%,
    100% {
        transform: rotate(0);
    }

    25% {
        transform: rotate(-5deg) scale(1.05);
    }

    75% {
        transform: rotate(5deg) scale(1.05);
    }
}

@keyframes happyBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-15px);
    }

    60% {
        transform: translateY(-8px);
    }
}

@keyframes popCorrect {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* ═══ Responsive ═══ */

/* Tablets landscape */
@media (min-width: 768px) and (orientation: landscape) {
    .game-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding-top: 80px;
    }

    .animal-section {
        flex: 0 0 40%;
    }

    .choices-grid {
        flex: 0 0 55%;
        max-width: 450px;
    }

    .animal-frame {
        width: 260px;
        height: 260px;
    }
}

/* Tablets portrait */
@media (min-width: 600px) and (orientation: portrait) {
    .animal-frame {
        width: 280px;
        height: 280px;
    }

    #speech-text {
        font-size: 1.8rem;
    }

    .fruit-card-label {
        font-size: 1.5rem;
    }

    .choices-grid {
        max-width: 600px;
        gap: 20px;
    }
}

/* Small phones */
@media (max-height: 700px) {
    .animal-frame {
        width: 160px;
        height: 160px;
    }

    #speech-text {
        font-size: 1.2rem;
    }

    .speech-bubble {
        padding: 10px 20px;
    }

    .fruit-card {
        padding: 8px;
    }

    .fruit-card-label {
        font-size: 1rem;
    }
}

/* iPad landscape: both the hungry friend and all four choices stay visible. */
@media (min-width: 768px) and (max-width: 1366px) and (orientation: landscape) {
    body { min-height: 100dvh; overflow: hidden; }
    .top-bar { padding-left: calc(20px + env(safe-area-inset-left)); padding-right: calc(20px + env(safe-area-inset-right)); }
    .game-container { min-height: 100dvh; padding: calc(76px + env(safe-area-inset-top)) 28px calc(18px + env(safe-area-inset-bottom)); gap: 12px; }
    .animal-section { flex-basis: 39%; }
    .animal-frame { width: 248px; height: 248px; }
    .speech-bubble { max-width: 360px; padding: 12px 22px; }
    #speech-text { font-size: 1.35rem; }
    .choices-grid { flex-basis: 52%; max-width: 500px; gap: 12px; }
    .fruit-card { min-height: 190px; }
    .fruit-card-emoji { min-height: 70px; font-size: 2.7rem; }
    .choices-grid.number-grid { max-width: 640px; }
    .fruit-card.number-card { min-height: 160px; }
    .number-clue { padding: 8px 14px; }
    .number-clue-fruit { font-size: 2.55rem; }
    .number-clue-image { max-height: 84px; }
}
