        :root {
            --bg: #f3f6ff;
            --card-bg: #ffffff;
            --accent: #6b8bff;
            --accent-soft: #e0e6ff;
            --grid-border: #d2dbff;
            --text-main: #1f2933;
            --text-muted: #6b7280;
            --danger: #ef4444;
            --success: #10b981;
        }

        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                sans-serif;
            background: radial-gradient(circle at top left, #e0f2fe, #eef2ff);
            color: var(--text-main);
            min-height: 100vh;
            display: flex;
            align-items: stretch;
            justify-content: center;
            padding: 16px;
        }

        .app {
            display: grid;
            grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr);
            gap: 16px;
            max-width: 1200px;
            width: 100%;
        }

        .card {
            background: var(--card-bg);
            border-radius: 18px;
            padding: 16px 18px;
            box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
            display: flex;
            flex-direction: column;
            min-height: 0;
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            margin-bottom: 10px;
            gap: 8px;
        }

        .card-title {
            font-size: 1rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .card-title span.emoji {
            font-size: 1.3rem;
        }

        .card-subtitle {
            font-size: 0.8rem;
            color: var(--text-muted);
        }

        .pill {
            font-size: 0.7rem;
            padding: 4px 8px;
            border-radius: 999px;
            background: var(--accent-soft);
            color: var(--accent);
            font-weight: 600;
            letter-spacing: 0.03em;
            text-transform: uppercase;
        }

        /* FARM VIEW */

        .farm-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
            gap: 8px;
            flex-wrap: wrap;
        }

        .stats {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .stat-chip {
            background: var(--accent-soft);
            color: var(--accent);
            border-radius: 999px;
            padding: 4px 10px;
            font-size: 0.75rem;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .stat-chip span.icon {
            font-size: 1rem;
        }

        .actions {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }

        button {
            border: none;
            border-radius: 999px;
            padding: 6px 12px;
            font-size: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            background: var(--accent);
            color: white;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
            transition: transform 0.08s ease, box-shadow 0.08s ease,
                opacity 0.08s ease;
            white-space: nowrap;
        }

        button.secondary {
            background: var(--card-bg);
            color: var(--text-main);
            border: 1px solid #e5e7eb;
            box-shadow: none;
        }

        button:active {
            transform: translateY(1px);
            box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
        }

        button:disabled {
            opacity: 0.6;
            cursor: default;
            box-shadow: none;
            transform: none;
        }

        .farm-grid {
            margin-top: 10px;
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 6px;
            padding: 10px;
            background: linear-gradient(135deg, #dbeafe, #e5e7eb);
            border-radius: 16px;
            border: 1px solid var(--grid-border);
            flex: 1;
            min-height: 220px;
        }

        .tile {
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.9);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.3rem;
            position: relative;
            overflow: hidden;
        }

        .tile::before {
            content: "";
            position: absolute;
            inset: 0;
            background: radial-gradient(circle at 30% 20%,
                    rgba(255, 255, 255, 0.7),
                    transparent);
            opacity: 0.8;
            pointer-events: none;
        }

        .tile.empty {
            background: linear-gradient(145deg, #a15805, #753f02);
        }

        .tile.planted {
            background: linear-gradient(145deg, #dcfce7, #bbf7d0);
        }

        .tile.growing {
            background: linear-gradient(145deg, #bbf7d0, #22c55e);
        }

        .tile.ready {
            background: linear-gradient(145deg, #fed7aa, #f97316);
        }

        .tile .robot {
            position: absolute;
            font-size: 1.5rem;
        }

        .legend {
            font-size: 0.75rem;
            color: var(--text-muted);
            display: flex;
            gap: 10px;
            margin-top: 6px;
            flex-wrap: wrap;
        }

        .legend span {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        /* LOG AREA */

        .log {
            margin-top: 8px;
            padding: 8px 10px;
            background: #0f172a;
            color: #e5e7eb;
            border-radius: 12px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                "Liberation Mono", "Courier New", monospace;
            font-size: 0.75rem;
            max-height: 120px;
            overflow: auto;
            white-space: pre-wrap;
        }

        .log-title {
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: #9ca3af;
            margin-bottom: 4px;
        }

        /* CODE PANEL */

        .editor {
            display: flex;
            flex-direction: column;
            gap: 8px;
            flex: 1;
            min-height: 0;
        }

        .editor textarea {
            flex: 1;
            resize: none;
            width: 100%;
            border-radius: 12px;
            border: 1px solid #e5e7eb;
            padding: 10px 12px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                "Liberation Mono", "Courier New", monospace;
            font-size: 0.8rem;
            line-height: 1.4;
            background: #f9fafb;
        }

        .editor-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 8px;
        }

        .hint {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        .hint code {
            background: #f3f4f6;
            padding: 2px 6px;
            border-radius: 999px;
            font-size: 0.7rem;
        }

        .error {
            color: var(--danger);
            font-size: 0.75rem;
            margin-top: 2px;
        }

        .success {
            color: var(--success);
            font-size: 0.75rem;
            margin-top: 2px;
        }

        @media (max-width: 900px) {
            .app {
                grid-template-columns: 1fr;
                max-width: 680px;
            }
        }
        /* Smooth transitions for main UI elements */
.card,
.tile,
button {
    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease,
        background 0.25s ease,
        opacity 0.25s ease;
}

/* Card hover lift */
.card {
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.14);
}

/* Soft animated glow on cards */
.card::before {
    content: "";
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle at 10% 0%, rgba(129, 140, 248, 0.26), transparent 55%);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.card:hover::before {
    opacity: 1;
    transform: translateY(0);
}
button:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.35);
}

button.secondary:hover:not(:disabled) {
    background: #f9fafb;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

button:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.28);
}
/* Base tile subtle hover */
.tile {
    transform: translateY(0);
}

.tile:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

/* Growing crops gently sway */
.tile.growing {
    animation: cropSway 1.4s ease-in-out infinite;
}

/* Ready crops have a soft pulse to attract attention */
.tile.ready {
    animation: cropPulse 1.2s ease-in-out infinite;
}

/* Robot has a small floating idle animation */
.tile .robot {
    animation: robotFloat 1.4s ease-in-out infinite;
}

/* Keyframes for tile + robot animations */
@keyframes cropSway {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

@keyframes cropPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.0);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.25);
    }
}

@keyframes robotFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}
/* App fade-in */
.app {
    opacity: 0;
    animation: appFadeIn 0.45s ease-out forwards;
}

/* Left/right panels enter slightly staggered */
.card:first-of-type {
    animation: cardInLeft 0.45s ease-out forwards;
}

.card:last-of-type {
    animation: cardInRight 0.45s ease-out forwards;
}

/* Grid and editor content */
.grid {
    animation: fadeInUp 0.4s ease-out 0.15s both;
}

.editor {
    animation: fadeInUp 0.4s ease-out 0.25s both;
}

/* Keyframes for entrances */
@keyframes appFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cardInLeft {
    from { opacity: 0; transform: translateX(-12px) scale(0.98); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes cardInRight {
    from { opacity: 0; transform: translateX(12px) scale(0.98); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.log {
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.7);
    background: radial-gradient(circle at top left, #020617, #020617 45%, #0b1120);
}

.log-title {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 600;
    position: relative;
}

.log-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -3px;
    width: 38px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, #6b8bff, transparent);
}
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
/* ---------- LEVEL COMPLETE MODAL ---------- */

body.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.55), rgba(15, 23, 42, 0.85));
    backdrop-filter: blur(6px);
    z-index: 40;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 24px 24px 18px;
    max-width: 420px;
    width: min(90vw, 420px);
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.25);

    transform: translateY(12px) scale(0.96);
    animation: modalIn 0.35s ease-out forwards;
}

.modal-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text-main);
}

.modal-message {
    margin: 0 0 16px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

/* Button styles are reused from your existing buttons,
   so no extra special styling needed here */

@keyframes modalIn {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.9);
    }
    60% {
        opacity: 1;
        transform: translateY(-2px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
