/* ========== 动物乐园 ========== */

body { overflow-x: hidden; }

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 60px 20px 40px;
}

.page-header {
    text-align: center;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin: 0 0 10px;
}
.lead {
    color: var(--text-2);
    font-size: 1.05rem;
    margin: 0;
}

/* ========== Tab ========== */
.mode-tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    border: 3px solid var(--border-2);
    border-radius: var(--r-pill);
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-2);
    box-shadow: 0 4px 0 var(--border-2);
    transition: transform 0.15s cubic-bezier(.34,1.56,.64,1), box-shadow 0.15s;
}
.tab-btn:hover {
    transform: translateY(-2px);
}
.tab-btn.active {
    background: var(--grad-warm);
    color: #fff;
    border-color: var(--c-peach-d);
    box-shadow: 0 4px 0 var(--c-peach-d), var(--shadow-md);
}

/* ========== HUD ========== */
.memory-hud, .habitat-hud {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}
.hud-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--bg-card);
    border: 2px solid var(--border-2);
    border-radius: var(--r-pill);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-2);
    box-shadow: var(--shadow-sm);
}
.hud-pill strong {
    font-family: var(--font-display);
    color: var(--c-peach-d);
    font-size: 1.1rem;
}
.btn-sm { padding: 8px 16px; font-size: 0.9rem; }

/* ========== 记忆翻牌 ========== */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-width: 540px;
    margin: 0 auto;
}
.mem-card {
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
}
.mem-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s cubic-bezier(.34,1.56,.64,1);
    transform-style: preserve-3d;
}
.mem-card.flipped .mem-card-inner {
    transform: rotateY(180deg);
}
.mem-card.matched .mem-card-inner {
    transform: rotateY(180deg);
}
.mem-front, .mem-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    border: 3px solid var(--border-2);
    box-shadow: var(--shadow-sm);
}
.mem-front {
    background: var(--grad-warm);
    color: #fff;
    font-size: 2.4rem;
    font-family: var(--font-display);
}
.mem-front::after {
    content: '?';
}
.mem-back {
    background: var(--bg-card);
    transform: rotateY(180deg);
    font-size: clamp(2rem, 8vw, 3rem);
}
.mem-card.matched .mem-back {
    background: var(--c-mint);
    border-color: var(--c-mint-d);
    box-shadow: 0 4px 0 var(--c-mint-d);
    animation: match-pop 0.5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes match-pop {
    0%   { transform: rotateY(180deg) scale(1); }
    50%  { transform: rotateY(180deg) scale(1.15); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* ========== 栖息地匹配 ========== */
.section-intro {
    text-align: center;
    color: var(--text-2);
    margin: 0 0 16px;
    font-size: 0.95rem;
}
.habitat-stage {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.habitat-zones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.zone {
    position: relative;
    background: var(--bg-card);
    border: 3px dashed var(--border-2);
    border-radius: var(--r-lg);
    padding: 18px 12px 12px;
    min-height: 150px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.zone.drop-hover {
    border-color: var(--c-mint-d);
    background: var(--c-mint);
    border-style: solid;
    transform: scale(1.03);
}
.zone-bg-emoji {
    font-size: 3.4rem;
    line-height: 1;
    margin-bottom: 6px;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}
.zone-title {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-1);
    font-size: 1rem;
    margin-bottom: 8px;
}
.zone-residents {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    min-height: 40px;
}
.zone-resident {
    font-size: 1.8rem;
    animation: pop-in 0.4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop-in {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}

.animal-pool {
    background: var(--bg-soft);
    border: 3px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 16px;
    min-height: 90px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
}
.animal-token {
    font-size: 2.4rem;
    cursor: grab;
    user-select: none;
    transition: transform 0.15s;
    padding: 6px 10px;
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 2px solid var(--border-2);
    box-shadow: 0 3px 0 var(--border-2);
}
.animal-token:hover {
    transform: scale(1.15) rotate(-5deg);
}
.animal-token:active {
    cursor: grabbing;
}
.animal-token.dragging {
    opacity: 0.5;
}

/* ========== 弹窗 ========== */
.result-mask {
    position: fixed; inset: 0;
    background: rgba(20, 12, 50, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: maskIn 0.25s ease;
}
.result-mask[hidden] { display: none !important; }
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }

.result-card {
    background: var(--bg-card);
    border-radius: var(--r-xl);
    padding: 36px 28px;
    text-align: center;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 3px solid var(--c-sun);
    animation: popIn 0.4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
    from { transform: scale(0.6); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.result-emoji {
    font-size: 4rem;
    margin-bottom: 12px;
    animation: bounce 1s ease-in-out infinite alternate;
}
@keyframes bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-12px); }
}
.result-card h3 {
    font-size: 1.7rem;
    margin: 0 0 8px;
    color: var(--c-grape-d);
}
.result-card p {
    color: var(--text-2);
    margin: 0 0 20px;
}
.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========== 彩花 ========== */
.confetti-root {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 1500;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    width: 10px; height: 16px;
    animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
    0%   { transform: translateY(-20vh) rotate(0); opacity: 1; }
    100% { transform: translateY(120vh) rotate(720deg); opacity: 0.5; }
}

/* ========== 响应式 ========== */
@media (max-width: 600px) {
    .container { padding: 60px 14px 30px; }
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    .habitat-zones {
        grid-template-columns: repeat(2, 1fr);
    }
    .mem-front { font-size: 1.8rem; }
    .mem-back  { font-size: 2rem; }
    .animal-token { font-size: 2rem; padding: 4px 8px; }
}
