:root {
    --primary-color: #64748b;
    /* Slate */
    --secondary-color: #94a3b8;
    --accent-color: #f59e0b;
    --background-color: #f1f5f9;
    --text-color: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    max-height: 600px;
    background-color: white;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#game-header {
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    color: white;
    z-index: 10;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.game-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 12px;
    border-radius: 8px;
    color: white;
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.9;
}

.stat-value {
    font-weight: bold;
    font-family: monospace;
    font-size: 1.2rem;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: white;
}

#game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #e2e8f0;
}

.factory-layout {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    /* Connected */
    padding: 20px;
}

.conveyor {
    flex: 1;
    height: 100px;
    background: #cbd5e1;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    border-top: 4px solid #94a3b8;
    border-bottom: 4px solid #94a3b8;
}

.conveyor::after {
    /* Moving belt effect */
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(90deg, transparent 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 40px 100%;
    animation: beltMove 1s linear infinite;
}

@keyframes beltMove {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(40px);
    }
}

.label {
    position: absolute;
    top: -25px;
    left: 10px;
    font-weight: bold;
    color: #64748b;
}

.item-box {
    width: 60px;
    height: 60px;
    background: #fbbf24;
    border: 3px solid #b45309;
    color: #78350f;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    position: relative;
    /* Animation handled in JS usually, or assume center for now */
    left: 20%;
}

.machine {
    width: 140px;
    height: 140px;
    background: #475569;
    border-radius: 10px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    position: relative;
}

.machine::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 20px;
    right: 20px;
    height: 10px;
    background: #334155;
    border-radius: 5px 5px 0 0;
}

.machine-screen {
    width: 100px;
    height: 80px;
    background: #0f172a;
    border: 2px solid #94a3b8;
    color: #22c55e;
    font-family: monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    text-shadow: 0 0 5px #22c55e;
}

.output-slot {
    width: 60px;
    height: 60px;
    border: 2px dashed #64748b;
    margin-left: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #64748b;
    font-weight: bold;
    z-index: 5;
}

.output-slot.filled {
    background: #fbbf24;
    border: 3px solid #b45309;
    color: #78350f;
    font-size: 1.5rem;
    border-style: solid;
}

.control-panel {
    flex: 1;
    background: white;
    padding: 20px;
    border-top: 4px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.instruction {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.function-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.option-btn {
    padding: 10px 20px;
    font-size: 1.2rem;
    background: #f8fafc;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    cursor: pointer;
    font-family: monospace;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: #64748b;
    background: #e2e8f0;
}

.option-btn.correct {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}

.option-btn.wrong {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 320px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1.1rem;
    cursor: pointer;
    margin-top: 15px;
}

.btn-secondary {
    background-color: transparent;
    color: #64748b;
    border: 2px solid #cbd5e1;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    margin-top: 10px;
}