:root {
    --primary: #4a7c59;
    --secondary: #8b4513;
    --accent: #ffd700;
    --bg: #87ceeb; /* Sky blue */
    --text: #2c1810;
    --plot-side: #654321;
    --plot-top: #8b7355;
    --plot-planted: #5c4033;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: radial-gradient(circle at center, #87ceeb 0%, #e0f7fa 100%);
    min-height: 100vh;
    color: var(--text);
    overflow-x: hidden;
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Stats */
.stats-bar {
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 25px;
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 100;
}

.stat {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.actions {
    display: flex;
    gap: 10px;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 0 #2a4d35;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #2a4d35;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #2a4d35;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #ccc;
    box-shadow: none;
    transform: none;
}

/* Main Game Area */
.game-area {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
    align-items: start;
    position: relative;
    z-index: 5;
}

/* 3D Farm Section */
.farm-section {
    perspective: 1000px;
    padding: 20px;
    display: flex;
    justify-content: center;
    padding-top: 50px;
}

.deco {
    position: absolute;
    pointer-events: none;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.2));
    z-index: 0;
    mix-blend-mode: multiply; /* Hide white background */
}

.barn {
    top: 20px;
    left: 10%;
    width: 250px;
    z-index: 0;
}

.market {
    top: 50px;
    right: 15%;
    width: 180px;
    z-index: 20; /* In front of back row? */
}

/* Fence Styles Removed */

.farm-section h2 {
    display: none;
}

/* Ensure 3D context doesn't clip fixed elements */
.farm-section {
    perspective: 1000px;
    padding: 20px;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1; /* Lower than UI */
    
    /* Farm "Island" Styles */
    background: #a67c52; /* Solid Earth/Dirt Color */
    /* Remove the overlay gradients */
    background-size: initial; 
    border-radius: 40px;
    border: 8px solid #8b5a2b; /* Darker brown border/fence base */
    border-bottom: 20px solid #654321; /* Deep 3D base */
    margin: 20px 0;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    min-height: 600px; /* Ensure enough space for content */
}

/* Isometric Grid Container */
.farm-grid {
    position: relative;
    width: 600px;
    height: 400px;
    margin: 50px auto;
    /* transform removed - using absolute positioning */
}

.farm-grid.size-4 {
    width: 700px;
    height: 500px;
}

.farm-grid.size-5 {
    width: 800px;
    height: 600px;
}

/* Isometric Plot */
.plot {
    position: absolute;
    width: 120px; /* Adjust based on image size */
    height: 120px;
    cursor: pointer;
    transition: filter 0.2s;
    /* Fix checking: Ensure click target matches the diamond shape */
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.plot:hover {
    filter: brightness(1.2) drop-shadow(0 0 10px #ffd700); /* Golden glow */
    transform: translateY(-5px); /* Pop up slightly */
    z-index: 100 !important; /* Bring to front on hover */
}

.plot img.base {
    width: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.05); /* Slight scale to prevent gaps */
    z-index: 1;
    padding: 10px; /* User requested padding */
}

.plot img.crop {
    width: 80%; /* Reduce size slightly */
    position: absolute;
    bottom: 30%; /* Move up slightly to sit on 'top' of soil */
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Attempt to remove white background for crops using mix-blend (hacky but effective for white bg) */
    mix-blend-mode: multiply; 
}

/* Growth Sizes
   Simply scale the image based on stage. 
   No extra animations. 
*/
.plot img.crop.stage-0 { transform: translateX(-50%) scale(0.4); opacity: 0.9; }
.plot img.crop.stage-1 { transform: translateX(-50%) scale(0.6); }
.plot img.crop.stage-2 { transform: translateX(-50%) scale(0.8); }
.plot img.crop.stage-3 { transform: translateX(-50%) scale(1.0); }

/* Progress Bar Removed */

/* Inventory Sidebar */
.inventory-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 100;
    position: relative;
}

.inventory-section h2 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.seed-btn {
    background: white;
    border: 2px solid #eee;
    margin-bottom: 10px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
}

.icon-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.icon-sm {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 5px;
}

.icon-md {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.seed-btn:hover {
    border-color: var(--primary);
    transform: translateX(-2px);
}

.seed-btn.active {
    border-color: var(--primary);
    background: #e8f5e9;
    box-shadow: inset 0 0 10px rgba(74, 124, 89, 0.1);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* Must be higher than 3D content */
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    border: 4px solid var(--primary);
    position: relative;
    z-index: 10001;
}

/* Responsive */
@media (max-width: 900px) {
    .game-area {
        grid-template-columns: 1fr;
    }
    
    .farm-section {
        height: 60vh;
        overflow: hidden;
        align-items: center;
    }
    
    .farm-grid {
        transform: rotateX(60deg) rotateZ(45deg) scale(0.8);
    }
}
