:root {
    --bg: #f0f7ff;
    --primary: #4cc9f0;
    --secondary: #4895ef;
    --accent: #f72585;
    --border: #e0e0e0;
    --text: #2b2d42;
    --carnivore: #ff4d4d;
    --herbivore: #4ce64c;
    --farm: #ffb347;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    background: white;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0,0,0,0.1);
}

/* HUD */
#hud {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

#stats {
    display: flex;
    gap: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #8fa3c2;
}

#moves, #timer {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--secondary);
}

.icon-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: #f0f4f8;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #d0d7de;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s;
}

.icon-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* PUZZLE SPACE */
#puzzle-space {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    position: relative;
    gap: 20px;
}

#target-grid {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1/1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 4px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 12px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
}

.slot {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 8px;
    border: 2px dashed #cbd5e1;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
}

.slot.drag-over {
    background: #e0f2fe;
    border-color: var(--secondary);
}

#pieces-bank {
    width: 100%;
    max-width: 400px;
    min-height: 100px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: #f1f5f9;
    border-radius: 20px;
}

.puzzle-piece {
    width: 80px;
    height: 80px;
    background-size: 300% 300%;
    border-radius: 10px;
    cursor: grab;
    background-repeat: no-repeat;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: 2px solid white;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: none;
}

.puzzle-piece:active {
    cursor: grabbing;
}

.puzzle-piece.dragging {
    opacity: 0.5;
    transform: scale(1.1);
}

.slot .puzzle-piece {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    border: none;
    box-shadow: none;
}

/* CATEGORY SELECTOR */
#category-selector {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
}

.category-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    background: #f8fafc;
    border-radius: 20px;
    border: 2px solid #f1f5f9;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.category-card:hover { 
    transform: translateY(-5px); 
    border-color: var(--secondary);
    background: #eef2ff;
}

.category-card.active {
    border-color: var(--secondary);
    background: #eef2ff;
    box-shadow: 0 10px 20px rgba(72, 149, 239, 0.2);
}

.cat-icon { font-size: 2rem; margin-bottom: 8px; }
.cat-name { font-size: 0.85rem; font-weight: 700; color: #475569; }

#animal-preview {
    margin-top: 10px;
    min-height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#animal-preview img {
    width: 150px;
    height: 150px;
    border-radius: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    animation: previewEnter 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes previewEnter {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* REFERENCE IMAGE */
#reference-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    z-index: 100;
}

#reference-image img { width: 100%; display: block; }

/* OVERLAYS */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px;
    z-index: 1000;
}

.hidden { display: none !important; }

h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--secondary);
    margin-bottom: 10px;
}

.victory-text { color: var(--herbivore); }

.main-btn {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 1rem;
    font-weight: 900;
    border: none;
    border-radius: 30px;
    background: var(--secondary);
    color: white;
    box-shadow: 0 8px 0 #2b6cb0;
    cursor: pointer;
    transition: transform 0.1s;
}

.main-btn:active { transform: translateY(4px); box-shadow: none; }

#animal-info {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#victory-img {
    width: 150px;
    height: 150px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.info-card {
    background: #f8fafc;
    padding: 20px;
    border-radius: 20px;
    max-width: 300px;
}

.info-card h2 { color: var(--text); margin-bottom: 10px; font-size: 1.2rem; }
#animal-facts-list {
    text-align: left;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#animal-facts-list li {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.4;
    position: relative;
    padding-left: 20px;
}

#animal-facts-list li::before {
    content: '✨';
    position: absolute;
    left: 0;
    font-size: 0.8rem;
}
