/* General Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', 'Segoe UI', sans-serif;
    background-color: #E0F7FA;
    color: #333;
    overflow: hidden;
    line-height: 1.5;
}

.game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden; /* Prevent scrollbars during dragging */
    touch-action: none; /* Prevent browser gestures during touch interactions */
}

/* Intro Screen */
.intro-screen {
    text-align: center;
    background: linear-gradient(135deg, #C5E8FF, #F0FFF0);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 10;
    transition: transform 1s ease-in-out;
}

.intro-screen h1 {
    font-size: 3em;
    color: #2E7D32;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.start-button {
    cursor: pointer;
    transition: transform 0.3s ease;
    background-color: #4CAF50;
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.start-button:hover {
    transform: scale(1.1);
    background-color: #45a049;
}

.start-button-inner {
    color: white;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.instruction {
    margin-top: 40px;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    font-size: 24px;
    max-width: 700px;
    text-align: center;
    font-weight: bold;
    color: #2E7D32;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 3px solid #AED581;
}

/* Game Screen */
.game-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: linear-gradient(to bottom, #B3E5FC, #E0F7FA);
}

header {
    margin-bottom: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    color: #2E7D32;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
    color: #1B5E20;
}

.game-area {
    display: flex;
    flex-direction: column;
    gap: 40px;
    width: 100%;
    max-width: 1200px;
    position: relative; /* Added for better positioning of dragged elements */
    margin-bottom: 30px; /* Extra space at bottom for better visibility */
}

/* Plants Container */
.plants-container {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 20px;
    width: 100%;
    min-height: 180px;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 15px;
    margin-bottom: 30px;
}

.plant {
    width: 180px;
    height: 220px;
    position: relative;
    cursor: grab;
    z-index: 5;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 8px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
    margin: 10px;
    touch-action: none; /* Prevents browser's default touch actions */
    user-select: none; /* Prevents text selection during drag */
}

.plant img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-height: 190px;
    pointer-events: none; /* Ensures drag works on the container */
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    -webkit-user-drag: none; /* Prevents default image dragging */
    -webkit-touch-callout: none; /* Disables callout on long-press */
}

.plant:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.plant.dragging {
    cursor: grabbing;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    transform-origin: center center;
    opacity: 0.95;
    user-select: none;
    pointer-events: none; /* Ensures it doesn't interfere with drop zone detection */
    z-index: 1000 !important;
}

.plant.placed {
    cursor: default;
}

.plant.placed-in-zone {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    border: 3px solid #4CAF50;
    background-color: rgba(220, 255, 220, 0.7);
    border-radius: 8px;
    transition: all 0.5s ease;
    z-index: 3;
    /* Don't mess with the plant's position */
    position: absolute;
    /* Will have transform applied by JS */
}

.plant.placed-in-zone img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.plant.touch-active {
    animation: touch-pulse 0.3s ease-out;
}

@keyframes touch-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1.1); }
}

.success-icon {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: #4CAF50;
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    z-index: 10;
    animation: pulse-success 2s infinite;
}

/* Adjust success icon for placed plants */
.plant.placed-in-zone .success-icon {
    width: 25px;
    height: 25px;
    font-size: 18px;
    top: -8px;
    right: -8px;
}

/* Plant Labels */
.plant-label {
    display: block;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #4CAF50;
    border-radius: 10px;
    padding: 5px 10px;
    margin-top: 10px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    color: #2E7D32;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.plant:hover .plant-label {
    background-color: #E8F5E9;
    transform: translateY(-3px);
}

/* Special styling for placed plants */
.plant.placed-in-zone .plant-label {
    font-size: 14px;
    padding: 3px 6px;
    margin-top: 5px;
}

/* Drop Zones */
.drop-zones {
    display: flex;
    justify-content: space-around;
    width: 100%;
    gap: 30px;
    min-height: 450px; /* Extra space to accommodate multiple plants */
    position: relative; /* Added for absolute position of children */
}

.drop-zone {
    flex: 1;
    min-height: 400px;
    border: 6px dashed #4CAF50;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: visible; /* Allow plants to be visible outside zone boundaries */
    margin: 0 15px;
    min-width: 350px; /* Ensure enough width for multiple plants */
}

.drop-zone h2 {
    color: #2E7D32;
    margin-bottom: 10px;
    font-size: 2.2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.drop-zone p {
    color: #558B2F;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: bold;
}

.drop-zone.highlight {
    background-color: rgba(200, 230, 201, 0.95);
    border-color: #2E7D32;
    border-width: 8px;
    transform: scale(1.03);
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.6);
    animation: pulse-highlight 1s infinite alternate;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Zone image placeholders removed for cleaner interface */

#bigPlantsZone .zone-image {
    background-image: url('../assets/images/big-plants-zone.svg');
}

#smallPlantsZone .zone-image {
    background-image: url('../assets/images/small-plants-zone.svg');
}

/* Drop Indicator */
.drop-indicator {
    padding: 10px 15px;
    background-color: rgba(76, 175, 80, 0.15);
    border: 2px dashed rgba(76, 175, 80, 0.5);
    border-radius: 10px;
    color: #2E7D32;
    font-size: 1.2rem;
    margin-top: 80px;
    transition: all 0.5s ease;
    opacity: 0.7;
}

/* Hide indicators when items have been placed */
.drop-zone:has(.placed-in-zone) .drop-indicator {
    opacity: 0;
}

/* Feedback Message */
.feedback-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.98);
    padding: 30px 50px;
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    font-size: 2.2em;
    font-weight: bold;
    color: #2E7D32;
    z-index: 100;
    text-align: center;
    display: none;
    max-width: 80%;
    border: 6px solid #AED581;
    line-height: 1.4;
}

/* Replay Button */
.replay-button {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 15px;
    padding: 15px 30px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    opacity: 0;
    animation: fade-in 1s ease-out forwards;
}

.replay-button:hover, .replay-button:focus {
    background-color: #45a049;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    transform: translateX(-50%) scale(1.05);
}

.replay-button:active {
    background-color: #3d8b40;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: translateX(-50%) scale(0.98);
}

/* Accessibility focus outline */
.replay-button:focus {
    outline: 3px solid #FFF59D;
}

/* Celebration effects */
.drop-zone.celebrate {
    animation: celebrateZone 2s infinite;
}

@keyframes celebrateZone {
    0%, 100% {
        background-color: rgba(255, 255, 255, 0.7);
    }
    50% {
        background-color: rgba(200, 230, 201, 0.9);
    }
}

/* Hint Highlight */
.drop-zone.hint-highlight {
    box-shadow: 0 0 15px 10px rgba(255, 235, 59, 0.5);
    animation: hint-pulse 2s ease-in-out;
}

@keyframes hint-pulse {
    0%, 100% { box-shadow: 0 0 10px 5px rgba(255, 235, 59, 0.3); }
    50% { box-shadow: 0 0 20px 10px rgba(255, 235, 59, 0.5); }
}

/* Accessibility & Utility Classes */
.hidden {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus styles for keyboard navigation */
*:focus {
    outline: 3px solid #2196F3;
    outline-offset: 2px;
}

/* Feedback Icons */
.feedback-icon,
.feedback-hint {
    display: inline-block;
    margin-right: 10px;
    font-size: 1.5em;
    vertical-align: middle;
}

.feedback-icon {
    color: #4CAF50;
}

.feedback-hint {
    color: #FFB74D;
    animation: gentle-pulse 2s infinite;
}

@keyframes gentle-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Drag Cursor Indicator */
.drag-cursor-indicator {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: rgba(76, 175, 80, 0.5);
    border: 2px solid rgba(76, 175, 80, 0.8);
    border-radius: 50%;
    pointer-events: none;
    display: none;
    transform: translate(-50%, -50%);
    z-index: 9999;
    animation: pulse-cursor 1s infinite alternate;
}

@keyframes pulse-cursor {
    0% { transform: translate(-50%, -50%) scale(0.8); }
    100% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .game-area {
        flex-direction: column;
    }
    
    .plants-container {
        margin-bottom: 40px;
    }
    
    .drop-zones {
        width: 100%;
    }
    
    .drop-zone {
        min-height: 300px;
        margin-bottom: 20px;
    }
    
    /* Make text larger for mobile */
    .plant-label {
        font-size: 18px;
    }
    
    /* Improve touch targets */
    .plant {
        margin: 15px;
    }
}

/* Smooth Transition */
.smooth-transition {
    transition: all 0.4s ease-out !important;
}
