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

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    margin: 0;
    padding: 0;
    /* Extend background into safe areas on iOS */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.game-container {
    text-align: center;
    width: 100%;
    max-width: 900px;
    max-height: 1024px;
    padding: 15px;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 20px;
    /* Ensure container doesn't extend into safe areas */
    box-sizing: border-box;
}

h1 {
    color: #fff;
    font-size: 2.5em;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 5px;
}

.instructions {
    color: #fff;
    font-size: 1.2em;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.score {
    color: #ffd93d;
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Drop Zone */
.drop-zone-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.drop-zone {
    width: 220px;
    height: 220px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 4px dashed rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    transform: perspective(1000px) rotateX(5deg);
    will-change: transform, background;
}

.drop-zone.drag-over {
    background: rgba(255, 255, 255, 0.4);
    transform: perspective(1000px) rotateX(0deg) scale(1.05);
    border-color: rgba(255, 255, 255, 0.8);
}

.drop-zone svg {
    width: 80%;
    height: 80%;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* Shape Basket */
.shapes-basket {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    padding: 20px;
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.shapes-basket h3 {
    color: #fff;
    font-size: 1.6em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.basket-shapes {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    min-height: 140px;
}

.shape {
    width: 110px;
    height: 110px;
    cursor: grab;
    transition: opacity 0.2s ease;
    transform: perspective(1000px) translateZ(0);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Only apply hover effects on devices that support hover (not touch screens) */
@media (hover: hover) and (pointer: fine) {
    .shape:hover {
        transform: perspective(1000px) translateZ(20px) scale(1.1) rotateZ(5deg);
        filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.4));
    }
}

.shape:active {
    cursor: grabbing;
}

.shape.dragging {
    opacity: 0.5;
}

.shape svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}

/* Success animation */
@keyframes successPulse {
    0% {
        transform: perspective(1000px) scale(1);
    }
    50% {
        transform: perspective(1000px) scale(1.3) rotateZ(10deg);
    }
    100% {
        transform: perspective(1000px) scale(1);
    }
}

.drop-zone.success {
    animation: successPulse 0.6s ease;
    background: rgba(144, 238, 144, 0.3);
    border-color: #90ee90;
}

/* Shape Name Label */
.shape-name {
    color: #fff;
    font-size: 2em;
    font-weight: bold;
    margin-top: 10px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    text-transform: capitalize;
    letter-spacing: 2px;
}

/* Confetti canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    /* Extend canvas into safe areas */
    margin-top: calc(-1 * env(safe-area-inset-top));
    margin-bottom: calc(-1 * env(safe-area-inset-bottom));
    margin-left: calc(-1 * env(safe-area-inset-left));
    margin-right: calc(-1 * env(safe-area-inset-right));
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        /* Safe areas already handled by parent body styles */
    }
    
    .game-container {
        max-height: 100vh;
        max-height: 100dvh;
        padding: 10px;
        width: 100%;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 3px;
    }
    
    .instructions {
        font-size: 1em;
        margin-bottom: 3px;
    }
    
    .score {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    
    .drop-zone-container {
        margin-bottom: 10px;
    }
    
    .drop-zone {
        width: 180px;
        height: 180px;
    }
    
    .shape-name {
        font-size: 1.5em;
        margin-top: 8px;
    }
    
    .shapes-basket {
        padding: 15px;
    }
    
    .shapes-basket h3 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    
    .basket-shapes {
        gap: 12px;
        min-height: 100px;
    }
    
    .shape {
        width: 85px;
        height: 85px;
    }
    
    .shape:hover {
        transform: perspective(1000px) translateZ(10px) scale(1.05);
    }
}

/* iPhone 14 Pro specific (and similar devices) */
@media (max-width: 430px) and (max-height: 932px) {
    h1 {
        font-size: 1.6em;
    }
    
    .drop-zone {
        width: 160px;
        height: 160px;
    }
    
    .shape {
        width: 75px;
        height: 75px;
    }
}
