* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent text selection and long-press menus on mobile */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    background-color: #fcebd5; /* A soft background color */
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    /* Handle iPhone notch/safe area */
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#game-container {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 50px);
    bottom: env(safe-area-inset-bottom, 0px);
    left: env(safe-area-inset-left, 0px);
    right: env(safe-area-inset-right, 0px);
    touch-action: none; /* Prevent scroll on canvas */
}

canvas {
    display: block;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* UI Layer Styles */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none; /* Let clicks pass through to the game */
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#player-info {
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    background: rgba(0,0,0,0.3);
    color: white;
    font-size: 16px;
    font-weight: bold;
}

#leaderboard-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    pointer-events: auto; /* Allow interactions on the leaderboard */
    color: #333;
    min-width: 300px;
    max-width: 90vw;
    text-align: center;
}

#leaderboard {
    list-style: none;
    margin: 15px 0;
    text-align: left;
    max-height: 50vh;
    overflow-y: auto;
}

#leaderboard li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 16px;
}

#close-leaderboard {
    padding: 10px 20px;
    background: #8b5a2b;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}


/* Cheer Zone (Bottom Empty Space) */
#cheer-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    display: flex;
    justify-content: space-evenly;
    align-items: flex-end;
    padding-bottom: 12px;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
    #cheer-zone {
        display: none;
    }
}

.cheer-fruit {
    opacity: 0.92;
    animation: idle-bob 2s infinite ease-in-out alternate;
    transform-origin: bottom center;
    position: relative;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    transition: filter 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cheer-fruit img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
    image-rendering: pixelated;
    user-select: none;
    -webkit-user-drag: none;
}

/* Speech bubble shown on jump */
.cheer-fruit::after {
    content: attr(data-cheer);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(255,255,255,0.96);
    border-radius: 10px;
    padding: 3px 8px;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    color: #8b5a2b;
    font-weight: bold;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

.cheer-fruit.jump::after {
    transform: translateX(-50%) scale(1);
    opacity: 1;
    transition-delay: 0.1s;
}

.cheer-fruit.jump {
    animation: cheer-jump 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
    filter: drop-shadow(0 10px 14px rgba(0,0,0,0.3)) brightness(1.2);
}

@keyframes idle-bob {
    0%   { transform: translateY(0px) rotate(-4deg); }
    50%  { transform: translateY(-6px) rotate(0deg); }
    100% { transform: translateY(-13px) rotate(4deg); }
}

@keyframes cheer-jump {
    0%   { transform: translateY(0)     scale(1)    rotate(0deg); }
    18%  { transform: translateY(-52px) scale(1.3)  rotate(-22deg); }
    38%  { transform: translateY(-58px) scale(1.35) rotate(22deg); }
    58%  { transform: translateY(-28px) scale(1.1)  rotate(-10deg); }
    75%  { transform: translateY(-8px)  scale(1.04) rotate(4deg); }
    88%  { transform: translateY(-2px)  scale(1.01) rotate(-1deg); }
    100% { transform: translateY(0)     scale(1)    rotate(0deg); }
}

/* Confetti burst that appears briefly on merge (CSS only elements) */
@keyframes confetti-fly {
    0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-80px) rotate(360deg); opacity: 0; }
}
