@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #1a472a 0%, #2d5a27 50%, #3d7a3d 100%);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.screen {
    display: none;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu-content {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 250, 245, 0.98) 100%);
    padding: 45px 50px;
    border-radius: 24px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    text-align: center;
    max-width: 650px;
    width: 90%;
    position: relative;
    overflow: hidden;
}

.menu-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4CAF50, #8BC34A, #CDDC39, #8BC34A, #4CAF50);
}

.game-title {
    font-size: 2.8em;
    font-weight: 600;
    color: #2d5016;
    margin-bottom: 8px;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.8);
    letter-spacing: -1px;
}

.game-subtitle {
    font-size: 1.15em;
    color: #666;
    margin-bottom: 25px;
    font-weight: 400;
}

.high-score-display {
    font-size: 1.1em;
    color: #8B6914;
    margin-bottom: 30px;
    font-weight: 500;
    padding: 12px 20px;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    border-radius: 12px;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(139, 105, 20, 0.15);
}

.btn {
    padding: 16px 36px;
    font-size: 1.15em;
    font-weight: 500;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    margin: 8px;
    font-family: 'Fredoka', 'Segoe UI', sans-serif;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(180deg, #5cb85c 0%, #449d44 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
    background: linear-gradient(180deg, #6bc76b 0%, #5cb85c 100%);
}

.btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-secondary {
    background: linear-gradient(180deg, #ff9800 0%, #f57c00 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 152, 0, 0.4);
    background: linear-gradient(180deg, #ffad33 0%, #ff9800 100%);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.instructions {
    text-align: left;
    margin: 25px 0;
    padding: 22px 25px;
    background: linear-gradient(135deg, #f8faf8 0%, #e8f5e9 100%);
    border-radius: 14px;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.instructions p {
    margin-bottom: 12px;
    color: #333;
}

.instructions ul {
    margin-left: 22px;
    margin-top: 12px;
}

.instructions li {
    margin: 10px 0;
    color: #444;
    line-height: 1.5;
}

.instructions li strong {
    color: #2d5016;
}

/* Animal Selection */
.animal-grid {
    margin: 20px 0;
}

.animal-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.1em;
    color: #2d5016;
    margin-bottom: 12px;
    text-align: left;
    font-weight: 600;
}

.section-hint {
    font-weight: 400;
    font-size: 0.85em;
    color: #666;
}

.animal-section.magical-section .section-title {
    color: #7B1FA2;
}

.animal-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
}

.animal-card {
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    padding: 16px 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.animal-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    border-color: #bbb;
}

.animal-card.selected {
    border-color: #4CAF50;
    background: linear-gradient(180deg, #e8f5e9 0%, #c8e6c9 100%);
    box-shadow: 
        0 8px 24px rgba(76, 175, 80, 0.25),
        inset 0 0 0 1px rgba(76, 175, 80, 0.3);
    transform: translateY(-4px);
}

/* Magical animal cards */
.animal-card.magical-card {
    background: linear-gradient(180deg, #f3e5f5 0%, #e1bee7 100%);
    border-color: #CE93D8;
}

.animal-card.magical-card:hover {
    border-color: #AB47BC;
    box-shadow: 0 12px 28px rgba(156, 39, 176, 0.2);
}

.animal-card.magical-card.selected {
    border-color: #7B1FA2;
    background: linear-gradient(180deg, #e1bee7 0%, #ce93d8 100%);
    box-shadow: 
        0 8px 24px rgba(123, 31, 162, 0.3),
        inset 0 0 0 1px rgba(123, 31, 162, 0.3);
}

.animal-card.magical-card .animal-ability {
    color: #7B1FA2;
}

.animal-emoji {
    font-size: 2.8em;
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.animal-name {
    font-weight: 600;
    font-size: 1.1em;
    margin-bottom: 4px;
    color: #333;
}

.animal-ability {
    font-size: 0.9em;
    color: #4CAF50;
    font-weight: 500;
}

.animal-card > div:last-child {
    font-size: 0.8em;
    color: #777;
    margin-top: 6px;
    line-height: 1.4;
}

.selection-hint {
    color: #666;
    margin-bottom: 12px;
    font-size: 1.05em;
}

.selected-animals {
    margin: 22px 0;
    font-size: 1.15em;
    color: #388E3C;
    font-weight: 500;
}

/* Game Screen */
#gameScreen {
    background: linear-gradient(180deg, #87CEEB 0%, #98D8C8 100%);
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    display: block;
    border-radius: 8px;
    box-shadow: 
        0 0 0 3px #2d5016,
        0 10px 40px rgba(0, 0, 0, 0.3);
}

.game-ui {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: -270px;
    margin-left: -380px;
    color: white;
    font-size: 1.4em;
    font-weight: 500;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
    pointer-events: none;
}

.score-display {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    margin-bottom: 10px;
    display: inline-block;
}

.helper-animals-display {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.helper-animal-icon {
    font-size: 1.4em;
    background: rgba(255, 255, 255, 0.25);
    padding: 6px 10px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Game Over Screen */
#gameOverScreen .menu-content {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 245, 245, 0.98) 100%);
}

#gameOverScreen .menu-content::before {
    background: linear-gradient(90deg, #EF5350, #FF7043, #FFCA28, #FF7043, #EF5350);
}

.final-score {
    font-size: 1.6em;
    margin: 25px 0;
    color: #333;
}

.final-score span {
    color: #2d5016;
    font-weight: 600;
    font-size: 1.2em;
}

.new-high-score {
    color: #FF8F00;
    font-size: 1.4em;
    font-weight: 600;
    margin: 15px 0;
    animation: pulse 1s infinite;
    text-shadow: 0 2px 4px rgba(255, 143, 0, 0.3);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* How to Play screen */
#howToPlayScreen h2 {
    color: #2d5016;
    margin-bottom: 20px;
    font-size: 1.8em;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .menu-content {
        padding: 30px 25px;
    }
    
    .game-title {
        font-size: 2.2em;
    }
    
    .animal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .animal-card {
        padding: 14px 10px;
    }
    
    .animal-emoji {
        font-size: 2.2em;
    }
}
