:root {
    --grass: #7fb069;
    --flower-pink: #ff8fa3;
    --sky-blue: #a2d2ff;
    --wood: #8c6239;
    --text-dark: #4a3728;
}

html, body {
    margin: 0; padding: 0;
    width: 100vw; height: 100vh;
    overflow: hidden;
    font-family: 'Nunito', sans-serif;
    color: var(--text-dark);
}

.sky-bg {
    position: fixed; inset: 0;
    background: var(--sky-blue);
    z-index: -10; /* Sent way back */
}

.garden-bg {
    position: fixed; inset: 0;
    background-size: cover;
    background-position: center bottom;
    opacity: 0.5;
    z-index: -5; /* Behind UI, in front of sky */
    pointer-events: none; /* Crucial: clicks go through this layer */
}

.game-ui {
    position: relative;
    z-index: 10;
    height: 100vh;
    display: flex; flex-direction: column;
    justify-content: space-between;
    padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom) 20px;
    box-sizing: border-box;
    align-items: center;
}

.top-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-top: 10px;
}

.wood-panel {
    background: var(--wood);
    border: 3px solid #5c4033;
    border-radius: 12px;
    padding: 8px 12px;
    color: #fff;
    box-shadow: 0 4px 0 #4a3728;
}

.panel-label { font-size: 0.6rem; letter-spacing: 1px; display: block; opacity: 0.9; }
.hall-of-fame { font-size: 0.75rem; display: flex; gap: 8px; margin-top: 4px; }

.level-badge {
    background: var(--flower-pink);
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    border: 3px solid #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.level-badge .label { font-size: 0.5rem; }
.level-badge .value { font-size: 1.2rem; font-weight: bold; }

/* Fixed Game Board */
#game-board {
    display: grid; 
    gap: 10px;
    width: 100%;
    max-width: 350px;
    max-height: 50vh; /* Keeps it from overlapping header/footer */
    margin: auto;
}

.grid-4 { grid-template-columns: repeat(2, 1fr); max-width: 220px !important; }
.grid-8 { grid-template-columns: repeat(4, 1fr); }
.grid-16 { grid-template-columns: repeat(4, 1fr); }

.card {
    aspect-ratio: 1/1;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 0 #ddd;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.8rem;
    transition: transform 0.1s;
    user-select: none;
}

.card:active { transform: scale(0.95); }
.card.flipped { background: #fff; border: 2px solid var(--flower-pink); }
.card.matched { visibility: hidden; }

.bottom-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
}

.hearts { font-size: 1.5rem; display: flex; gap: 3px; }
.env-bubble {
    background: rgba(255,255,255,0.9);
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.8rem;
    color: var(--grass);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; justify-content: center; align-items: center; z-index: 100;
}

.popup {
    background: #fff;
    padding: 30px;
    border-radius: 25px;
    border: 6px solid var(--flower-pink);
    text-align: center;
    max-width: 80%;
}

.cute-btn {
    background: var(--grass);
    color: white;
    padding: 12px 25px;
    border-radius: 50px;
    border: none;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #5a8a4a;
    margin-top: 15px;
}

.hidden { display: none !important; }