/* Alma's Limitless Playground CSS */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700&display=swap');

:root {
    --bg-dark: #2c3e50;
    --primary: #FF007A;
    /* Neon Pink */
    --secondary: #00FFF0;
    /* Cyan */
    --accent: #FFD700;
    /* Gold */
    --glass: rgba(255, 255, 255, 0.9);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

body {
    background: #f0f2f5;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(255, 0, 122, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 255, 240, 0.1) 0%, transparent 40%);
    font-family: 'Nunito', sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* HERO AREA */
header {
    text-align: center;
    padding: 2rem 1rem 2rem 1rem;
    position: relative;
    padding-top: 4rem;
    /* Space for sound btn */
}

.sound-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: 2px solid var(--primary);
    color: var(--primary);
    font-family: 'Fredoka One';
    font-size: 1.2rem;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    z-index: 50;
}

.sound-btn:hover {
    transform: scale(1.1);
}

.sound-btn.muted {
    background: #ccc;
    border-color: #999;
    color: #666;
}

h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 5rem;
    margin: 0;
    background: linear-gradient(to right, var(--primary), #9c27b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 0 white);
    animation: float 4s ease-in-out infinite;
    line-height: 1.1;
}

.subtitle {
    font-size: 1.5rem;
    color: #555;
    margin-top: 10px;
}

/* PLAYGROUND LAYOUT */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 100px;
    display: flex;
    flex-direction: column;
    gap: 80px;
}

.section-title {
    font-family: 'Fredoka One';
    font-size: 3rem;
    color: #444;
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.section-title::after {
    content: '';
    display: block;
    width: 60%;
    margin: 0 auto;
    height: 6px;
    background: var(--secondary);
    border-radius: 10px;
    opacity: 0.5;
    margin-top: 5px;
}

/* --- GAME CONTAINERS --- */
.game-box {
    background: white;
    border-radius: 30px;
    box-shadow: var(--shadow);
    padding: 40px;
    position: relative;
    border: 5px solid white;
    transition: transform 0.3s;
    overflow: hidden;
}

.game-box:hover {
    transform: translateY(-5px);
    border-color: var(--secondary);
}

/* 1. CANDY GAME */
#candy-area {
    width: 100%;
    height: 60vh;
    /* Big screen */
    background: #FFF3E0;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    /* Fallback */
    border: 4px dashed #FFCC80;
    touch-action: none;
    /* Prevent scroll on touch */
}

/* 2. JUMP GAME */
.jump-wrapper {
    display: flex;
    justify-content: center;
    background: #E1F5FE;
    border-radius: 20px;
    padding: 20px;
    overflow: hidden;
}

#jump-canvas {
    border: 4px solid #4FC3F7;
    border-radius: 10px;
    background: white;
    max-width: 100%;
    touch-action: none;
}

/* 3. MEMORY GAME */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: #7E57C2;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    color: transparent;
    /* Hides emoji properly */
    transition: transform 0.6s, background 0.3s;
    transform-style: preserve-3d;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    user-select: none;
}

.memory-card.flipped {
    background: white;
    color: black;
    /* Shows emoji */
    transform: rotateY(180deg);
}

.memory-card.matched {
    background: #66BB6A;
    opacity: 0.7;
    transform: scale(0.9);
}

/* 4. PIANO */
.piano-wrapper {
    display: flex;
    justify-content: center;
    padding: 40px 0;
    background: #333;
    border-radius: 20px;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
    overflow-x: auto;
    /* Scroll if too small */
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll iOS */
}

.keys {
    display: flex;
    position: relative;
    min-width: max-content;
    /* Ensure keys allow scrolling */
    padding: 0 10px;
    /* Padding for scroll */
}

.white-key {
    width: 60px;
    height: 250px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 0 0 8px 8px;
    margin: 0 2px;
    cursor: pointer;
    z-index: 1;
    box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1);
}

.white-key:active,
.white-key.active {
    background: #eee;
    transform: translateY(2px);
}

.black-key {
    width: 40px;
    height: 160px;
    background: black;
    border-radius: 0 0 5px 5px;
    position: absolute;
    top: 0;
    z-index: 2;
    cursor: pointer;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.black-key:active,
.black-key.active {
    background: #333;
}

/* 5. DRAWING */
.draw-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

#draw-canvas {
    background: white;
    border: 4px dashed #999;
    border-radius: 10px;
    cursor: crosshair;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    touch-action: none;
}

.palette {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.p-color {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.p-color:hover {
    transform: scale(1.2);
}

.p-color.active {
    border-color: #333;
    transform: scale(1.1);
}

/* 6. RSP */
.rsp-area {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 40px;
    font-size: 6rem;
    flex-wrap: wrap;
}

.rsp-btn {
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
}

.rsp-btn:hover {
    transform: scale(1.3) rotate(10deg);
}

#rsp-feedback {
    text-align: center;
    margin-top: 20px;
}

/* UTILS */
.big-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 50px;
    font-family: 'Fredoka One';
    cursor: pointer;
    box-shadow: 0 6px 0 #C2185B;
    transition: all 0.1s;
    display: block;
    margin: 20px auto;
}

.big-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #C2185B;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    h1 {
        font-size: 3rem;
    }

    .sound-btn {
        top: 10px;
        right: 10px;
        font-size: 0.9rem;
        padding: 5px 15px;
    }

    .game-box {
        padding: 20px;
    }

    .section-title {
        font-size: 2rem;
        white-space: normal;
    }

    /* Candy */
    #candy-area {
        height: 50vh;
    }

    /* Memory: 3 cols on small screens */
    .memory-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .memory-card {
        font-size: 2.5rem;
    }

    /* Jump: Resize is handled in JS for Canvas, but wrapper helps */
    .jump-wrapper {
        padding: 10px;
    }

    /* Piano: CSS handles scroll, just ensure styling looks ok */
    .white-key {
        width: 40px;
        height: 180px;
    }

    .black-key {
        width: 25px;
        height: 100px;
    }

    /* Adjust black key positions for smaller white keys is tricky in Grid/Flex without recalc.
       Ideally Piano uses fixed widths and scrolls. The current fixed sizes above (60px) work best with scrolling.
       So we might NOT shrink keys, just let it scroll. */

    /* RSP */
    .rsp-area {
        gap: 20px;
        font-size: 4rem;
    }

    /* Draw */
    .p-color {
        width: 40px;
        height: 40px;
    }
}