/* Main Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3f 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Navigation Styles */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 10px;
    margin: 10px auto;
    max-width: 600px;
    backdrop-filter: blur(5px);
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.nav-link.active {
    background: #f4a020;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}


/* Header with embedded interactive guide */
header {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 20px;
    color: white;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    max-width: 1400px;
    margin: 0 auto;
}

.header-title h1 {
    font-size: 1.8em;
    margin-bottom: 5px;
}

.header-title p {
    opacity: 0.9;
    font-size: 0.95em;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    background: #f4a020;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    white-space: nowrap;
}

/* Interactive Guide Tabs */
.guide-tabs {
    display: flex;
    gap: 5px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.guide-tab {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px 8px 0 0;
    color: rgb(255, 255, 255);
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.guide-tab:hover {
    background: rgba(255, 255, 255, 0.2);
}

.guide-tab.active {
    background: rgb(255, 255, 255);
    color: #1a472a;
    font-weight: bold;
}

.guide-content {
    background: rgb(64, 151, 30);
    border-radius: 0 10px 10px 10px;
    padding: 15px;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.guide-content.active {
    display: block;
}

.guide-content h3 {
    color: #1a472a;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.guide-item {
    background: #659b69;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85em;
}

.guide-item strong {
    color: #1a472a;
}

.wiring-table-mini {
    width: 100%;
    font-size: 0.8em;
    border-collapse: collapse;
}

.wiring-table-mini th {
    background: #1a472a;
    color: white;
    padding: 6px;
    text-align: left;
}

.wiring-table-mini td {
    padding: 5px 6px;
    border-bottom: 1px solid #ddd;
}

.pin-mini {
    background: #1a472a;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.85em;
}

/* Particle FX */
.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 200;
    animation: particleFly 0.8s ease-out forwards;
}

.particle.water-part {
    background: #03A9F4;
    opacity: 0.8;
}

.particle.spark {
    background: #FFD700;
    box-shadow: 0 0 5px orange;
    width: 4px;
    height: 4px;
}

.particle.smoke {
    background: #757575;
    width: 10px;
    height: 10px;
    opacity: 0.5;
    filter: blur(2px);
}

@keyframes particleFly {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(var(--vx), var(--vy)) scale(0);
        opacity: 0;
    }
}

/* Extracted Inline Styles */
.guide-intro-text {
    margin-bottom: 8px;
    font-size: 0.9em;
    line-height: 1.5;
}

.project-info-section {
    margin-bottom: 10px;
    font-size: 0.9em;
}

.project-section-small {
    font-size: 0.9em;
}

.project-list {
    margin-top: 5px;
    margin-left: 20px;
}

.diagram-header {
    background: #e8f5e9;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: bold;
    color: #1a472a;
    border: 1px dashed #4CAF50;
}

/* Scenario Selector */
.scenario-bar {
    background: linear-gradient(135deg, #263238, #37474F);
    padding: 15px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.scenario-label {
    color: white;
    font-weight: bold;
    margin-right: 10px;
}

.scenario-btn {
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scenario-btn.normal {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white;
}

.scenario-btn.drought {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

.scenario-btn.infestation {
    background: linear-gradient(135deg, #f44336, #c62828);
    color: white;
}

.scenario-btn.birds {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.scenario-btn.greenhouse {
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
    color: white;
}

.scenario-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.scenario-btn.active {
    border-color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* Main Layout */
.main-container {
    display: flex;
    flex-wrap: wrap;
    padding: 20px;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Farm Field */
.farm-container {
    flex: 2;
    min-width: 500px;
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.farm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.farm-title {
    color: #1a472a;
    font-size: 1.3em;
}

.environment-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.env-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: #f5f5f5;
    border-radius: 15px;
    font-size: 0.85em;
}

.farm-field {
    position: relative;
    width: 100%;
    height: 450px;
    border-radius: 15px;
    overflow: hidden;
    border: 4px solid #5D4037;
    transition: all 0.5s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Textured outdoor ground */
.farm-field.outdoor {
    background:
        radial-gradient(circle at 50% 10%, #87CEEB 0%, transparent 80%),
        /* Sun glare */
        linear-gradient(180deg, #87CEEB 0%, #87CEEB 35%, #558B2F 35%, #33691E 100%);
    /* Sky and Grass */
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.4),
        0 0 0 4px #3E2723,
        /* Darker wood border */
        inset 0 -20px 60px rgba(0, 0, 0, 0.3);
}

/* Drought conditions - Scorched Earth */
.farm-field.drought {
    background:
        radial-gradient(circle at 50% 10%, rgba(255, 87, 34, 0.3) 0%, transparent 70%),
        /* Intense Heat Glare */
        linear-gradient(180deg, #FFCC80 0%, #FFCC80 35%, #8D6E63 35%, #5D4037 100%);
    /* Orange Sky and Dry Soil */
    filter: sepia(0.4) contrast(1.2);
    /* Warm, dry filter */
}

/* Greenhouse */
.farm-field.greenhouse {
    background: linear-gradient(180deg, #E1F5FE 0%, #E1F5FE 30%, #4E342E 30%, #4E342E 100%);
}

/* Soil rows - Flat 2D */
.soil-row {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 0;
    background: rgba(62, 39, 35, 0.1);
}

.crop-row {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 90px;
    background: linear-gradient(90deg, transparent 5%, #5D4037 10%, #3E2723 50%, #5D4037 90%, transparent 95%);
    border-radius: 50% 50% 50% 50% / 10px 10px 10px 10px;
    margin: 5px 20px;
    position: relative;
}

/* Plants with base shadow */
.plant-spot {
    position: relative;
    width: 60px;
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 10px;
}

/* Plant Shadow on Soil - Simplified for 2D */
.plant-spot::after {
    content: '';
    position: absolute;
    bottom: 15px;
    left: 50%;
    width: 40px;
    height: 6px;
    background: rgba(0, 0, 0, 0.2);
    transform: translateX(-50%);
    border-radius: 50%;
    filter: blur(1px);
    z-index: 0;
}

.farm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.farm-title {
    color: #1a472a;
    font-size: 1.3em;
}

.environment-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.env-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: #f5f5f5;
    border-radius: 15px;
    font-size: 0.85em;
}

.farm-field {
    position: relative;
    width: 100%;
    height: 450px;
    border-radius: 15px;
    overflow: hidden;
    border: 4px solid #5D4037;
    transition: all 0.5s;
    transform-style: preserve-3d;
    transform: rotateX(25deg) rotateY(0deg) rotateZ(0deg);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.3),
        0 -5px 20px rgba(0, 0, 0, 0.1),
        inset 0 -10px 30px rgba(0, 0, 0, 0.2);
}

/* Textured outdoor ground */
.farm-field.outdoor {
    background:
        radial-gradient(circle at 50% 10%, #87CEEB 0%, transparent 80%),
        /* Sun glare */
        linear-gradient(180deg, #87CEEB 0%, #87CEEB 35%, #558B2F 35%, #33691E 100%);
    /* Sky and Grass */
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.4),
        0 0 0 4px #3E2723,
        /* Darker wood border */
        inset 0 -20px 60px rgba(0, 0, 0, 0.3);
}

/* Drought conditions - Scorched Earth */
.farm-field.drought {
    background:
        radial-gradient(circle at 50% 10%, rgba(255, 87, 34, 0.3) 0%, transparent 70%),
        /* Intense Heat Glare */
        linear-gradient(180deg, #FFCC80 0%, #FFCC80 35%, #8D6E63 35%, #5D4037 100%);
    /* Orange Sky and Dry Soil */
    filter: sepia(0.4) contrast(1.2);
    /* Warm, dry filter */
}

/* Greenhouse */
.farm-field.greenhouse {
    background: linear-gradient(180deg, #E1F5FE 0%, #E1F5FE 30%, #4E342E 30%, #4E342E 100%);
}

/* Soil rows - 3D Furrows */
.soil-row {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 0;
    background:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 80px,
            rgba(62, 39, 35, 0.3) 80px,
            rgba(62, 39, 35, 0.6) 100px,
            transparent 120px);
    /* Shadow lines for rows */
}

.crop-row {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 90px;
    background: linear-gradient(90deg, transparent 5%, #5D4037 10%, #3E2723 50%, #5D4037 90%, transparent 95%);
    border-radius: 50% 50% 100% 100% / 10px 10px 20px 20px;
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.5),
        inset 0 5px 15px rgba(0, 0, 0, 0.3);
    margin: 5px 20px;
    position: relative;
    transform: translateZ(20px);
    /* Lift rows slightly for 3D effect */
    transform-style: preserve-3d;
}

/* Plants with base shadow */
.plant-spot {
    position: relative;
    width: 60px;
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 10px;
    transform-style: preserve-3d;
}

/* Plant Shadow on Soil */
.plant-spot::after {
    content: '';
    position: absolute;
    bottom: 15px;
    left: 50%;
    width: 40px;
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    transform: translateX(-50%) rotateX(60deg);
    border-radius: 50%;
    filter: blur(2px);
    z-index: 0;
}

.plant {
    font-size: 45px;
    /* Larger plants */
    transition: all 0.5s;
    cursor: pointer;
    z-index: 10;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.3));
    transform-origin: bottom center;
}

/* Enhanced Status Indicators */
.soil-indicator {
    width: 40px;
    height: 6px;
    background: #3E2723;
    border-radius: 3px;
    margin-top: -5px;
    margin-bottom: 5px;
    position: relative;
    overflow: hidden;
    z-index: 15;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.moisture-level {
    height: 100%;
    background: linear-gradient(90deg, #29B6F6, #0277BD);
    border-radius: 3px;
    transition: width 0.5s;
    box-shadow: 0 0 5px #03A9F4;
}

/* Robot */
/* Robots Container */
#robotsContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#robotsContainer .robot {
    pointer-events: auto;
}

/* Robot - Industrial Design */
.robot {
    position: absolute;
    width: 80px;
    height: 100px;
    /* transition: all 0.3s ease; REMOVED for smooth JS animation */
    z-index: 100;
    transform: scale(0.65);
    /* Reduced by 35% */
}

.ind-base {
    width: 50px;
    height: 90px;
    background: linear-gradient(to bottom, #cfd8dc, #b0bec5);
    border: 1px solid #78909c;
    border-radius: 4px;
    position: absolute;
    left: 15px;
    top: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

/* Rugged Wheels */
.ind-wheel {
    position: absolute;
    width: 14px;
    height: 25px;
    background: #263238;
    border-radius: 4px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    background-image: repeating-linear-gradient(0deg, #263238, #263238 4px, #37474F 4px, #37474F 6px);
    z-index: 1;
}

.wheel-FL {
    top: 5px;
    left: -10px;
}

.wheel-FR {
    top: 5px;
    right: -10px;
}

.wheel-BL {
    bottom: 5px;
    left: -10px;
}

.wheel-BR {
    bottom: 5px;
    right: -10px;
}

/* Central Mast */
.ind-mast {
    position: absolute;
    width: 20px;
    height: 40px;
    background: #546e7a;
    left: 15px;
    top: 25px;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

.mast-top {
    width: 100%;
    height: 10px;
    background: #37474f;
    border-radius: 2px 2px 0 0;
}

/* Control Screen (Laptop style) */
.ind-screen {
    position: absolute;
    width: 36px;
    height: 24px;
    background: #212121;
    bottom: 10px;
    left: 7px;
    border-radius: 3px;
    border: 1px solid #424242;
    z-index: 4;
    overflow: hidden;
}

.screen-code {
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(transparent, transparent 4px, rgba(0, 255, 0, 0.2) 5px);
    animation: scrollCode 2s linear infinite;
}

@keyframes scrollCode {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 0 20px;
    }
}

/* Robotic Arms */
.ind-arm {
    position: absolute;
    width: 40px;
    height: 8px;
    background: #0288d1;
    /* Industrial Blue */
    top: 30px;
    z-index: 3;
    display: flex;
    align-items: center;
}

.ind-arm.left {
    right: 45px;
    /* Extends left from base center */
    transform-origin: right center;
    transform: rotate(15deg);
    border-radius: 4px 0 0 4px;
}

.ind-arm.right {
    left: 45px;
    /* Extends right from base center */
    transform-origin: left center;
    transform: rotate(-15deg);
    border-radius: 0 4px 4px 0;
}

.arm-tool {
    width: 12px;
    height: 12px;
    background: silver;
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 0 5px #0288d1;
}

.ind-arm.left .arm-tool {
    left: -6px;
}

.ind-arm.right .arm-tool {
    right: -6px;
}


/* Crates/Storage */
.ind-crate {
    position: absolute;
    width: 15px;
    height: 25px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #000;
    top: 60px;
    z-index: 2;
}

.ind-crate.left {
    left: -5px;
}

.ind-crate.right {
    right: -5px;
}


/* Movement Animation */
.robot.moving .ind-wheel {
    animation: roll 0.2s linear infinite;
}

@keyframes roll {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 6px;
    }
}

/* Water spray */
.water-spray {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    align-items: center;
}

.water-spray.active {
    display: flex;
    animation: spray 0.5s ease-out infinite;
}

@keyframes spray {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

.water-drop {
    color: #4FC3F7;
    font-size: 16px;
    margin: 2px;
}

/* Pests */
.pest {
    position: absolute;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 50;
}

.pest:hover {
    transform: scale(1.2);
}

.pest.scared {
    animation: runAway 0.5s forwards;
}

@keyframes runAway {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5) rotate(20deg);
    }

    100% {
        transform: scale(0) translateY(-100px);
        opacity: 0;
    }
}

.pest.sprayed {
    animation: sprayDeath 0.8s forwards;
}

@keyframes sprayDeath {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    30% {
        transform: scale(1.3) rotate(10deg);
        filter: hue-rotate(90deg);
    }

    60% {
        transform: scale(0.8) rotate(-10deg);
        opacity: 0.7;
    }

    100% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
}

.pest.zapped {
    animation: laserDeath 0.5s forwards;
}

@keyframes laserDeath {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }

    20% {
        transform: scale(1.5);
        filter: brightness(3) saturate(0);
    }

    40% {
        transform: scale(1.2);
        filter: brightness(5);
    }

    100% {
        transform: scale(0);
        opacity: 0;
        filter: brightness(10);
    }
}

.pest.trapped {
    animation: trapDeath 1s forwards;
}

@keyframes trapDeath {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }

    30% {
        transform: scale(0.8) translateY(10px);
    }

    50% {
        transform: scale(0.6) translateY(5px);
    }

    100% {
        transform: scale(0) translateY(20px);
        opacity: 0;
    }
}

.pest.netted {
    animation: netDeath 0.8s forwards;
}

@keyframes netDeath {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.5) rotate(360deg);
    }

    100% {
        transform: scale(0) translateY(50px);
        opacity: 0;
    }
}

/* Birds */
.bird {
    position: absolute;
    font-size: 32px;
    cursor: pointer;
    z-index: 60;
    animation: fly 3s ease-in-out infinite;
}

@keyframes fly {

    0%,
    100% {
        transform: translateY(0) rotate(-5deg);
    }

    50% {
        transform: translateY(-20px) rotate(5deg);
    }
}

.bird.scared {
    animation: birdFlyAway 1s forwards;
}

@keyframes birdFlyAway {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(0) translateY(-200px) translateX(100px);
        opacity: 0;
    }
}

.bird.netted {
    animation: netDeath 0.8s forwards;
}

/* Alert effect */
.alert-ring {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 4px solid #f44336;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.alert-ring.active {
    display: block;
    animation: alertPulse 0.5s ease-out infinite;
}

@keyframes alertPulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Spray cloud effect */
.spray-cloud {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(139, 195, 74, 0.6) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: sprayCloud 1s forwards;
    z-index: 80;
}

@keyframes sprayCloud {
    0% {
        transform: scale(0.3);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Laser beam effect */
.laser-beam {
    position: absolute;
    height: 4px;
    background: linear-gradient(90deg, #E91E63, #FF5722, #FFEB3B);
    box-shadow: 0 0 10px #E91E63, 0 0 20px #FF5722;
    z-index: 90;
    animation: laserShoot 0.3s forwards;
    transform-origin: left center;
}

@keyframes laserShoot {
    0% {
        width: 0;
        opacity: 1;
    }

    50% {
        width: 100%;
        opacity: 1;
    }

    100% {
        width: 100%;
        opacity: 0;
    }
}

/* Net effect */
.net-projectile {
    position: absolute;
    font-size: 30px;
    z-index: 85;
    animation: throwNet 0.4s forwards;
}

@keyframes throwNet {
    0% {
        transform: scale(0.5);
    }

    100% {
        transform: scale(1.5);
    }
}

/* Trap on field */
.trap {
    position: absolute;
    font-size: 24px;
    z-index: 40;
    cursor: pointer;
    animation: trapPlace 0.3s ease-out;
}

@keyframes trapPlace {
    0% {
        transform: scale(0) rotate(-45deg);
    }

    70% {
        transform: scale(1.2) rotate(10deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

.trap.triggered {
    animation: trapSnap 0.5s forwards;
}

@keyframes trapSnap {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
        filter: brightness(1.2);
    }
}

/* Scarecrow */
.scarecrow {
    position: absolute;
    font-size: 50px;
    z-index: 45;
    animation: scarecrowSway 2s ease-in-out infinite;
    display: none;
}

.scarecrow.active {
    display: block;
}

@keyframes scarecrowSway {

    0%,
    100% {
        transform: rotate(-3deg);
    }

    50% {
        transform: rotate(3deg);
    }
}

/* Control Panel */
.control-panel {
    flex: 1;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.panel h3 {
    color: #1a472a;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4CAF50;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
}

/* Movement Controls */
.movement-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 200px;
    margin: 0 auto;
}

.move-btn {
    width: 60px;
    height: 50px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.move-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.move-btn:active {
    transform: scale(0.95);
}

.move-btn.stop {
    background: linear-gradient(135deg, #f44336, #d32f2f);
}

.empty-cell {
    visibility: hidden;
}

/* Status Display */
.status-grid {
    display: grid;
    gap: 10px;
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 10px;
    font-size: 0.9em;
}

.status-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #333;
}

.status-value {
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
}

.status-value.dry {
    background: #FFCDD2;
    color: #C62828;
}

.status-value.wet {
    background: #B3E5FC;
    color: #0277BD;
}

.status-value.detected {
    background: #FFCDD2;
    color: #C62828;
    animation: pulse 0.5s infinite;
}

.status-value.clear {
    background: #C8E6C9;
    color: #2E7D32;
}

.status-value.warning {
    background: #FFF3E0;
    color: #E65100;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-btn {
    padding: 12px 10px;
    border: none;
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.action-btn.water {
    background: linear-gradient(135deg, #03A9F4, #0288D1);
    color: white;
}

.action-btn.alarm {
    background: linear-gradient(135deg, #FF5722, #E64A19);
    color: white;
}

.action-btn.spray {
    background: linear-gradient(135deg, #8BC34A, #689F38);
    color: white;
}

.action-btn.laser {
    background: linear-gradient(135deg, #E91E63, #C2185B);
    color: white;
}

.action-btn.trap {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

.action-btn.net {
    background: linear-gradient(135deg, #00BCD4, #0097A7);
    color: white;
}

.action-btn.auto {
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
    color: white;
    grid-column: span 2;
}

.action-btn.add-pest {
    background: linear-gradient(135deg, #795548, #5D4037);
    color: white;
}

.action-btn.add-bird {
    background: linear-gradient(135deg, #607D8B, #455A64);
    color: white;
}

.action-btn.scarecrow {
    background: linear-gradient(135deg, #FFEB3B, #FBC02D);
    color: #333;
}

.action-btn.rain {
    background: linear-gradient(135deg, #90CAF9, #42A5F5);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.action-btn.active {
    animation: buttonPulse 1s infinite;
}

@keyframes buttonPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
    }
}

/* Mode Selector */
.mode-selector {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 10px;
    margin-top: 10px;
}

.mode-selector label {
    font-weight: bold;
    color: #333;
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s;
}

.mode-option:hover {
    background: #e8f5e9;
}

.mode-option input:checked+span {
    font-weight: bold;
    color: #1a472a;
}

/* Kill counter */
.stats-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.stat-box {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    color: white;
    font-weight: bold;
}

.stat-box.kills {
    background: linear-gradient(135deg, #f44336, #c62828);
}

.stat-box.saved {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.stat-box .count {
    font-size: 1.5em;
    display: block;
}

.stat-box .label {
    font-size: 0.75em;
    opacity: 0.9;
}

/* Log Panel */
.log-container {
    height: 120px;
    overflow-y: auto;
    background: #1e1e1e;
    border-radius: 10px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid #333;
    color: #4EC9B0;
}

.log-entry.warning {
    color: #FFEB3B;
}

.log-entry.error {
    color: #f44336;
}

.log-entry.success {
    color: #4CAF50;
}

.log-entry .time {
    color: #888;
    margin-right: 8px;
}

/* Info box */
.info-box {
    background: #E3F2FD;
    border-left: 4px solid #2196F3;
    padding: 10px;
    border-radius: 0 8px 8px 0;
    margin-top: 10px;
    font-size: 0.85em;
    color: #1565C0;
}


/* Diagram Simulation */
.sim-diagram {
    display: flex;
    justify-content: space-between;
    background: white;
    padding: 20px;
    border-radius: 10px;
    align-items: center;
    overflow-x: auto;
    position: relative;
    min-width: 800px;
}

.d-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 2;
    min-width: 100px;
}

.d-box {
    border: 2px solid #555;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    background: #f8f9fa;
    font-weight: bold;
    font-size: 0.7em;
    width: 90px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s;
    color: #1a472a;
    position: relative;
    cursor: default;
}

.d-box:hover,
.d-circle:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.d-circle {
    border: 2px solid #555;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    background: #fff;
    font-weight: bold;
    font-size: 0.7em;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 2;
    color: #1a472a;
}

/* Component Styles */
.battery {
    border-color: #333;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pump {
    border-color: #03A9F4;
}

.micro {
    height: 300px;
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e3f2fd;
    border-color: #1565C0;
    font-size: 0.9em;
}

.driver {
    background: #e8f5e9;
    border-color: #2E7D32;
}

.servo {
    background: #fff3e0;
    border-color: #EF6C00;
}

.motor {
    background: #fce4ec;
    border-color: #C2185B;
}

.relay {
    background: #f3e5f5;
    border-color: #7B1FA2;
}

.regulator {
    background: #fffde7;
    border-color: #FBC02D;
}

.wires-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.wire {
    fill: none;
    stroke: #ddd;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-width 0.3s, filter 0.3s;
}

.wire:hover {
    stroke-width: 5;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.3));
    z-index: 10;
}

/* Animation Classes */
.power-flow {
    stroke: #FBC02D;
    stroke-dasharray: 8;
    stroke-width: 3;
    animation: flow 1s linear infinite;
}

.power-high {
    stroke: #d32f2f;
    stroke-width: 4;
    stroke-dasharray: 10;
    animation: flow 0.8s linear infinite;
}

.signal-flow {
    stroke: #4CAF50;
    stroke-dasharray: 6;
    stroke-width: 3;
    animation: flow 2s linear infinite;
}

.data-flow {
    stroke: #2196F3;
    stroke-dasharray: 5;
    stroke-width: 3;
    animation: flow 1.5s linear infinite;
}

.power-motor {
    stroke: #333;
    stroke-width: 4;
    stroke-dasharray: 8;
    animation: flow 0.3s linear infinite;
}

@keyframes flow {
    to {
        stroke-dashoffset: -20;
    }
}

.spacer {
    width: 100%;
}

.spacer-sm {
    height: 20px;
}

.motor-group {
    display: flex;
    gap: 5px;
}


/* Responsive */
/* =========================================================================
   COMPREHENSIVE MOBILE RESPONSIVENESS
========================================================================= */

@media (max-width: 900px) {

    /* Tablet & Small Laptop Layout */
    .header-top {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .badges {
        justify-content: center;
    }

    .main-container {
        flex-direction: column;
        padding: 10px;
    }

    /* Make game and controls stack vertically */
    .main-container>div[style*="justify-content: center;"] {
        flex-direction: column !important;
        align-items: center !important;
    }

    /* Expand panels to full width on smaller screens */
    .farm-container,
    .panel {
        width: 100% !important;
        min-width: unset !important;
        max-width: 100% !important;
    }

    .farm-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .environment-stats {
        justify-content: center;
        margin-top: 10px;
    }
}

@media (max-width: 600px) {

    /* Mobile Phone Layout */
    body {
        padding: 10px;
    }

    /* Header Adjustments */
    .header-title h1 {
        font-size: 1.4em;
    }

    .main-nav {
        flex-direction: column;
        gap: 8px;
        padding: 5px;
    }

    .nav-link {
        width: 100%;
        text-align: center;
        padding: 10px;
    }

    /* Guide Tabs Scrollable */
    .guide-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll */
    }

    .guide-tab {
        flex: 0 0 auto;
        /* Don't shrink */
        font-size: 0.8em;
        white-space: nowrap;
    }

    /* Game Canvas Responsive */
    #phaser-container {
        width: 100% !important;
        height: auto !important;
    }

    #phaser-container canvas {
        width: 100% !important;
        height: auto !important;
    }

    /* Controls & Buttons */
    .action-btn {
        padding: 12px 10px;
        /* Larger touch targets */
        font-size: 0.9em;
    }

    .movement-grid {
        gap: 5px;
        transform: scale(0.9);
        /* Slightly smaller to fit width */
    }

    .move-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5em;
        /* Larger icons */
    }

    /* Scenario Bar */
    .scenario-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .scenario-label {
        text-align: center;
        margin-bottom: 5px;
    }

    .scenario-btn {
        width: 100%;
        /* Full width buttons */
        justify-content: center;
        margin-bottom: 5px;
    }

    /* Sensor Panel Grid */
    .panel div[style*="flex-wrap: wrap"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 10px !important;
    }

    .status-value {
        font-size: 1em !important;
    }
}

/* Diagram Expansion */
.expand-btn {
    background: #1a472a;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    margin-left: 10px;
    vertical-align: middle;
    z-index: 1000;
    position: relative;
    transition: transform 0.2s;
}

.expand-btn:hover {
    transform: scale(1.05);
    background: #2d5a3f;
}

.sim-diagram.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw !important;
    height: 90vh !important;
    z-index: 9999;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.8);
    border: 5px solid #1a472a;
    background: white;
    display: flex;
    justify-content: center;
    min-width: unset;
    padding: 40px;
}

.sim-diagram.expanded .close-btn {
    display: block;
}

.close-btn {
    display: none;
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 10000;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.close-btn:hover {
    background: #d32f2f;
}

/* Pin Labels for Wiring Diagram */
.pin-lbl {
    position: absolute;
    background: #ffffff;
    border: 1px solid #666;
    border-radius: 3px;
    padding: 1px 3px;
    font-size: 9px;
    font-family: 'Consolas', monospace;
    font-weight: bold;
    color: #333;
    z-index: 5;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0.9;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Robot Rotation Animation */
.robot.rotating {
    animation: robotRotate 0.3s ease-in-out;
}

@keyframes robotRotate {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Circular Rotate Button */
.rotate-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid #fff;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    font-size: 20px;
}

.rotate-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.rotate-btn:active {
    transform: scale(0.95) rotate(30deg);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

/* Fullscreen Diagram Mode */
.fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100vh !important;
    z-index: 9999;
    margin: 0 !important;
    max-width: none !important;
    border-radius: 0;
    background: white;
    padding: 20px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.fullscreen #simDiagram {
    height: calc(100vh - 100px) !important;
}