/* Prevent default drag behavior and text selection */
body {
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior-y: contain;
    /* Safe area for iPhone notch */
    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);
}

.cell {
    transition: all 0.2s;
    /* Ensure cells are touchable */
    min-width: 0;
    min-height: 0;
}

/* Effect when clearing lines */
.clearing {
    animation: flash 0.3s ease-out;
}

@keyframes flash {
    0% { transform: scale(1); opacity: 1; background-color: white; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

/* Grid board background */
.grid-bg {
    background-color: #e5e7eb; /* gray-200 */
}

.empty-cell {
    background-color: #d1d5db; /* gray-300 */
    border-radius: 4px;
}

.filled-cell {
    border-radius: 4px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

/* Piece draggable container */
.piece-container {
    touch-action: none; 
}

/* Piece element - touch handling */
.piece {
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    /* min-width and min-height removed - handled in JS to maintain aspect ratio */
    position: relative;
    z-index: 1;
    /* Ensure each piece is properly contained within its slot */
    margin: 0 auto;
}

/* 3D effect for piece blocks */
.piece > div:not(.opacity-0) {
    /* 3D raised effect */
    box-shadow: 
        inset -2px -2px 4px rgba(0, 0, 0, 0.3),
        inset 2px 2px 4px rgba(255, 255, 255, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Add subtle gradient overlay for 3D depth */
.piece > div:not(.opacity-0)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%, rgba(0, 0, 0, 0.15) 100%);
    border-radius: inherit;
    pointer-events: none;
}

/* Ghost piece when dragging */
.dragging-ghost {
    position: fixed !important; /* IMPORTANT: Override Tailwind's position: relative */
    pointer-events: none;
    z-index: 1000;
    opacity: 0.9;
    transform: translate(-50%, -50%); /* Center on finger/cursor */
    margin: 0 !important; /* Remove margin if any */
    transform-origin: center center;
    /* Better visibility on mobile */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    /* Larger touch targets */
    button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for mobile */
    .piece-slot {
        padding: 4px;
        /* Ensure each slot is isolated */
        position: relative;
        overflow: visible;
    }
    
    /* Larger pieces on mobile for easier interaction */
    .piece {
        transform: scale(1.1);
        /* Ensure pieces don't overlap */
        position: relative;
        z-index: 1;
    }
}

/* Piece slot styling - ensure each slot is isolated */
.piece-slot {
    position: relative;
    isolation: isolate; /* Create new stacking context for each slot */
    overflow: visible;
}

/* Prevent iOS bounce scroll and overscroll */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Safe area support for header and footer */
.header-safe {
    padding-top: env(safe-area-inset-top);
}

.footer-safe {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Footer styles */
footer {
    flex-shrink: 0;
}

.footer-avatar img {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

