:root {
    --bg:      #FFF9F0;
    --text:    #2D3748;
    --primary: #FF6B6B;
    --pshad:   #E85555;
    --bar-h:   72px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Fredoka', sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(circle at 15% 20%, rgba(255,107,107,0.09) 0%, transparent 50%),
        radial-gradient(circle at 85% 80%, rgba(116,185,255,0.10) 0%, transparent 50%);
    color: var(--text);
    padding: 16px 16px calc(var(--bar-h) + 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── HEADER ── */
header {
    text-align: center;
    margin: 12px 0 14px;
    animation: dropIn 0.55s cubic-bezier(0.175,0.885,0.32,1.275) both;
    width: 100%;
    max-width: 640px;
}
h1 {
    font-size: clamp(2rem, 8vw, 2.8rem);
    font-weight: 700;
    color: var(--primary);
    text-shadow: 3px 3px 0 rgba(255,107,107,0.18);
    letter-spacing: 1px;
}
.subtitle {
    font-size: clamp(0.95rem, 3.5vw, 1.1rem);
    color: #718096;
    margin-top: 4px;
}

/* ── GRID ── */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 640px;
    padding: 4px;
    animation: dropIn 0.6s 0.15s both;
}

/* ── CARD ── */
.animal-card {
    border-radius: 28px;
    padding: 24px 12px 20px;
    text-align: center;
    cursor: pointer;
    border: 4px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 172px;
    position: relative;
    box-shadow: 0 8px 0 rgba(0,0,0,0.06), 0 12px 20px rgba(0,0,0,0.04);
    opacity: 0;
    animation: cardIn 0.5s cubic-bezier(0.175,0.885,0.32,1.275) forwards;
    transition: transform 0.15s cubic-bezier(0.175,0.885,0.32,1.275),
                box-shadow 0.15s, border-color 0.15s;
}
.animal-card:active {
    transform: scale(0.91) translateY(4px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.06);
}
@media (hover: hover) {
    .animal-card:hover {
        transform: translateY(-6px) rotate(-1.2deg);
        box-shadow: 0 14px 24px rgba(0,0,0,0.10);
    }
}
.animal-card:focus-visible { outline: 4px solid var(--primary); outline-offset: 3px; }

.animal-card.playing {
    transform: scale(1.07) rotate(1deg);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255,107,107,0.22), 0 10px 24px rgba(0,0,0,0.12);
}
.animal-card.playing .animal-emoji { animation: wiggle 0.35s ease infinite alternate; }

.animal-card.error .animal-emoji { filter: grayscale(1) opacity(0.5); }
.error-hint { font-size: 0.72rem; color: #c0392b; position: absolute; bottom: 8px; }

/* Card colour themes */
.cat-theme      { background: #FFDEE9; }
.dog-theme      { background: #74B9FF; }
.goat-theme     { background: #FFEAA7; }
.cow-theme      { background: #A8E6CF; }
.duck-theme     { background: #FFD3B6; }
.lion-theme     { background: #FAB1A0; }
.elephant-theme { background: #C3B1E1; }

/* Staggered entrance */
.animal-card:nth-child(1){animation-delay:.15s}
.animal-card:nth-child(2){animation-delay:.22s}
.animal-card:nth-child(3){animation-delay:.29s}
.animal-card:nth-child(4){animation-delay:.36s}
.animal-card:nth-child(5){animation-delay:.43s}
.animal-card:nth-child(6){animation-delay:.50s}
.animal-card:nth-child(7){animation-delay:.57s}

.animal-emoji {
    font-size: clamp(3.5rem, 10vw, 4.5rem);
    margin-bottom: 10px;
    user-select: none;
    display: block;
    line-height: 1;
}
.animal-name  { font-size: clamp(1.2rem, 4vw, 1.5rem); font-weight: 700; }
.animal-sound { font-size: clamp(0.82rem, 3vw, 1rem); opacity: .65; margin-top: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ── BOTTOM ACTION BAR ── */
.bottom-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bar-h);
    background: white;
    border-top: 1.5px solid rgba(0,0,0,0.07);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 20px;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 13px 28px;
    border-radius: 50px;
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(0.95rem, 3.5vw, 1.05rem);
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 5px 0 var(--pshad);
    transition: transform 0.1s, box-shadow 0.1s;
    user-select: none;
    flex: 1;
    max-width: 200px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--pshad); }

.btn.outline {
    background: white;
    color: var(--primary);
    box-shadow: 0 5px 0 #ddd;
    border: 2px solid var(--primary);
}
.btn.outline:active { box-shadow: 0 1px 0 #ddd; }

.btn.stop-mode {
    background: #2D3748;
    box-shadow: 0 5px 0 #1a202c;
}
.btn.stop-mode:active { box-shadow: 0 1px 0 #1a202c; }

/* ── TOAST ── */
.toast {
    position: fixed; bottom: calc(var(--bar-h) + 12px); left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #2D3748; color: white;
    padding: 12px 24px; border-radius: 50px;
    font-size: 1rem; font-weight: 600;
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275), opacity 0.3s;
    opacity: 0; pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── CONFETTI ── */
.confetti-piece {
    position: fixed; width: 10px; height: 10px;
    border-radius: 2px; pointer-events: none; z-index: 300;
    animation: confettiFall 0.9s ease-out forwards;
}

/* ── ANIMATIONS ── */
@keyframes dropIn    { from{opacity:0;transform:translateY(-18px)} to{opacity:1;transform:translateY(0)} }
@keyframes cardIn    { from{opacity:0;transform:scale(.72) translateY(18px)} to{opacity:1;transform:scale(1) translateY(0)} }
@keyframes wiggle    { from{transform:rotate(-9deg) scale(1.1)} to{transform:rotate(9deg) scale(1.16)} }
@keyframes confettiFall { 0%{opacity:1;transform:translateY(0) rotate(0)} 100%{opacity:0;transform:translateY(130px) rotate(420deg)} }

/* ── KEYBOARD HINT ── */
.keyboard-hint {
    margin-top: 20px;
    font-size: 0.82rem;
    color: #a0aab4;
    text-align: center;
    padding: 10px 18px;
    border-radius: 12px;
    background: rgba(0,0,0,0.03);
    max-width: 640px;
    width: 100%;
    line-height: 1.6;
}
kbd {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    border: 1.5px solid #d0d7e0;
    background: white;
    color: #4A5568;
    font-family: monospace;
    font-size: 0.82rem;
    box-shadow: 0 2px 0 #c0c8d4;
    margin: 0 1px;
}

/* ── SEO CONTENT ── */
.seo-content {
    margin-top: 28px;
    max-width: 640px;
    width: 100%;
    padding: 0 4px;
}
.seo-content h2 {
    font-size: clamp(1.1rem, 4vw, 1.3rem);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}
.seo-content p {
    font-size: 0.88rem;
    line-height: 1.7;
    color: #718096;
    margin-bottom: 10px;
}

/* ── FOOTER ── */
footer {
    margin-top: 12px;
    font-size: .82rem;
    color: #b0b8c4;
    text-align: center;
    line-height: 1.8;
}
footer a {
    color: #FF6B6B;
    text-decoration: none;
    font-weight: 600;
}
footer a:hover { text-decoration: underline; }

/* ── iOS INSTALL NUDGE ── */
.ios-nudge {
    position: fixed;
    bottom: calc(var(--bar-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: #2D3748;
    color: white;
    padding: 11px 20px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 200;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    max-width: 300px;
    width: calc(100% - 40px);
    animation: dropIn 0.4s cubic-bezier(0.175,0.885,0.32,1.275) both;
    line-height: 1.4;
}
.ios-nudge button {
    position: absolute;
    top: 6px; right: 10px;
    background: none; border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1rem; cursor: pointer;
}
